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.

360 lines
15KB

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