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.

528 lines
18KB

  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. build_dir = ARGUMENTS.get('BUILDDIR', "")
  23. if build_dir:
  24. build_base=build_dir+'/'
  25. if not os.path.isdir( build_base ):
  26. os.makedirs( build_base )
  27. print "Building into: " + build_base
  28. else:
  29. build_base=''
  30. if not os.path.isdir( "cache" ):
  31. os.makedirs( "cache" )
  32. opts = Options( "cache/"+build_base+"options.cache" )
  33. # make this into a command line option and/or a detected value
  34. build_for_linux = True
  35. #
  36. # If this is just to display a help-text for the variable used via ARGUMENTS, then its wrong...
  37. opts.Add( "BUILDDIR", "Path to place the built files in", "")
  38. opts.AddOptions(
  39. # BoolOption( "DEBUG", """\
  40. #Toggle debug-build. DEBUG means \"-g -Wall\" and more, otherwise we will use
  41. # \"-O2\" to optimise.""", True ),
  42. PathOption( "PREFIX", "The prefix where jackdmp will be installed to.", "/usr/local", PathOption.PathAccept ),
  43. PathOption( "BINDIR", "Overwrite the directory where apps are installed to.", "$PREFIX/bin", PathOption.PathAccept ),
  44. PathOption( "LIBDIR", "Overwrite the directory where libs are installed to.", "$PREFIX/lib", PathOption.PathAccept ),
  45. PathOption( "INCLUDEDIR", "Overwrite the directory where headers are installed to.", "$PREFIX/include", PathOption.PathAccept ),
  46. PathOption( "SHAREDIR", "Overwrite the directory where misc shared files are installed to.", "$PREFIX/share/libffado", 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={}
  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'], ENV=buildenv, options=opts )
  71. Help( """
  72. For building jackdmp you can set different options as listed below. You have to
  73. specify them only once, scons will save the last value you used and re-use
  74. that.
  75. To really undo your settings and return to the factory defaults, remove the
  76. "cache"-folder and the file ".sconsign.dblite" from this directory.
  77. For example with: "rm -Rf .sconsign.dblite cache"
  78. """ )
  79. Help( opts.GenerateHelpText( env ) )
  80. # make sure the necessary dirs exist
  81. if not os.path.isdir( "cache/" + build_base ):
  82. os.makedirs( "cache/" + build_base )
  83. if not os.path.isdir( 'cache/objects' ):
  84. os.makedirs( 'cache/objects' )
  85. if build_base:
  86. env['build_base']="#/"+build_base
  87. else:
  88. env['build_base']="#/"
  89. CacheDir( 'cache/objects' )
  90. opts.Save( 'cache/' + build_base + "options.cache", env )
  91. tests = {}
  92. tests.update( env['PKGCONFIG_TESTS'] )
  93. if not env.GetOption('clean'):
  94. conf = Configure( env,
  95. custom_tests = tests,
  96. conf_dir = "cache/" + build_base,
  97. log_file = "cache/" + build_base + 'config.log' )
  98. #
  99. # Check if the environment can actually compile c-files by checking for a
  100. # header shipped with gcc.
  101. #
  102. if not conf.CheckHeader( "stdio.h" ):
  103. 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."
  104. Exit( 1 )
  105. #
  106. # The following checks are for headers and libs and packages we need.
  107. #
  108. allpresent = 1;
  109. if build_for_linux:
  110. allpresent &= conf.CheckForPKGConfig();
  111. # example on how to check for additional libs
  112. # pkgs = {
  113. # 'alsa' : '1.0.0',
  114. # }
  115. # for pkg in pkgs:
  116. # name2 = pkg.replace("+","").replace(".","").replace("-","").upper()
  117. # env['%s_FLAGS' % name2] = conf.GetPKGFlags( pkg, pkgs[pkg] )
  118. # if env['%s_FLAGS'%name2] == 0:
  119. # allpresent &= 0
  120. if not allpresent:
  121. print """
  122. (At least) One of the dependencies is missing. I can't go on without it, please
  123. install the needed packages (remember to also install the *-devel packages)
  124. """
  125. Exit( 1 )
  126. # jack doesn't have to be present, but it would be nice to know if it is
  127. env['JACK_FLAGS'] = conf.GetPKGFlags( 'jack', '0.100.0' )
  128. if env['JACK_FLAGS']:
  129. env['JACK_PREFIX'] = conf.GetPKGPrefix( 'jack' )
  130. env['JACK_EXEC_PREFIX'] = conf.GetPKGExecPrefix( 'jack' )
  131. env['JACK_LIBDIR'] = conf.GetPKGLibdir( 'jack' )
  132. env['JACK_INCLUDEDIR'] = conf.GetPKGIncludedir( 'jack' )
  133. #
  134. # Optional checks follow:
  135. #
  136. if build_for_linux and env['ENABLE_ALSA']:
  137. env['ALSA_FLAGS'] = conf.GetPKGFlags( 'ALSA', '1.0.0' )
  138. if env['ALSA_FLAGS'] == 0:
  139. print " Disabling 'alsa' backend since no useful ALSA installation found."
  140. env['ENABLE_ALSA'] = False
  141. if build_for_linux and env['ENABLE_FREEBOB']:
  142. env['FREEBOB_FLAGS'] = conf.GetPKGFlags( 'libfreebob', '1.0.0' )
  143. if env['FREEBOB_FLAGS'] == 0:
  144. print " Disabling 'freebob' backend since no useful FreeBoB installation found."
  145. env['ENABLE_FREEBOB'] = False
  146. if build_for_linux and env['ENABLE_FIREWIRE']:
  147. env['FFADO_FLAGS'] = conf.GetPKGFlags( 'libffado', '1.999.7' )
  148. if env['FFADO_FLAGS'] == 0:
  149. print " Disabling 'firewire' backend since no useful FFADO installation found."
  150. env['ENABLE_FIREWIRE'] = False
  151. env = conf.Finish()
  152. if env['DEBUG']:
  153. print "Doing a DEBUG build"
  154. # -Werror could be added to, which would force the devs to really remove all the warnings :-)
  155. env.AppendUnique( CCFLAGS=["-DDEBUG","-Wall","-g"] )
  156. env.AppendUnique( CFLAGS=["-DDEBUG","-Wall","-g"] )
  157. else:
  158. env.AppendUnique( CCFLAGS=["-O2","-DNDEBUG"] )
  159. env.AppendUnique( CFLAGS=["-O2","-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 build_for_linux:
  199. subdirs.append('linux')
  200. if env['BUILD_EXAMPLES']:
  201. subdirs.append('example-clients')
  202. if env['BUILD_TESTS']:
  203. subdirs.append('tests')
  204. if build_base:
  205. env.SConscript( dirs=subdirs, exports="env", build_dir=build_base+subdir )
  206. else:
  207. env.SConscript( dirs=subdirs, exports="env" )
  208. #
  209. # Copyright (C) 2007 Arnold Krille
  210. # Copyright (C) 2007 Pieter Palmers
  211. #
  212. # This file originates from FFADO (www.ffado.org)
  213. #
  214. # This program is free software: you can redistribute it and/or modify
  215. # it under the terms of the GNU General Public License as published by
  216. # the Free Software Foundation, either version 3 of the License, or
  217. # (at your option) any later version.
  218. #
  219. # This program is distributed in the hope that it will be useful,
  220. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  221. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  222. # GNU General Public License for more details.
  223. #
  224. # You should have received a copy of the GNU General Public License
  225. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  226. #
  227. import os
  228. from string import Template
  229. build_dir = ARGUMENTS.get('BUILDDIR', "")
  230. if build_dir:
  231. build_base=build_dir+'/'
  232. if not os.path.isdir( build_base ):
  233. os.makedirs( build_base )
  234. print "Building into: " + build_base
  235. else:
  236. build_base=''
  237. if not os.path.isdir( "cache" ):
  238. os.makedirs( "cache" )
  239. opts = Options( "cache/"+build_base+"options.cache" )
  240. # make this into a command line option and/or a detected value
  241. build_for_linux = True
  242. #
  243. # If this is just to display a help-text for the variable used via ARGUMENTS, then its wrong...
  244. opts.Add( "BUILDDIR", "Path to place the built files in", "")
  245. opts.AddOptions(
  246. # BoolOption( "DEBUG", """\
  247. #Toggle debug-build. DEBUG means \"-g -Wall\" and more, otherwise we will use
  248. # \"-O2\" to optimise.""", True ),
  249. PathOption( "PREFIX", "The prefix where jackdmp will be installed to.", "/usr/local", PathOption.PathAccept ),
  250. PathOption( "BINDIR", "Overwrite the directory where apps are installed to.", "$PREFIX/bin", PathOption.PathAccept ),
  251. PathOption( "LIBDIR", "Overwrite the directory where libs are installed to.", "$PREFIX/lib", PathOption.PathAccept ),
  252. PathOption( "INCLUDEDIR", "Overwrite the directory where headers are installed to.", "$PREFIX/include", PathOption.PathAccept ),
  253. PathOption( "SHAREDIR", "Overwrite the directory where misc shared files are installed to.", "$PREFIX/share/libffado", PathOption.PathAccept ),
  254. BoolOption( "ENABLE_ALSA", "Enable/Disable the ALSA backend.", True ),
  255. BoolOption( "ENABLE_FREEBOB", "Enable/Disable the FreeBoB backend.", True ),
  256. BoolOption( "ENABLE_FIREWIRE", "Enable/Disable the FireWire backend.", True ),
  257. BoolOption( "DEBUG", """Do a debug build.""", True ),
  258. BoolOption( "BUILD_TESTS", """Build tests where applicable.""", True ),
  259. BoolOption( "BUILD_EXAMPLES", """Build the example clients in their directory.""", True ),
  260. BoolOption( "INSTALL_EXAMPLES", """Install the example clients in the BINDIR directory.""", True ),
  261. BoolOption( "BUILD_DOXYGEN_DOCS", """Build doxygen documentation.""", True ),
  262. )
  263. ## Load the builders in config
  264. buildenv={}
  265. if os.environ.has_key('PATH'):
  266. buildenv['PATH']=os.environ['PATH']
  267. else:
  268. buildenv['PATH']=''
  269. if os.environ.has_key('PKG_CONFIG_PATH'):
  270. buildenv['PKG_CONFIG_PATH']=os.environ['PKG_CONFIG_PATH']
  271. else:
  272. buildenv['PKG_CONFIG_PATH']=''
  273. if os.environ.has_key('LD_LIBRARY_PATH'):
  274. buildenv['LD_LIBRARY_PATH']=os.environ['LD_LIBRARY_PATH']
  275. else:
  276. buildenv['LD_LIBRARY_PATH']=''
  277. env = Environment( tools=['default','scanreplace','pkgconfig', 'doxygen'], toolpath=['admin'], ENV=buildenv, options=opts )
  278. Help( """
  279. For building jackdmp you can set different options as listed below. You have to
  280. specify them only once, scons will save the last value you used and re-use
  281. that.
  282. To really undo your settings and return to the factory defaults, remove the
  283. "cache"-folder and the file ".sconsign.dblite" from this directory.
  284. For example with: "rm -Rf .sconsign.dblite cache"
  285. """ )
  286. Help( opts.GenerateHelpText( env ) )
  287. # make sure the necessary dirs exist
  288. if not os.path.isdir( "cache/" + build_base ):
  289. os.makedirs( "cache/" + build_base )
  290. if not os.path.isdir( 'cache/objects' ):
  291. os.makedirs( 'cache/objects' )
  292. if build_base:
  293. env['build_base']="#/"+build_base
  294. else:
  295. env['build_base']="#/"
  296. CacheDir( 'cache/objects' )
  297. opts.Save( 'cache/' + build_base + "options.cache", env )
  298. tests = {}
  299. tests.update( env['PKGCONFIG_TESTS'] )
  300. if not env.GetOption('clean'):
  301. conf = Configure( env,
  302. custom_tests = tests,
  303. conf_dir = "cache/" + build_base,
  304. log_file = "cache/" + build_base + 'config.log' )
  305. #
  306. # Check if the environment can actually compile c-files by checking for a
  307. # header shipped with gcc.
  308. #
  309. if not conf.CheckHeader( "stdio.h" ):
  310. 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."
  311. Exit( 1 )
  312. #
  313. # The following checks are for headers and libs and packages we need.
  314. #
  315. allpresent = 1;
  316. if build_for_linux:
  317. allpresent &= conf.CheckForPKGConfig();
  318. # example on how to check for additional libs
  319. # pkgs = {
  320. # 'alsa' : '1.0.0',
  321. # }
  322. # for pkg in pkgs:
  323. # name2 = pkg.replace("+","").replace(".","").replace("-","").upper()
  324. # env['%s_FLAGS' % name2] = conf.GetPKGFlags( pkg, pkgs[pkg] )
  325. # if env['%s_FLAGS'%name2] == 0:
  326. # allpresent &= 0
  327. if not allpresent:
  328. print """
  329. (At least) One of the dependencies is missing. I can't go on without it, please
  330. install the needed packages (remember to also install the *-devel packages)
  331. """
  332. Exit( 1 )
  333. # jack doesn't have to be present, but it would be nice to know if it is
  334. env['JACK_FLAGS'] = conf.GetPKGFlags( 'jack', '0.100.0' )
  335. if env['JACK_FLAGS']:
  336. env['JACK_PREFIX'] = conf.GetPKGPrefix( 'jack' )
  337. env['JACK_EXEC_PREFIX'] = conf.GetPKGExecPrefix( 'jack' )
  338. env['JACK_LIBDIR'] = conf.GetPKGLibdir( 'jack' )
  339. env['JACK_INCLUDEDIR'] = conf.GetPKGIncludedir( 'jack' )
  340. #
  341. # Optional checks follow:
  342. #
  343. if build_for_linux and env['ENABLE_ALSA']:
  344. env['ALSA_FLAGS'] = conf.GetPKGFlags( 'ALSA', '1.0.0' )
  345. if env['ALSA_FLAGS'] == 0:
  346. print " Disabling 'alsa' backend since no useful ALSA installation found."
  347. env['ENABLE_ALSA'] = False
  348. if build_for_linux and env['ENABLE_FREEBOB']:
  349. env['FREEBOB_FLAGS'] = conf.GetPKGFlags( 'libfreebob', '1.0.0' )
  350. if env['FREEBOB_FLAGS'] == 0:
  351. print " Disabling 'freebob' backend since no useful FreeBoB installation found."
  352. env['ENABLE_FREEBOB'] = False
  353. if build_for_linux and env['ENABLE_FIREWIRE']:
  354. env['FFADO_FLAGS'] = conf.GetPKGFlags( 'libffado', '1.999.7' )
  355. if env['FFADO_FLAGS'] == 0:
  356. print " Disabling 'firewire' backend since no useful FFADO installation found."
  357. env['ENABLE_FIREWIRE'] = False
  358. env = conf.Finish()
  359. if env['DEBUG']:
  360. print "Doing a DEBUG build"
  361. # -Werror could be added to, which would force the devs to really remove all the warnings :-)
  362. env.AppendUnique( CCFLAGS=["-DDEBUG","-Wall","-g"] )
  363. env.AppendUnique( CFLAGS=["-DDEBUG","-Wall","-g"] )
  364. else:
  365. env.AppendUnique( CCFLAGS=["-O2","-DNDEBUG"] )
  366. env.AppendUnique( CFLAGS=["-O2","-DNDEBUG"] )
  367. env.AppendUnique( CCFLAGS=["-fPIC", "-DSOCKET_RPC_FIFO_SEMA", "-D__SMP__"] )
  368. env.AppendUnique( CFLAGS=["-fPIC", "-DUSE_POSIX_SHM"] )
  369. #
  370. # XXX: Maybe we can even drop these lower-case variables and only use the uppercase ones?
  371. #
  372. env['prefix'] = Template( os.path.join( env['PREFIX'] ) ).safe_substitute( env )
  373. env['bindir'] = Template( os.path.join( env['BINDIR'] ) ).safe_substitute( env )
  374. env['libdir'] = Template( os.path.join( env['LIBDIR'] ) ).safe_substitute( env )
  375. env['includedir'] = Template( os.path.join( env['INCLUDEDIR'] ) ).safe_substitute( env )
  376. env['sharedir'] = Template( os.path.join( env['SHAREDIR'] ) ).safe_substitute( env )
  377. env.Alias( "install", env['libdir'] )
  378. env.Alias( "install", env['includedir'] )
  379. env.Alias( "install", env['sharedir'] )
  380. env.Alias( "install", env['bindir'] )
  381. # for config.h.in
  382. env['ADDON_DIR']='%s' % env['prefix']
  383. env['LIB_DIR']='lib'
  384. env['JACK_LOCATION']='%s' % env['bindir']
  385. #
  386. # To have the top_srcdir as the doxygen-script is used from auto*
  387. #
  388. env['top_srcdir'] = env.Dir( "." ).abspath
  389. #subprojects = env.Split('common common/jack tests example-clients linux/alsa linux/freebob linux/firewire')
  390. #for subproject in subprojects:
  391. #env.AppendUnique( CCFLAGS=["-I%s" % subproject] )
  392. #env.AppendUnique( CFLAGS=["-I%s" % subproject] )
  393. env.ScanReplace( "config.h.in" )
  394. # ensure that the config.h is always updated, since it
  395. # sometimes fails to pick up the changes
  396. # note: this still doesn't seem to cause dependent files to be rebuilt.
  397. NoCache("config.h")
  398. AlwaysBuild("config.h")
  399. #
  400. # Start building
  401. #
  402. if env['BUILD_DOXYGEN_DOCS']:
  403. env.Doxygen("doxyfile")
  404. subdirs=['common']
  405. if build_for_linux:
  406. subdirs.append('linux')
  407. if env['BUILD_EXAMPLES']:
  408. subdirs.append('example-clients')
  409. if env['BUILD_TESTS']:
  410. subdirs.append('tests')
  411. if build_base:
  412. env.SConscript( dirs=subdirs, exports="env", build_dir=build_base+subdir )
  413. else:
  414. env.SConscript( dirs=subdirs, exports="env" )
  415. # -*- python -*-
  416. import os
  417. import sys
  418. import re
  419. import shutil
  420. import glob
  421. import errno
  422. import time
  423. import platform
  424. import string
  425. import commands
  426. platform = ARGUMENTS.get('OS', Platform())
  427. env = Environment(PLATFORM = platform,
  428. CPPPATH = ['macosx', 'common'])
  429. Export('env')
  430. print platform
  431. env.SConscript(['common/SConscript'])