jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

217 lines
7.9KB

  1. #
  2. # Copyright (C) 2007 Arnold Krille
  3. # Copyright (C) 2007 Pieter Palmers
  4. # Copyright (C) 2008 Marc-Olivier Barre
  5. #
  6. # This file originates from FFADO (www.ffado.org)
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. import os
  22. from string import Template
  23. platform = ARGUMENTS.get('OS', str(Platform()))
  24. build_dir = ARGUMENTS.get('BUILDDIR', '')
  25. if build_dir:
  26. build_base = build_dir + '/'
  27. if not os.path.isdir(build_base):
  28. os.makedirs(build_base)
  29. print 'Building into: ' + build_base
  30. else:
  31. build_base=''
  32. if not os.path.isdir('cache'):
  33. os.makedirs('cache')
  34. opts = Options('cache/'+build_base+'options.cache')
  35. #
  36. # Command-line options section
  37. #
  38. # If this is just to display a help-text for the variable used via ARGUMENTS, then its wrong...
  39. opts.Add( 'BUILDDIR', 'Path to place the built files in', '')
  40. opts.AddOptions(
  41. PathOption('PREFIX', 'The prefix where jackdmp will be installed to', '/usr/local', PathOption.PathAccept),
  42. PathOption('BINDIR', 'Overwrite the directory where apps are installed to', '$PREFIX/bin', PathOption.PathAccept),
  43. PathOption('LIBDIR', 'Overwrite the directory where libs are installed to', '$PREFIX/lib', PathOption.PathAccept),
  44. PathOption('INCLUDEDIR', 'Overwrite the directory where headers are installed to', '$PREFIX/include', PathOption.PathAccept),
  45. # TODO: The next one is stupid, should be autodetected
  46. BoolOption('BUILD_FOR_LINUX', 'Enable/Disable depending on your system', True),
  47. BoolOption('ENABLE_ALSA', 'Enable/Disable the ALSA backend', True),
  48. BoolOption('ENABLE_FREEBOB', 'Enable/Disable the FreeBoB backend', True),
  49. BoolOption('ENABLE_FIREWIRE', 'Enable/Disable the FireWire backend', True),
  50. BoolOption('DEBUG', 'Do a debug build', False),
  51. BoolOption('BUILD_TESTS', 'Build tests where applicable', True),
  52. BoolOption('BUILD_EXAMPLES', 'Build the example clients in their directory', True),
  53. BoolOption('INSTALL_EXAMPLES', 'Install the example clients in the BINDIR directory', True),
  54. BoolOption('BUILD_DOXYGEN_DOCS', 'Build doxygen documentation', False),
  55. )
  56. #
  57. # Configuration section
  58. #
  59. # Load the builders in config
  60. buildenv = os.environ
  61. if os.environ.has_key('PATH'):
  62. buildenv['PATH'] = os.environ['PATH']
  63. else:
  64. buildenv['PATH'] = ''
  65. if os.environ.has_key('PKG_CONFIG_PATH'):
  66. buildenv['PKG_CONFIG_PATH'] = os.environ['PKG_CONFIG_PATH']
  67. else:
  68. buildenv['PKG_CONFIG_PATH'] = ''
  69. if os.environ.has_key('LD_LIBRARY_PATH'):
  70. buildenv['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
  71. else:
  72. buildenv['LD_LIBRARY_PATH'] = ''
  73. env = Environment(tools=['default', 'scanreplace', 'pkgconfig', 'doxygen'], toolpath = ['admin'], ENV=buildenv, PLATFORM = platform, options = opts)
  74. Help('To build jackdmp you can set different options as listed below. You have to specify them only once, scons will save the latest values you set and re-use then. To really undo your settings and return to the factory defaults, remove the .sconsign.dblite and options.cache files from your BUILDDIR directory.')
  75. Help(opts.GenerateHelpText(env))
  76. # make sure the necessary dirs exist
  77. if not os.path.isdir('cache/' + build_base):
  78. os.makedirs('cache/' + build_base)
  79. if build_base:
  80. env['build_base']='#/'+build_base
  81. else:
  82. env['build_base']='#/'
  83. opts.Save('cache/' + build_base + 'options.cache', env)
  84. tests = {}
  85. tests.update(env['PKGCONFIG_TESTS'])
  86. if not env.GetOption('clean'):
  87. conf = Configure(env,
  88. custom_tests = tests,
  89. conf_dir = 'cache/' + build_base,
  90. log_file = 'cache/' + build_base + 'config.log')
  91. # Check if the environment can actually compile c-files by checking for a
  92. # header shipped with gcc
  93. if not conf.CheckHeader( 'stdio.h' ):
  94. print 'Error: It seems as if stdio.h is missing. This probably means that your build environment is broken, please make sure you have a working c-compiler and libstdc installed and usable.'
  95. Exit(1)
  96. # The following checks are for headers, libs and packages we depend on
  97. allpresent = 1;
  98. if env['BUILD_FOR_LINUX']:
  99. allpresent &= conf.CheckForPKGConfig('0.20');
  100. if not allpresent:
  101. print "--> At least one of the dependencies is missing. I can't go on without it, please install the needed packages (remember to also install the *-devel packages)"
  102. Exit(1)
  103. # If jack has the same PREFIX as the one we plan to use, exit with an error message
  104. env['JACK_FLAGS'] = conf.GetPKGFlags('jack', '0.90')
  105. if env['JACK_FLAGS']:
  106. print "--> Found an existing JACK installation, let's be careful not to erase it"
  107. if conf.GetPKGPrefix( 'jack' ) == env['PREFIX']:
  108. print '--> JACK is installed in the same directory as our current PREFIX. Either remove JACK or change your installation PREFIX.'
  109. Exit(1)
  110. # Optional checks follow:
  111. if env['BUILD_FOR_LINUX'] and env['ENABLE_ALSA']:
  112. env['ALSA_FLAGS'] = conf.GetPKGFlags('alsa', '1.0.0')
  113. if env['ALSA_FLAGS'] == 0:
  114. print "--> Disabling 'alsa' backend since no useful ALSA installation found"
  115. env['ENABLE_ALSA'] = False
  116. if env['BUILD_FOR_LINUX'] and env['ENABLE_FREEBOB']:
  117. env['FREEBOB_FLAGS'] = conf.GetPKGFlags('libfreebob', '1.0.0')
  118. if env['FREEBOB_FLAGS'] == 0:
  119. print "--> Disabling 'freebob' backend since no useful FreeBoB installation found"
  120. env['ENABLE_FREEBOB'] = False
  121. if env['BUILD_FOR_LINUX'] and env['ENABLE_FIREWIRE']:
  122. env['FFADO_FLAGS'] = conf.GetPKGFlags('libffado', '1.999.14')
  123. if env['FFADO_FLAGS'] == 0:
  124. print "--> Disabling 'firewire' backend since no useful FFADO installation found"
  125. env['ENABLE_FIREWIRE'] = False
  126. env = conf.Finish()
  127. if env['DEBUG']:
  128. print '--> Doing a DEBUG build'
  129. # TODO: -Werror could be added to, which would force the devs to really remove all the warnings :-)
  130. env.AppendUnique(CCFLAGS = ['-DDEBUG', '-Wall', '-g'])
  131. else:
  132. env.AppendUnique(CCFLAGS = ['-O3','-DNDEBUG'])
  133. env.AppendUnique(CCFLAGS = ['-fPIC', '-DSOCKET_RPC_FIFO_SEMA', '-D__SMP__'])
  134. env.AppendUnique(CFLAGS = ['-fPIC', '-DUSE_POSIX_SHM'])
  135. env.Alias('install', env['LIBDIR'])
  136. env.Alias('install', env['INCLUDEDIR'])
  137. env.Alias('install', env['BINDIR'])
  138. # for config.h.in
  139. # TODO: Is that necessary ?
  140. env['ADDON_DIR']='%s' % env['PREFIX']
  141. env['LIB_DIR']='lib'
  142. env['JACK_LOCATION']='%s' % env['BINDIR']
  143. # To have the top_srcdir as the doxygen-script is used from auto*
  144. # TODO: Understand the previous comment
  145. env['top_srcdir'] = env.Dir('.').abspath
  146. env.ScanReplace( 'config.h.in' )
  147. # TODO: find out what's that about. Is it useful ?
  148. AlwaysBuild('config.h')
  149. # Ensure we have a path to where the libraries are
  150. env.AppendUnique(LIBPATH=['#/common'])
  151. #
  152. # Build section
  153. #
  154. if env['BUILD_DOXYGEN_DOCS']:
  155. env.Doxygen('doxyfile')
  156. subdirs=['common']
  157. # TODO: Really handle each platform automatically
  158. if env['PLATFORM'] == 'posix':
  159. subdirs.append('linux')
  160. # TODO FOR SLETZ: test macosx/SConscript
  161. if env['PLATFORM'] == 'macosx':
  162. subdirs.append('macosx')
  163. # TODO FOR SLETZ & MARC: create/check windows/SConscript
  164. #if env['PLATFORM'] == 'windows':
  165. # subdirs.append('windows')
  166. if env['BUILD_EXAMPLES']:
  167. subdirs.append('example-clients')
  168. if env['BUILD_TESTS']:
  169. subdirs.append('tests')
  170. if build_base:
  171. env.SConscript(dirs=subdirs, exports='env', build_dir=build_base+subdir)
  172. else:
  173. env.SConscript(dirs=subdirs, exports='env')