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.

255 lines
9.2KB

  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. JACK_MAJOR_VERSION=1
  24. JACK_MINOR_VERSION=9
  25. JACK_MICRO_VERSION=0
  26. JACKAPI_MAJOR_VERSION=0
  27. JACKAPI_MINOR_VERSION=1
  28. JACKAPI_MICRO_VERSION=0
  29. JACK_VERSION="%u.%u.%u" % (JACK_MAJOR_VERSION, JACK_MINOR_VERSION, JACK_MICRO_VERSION)
  30. JACKAPI_VERSION="%u.%u.%u" % (JACKAPI_MAJOR_VERSION, JACKAPI_MINOR_VERSION, JACKAPI_MICRO_VERSION)
  31. platform = ARGUMENTS.get('OS', str(Platform()))
  32. build_dir = ARGUMENTS.get('BUILDDIR', '')
  33. if build_dir:
  34. build_base = build_dir + '/'
  35. if not os.path.isdir(build_base):
  36. os.makedirs(build_base)
  37. print 'Building into: ' + build_base
  38. else:
  39. build_base=''
  40. if not os.path.isdir('cache'):
  41. os.makedirs('cache')
  42. opts = Options('cache/'+build_base+'options.cache')
  43. #
  44. # Command-line options section
  45. #
  46. # If this is just to display a help-text for the variable used via ARGUMENTS, then its wrong...
  47. opts.Add( 'BUILDDIR', 'Path to place the built files in', '')
  48. opts.AddOptions(
  49. PathOption('DESTDIR', 'A prefix where the installed tree will be placed - for package maintainers', '', PathOption.PathAccept),
  50. PathOption('PREFIX', 'The prefix where jackdmp will be installed to', '/usr/local', PathOption.PathAccept),
  51. PathOption('BINDIR', 'Overwrite the directory where apps are installed to', '$PREFIX/bin', PathOption.PathAccept),
  52. PathOption('LIBDIR', 'Overwrite the directory where libs are installed to', '$PREFIX/lib', PathOption.PathAccept),
  53. PathOption('INCLUDEDIR', 'Overwrite the directory where headers are installed to', '$PREFIX/include', PathOption.PathAccept),
  54. # TODO: The next one is stupid, should be autodetected
  55. BoolOption('BUILD_FOR_LINUX', 'Enable/Disable depending on your system', True),
  56. BoolOption('ENABLE_ALSA', 'Enable/Disable the ALSA backend', True),
  57. BoolOption('ENABLE_FREEBOB', 'Enable/Disable the FreeBoB backend', True),
  58. BoolOption('ENABLE_FIREWIRE', 'Enable/Disable the FireWire backend', True),
  59. BoolOption('DEBUG', 'Do a debug build', False),
  60. BoolOption('BUILD_TESTS', 'Build tests where applicable', True),
  61. BoolOption('BUILD_EXAMPLES', 'Build the example clients in their directory', True),
  62. BoolOption('INSTALL_EXAMPLES', 'Install the example clients in the BINDIR directory', True),
  63. BoolOption('BUILD_DOXYGEN_DOCS', 'Build doxygen documentation', False),
  64. )
  65. #
  66. # Configuration section
  67. #
  68. # Load the builders in config
  69. buildenv = os.environ
  70. if os.environ.has_key('PATH'):
  71. buildenv['PATH'] = os.environ['PATH']
  72. else:
  73. buildenv['PATH'] = ''
  74. if os.environ.has_key('PKG_CONFIG_PATH'):
  75. buildenv['PKG_CONFIG_PATH'] = os.environ['PKG_CONFIG_PATH']
  76. else:
  77. buildenv['PKG_CONFIG_PATH'] = ''
  78. if os.environ.has_key('LD_LIBRARY_PATH'):
  79. buildenv['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
  80. else:
  81. buildenv['LD_LIBRARY_PATH'] = ''
  82. env = Environment(tools=['default', 'scanreplace', 'pkgconfig', 'doxygen'], toolpath = ['admin'], ENV=buildenv, PLATFORM = platform, options = opts)
  83. 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.')
  84. Help(opts.GenerateHelpText(env))
  85. # Set version
  86. env['JACK_MAJOR_VERSION'] = JACK_MAJOR_VERSION
  87. env['JACK_MINOR_VERSION'] = JACK_MINOR_VERSION
  88. env['JACK_MICRO_VERSION'] = JACK_MICRO_VERSION
  89. env['JACK_VERSION'] = JACK_VERSION
  90. env['JACKAPI_MAJOR_VERSION'] = JACKAPI_MAJOR_VERSION
  91. env['JACKAPI_MINOR_VERSION'] = JACKAPI_MINOR_VERSION
  92. env['JACKAPI_MICRO_VERSION'] = JACKAPI_MICRO_VERSION
  93. env['JACKAPI_VERSION'] = JACKAPI_VERSION
  94. # make sure the necessary dirs exist
  95. if not os.path.isdir('cache/' + build_base):
  96. os.makedirs('cache/' + build_base)
  97. if build_base:
  98. env['build_base']='#/'+build_base
  99. else:
  100. env['build_base']='#/'
  101. opts.Save('cache/' + build_base + 'options.cache', env)
  102. tests = {}
  103. tests.update(env['PKGCONFIG_TESTS'])
  104. if not env.GetOption('clean'):
  105. conf = Configure(env,
  106. custom_tests = tests,
  107. conf_dir = 'cache/' + build_base,
  108. log_file = 'cache/' + build_base + 'config.log')
  109. # Check if the environment can actually compile c-files by checking for a
  110. # header shipped with gcc
  111. if not conf.CheckHeader( 'stdio.h' ):
  112. 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.'
  113. Exit(1)
  114. # The following checks are for headers, libs and packages we depend on
  115. allpresent = 1;
  116. if env['BUILD_FOR_LINUX']:
  117. allpresent &= conf.CheckForPKGConfig('0.20');
  118. if not allpresent:
  119. 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)"
  120. Exit(1)
  121. # Optional checks follow:
  122. if env['BUILD_FOR_LINUX'] and env['ENABLE_ALSA']:
  123. env['ALSA_FLAGS'] = conf.GetPKGFlags('alsa', '1.0.0')
  124. if env['ALSA_FLAGS'] == 0:
  125. print "--> Disabling 'alsa' backend since no useful ALSA installation found"
  126. env['ENABLE_ALSA'] = False
  127. if env['BUILD_FOR_LINUX'] and env['ENABLE_FREEBOB']:
  128. env['FREEBOB_FLAGS'] = conf.GetPKGFlags('libfreebob', '1.0.0')
  129. if env['FREEBOB_FLAGS'] == 0:
  130. print "--> Disabling 'freebob' backend since no useful FreeBoB installation found"
  131. env['ENABLE_FREEBOB'] = False
  132. if env['BUILD_FOR_LINUX'] and env['ENABLE_FIREWIRE']:
  133. env['FFADO_FLAGS'] = conf.GetPKGFlags('libffado', '1.999.17')
  134. if env['FFADO_FLAGS'] == 0:
  135. print "--> Disabling 'firewire' backend since no useful FFADO installation found"
  136. env['ENABLE_FIREWIRE'] = False
  137. env = conf.Finish()
  138. if env['DEBUG']:
  139. print '--> Doing a DEBUG build'
  140. # TODO: -Werror could be added to, which would force the devs to really remove all the warnings :-)
  141. env.AppendUnique(CCFLAGS = ['-DDEBUG', '-Wall', '-g'])
  142. else:
  143. env.AppendUnique(CCFLAGS = ['-O3','-DNDEBUG'])
  144. env.AppendUnique(CCFLAGS = ['-fPIC', '-DSOCKET_RPC_FIFO_SEMA', '-D__SMP__'])
  145. env.AppendUnique(CFLAGS = ['-fPIC', '-DUSE_POSIX_SHM'])
  146. # used for alsa midi code, probably this define should be removed
  147. env.AppendUnique(CFLAGS = ['-DJACKMP'])
  148. env.AppendUnique(CPPFLAGS = ['-DJACKMP'])
  149. env['PREFIX'] = env.subst(env['PREFIX'])
  150. env['BINDIR'] = env.subst(env['BINDIR'])
  151. env['LIBDIR'] = env.subst(env['LIBDIR'])
  152. env['INCLUDEDIR'] = env.subst(env['INCLUDEDIR'])
  153. env['SERVER'] = 'jackd'
  154. env['CLIENTLIB'] = 'jack'
  155. env['SERVERLIB'] = 'jackserver'
  156. env['ADDON_DIR'] = env.subst(env['LIBDIR']) + "/jack"
  157. env['INSTALL_ADDON_DIR'] = env['DESTDIR'] + env.subst(env['LIBDIR']) + "/jack"
  158. env['INSTALL_PREFIX'] = env['DESTDIR'] + env['PREFIX']
  159. env['INSTALL_BINDIR'] = env['DESTDIR'] + env['BINDIR']
  160. env['INSTALL_LIBDIR'] = env['DESTDIR'] + env['LIBDIR']
  161. env['INSTALL_INCLUDEDIR'] = env['DESTDIR'] + env['INCLUDEDIR'] + '/jack'
  162. env.Alias('install', env['INSTALL_LIBDIR'])
  163. env.Alias('install', env['INSTALL_INCLUDEDIR'])
  164. env.Alias('install', env['INSTALL_BINDIR'])
  165. env.Alias('install', env['INSTALL_ADDON_DIR'])
  166. env.ScanReplace('jack.pc.in')
  167. # jack.pc is always updated in case of config changes
  168. # (PREFIX or JACK_VERSION for instance)
  169. AlwaysBuild('jack.pc')
  170. pkg_config_dir = env['INSTALL_LIBDIR']+"/pkgconfig/"
  171. env.Install(pkg_config_dir, 'jack.pc')
  172. env.Alias('install', pkg_config_dir)
  173. # To have the top_srcdir as the doxygen-script is used from auto*
  174. env['top_srcdir'] = env.Dir('.').abspath
  175. # for config.h.in
  176. env['JACK_LOCATION']=env.subst(env['BINDIR'])
  177. env.ScanReplace( 'config.h.in' )
  178. # just like jack.pc, config.h is always updated in case of config changes
  179. # (PREFIX or JACK_VERSION for instance)
  180. AlwaysBuild('config.h')
  181. # Ensure we have a path to where the libraries are
  182. env.AppendUnique(LIBPATH=['#/common'])
  183. #
  184. # Build section
  185. #
  186. if env['BUILD_DOXYGEN_DOCS']:
  187. env.Doxygen('doxyfile')
  188. subdirs=['common']
  189. if env['PLATFORM'] == 'posix':
  190. subdirs.append('linux')
  191. # TODO FOR Marc: make macosx/SConscript work right
  192. if env['PLATFORM'] == 'macosx':
  193. subdirs.append('macosx')
  194. # TODO FOR Marc: create/check windows/SConscript
  195. #if env['PLATFORM'] == 'windows':
  196. # subdirs.append('windows')
  197. if env['BUILD_EXAMPLES']:
  198. subdirs.append('example-clients')
  199. if env['BUILD_TESTS']:
  200. subdirs.append('tests')
  201. if build_base:
  202. env.SConscript(dirs=subdirs, exports='env', build_dir=build_base+subdir)
  203. else:
  204. env.SConscript(dirs=subdirs, exports='env')