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.

262 lines
9.3KB

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