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.5KB

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