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.

273 lines
10KB

  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. BoolOption('FULL_MIMIC', 'Mimic jack-1.0 installation layout as much as possible', False),
  65. )
  66. #
  67. # Configuration section
  68. #
  69. # Load the builders in config
  70. buildenv = os.environ
  71. if os.environ.has_key('PATH'):
  72. buildenv['PATH'] = os.environ['PATH']
  73. else:
  74. buildenv['PATH'] = ''
  75. if os.environ.has_key('PKG_CONFIG_PATH'):
  76. buildenv['PKG_CONFIG_PATH'] = os.environ['PKG_CONFIG_PATH']
  77. else:
  78. buildenv['PKG_CONFIG_PATH'] = ''
  79. if os.environ.has_key('LD_LIBRARY_PATH'):
  80. buildenv['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
  81. else:
  82. buildenv['LD_LIBRARY_PATH'] = ''
  83. env = Environment(tools=['default', 'scanreplace', 'pkgconfig', 'doxygen'], toolpath = ['admin'], ENV=buildenv, PLATFORM = platform, options = opts)
  84. 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.')
  85. Help(opts.GenerateHelpText(env))
  86. # Set version
  87. env['JACK_MAJOR_VERSION'] = JACK_MAJOR_VERSION
  88. env['JACK_MINOR_VERSION'] = JACK_MINOR_VERSION
  89. env['JACK_MICRO_VERSION'] = JACK_MICRO_VERSION
  90. env['JACK_VERSION'] = JACK_VERSION
  91. env['JACKAPI_MAJOR_VERSION'] = JACKAPI_MAJOR_VERSION
  92. env['JACKAPI_MINOR_VERSION'] = JACKAPI_MINOR_VERSION
  93. env['JACKAPI_MICRO_VERSION'] = JACKAPI_MICRO_VERSION
  94. env['JACKAPI_VERSION'] = JACKAPI_VERSION
  95. # make sure the necessary dirs exist
  96. if not os.path.isdir('cache/' + build_base):
  97. os.makedirs('cache/' + build_base)
  98. if build_base:
  99. env['build_base']='#/'+build_base
  100. else:
  101. env['build_base']='#/'
  102. opts.Save('cache/' + build_base + 'options.cache', env)
  103. tests = {}
  104. tests.update(env['PKGCONFIG_TESTS'])
  105. if not env.GetOption('clean'):
  106. conf = Configure(env,
  107. custom_tests = tests,
  108. conf_dir = 'cache/' + build_base,
  109. log_file = 'cache/' + build_base + 'config.log')
  110. # Check if the environment can actually compile c-files by checking for a
  111. # header shipped with gcc
  112. if not conf.CheckHeader( 'stdio.h' ):
  113. 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.'
  114. Exit(1)
  115. # The following checks are for headers, libs and packages we depend on
  116. allpresent = 1;
  117. if env['BUILD_FOR_LINUX']:
  118. allpresent &= conf.CheckForPKGConfig('0.20');
  119. if not allpresent:
  120. 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)"
  121. Exit(1)
  122. # Shouldn't be needed with the new wrapper/full_mimic features
  123. # env['JACK_FLAGS'] = conf.GetPKGFlags('jack', '0.90')
  124. # if env['JACK_FLAGS']:
  125. # print "--> Found an existing JACK installation, let's be careful not to erase it"
  126. # if conf.GetPKGPrefix( 'jack' ) == env['PREFIX']:
  127. # print '--> JACK is installed in the same directory as our current PREFIX. Either remove JACK or change your installation PREFIX.'
  128. # Exit(1)
  129. # Optional checks follow:
  130. if env['BUILD_FOR_LINUX'] and env['ENABLE_ALSA']:
  131. env['ALSA_FLAGS'] = conf.GetPKGFlags('alsa', '1.0.0')
  132. if env['ALSA_FLAGS'] == 0:
  133. print "--> Disabling 'alsa' backend since no useful ALSA installation found"
  134. env['ENABLE_ALSA'] = False
  135. if env['BUILD_FOR_LINUX'] and env['ENABLE_FREEBOB']:
  136. env['FREEBOB_FLAGS'] = conf.GetPKGFlags('libfreebob', '1.0.0')
  137. if env['FREEBOB_FLAGS'] == 0:
  138. print "--> Disabling 'freebob' backend since no useful FreeBoB installation found"
  139. env['ENABLE_FREEBOB'] = False
  140. if env['BUILD_FOR_LINUX'] and env['ENABLE_FIREWIRE']:
  141. env['FFADO_FLAGS'] = conf.GetPKGFlags('libffado', '1.999.17')
  142. if env['FFADO_FLAGS'] == 0:
  143. print "--> Disabling 'firewire' backend since no useful FFADO installation found"
  144. env['ENABLE_FIREWIRE'] = False
  145. env = conf.Finish()
  146. if env['DEBUG']:
  147. print '--> Doing a DEBUG build'
  148. # TODO: -Werror could be added to, which would force the devs to really remove all the warnings :-)
  149. env.AppendUnique(CCFLAGS = ['-DDEBUG', '-Wall', '-g'])
  150. else:
  151. env.AppendUnique(CCFLAGS = ['-O3','-DNDEBUG'])
  152. env.AppendUnique(CCFLAGS = ['-fPIC', '-DSOCKET_RPC_FIFO_SEMA', '-D__SMP__'])
  153. env.AppendUnique(CFLAGS = ['-fPIC', '-DUSE_POSIX_SHM'])
  154. # used for alsa midi code, probably this define should be removed
  155. env.AppendUnique(CFLAGS = ['-DJACKMP'])
  156. env.AppendUnique(CPPFLAGS = ['-DJACKMP'])
  157. if env['FULL_MIMIC']:
  158. env['SERVER'] = 'jackd'
  159. env['CLIENTLIB'] = 'jack'
  160. env['SERVERLIB'] = 'jackserver'
  161. env['ADDON_DIR'] = env.subst(env['LIBDIR']) + "/jack"
  162. env['INSTALL_ADDON_DIR'] = env['DESTDIR'] + env.subst(env['LIBDIR']) + "/jack"
  163. else:
  164. env['SERVER'] = 'jackdmp'
  165. env['CLIENTLIB'] = 'jackmp'
  166. env['SERVERLIB'] = 'jackservermp'
  167. env['WRAPPERLIB'] = 'jack'
  168. env['ADDON_DIR'] = env.subst(env['LIBDIR']) + "/jackmp"
  169. env['INSTALL_ADDON_DIR'] = env['DESTDIR'] + env.subst(env['LIBDIR']) + "/jackmp"
  170. env['PREFIX'] = env.subst(env['PREFIX'])
  171. env['BINDIR'] = env.subst(env['BINDIR'])
  172. env['LIBDIR'] = env.subst(env['LIBDIR'])
  173. env['INCLUDEDIR'] = env.subst(env['INCLUDEDIR'])
  174. env['INSTALL_PREFIX'] = env['DESTDIR'] + env['PREFIX']
  175. env['INSTALL_BINDIR'] = env['DESTDIR'] + env['BINDIR']
  176. env['INSTALL_LIBDIR'] = env['DESTDIR'] + env['LIBDIR']
  177. env['INSTALL_INCLUDEDIR'] = env['DESTDIR'] + env['INCLUDEDIR'] + '/jack'
  178. env.Alias('install', env['INSTALL_LIBDIR'])
  179. env.Alias('install', env['INSTALL_INCLUDEDIR'])
  180. env.Alias('install', env['INSTALL_BINDIR'])
  181. env.Alias('install', env['INSTALL_ADDON_DIR'])
  182. env.ScanReplace('jack.pc.in')
  183. # jack.pc is always updated in case of config changes
  184. # (PREFIX or JACK_VERSION for instance)
  185. AlwaysBuild('jack.pc')
  186. pkg_config_dir = env['INSTALL_LIBDIR']+"/pkgconfig/"
  187. env.Install(pkg_config_dir, 'jack.pc')
  188. env.Alias('install', pkg_config_dir)
  189. # To have the top_srcdir as the doxygen-script is used from auto*
  190. env['top_srcdir'] = env.Dir('.').abspath
  191. # for config.h.in
  192. env['LIB_DIR']='lib'
  193. env['JACK_LOCATION']=env.subst(env['BINDIR'])
  194. env.ScanReplace( 'config.h.in' )
  195. # just like jack.pc, config.h is always updated in case of config changes
  196. # (PREFIX or JACK_VERSION for instance)
  197. AlwaysBuild('config.h')
  198. # Ensure we have a path to where the libraries are
  199. env.AppendUnique(LIBPATH=['#/common'])
  200. #
  201. # Build section
  202. #
  203. if env['BUILD_DOXYGEN_DOCS']:
  204. env.Doxygen('doxyfile')
  205. subdirs=['common']
  206. if env['PLATFORM'] == 'posix':
  207. subdirs.append('linux')
  208. # TODO FOR Marc: make macosx/SConscript work right
  209. if env['PLATFORM'] == 'macosx':
  210. subdirs.append('macosx')
  211. # TODO FOR Marc: create/check windows/SConscript
  212. #if env['PLATFORM'] == 'windows':
  213. # subdirs.append('windows')
  214. if env['BUILD_EXAMPLES']:
  215. subdirs.append('example-clients')
  216. if env['BUILD_TESTS']:
  217. subdirs.append('tests')
  218. if build_base:
  219. env.SConscript(dirs=subdirs, exports='env', build_dir=build_base+subdir)
  220. else:
  221. env.SConscript(dirs=subdirs, exports='env')