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.

259 lines
9.1KB

  1. #
  2. # Copyright (C) 2007 Arnold Krille
  3. # Copyright (C) 2007 Pieter Palmers
  4. #
  5. # This file originates from FFADO (www.ffado.org)
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. import os
  21. from string import Template
  22. platform = ARGUMENTS.get('OS', str(Platform()))
  23. build_dir = ARGUMENTS.get('BUILDDIR', "")
  24. if build_dir:
  25. build_base=build_dir+'/'
  26. if not os.path.isdir( build_base ):
  27. os.makedirs( build_base )
  28. print "Building into: " + build_base
  29. else:
  30. build_base=''
  31. if not os.path.isdir( "cache" ):
  32. os.makedirs( "cache" )
  33. opts = Options( "cache/"+build_base+"options.cache" )
  34. # make this into a command line option and/or a detected value
  35. build_for_linux = True
  36. #
  37. # If this is just to display a help-text for the variable used via ARGUMENTS, then its wrong...
  38. opts.Add( "BUILDDIR", "Path to place the built files in", "")
  39. opts.AddOptions(
  40. # BoolOption( "DEBUG", """\
  41. #Toggle debug-build. DEBUG means \"-g -Wall\" and more, otherwise we will use
  42. # \"-O2\" to optimise.""", True ),
  43. PathOption( "PREFIX", "The prefix where jackdmp will be installed to.", "/usr/local", PathOption.PathAccept ),
  44. PathOption( "BINDIR", "Overwrite the directory where apps are installed to.", "$PREFIX/bin", PathOption.PathAccept ),
  45. PathOption( "LIBDIR", "Overwrite the directory where libs are installed to.", "$PREFIX/lib", PathOption.PathAccept ),
  46. PathOption( "INCLUDEDIR", "Overwrite the directory where headers are installed to.", "$PREFIX/include", PathOption.PathAccept ),
  47. BoolOption( "ENABLE_ALSA", "Enable/Disable the ALSA backend.", True ),
  48. BoolOption( "ENABLE_FREEBOB", "Enable/Disable the FreeBoB backend.", True ),
  49. BoolOption( "ENABLE_FIREWIRE", "Enable/Disable the FireWire backend.", True ),
  50. BoolOption( "DEBUG", """Do a debug build.""", True ),
  51. BoolOption( "BUILD_TESTS", """Build tests where applicable.""", True ),
  52. BoolOption( "BUILD_EXAMPLES", """Build the example clients in their directory.""", True ),
  53. BoolOption( "INSTALL_EXAMPLES", """Install the example clients in the BINDIR directory.""", True ),
  54. BoolOption( "BUILD_DOXYGEN_DOCS", """Build doxygen documentation.""", True ),
  55. )
  56. ## Load the builders in config
  57. buildenv = os.environ
  58. if os.environ.has_key('PATH'):
  59. buildenv['PATH'] = os.environ['PATH']
  60. else:
  61. buildenv['PATH'] = ''
  62. if os.environ.has_key('PKG_CONFIG_PATH'):
  63. buildenv['PKG_CONFIG_PATH'] = os.environ['PKG_CONFIG_PATH']
  64. else:
  65. buildenv['PKG_CONFIG_PATH'] = ''
  66. if os.environ.has_key('LD_LIBRARY_PATH'):
  67. buildenv['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
  68. else:
  69. buildenv['LD_LIBRARY_PATH'] = ''
  70. env = Environment( tools=['default','scanreplace','pkgconfig', 'doxygen'], toolpath=['admin'],
  71. ENV=buildenv, PLATFORM = platform, options=opts )
  72. Help( """
  73. For building jackdmp you can set different options as listed below. You have to
  74. specify them only once, scons will save the last value you used and re-use
  75. that.
  76. To really undo your settings and return to the factory defaults, remove the
  77. "cache"-folder and the file ".sconsign.dblite" from this directory.
  78. For example with: "rm -Rf .sconsign.dblite cache"
  79. """ )
  80. Help( opts.GenerateHelpText( env ) )
  81. # make sure the necessary dirs exist
  82. if not os.path.isdir( "cache/" + build_base ):
  83. os.makedirs( "cache/" + build_base )
  84. if not os.path.isdir( 'cache/objects' ):
  85. os.makedirs( 'cache/objects' )
  86. if build_base:
  87. env['build_base']="#/"+build_base
  88. else:
  89. env['build_base']="#/"
  90. CacheDir( 'cache/objects' )
  91. opts.Save( 'cache/' + build_base + "options.cache", env )
  92. tests = {}
  93. tests.update( env['PKGCONFIG_TESTS'] )
  94. if not env.GetOption('clean'):
  95. conf = Configure( env,
  96. custom_tests = tests,
  97. conf_dir = "cache/" + build_base,
  98. log_file = "cache/" + build_base + 'config.log' )
  99. #
  100. # Check if the environment can actually compile c-files by checking for a
  101. # header shipped with gcc.
  102. #
  103. if not conf.CheckHeader( "stdio.h" ):
  104. print "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."
  105. Exit( 1 )
  106. #
  107. # The following checks are for headers and libs and packages we need.
  108. #
  109. allpresent = 1;
  110. if build_for_linux:
  111. allpresent &= conf.CheckForPKGConfig();
  112. # example on how to check for additional libs
  113. # pkgs = {
  114. # 'alsa' : '1.0.0',
  115. # }
  116. # for pkg in pkgs:
  117. # name2 = pkg.replace("+","").replace(".","").replace("-","").upper()
  118. # env['%s_FLAGS' % name2] = conf.GetPKGFlags( pkg, pkgs[pkg] )
  119. # if env['%s_FLAGS'%name2] == 0:
  120. # allpresent &= 0
  121. if not allpresent:
  122. print """
  123. (At least) One of the dependencies is missing. I can't go on without it, please
  124. install the needed packages (remember to also install the *-devel packages)
  125. """
  126. Exit( 1 )
  127. # jack doesn't have to be present, but it would be nice to know if it is
  128. env['JACK_FLAGS'] = conf.GetPKGFlags( 'jack', '0.100.0' )
  129. if env['JACK_FLAGS']:
  130. env['JACK_PREFIX'] = conf.GetPKGPrefix( 'jack' )
  131. env['JACK_EXEC_PREFIX'] = conf.GetPKGExecPrefix( 'jack' )
  132. env['JACK_LIBDIR'] = conf.GetPKGLibdir( 'jack' )
  133. env['JACK_INCLUDEDIR'] = conf.GetPKGIncludedir( 'jack' )
  134. #
  135. # Optional checks follow:
  136. #
  137. if build_for_linux and env['ENABLE_ALSA']:
  138. env['ALSA_FLAGS'] = conf.GetPKGFlags( 'alsa', '1.0.0' )
  139. if env['ALSA_FLAGS'] == 0:
  140. print " Disabling 'alsa' backend since no useful ALSA installation found."
  141. env['ENABLE_ALSA'] = False
  142. if build_for_linux and env['ENABLE_FREEBOB']:
  143. env['FREEBOB_FLAGS'] = conf.GetPKGFlags( 'libfreebob', '1.0.0' )
  144. if env['FREEBOB_FLAGS'] == 0:
  145. print " Disabling 'freebob' backend since no useful FreeBoB installation found."
  146. env['ENABLE_FREEBOB'] = False
  147. if build_for_linux and env['ENABLE_FIREWIRE']:
  148. env['FFADO_FLAGS'] = conf.GetPKGFlags( 'libffado', '1.999.14' )
  149. if env['FFADO_FLAGS'] == 0:
  150. print " Disabling 'firewire' backend since no useful FFADO installation found."
  151. env['ENABLE_FIREWIRE'] = False
  152. env = conf.Finish()
  153. if env['DEBUG']:
  154. print "Doing a DEBUG build"
  155. # -Werror could be added to, which would force the devs to really remove all the warnings :-)
  156. env.AppendUnique( CCFLAGS=["-DDEBUG","-Wall","-g"] )
  157. else:
  158. env.AppendUnique( CCFLAGS=["-O3","-DNDEBUG"] )
  159. env.AppendUnique( CCFLAGS=["-fPIC", "-DSOCKET_RPC_FIFO_SEMA", "-D__SMP__"] )
  160. env.AppendUnique( CFLAGS=["-fPIC", "-DUSE_POSIX_SHM"] )
  161. #
  162. # XXX: Maybe we can even drop these lower-case variables and only use the uppercase ones?
  163. #
  164. env['prefix'] = Template( os.path.join( env['PREFIX'] ) ).safe_substitute( env )
  165. env['bindir'] = Template( os.path.join( env['BINDIR'] ) ).safe_substitute( env )
  166. env['libdir'] = Template( os.path.join( env['LIBDIR'] ) ).safe_substitute( env )
  167. env['includedir'] = Template( os.path.join( env['INCLUDEDIR'] ) ).safe_substitute( env )
  168. env.Alias( "install", env['libdir'] )
  169. env.Alias( "install", env['includedir'] )
  170. env.Alias( "install", env['bindir'] )
  171. # for config.h.in
  172. env['ADDON_DIR']='%s' % env['prefix']
  173. env['LIB_DIR']='lib'
  174. env['JACK_LOCATION']='%s' % env['bindir']
  175. #
  176. # To have the top_srcdir as the doxygen-script is used from auto*
  177. #
  178. env['top_srcdir'] = env.Dir( "." ).abspath
  179. #subprojects = env.Split('common common/jack tests example-clients linux/alsa linux/freebob linux/firewire')
  180. #for subproject in subprojects:
  181. #env.AppendUnique( CCFLAGS=["-I%s" % subproject] )
  182. #env.AppendUnique( CFLAGS=["-I%s" % subproject] )
  183. env.ScanReplace( "config.h.in" )
  184. # ensure that the config.h is always updated, since it
  185. # sometimes fails to pick up the changes
  186. # note: this still doesn't seem to cause dependent files to be rebuilt.
  187. NoCache("config.h")
  188. AlwaysBuild("config.h")
  189. # ensure we have a path to where the libraries are
  190. env.AppendUnique( LIBPATH=["#/common"] )
  191. #
  192. # Start building
  193. #
  194. if env['BUILD_DOXYGEN_DOCS']:
  195. env.Doxygen("doxyfile")
  196. subdirs=['common']
  197. if env['PLATFORM'] == 'posix':
  198. subdirs.append('linux')
  199. if env['PLATFORM'] == 'macosx': # FIXME FOR SLETZ: check macosx/SConscript
  200. subdirs.append('macosx')
  201. if env['PLATFORM'] == 'windows': # FIXME FOR SLETZ: create/check macosx/SConscript
  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" )