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.

354 lines
15KB

  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. import os
  4. import Utils
  5. import Options
  6. import commands
  7. g_maxlen = 40
  8. import shutil
  9. import Task
  10. import re
  11. import Logs
  12. VERSION='1.9.9'
  13. APPNAME='jack'
  14. JACK_API_VERSION = '0.1.0'
  15. # these variables are mandatory ('/' are converted automatically)
  16. srcdir = '.'
  17. blddir = 'build'
  18. def display_msg(msg, status = None, color = None):
  19. sr = msg
  20. global g_maxlen
  21. g_maxlen = max(g_maxlen, len(msg))
  22. if status:
  23. print "%s :" % msg.ljust(g_maxlen),
  24. Utils.pprint(color, status)
  25. else:
  26. print "%s" % msg.ljust(g_maxlen)
  27. def display_feature(msg, build):
  28. if build:
  29. display_msg(msg, "yes", 'GREEN')
  30. else:
  31. display_msg(msg, "no", 'YELLOW')
  32. def create_svnversion_task(bld, header='svnversion.h', define=None):
  33. import Constants, Build
  34. cmd = '../svnversion_regenerate.sh ${TGT}'
  35. if define:
  36. cmd += " " + define
  37. cls = Task.simple_task_type('svnversion', cmd, color='BLUE', before='cc')
  38. cls.runnable_status = lambda self: Constants.RUN_ME
  39. def post_run(self):
  40. sg = Utils.h_file(self.outputs[0].abspath(self.env))
  41. #print sg.encode('hex')
  42. Build.bld.node_sigs[self.env.variant()][self.outputs[0].id] = sg
  43. cls.post_run = post_run
  44. tsk = cls(bld.env.copy())
  45. tsk.inputs = []
  46. tsk.outputs = [bld.path.find_or_declare(header)]
  47. def set_options(opt):
  48. # options provided by the modules
  49. opt.tool_options('compiler_cxx')
  50. opt.tool_options('compiler_cc')
  51. opt.add_option('--libdir', type='string', help="Library directory [Default: <prefix>/lib]")
  52. opt.add_option('--libdir32', type='string', help="32bit Library directory [Default: <prefix>/lib32]")
  53. opt.add_option('--mandir', type='string', help="Manpage directory [Default: <prefix>/share/man/man1]")
  54. opt.add_option('--dbus', action='store_true', default=False, help='Enable D-Bus JACK (jackdbus)')
  55. opt.add_option('--classic', action='store_true', default=False, help='Force enable standard JACK (jackd) even if D-Bus JACK (jackdbus) is enabled too')
  56. opt.add_option('--doxygen', action='store_true', default=False, help='Enable build of doxygen documentation')
  57. opt.add_option('--profile', action='store_true', default=False, help='Build with engine profiling')
  58. opt.add_option('--mixed', action='store_true', default=False, help='Build with 32/64 bits mixed mode')
  59. opt.add_option('--clients', default=64, type="int", dest="clients", help='Maximum number of JACK clients')
  60. opt.add_option('--ports-per-application', default=768, type="int", dest="application_ports", help='Maximum number of ports per application')
  61. opt.add_option('--debug', action='store_true', default=False, dest='debug', help='Build debuggable binaries')
  62. opt.add_option('--firewire', action='store_true', default=False, help='Enable FireWire driver (FFADO)')
  63. opt.add_option('--freebob', action='store_true', default=False, help='Enable FreeBob driver')
  64. opt.add_option('--alsa', action='store_true', default=False, help='Enable ALSA driver')
  65. opt.sub_options('dbus')
  66. def configure(conf):
  67. platform = Utils.detect_platform()
  68. conf.env['IS_MACOSX'] = platform == 'darwin'
  69. conf.env['IS_LINUX'] = platform == 'linux' or platform == 'posix'
  70. conf.env['IS_SUN'] = platform == 'sunos'
  71. if conf.env['IS_LINUX']:
  72. Utils.pprint('CYAN', "Linux detected")
  73. if conf.env['IS_MACOSX']:
  74. Utils.pprint('CYAN', "MacOS X detected")
  75. if conf.env['IS_SUN']:
  76. Utils.pprint('CYAN', "SunOS detected")
  77. if conf.env['IS_LINUX']:
  78. conf.check_tool('compiler_cxx')
  79. conf.check_tool('compiler_cc')
  80. if conf.env['IS_MACOSX']:
  81. conf.check_tool('compiler_cxx')
  82. conf.check_tool('compiler_cc')
  83. # waf 1.5 : check_tool('compiler_cxx') and check_tool('compiler_cc') do not work correctly, so explicit use of gcc and g++
  84. if conf.env['IS_SUN']:
  85. conf.check_tool('g++')
  86. conf.check_tool('gcc')
  87. #if conf.env['IS_SUN']:
  88. # conf.check_tool('compiler_cxx')
  89. # conf.check_tool('compiler_cc')
  90. conf.env.append_unique('CXXFLAGS', '-Wall')
  91. conf.env.append_unique('CCFLAGS', '-Wall')
  92. conf.sub_config('common')
  93. if conf.env['IS_LINUX']:
  94. conf.sub_config('linux')
  95. if Options.options.alsa and not conf.env['BUILD_DRIVER_ALSA']:
  96. conf.fatal('ALSA driver was explicitly requested but cannot be built')
  97. if Options.options.freebob and not conf.env['BUILD_DRIVER_FREEBOB']:
  98. conf.fatal('FreeBob driver was explicitly requested but cannot be built')
  99. if Options.options.firewire and not conf.env['BUILD_DRIVER_FFADO']:
  100. conf.fatal('FFADO driver was explicitly requested but cannot be built')
  101. conf.env['BUILD_DRIVER_ALSA'] = Options.options.alsa
  102. conf.env['BUILD_DRIVER_FFADO'] = Options.options.firewire
  103. conf.env['BUILD_DRIVER_FREEBOB'] = Options.options.freebob
  104. if Options.options.dbus:
  105. conf.sub_config('dbus')
  106. if conf.env['BUILD_JACKDBUS'] != True:
  107. conf.fatal('jackdbus was explicitly requested but cannot be built')
  108. conf.check_cc(header_name='samplerate.h', define_name="HAVE_SAMPLERATE")
  109. if conf.is_defined('HAVE_SAMPLERATE'):
  110. conf.env['LIB_SAMPLERATE'] = ['samplerate']
  111. conf.sub_config('example-clients')
  112. if conf.check_cfg(package='celt', atleast_version='0.11.0', args='--cflags --libs'):
  113. conf.define('HAVE_CELT', 1)
  114. conf.define('HAVE_CELT_API_0_11', 1)
  115. conf.define('HAVE_CELT_API_0_8', 0)
  116. conf.define('HAVE_CELT_API_0_7', 0)
  117. conf.define('HAVE_CELT_API_0_5', 0)
  118. elif conf.check_cfg(package='celt', atleast_version='0.8.0', args='--cflags --libs'):
  119. conf.define('HAVE_CELT', 1)
  120. conf.define('HAVE_CELT_API_0_11', 0)
  121. conf.define('HAVE_CELT_API_0_8', 1)
  122. conf.define('HAVE_CELT_API_0_7', 0)
  123. conf.define('HAVE_CELT_API_0_5', 0)
  124. elif conf.check_cfg(package='celt', atleast_version='0.7.0', args='--cflags --libs'):
  125. conf.define('HAVE_CELT', 1)
  126. conf.define('HAVE_CELT_API_0_11', 0)
  127. conf.define('HAVE_CELT_API_0_8', 0)
  128. conf.define('HAVE_CELT_API_0_7', 1)
  129. conf.define('HAVE_CELT_API_0_5', 0)
  130. elif conf.check_cfg(package='celt', atleast_version='0.5.0', args='--cflags --libs', required=True):
  131. conf.define('HAVE_CELT', 1)
  132. conf.define('HAVE_CELT_API_0_11', 0)
  133. conf.define('HAVE_CELT_API_0_8', 0)
  134. conf.define('HAVE_CELT_API_0_7', 0)
  135. conf.define('HAVE_CELT_API_0_5', 1)
  136. else:
  137. conf.define('HAVE_CELT', 0)
  138. conf.define('HAVE_CELT_API_0_11', 0)
  139. conf.define('HAVE_CELT_API_0_8', 0)
  140. conf.define('HAVE_CELT_API_0_7', 0)
  141. conf.define('HAVE_CELT_API_0_5', 0)
  142. conf.env['LIB_PTHREAD'] = ['pthread']
  143. conf.env['LIB_DL'] = ['dl']
  144. conf.env['LIB_RT'] = ['rt']
  145. conf.env['JACK_API_VERSION'] = JACK_API_VERSION
  146. conf.env['JACK_VERSION'] = VERSION
  147. conf.env['BUILD_DOXYGEN_DOCS'] = Options.options.doxygen
  148. conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
  149. conf.env['BUILD_WITH_32_64'] = Options.options.mixed
  150. conf.env['BUILD_CLASSIC'] = Options.options.classic
  151. conf.env['BUILD_DEBUG'] = Options.options.debug
  152. if conf.env['BUILD_JACKDBUS']:
  153. conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
  154. else:
  155. conf.env['BUILD_JACKD'] = True
  156. if Options.options.libdir:
  157. conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir
  158. else:
  159. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
  160. if Options.options.mandir:
  161. conf.env['MANDIR'] = conf.env['PREFIX'] + Options.options.mandir
  162. else:
  163. conf.env['MANDIR'] = conf.env['PREFIX'] + '/share/man/man1'
  164. if conf.env['BUILD_DEBUG']:
  165. conf.env.append_unique('CXXFLAGS', '-g')
  166. conf.env.append_unique('CCFLAGS', '-g')
  167. conf.env.append_unique('LINKFLAGS', '-g')
  168. conf.define('CLIENT_NUM', Options.options.clients)
  169. conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
  170. conf.define('ADDON_DIR', os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack')))
  171. conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
  172. conf.define('USE_POSIX_SHM', 1)
  173. conf.define('JACKMP', 1)
  174. if conf.env['BUILD_JACKDBUS'] == True:
  175. conf.define('JACK_DBUS', 1)
  176. if conf.env['BUILD_JACKD'] == False:
  177. conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
  178. if conf.env['BUILD_WITH_PROFILE'] == True:
  179. conf.define('JACK_MONITOR', 1)
  180. if conf.env['BUILD_WITH_32_64'] == True:
  181. conf.define('JACK_32_64', 1)
  182. conf.write_config_header('config.h')
  183. svnrev = None
  184. if os.access('svnversion.h', os.R_OK):
  185. data = file('svnversion.h').read()
  186. m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
  187. if m != None:
  188. svnrev = m.group(1)
  189. conf.env.append_unique('LINKFLAGS', '-lm -lstdc++')
  190. if Options.options.mixed == True:
  191. env_variant2 = conf.env.copy()
  192. conf.set_env_name('lib32', env_variant2)
  193. env_variant2.set_variant('lib32')
  194. conf.setenv('lib32')
  195. conf.env.append_unique('CXXFLAGS', '-m32')
  196. conf.env.append_unique('CCFLAGS', '-m32')
  197. conf.env.append_unique('LINKFLAGS', '-m32')
  198. if Options.options.libdir32:
  199. conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir32
  200. else:
  201. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
  202. conf.write_config_header('config.h')
  203. print
  204. display_msg("==================")
  205. version_msg = "JACK " + VERSION
  206. if svnrev:
  207. version_msg += " exported from r" + svnrev
  208. else:
  209. version_msg += " svn revision will checked and eventually updated during build"
  210. print version_msg
  211. print "Build with a maximum of %d JACK clients" % conf.env['CLIENT_NUM']
  212. print "Build with a maximum of %d ports per application" % conf.env['PORT_NUM_FOR_CLIENT']
  213. display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
  214. display_msg("Library directory", conf.env['LIBDIR'], 'CYAN')
  215. display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
  216. display_feature('Build debuggable binaries', conf.env['BUILD_DEBUG'])
  217. display_msg('C compiler flags', repr(conf.env['CCFLAGS']))
  218. display_msg('C++ compiler flags', repr(conf.env['CXXFLAGS']))
  219. display_msg('Linker flags', repr(conf.env['LINKFLAGS']))
  220. display_feature('Build doxygen documentation', conf.env['BUILD_DOXYGEN_DOCS'])
  221. display_feature('Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
  222. display_feature('Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
  223. display_feature('Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
  224. display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
  225. if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
  226. print Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs.colors.NORMAL
  227. print Logs.colors.RED + 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs.colors.NORMAL
  228. if conf.env['IS_LINUX']:
  229. display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True)
  230. display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True)
  231. display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True)
  232. if conf.env['BUILD_JACKDBUS'] == True:
  233. display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
  234. #display_msg('Settings persistence', xxx)
  235. if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
  236. print
  237. print Logs.colors.RED + "WARNING: D-Bus session services directory as reported by pkg-config is"
  238. print Logs.colors.RED + "WARNING:",
  239. print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL']
  240. print Logs.colors.RED + 'WARNING: but service file will be installed in'
  241. print Logs.colors.RED + "WARNING:",
  242. print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR']
  243. print Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
  244. print 'WARNING: You can override dbus service install directory'
  245. print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
  246. print Logs.colors.NORMAL,
  247. print
  248. def build(bld):
  249. print ("make[1]: Entering directory `" + os.getcwd() + "/" + blddir + "'" )
  250. if not os.access('svnversion.h', os.R_OK):
  251. create_svnversion_task(bld)
  252. # process subfolders from here
  253. bld.add_subdirs('common')
  254. if bld.env['IS_LINUX']:
  255. bld.add_subdirs('linux')
  256. bld.add_subdirs('example-clients')
  257. bld.add_subdirs('tests')
  258. bld.add_subdirs('man')
  259. if bld.env['BUILD_JACKDBUS'] == True:
  260. bld.add_subdirs('dbus')
  261. if bld.env['IS_MACOSX']:
  262. bld.add_subdirs('macosx')
  263. bld.add_subdirs('example-clients')
  264. bld.add_subdirs('tests')
  265. if bld.env['BUILD_JACKDBUS'] == True:
  266. bld.add_subdirs('dbus')
  267. if bld.env['IS_SUN']:
  268. bld.add_subdirs('solaris')
  269. bld.add_subdirs('example-clients')
  270. bld.add_subdirs('tests')
  271. if bld.env['BUILD_JACKDBUS'] == True:
  272. bld.add_subdirs('dbus')
  273. if bld.env['BUILD_DOXYGEN_DOCS'] == True:
  274. share_dir = bld.env.get_destdir() + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
  275. html_docs_source_dir = "build/default/html"
  276. html_docs_install_dir = share_dir + '/reference/html/'
  277. if Options.commands['install']:
  278. if os.path.isdir(html_docs_install_dir):
  279. Utils.pprint('CYAN', "Removing old doxygen documentation installation...")
  280. shutil.rmtree(html_docs_install_dir)
  281. Utils.pprint('CYAN', "Removing old doxygen documentation installation done.")
  282. Utils.pprint('CYAN', "Installing doxygen documentation...")
  283. shutil.copytree(html_docs_source_dir, html_docs_install_dir)
  284. Utils.pprint('CYAN', "Installing doxygen documentation done.")
  285. elif Options.commands['uninstall']:
  286. Utils.pprint('CYAN', "Uninstalling doxygen documentation...")
  287. if os.path.isdir(share_dir):
  288. shutil.rmtree(share_dir)
  289. Utils.pprint('CYAN', "Uninstalling doxygen documentation done.")
  290. elif Options.commands['clean']:
  291. if os.access(html_docs_source_dir, os.R_OK):
  292. Utils.pprint('CYAN', "Removing doxygen generated documentation...")
  293. shutil.rmtree(html_docs_source_dir)
  294. Utils.pprint('CYAN', "Removing doxygen generated documentation done.")
  295. elif Options.commands['build']:
  296. if not os.access(html_docs_source_dir, os.R_OK):
  297. os.popen("doxygen").read()
  298. else:
  299. Utils.pprint('CYAN', "doxygen documentation already built.")
  300. def dist_hook():
  301. os.remove('svnversion_regenerate.sh')
  302. os.system('../svnversion_regenerate.sh svnversion.h')