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.

288 lines
10.0KB

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