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.

260 lines
9.2KB

  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. PathOption( "SHAREDIR", "Overwrite the directory where misc shared files are installed to.", "$PREFIX/share/libffado", PathOption.PathAccept ),
  48. BoolOption( "ENABLE_ALSA", "Enable/Disable the ALSA backend.", True ),
  49. BoolOption( "ENABLE_FREEBOB", "Enable/Disable the FreeBoB backend.", True ),
  50. BoolOption( "ENABLE_FIREWIRE", "Enable/Disable the FireWire backend.", True ),
  51. BoolOption( "DEBUG", """Do a debug build.""", True ),
  52. BoolOption( "BUILD_TESTS", """Build tests where applicable.""", True ),
  53. BoolOption( "BUILD_EXAMPLES", """Build the example clients in their directory.""", True ),
  54. BoolOption( "INSTALL_EXAMPLES", """Install the example clients in the BINDIR directory.""", True ),
  55. BoolOption( "BUILD_DOXYGEN_DOCS", """Build doxygen documentation.""", True ),
  56. )
  57. ## Load the builders in config
  58. buildenv={}
  59. if os.environ.has_key('PATH'):
  60. buildenv['PATH']=os.environ['PATH']
  61. else:
  62. buildenv['PATH']=''
  63. if os.environ.has_key('PKG_CONFIG_PATH'):
  64. buildenv['PKG_CONFIG_PATH']=os.environ['PKG_CONFIG_PATH']
  65. else:
  66. buildenv['PKG_CONFIG_PATH']=''
  67. if os.environ.has_key('LD_LIBRARY_PATH'):
  68. buildenv['LD_LIBRARY_PATH']=os.environ['LD_LIBRARY_PATH']
  69. else:
  70. buildenv['LD_LIBRARY_PATH']=''
  71. env = Environment( tools=['default','scanreplace','pkgconfig', 'doxygen'], toolpath=['admin'],
  72. ENV=buildenv, PLATFORM = platform, options=opts )
  73. Help( """
  74. For building jackdmp you can set different options as listed below. You have to
  75. specify them only once, scons will save the last value you used and re-use
  76. that.
  77. To really undo your settings and return to the factory defaults, remove the
  78. "cache"-folder and the file ".sconsign.dblite" from this directory.
  79. For example with: "rm -Rf .sconsign.dblite cache"
  80. """ )
  81. Help( opts.GenerateHelpText( env ) )
  82. # make sure the necessary dirs exist
  83. if not os.path.isdir( "cache/" + build_base ):
  84. os.makedirs( "cache/" + build_base )
  85. if not os.path.isdir( 'cache/objects' ):
  86. os.makedirs( 'cache/objects' )
  87. if build_base:
  88. env['build_base']="#/"+build_base
  89. else:
  90. env['build_base']="#/"
  91. CacheDir( 'cache/objects' )
  92. opts.Save( 'cache/' + build_base + "options.cache", env )
  93. tests = {}
  94. tests.update( env['PKGCONFIG_TESTS'] )
  95. if not env.GetOption('clean'):
  96. conf = Configure( env,
  97. custom_tests = tests,
  98. conf_dir = "cache/" + build_base,
  99. log_file = "cache/" + build_base + 'config.log' )
  100. #
  101. # Check if the environment can actually compile c-files by checking for a
  102. # header shipped with gcc.
  103. #
  104. if not conf.CheckHeader( "stdio.h" ):
  105. 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."
  106. Exit( 1 )
  107. #
  108. # The following checks are for headers and libs and packages we need.
  109. #
  110. allpresent = 1;
  111. if build_for_linux:
  112. allpresent &= conf.CheckForPKGConfig();
  113. # example on how to check for additional libs
  114. # pkgs = {
  115. # 'alsa' : '1.0.0',
  116. # }
  117. # for pkg in pkgs:
  118. # name2 = pkg.replace("+","").replace(".","").replace("-","").upper()
  119. # env['%s_FLAGS' % name2] = conf.GetPKGFlags( pkg, pkgs[pkg] )
  120. # if env['%s_FLAGS'%name2] == 0:
  121. # allpresent &= 0
  122. if not allpresent:
  123. print """
  124. (At least) One of the dependencies is missing. I can't go on without it, please
  125. install the needed packages (remember to also install the *-devel packages)
  126. """
  127. Exit( 1 )
  128. # jack doesn't have to be present, but it would be nice to know if it is
  129. env['JACK_FLAGS'] = conf.GetPKGFlags( 'jack', '0.100.0' )
  130. if env['JACK_FLAGS']:
  131. env['JACK_PREFIX'] = conf.GetPKGPrefix( 'jack' )
  132. env['JACK_EXEC_PREFIX'] = conf.GetPKGExecPrefix( 'jack' )
  133. env['JACK_LIBDIR'] = conf.GetPKGLibdir( 'jack' )
  134. env['JACK_INCLUDEDIR'] = conf.GetPKGIncludedir( 'jack' )
  135. #
  136. # Optional checks follow:
  137. #
  138. if build_for_linux and env['ENABLE_ALSA']:
  139. env['ALSA_FLAGS'] = conf.GetPKGFlags( 'alsa', '1.0.0' )
  140. if env['ALSA_FLAGS'] == 0:
  141. print " Disabling 'alsa' backend since no useful ALSA installation found."
  142. env['ENABLE_ALSA'] = False
  143. if build_for_linux and env['ENABLE_FREEBOB']:
  144. env['FREEBOB_FLAGS'] = conf.GetPKGFlags( 'libfreebob', '1.0.0' )
  145. if env['FREEBOB_FLAGS'] == 0:
  146. print " Disabling 'freebob' backend since no useful FreeBoB installation found."
  147. env['ENABLE_FREEBOB'] = False
  148. if build_for_linux and env['ENABLE_FIREWIRE']:
  149. env['FFADO_FLAGS'] = conf.GetPKGFlags( 'libffado', '1.999.7' )
  150. if env['FFADO_FLAGS'] == 0:
  151. print " Disabling 'firewire' backend since no useful FFADO installation found."
  152. env['ENABLE_FIREWIRE'] = False
  153. env = conf.Finish()
  154. if env['DEBUG']:
  155. print "Doing a DEBUG build"
  156. # -Werror could be added to, which would force the devs to really remove all the warnings :-)
  157. env.AppendUnique( CCFLAGS=["-DDEBUG","-Wall","-g"] )
  158. else:
  159. env.AppendUnique( CCFLAGS=["-O3","-DNDEBUG"] )
  160. env.AppendUnique( CCFLAGS=["-fPIC", "-DSOCKET_RPC_FIFO_SEMA", "-D__SMP__"] )
  161. env.AppendUnique( CFLAGS=["-fPIC", "-DUSE_POSIX_SHM"] )
  162. #
  163. # XXX: Maybe we can even drop these lower-case variables and only use the uppercase ones?
  164. #
  165. env['prefix'] = Template( os.path.join( env['PREFIX'] ) ).safe_substitute( env )
  166. env['bindir'] = Template( os.path.join( env['BINDIR'] ) ).safe_substitute( env )
  167. env['libdir'] = Template( os.path.join( env['LIBDIR'] ) ).safe_substitute( env )
  168. env['includedir'] = Template( os.path.join( env['INCLUDEDIR'] ) ).safe_substitute( env )
  169. env['sharedir'] = Template( os.path.join( env['SHAREDIR'] ) ).safe_substitute( env )
  170. env.Alias( "install", env['libdir'] )
  171. env.Alias( "install", env['includedir'] )
  172. env.Alias( "install", env['sharedir'] )
  173. env.Alias( "install", env['bindir'] )
  174. # for config.h.in
  175. env['ADDON_DIR']='%s' % env['prefix']
  176. env['LIB_DIR']='lib'
  177. env['JACK_LOCATION']='%s' % env['bindir']
  178. #
  179. # To have the top_srcdir as the doxygen-script is used from auto*
  180. #
  181. env['top_srcdir'] = env.Dir( "." ).abspath
  182. #subprojects = env.Split('common common/jack tests example-clients linux/alsa linux/freebob linux/firewire')
  183. #for subproject in subprojects:
  184. #env.AppendUnique( CCFLAGS=["-I%s" % subproject] )
  185. #env.AppendUnique( CFLAGS=["-I%s" % subproject] )
  186. env.ScanReplace( "config.h.in" )
  187. # ensure that the config.h is always updated, since it
  188. # sometimes fails to pick up the changes
  189. # note: this still doesn't seem to cause dependent files to be rebuilt.
  190. NoCache("config.h")
  191. AlwaysBuild("config.h")
  192. #
  193. # Start building
  194. #
  195. if env['BUILD_DOXYGEN_DOCS']:
  196. env.Doxygen("doxyfile")
  197. subdirs=['common']
  198. if env['PLATFORM'] == 'posix':
  199. subdirs.append('linux')
  200. if env['PLATFORM'] == 'macosx': # FIXME FOR SLETZ: check macosx/SConscript
  201. subdirs.append('macosx')
  202. if env['PLATFORM'] == 'windows': # FIXME FOR SLETZ: create/check macosx/SConscript
  203. subdirs.append('windows')
  204. if env['BUILD_EXAMPLES']:
  205. subdirs.append('example-clients')
  206. if env['BUILD_TESTS']:
  207. subdirs.append('tests')
  208. if build_base:
  209. env.SConscript( dirs=subdirs, exports="env", build_dir=build_base+subdir )
  210. else:
  211. env.SConscript( dirs=subdirs, exports="env" )