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.

266 lines
9.6KB

  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('PREFIX', 'The prefix where jackdmp will be installed to', '/usr/local', PathOption.PathAccept),
  50. PathOption('BINDIR', 'Overwrite the directory where apps are installed to', '$PREFIX/bin', PathOption.PathAccept),
  51. PathOption('LIBDIR', 'Overwrite the directory where libs are installed to', '$PREFIX/lib', PathOption.PathAccept),
  52. PathOption('INCLUDEDIR', 'Overwrite the directory where headers are installed to', '$PREFIX/include', PathOption.PathAccept),
  53. # TODO: The next one is stupid, should be autodetected
  54. BoolOption('BUILD_FOR_LINUX', 'Enable/Disable depending on your system', True),
  55. BoolOption('ENABLE_ALSA', 'Enable/Disable the ALSA backend', True),
  56. BoolOption('ENABLE_FREEBOB', 'Enable/Disable the FreeBoB backend', True),
  57. BoolOption('ENABLE_FIREWIRE', 'Enable/Disable the FireWire backend', True),
  58. BoolOption('DEBUG', 'Do a debug build', False),
  59. BoolOption('BUILD_TESTS', 'Build tests where applicable', True),
  60. BoolOption('BUILD_EXAMPLES', 'Build the example clients in their directory', True),
  61. BoolOption('INSTALL_EXAMPLES', 'Install the example clients in the BINDIR directory', True),
  62. BoolOption('BUILD_DOXYGEN_DOCS', 'Build doxygen documentation', False),
  63. BoolOption('FULL_MIMIC', 'Mimic jack-1.0 installation layout as much as possible', 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. # Shouldn't be needed with the new wrapper/full_mimic features
  122. # env['JACK_FLAGS'] = conf.GetPKGFlags('jack', '0.90')
  123. # if env['JACK_FLAGS']:
  124. # print "--> Found an existing JACK installation, let's be careful not to erase it"
  125. # if conf.GetPKGPrefix( 'jack' ) == env['PREFIX']:
  126. # print '--> JACK is installed in the same directory as our current PREFIX. Either remove JACK or change your installation PREFIX.'
  127. # Exit(1)
  128. # Optional checks follow:
  129. if env['BUILD_FOR_LINUX'] and env['ENABLE_ALSA']:
  130. env['ALSA_FLAGS'] = conf.GetPKGFlags('alsa', '1.0.0')
  131. if env['ALSA_FLAGS'] == 0:
  132. print "--> Disabling 'alsa' backend since no useful ALSA installation found"
  133. env['ENABLE_ALSA'] = False
  134. if env['BUILD_FOR_LINUX'] and env['ENABLE_FREEBOB']:
  135. env['FREEBOB_FLAGS'] = conf.GetPKGFlags('libfreebob', '1.0.0')
  136. if env['FREEBOB_FLAGS'] == 0:
  137. print "--> Disabling 'freebob' backend since no useful FreeBoB installation found"
  138. env['ENABLE_FREEBOB'] = False
  139. if env['BUILD_FOR_LINUX'] and env['ENABLE_FIREWIRE']:
  140. env['FFADO_FLAGS'] = conf.GetPKGFlags('libffado', '1.999.17')
  141. if env['FFADO_FLAGS'] == 0:
  142. print "--> Disabling 'firewire' backend since no useful FFADO installation found"
  143. env['ENABLE_FIREWIRE'] = False
  144. env = conf.Finish()
  145. if env['DEBUG']:
  146. print '--> Doing a DEBUG build'
  147. # TODO: -Werror could be added to, which would force the devs to really remove all the warnings :-)
  148. env.AppendUnique(CCFLAGS = ['-DDEBUG', '-Wall', '-g'])
  149. else:
  150. env.AppendUnique(CCFLAGS = ['-O3','-DNDEBUG'])
  151. env.AppendUnique(CCFLAGS = ['-fPIC', '-DSOCKET_RPC_FIFO_SEMA', '-D__SMP__'])
  152. env.AppendUnique(CFLAGS = ['-fPIC', '-DUSE_POSIX_SHM'])
  153. # used for alsa midi code, probably this define should be removed
  154. env.AppendUnique(CFLAGS = ['-DJACKMP'])
  155. env.AppendUnique(CPPFLAGS = ['-DJACKMP'])
  156. if env['FULL_MIMIC']:
  157. env['SERVER'] = 'jackd'
  158. env['CLIENTLIB'] = 'jack'
  159. env['SERVERLIB'] = 'jackserver'
  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'] = 'jack'
  166. env['ADDON_DIR'] = env.subst(env['LIBDIR']) + "/jackmp"
  167. env.Alias('install', env['LIBDIR'])
  168. env.Alias('install', env['INCLUDEDIR'])
  169. env.Alias('install', env['BINDIR'])
  170. env.Alias('install', env['ADDON_DIR'])
  171. env['PREFIX'] = env.subst(env['PREFIX'])
  172. env['BINDIR'] = env.subst(env['BINDIR'])
  173. env['LIBDIR'] = env.subst(env['LIBDIR'])
  174. env['INCLUDEDIR'] = env.subst(env['INCLUDEDIR'])
  175. env.ScanReplace('jack.pc.in')
  176. # jack.pc is always updated in case of config changes
  177. # (PREFIX or JACK_VERSION for instance)
  178. AlwaysBuild('jack.pc')
  179. pkg_config_dir = env['LIBDIR']+"/pkgconfig/"
  180. env.Install(pkg_config_dir, 'jack.pc')
  181. env.Alias('install', pkg_config_dir)
  182. # To have the top_srcdir as the doxygen-script is used from auto*
  183. env['top_srcdir'] = env.Dir('.').abspath
  184. # for config.h.in
  185. env['LIB_DIR']='lib'
  186. env['JACK_LOCATION']=env.subst(env['BINDIR'])
  187. env.ScanReplace( 'config.h.in' )
  188. # just like jack.pc, config.h is always updated in case of config changes
  189. # (PREFIX or JACK_VERSION for instance)
  190. AlwaysBuild('config.h')
  191. # Ensure we have a path to where the libraries are
  192. env.AppendUnique(LIBPATH=['#/common'])
  193. #
  194. # Build section
  195. #
  196. if env['BUILD_DOXYGEN_DOCS']:
  197. env.Doxygen('doxyfile')
  198. subdirs=['common']
  199. # TODO: Really handle each platform automatically
  200. if env['PLATFORM'] == 'posix':
  201. subdirs.append('linux')
  202. # TODO FOR SLETZ: test macosx/SConscript
  203. if env['PLATFORM'] == 'macosx':
  204. subdirs.append('macosx')
  205. # TODO FOR SLETZ & MARC: create/check windows/SConscript
  206. #if env['PLATFORM'] == 'windows':
  207. # subdirs.append('windows')
  208. if env['BUILD_EXAMPLES']:
  209. subdirs.append('example-clients')
  210. if env['BUILD_TESTS']:
  211. subdirs.append('tests')
  212. if build_base:
  213. env.SConscript(dirs=subdirs, exports='env', build_dir=build_base+subdir)
  214. else:
  215. env.SConscript(dirs=subdirs, exports='env')