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.

893 lines
31KB

  1. #! /usr/bin/python3
  2. # encoding: utf-8
  3. from __future__ import print_function
  4. import os
  5. import subprocess
  6. import shutil
  7. import re
  8. import sys
  9. from waflib import Logs, Options, Task, Utils
  10. from waflib.Build import BuildContext, CleanContext, InstallContext, UninstallContext
  11. VERSION='1.9.14'
  12. APPNAME='jack'
  13. JACK_API_VERSION = '0.1.0'
  14. # these variables are mandatory ('/' are converted automatically)
  15. top = '.'
  16. out = 'build'
  17. # lib32 variant name used when building in mixed mode
  18. lib32 = 'lib32'
  19. def display_feature(conf, msg, build):
  20. if build:
  21. conf.msg(msg, 'yes', color='GREEN')
  22. else:
  23. conf.msg(msg, 'no', color='YELLOW')
  24. def check_for_celt(conf):
  25. found = False
  26. for version in ['11', '8', '7', '5']:
  27. define = 'HAVE_CELT_API_0_' + version
  28. if not found:
  29. try:
  30. conf.check_cfg(
  31. package='celt >= 0.%s.0' % version,
  32. args='--cflags --libs')
  33. found = True
  34. conf.define(define, 1)
  35. continue
  36. except conf.errors.ConfigurationError:
  37. pass
  38. conf.define(define, 0)
  39. if not found:
  40. raise conf.errors.ConfigurationError
  41. def options(opt):
  42. # options provided by the modules
  43. opt.load('compiler_cxx')
  44. opt.load('compiler_c')
  45. opt.load('autooptions');
  46. opt.load('xcode6')
  47. opt.recurse('compat')
  48. # install directories
  49. opt.add_option('--htmldir', type='string', default=None, help='HTML documentation directory [Default: <prefix>/share/jack-audio-connection-kit/reference/html/')
  50. opt.add_option('--libdir', type='string', help='Library directory [Default: <prefix>/lib]')
  51. opt.add_option('--libdir32', type='string', help='32bit Library directory [Default: <prefix>/lib32]')
  52. opt.add_option('--pkgconfigdir', type='string', help='pkg-config file directory [Default: <libdir>/pkgconfig]')
  53. opt.add_option('--mandir', type='string', help='Manpage directory [Default: <prefix>/share/man/man1]')
  54. # options affecting binaries
  55. opt.add_option('--platform', type='string', default=sys.platform, help='Target platform for cross-compiling, e.g. cygwin or win32')
  56. opt.add_option('--mixed', action='store_true', default=False, help='Build with 32/64 bits mixed mode')
  57. opt.add_option('--debug', action='store_true', default=False, dest='debug', help='Build debuggable binaries')
  58. # options affecting general jack functionality
  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('--dbus', action='store_true', default=False, help='Enable D-Bus JACK (jackdbus)')
  61. opt.add_option('--autostart', type='string', default='default', help='Autostart method. Possible values: "default", "classic", "dbus", "none"')
  62. opt.add_option('--profile', action='store_true', default=False, help='Build with engine profiling')
  63. opt.add_option('--clients', default=256, type='int', dest='clients', help='Maximum number of JACK clients')
  64. opt.add_option('--ports-per-application', default=2048, type='int', dest='application_ports', help='Maximum number of ports per application')
  65. opt.add_option('--systemd-unit', action='store_true', default=False, help='Install systemd units.')
  66. opt.set_auto_options_define('HAVE_%s')
  67. opt.set_auto_options_style('yesno_and_hack')
  68. # options with third party dependencies
  69. doxygen = opt.add_auto_option(
  70. 'doxygen',
  71. help='Build doxygen documentation',
  72. conf_dest='BUILD_DOXYGEN_DOCS',
  73. default=False)
  74. doxygen.find_program('doxygen')
  75. alsa = opt.add_auto_option(
  76. 'alsa',
  77. help='Enable ALSA driver',
  78. conf_dest='BUILD_DRIVER_ALSA')
  79. alsa.check_cfg(
  80. package='alsa >= 1.0.18',
  81. args='--cflags --libs')
  82. # Check for QNX sound headers
  83. qsa = opt.add_auto_option(
  84. 'qsa',
  85. help='Enable QNX sound driver',
  86. conf_dest='BUILD_DRIVER_ALSA')
  87. qsa.check(lib='asound', uselib_store='ALSA')
  88. qsa.check(
  89. header_name=['sys/asoundlib.h'],
  90. msg='Checking for header sys/asoundlib.h')
  91. firewire = opt.add_auto_option(
  92. 'firewire',
  93. help='Enable FireWire driver (FFADO)',
  94. conf_dest='BUILD_DRIVER_FFADO')
  95. firewire.check_cfg(
  96. package='libffado >= 1.999.17',
  97. args='--cflags --libs')
  98. iio = opt.add_auto_option(
  99. 'iio',
  100. help='Enable IIO driver',
  101. conf_dest='BUILD_DRIVER_IIO')
  102. iio.check_cfg(
  103. package='gtkIOStream >= 1.4.0',
  104. args='--cflags --libs')
  105. iio.check_cfg(
  106. package='eigen3 >= 3.1.2',
  107. args='--cflags --libs')
  108. portaudio = opt.add_auto_option(
  109. 'portaudio',
  110. help='Enable Portaudio driver',
  111. conf_dest='BUILD_DRIVER_PORTAUDIO')
  112. portaudio.check(header_name='windows.h') # only build portaudio on windows
  113. portaudio.check_cfg(
  114. package='portaudio-2.0 >= 19',
  115. uselib_store='PORTAUDIO',
  116. args='--cflags --libs')
  117. winmme = opt.add_auto_option(
  118. 'winmme',
  119. help='Enable WinMME driver',
  120. conf_dest='BUILD_DRIVER_WINMME')
  121. winmme.check(
  122. header_name=['windows.h', 'mmsystem.h'],
  123. msg='Checking for header mmsystem.h')
  124. celt = opt.add_auto_option(
  125. 'celt',
  126. help='Build with CELT')
  127. celt.add_function(check_for_celt)
  128. # Suffix _PKG to not collide with HAVE_OPUS defined by the option.
  129. opus = opt.add_auto_option(
  130. 'opus',
  131. help='Build Opus netjack2')
  132. opus.check(header_name='opus/opus_custom.h')
  133. opus.check_cfg(
  134. package='opus >= 0.9.0',
  135. args='--cflags --libs',
  136. define_name='HAVE_OPUS_PKG')
  137. samplerate = opt.add_auto_option(
  138. 'samplerate',
  139. help='Build with libsamplerate')
  140. samplerate.check_cfg(
  141. package='samplerate',
  142. args='--cflags --libs')
  143. sndfile = opt.add_auto_option(
  144. 'sndfile',
  145. help='Build with libsndfile')
  146. sndfile.check_cfg(
  147. package='sndfile',
  148. args='--cflags --libs')
  149. readline = opt.add_auto_option(
  150. 'readline',
  151. help='Build with readline')
  152. readline.check(lib='readline')
  153. readline.check(
  154. header_name=['stdio.h', 'readline/readline.h'],
  155. msg='Checking for header readline/readline.h')
  156. sd = opt.add_auto_option(
  157. 'systemd',
  158. help='Use systemd notify')
  159. sd.check(header_name='systemd/sd-daemon.h')
  160. sd.check(lib='systemd')
  161. db = opt.add_auto_option(
  162. 'db',
  163. help='Use Berkeley DB (metadata)')
  164. db.check(header_name='db.h')
  165. db.check(lib='db')
  166. # dbus options
  167. opt.recurse('dbus')
  168. # this must be called before the configure phase
  169. opt.apply_auto_options_hack()
  170. def detect_platform(conf):
  171. # GNU/kFreeBSD and GNU/Hurd are treated as Linux
  172. platforms = [
  173. # ('KEY, 'Human readable name', ['strings', 'to', 'check', 'for'])
  174. ('IS_LINUX', 'Linux', ['gnu0', 'gnukfreebsd', 'linux', 'posix']),
  175. ('IS_QNX', 'QNX', ['qnx']),
  176. ('IS_MACOSX', 'MacOS X', ['darwin']),
  177. ('IS_SUN', 'SunOS', ['sunos']),
  178. ('IS_WINDOWS', 'Windows', ['cygwin', 'msys', 'win32'])
  179. ]
  180. for key,name,strings in platforms:
  181. conf.env[key] = False
  182. conf.start_msg('Checking platform')
  183. platform = Options.options.platform
  184. for key,name,strings in platforms:
  185. for s in strings:
  186. if platform.startswith(s):
  187. conf.env[key] = True
  188. conf.end_msg(name, color='CYAN')
  189. break
  190. def configure(conf):
  191. conf.load('compiler_cxx')
  192. conf.load('compiler_c')
  193. detect_platform(conf)
  194. if conf.env['IS_WINDOWS']:
  195. conf.env.append_unique('CCDEFINES', '_POSIX')
  196. conf.env.append_unique('CXXDEFINES', '_POSIX')
  197. conf.env.append_unique('CFLAGS', '-Wall')
  198. conf.env.append_unique('CXXFLAGS', '-Wall')
  199. conf.env.append_unique('CXXFLAGS', '-std=gnu++11')
  200. if not conf.env['IS_MACOSX']:
  201. conf.env.append_unique('LDFLAGS', '-Wl,--no-undefined')
  202. else:
  203. conf.check(lib='aften', uselib='AFTEN', define_name='AFTEN')
  204. conf.check_cxx(
  205. fragment=''
  206. + '#include <aften/aften.h>\n'
  207. + 'int\n'
  208. + 'main(void)\n'
  209. + '{\n'
  210. + 'AftenContext fAftenContext;\n'
  211. + 'aften_set_defaults(&fAftenContext);\n'
  212. + 'unsigned char *fb;\n'
  213. + 'float *buf=new float[10];\n'
  214. + 'int res = aften_encode_frame(&fAftenContext, fb, buf, 1);\n'
  215. + '}\n',
  216. lib='aften',
  217. msg='Checking for aften_encode_frame()',
  218. define_name='HAVE_AFTEN_NEW_API',
  219. mandatory=False)
  220. conf.load('autooptions')
  221. conf.recurse('compat')
  222. # Check for functions.
  223. conf.check(
  224. fragment=''
  225. + '#define _GNU_SOURCE\n'
  226. + '#include <poll.h>\n'
  227. + '#include <signal.h>\n'
  228. + '#include <stddef.h>\n'
  229. + 'int\n'
  230. + 'main(void)\n'
  231. + '{\n'
  232. + ' ppoll(NULL, 0, NULL, NULL);\n'
  233. + '}\n',
  234. msg='Checking for ppoll',
  235. define_name='HAVE_PPOLL',
  236. mandatory=False)
  237. # Check for backtrace support
  238. conf.check(
  239. header_name='execinfo.h',
  240. define_name='HAVE_EXECINFO_H',
  241. mandatory=False)
  242. conf.recurse('common')
  243. if Options.options.dbus:
  244. conf.recurse('dbus')
  245. if conf.env['BUILD_JACKDBUS'] != True:
  246. conf.fatal('jackdbus was explicitly requested but cannot be built')
  247. if conf.env['IS_LINUX']:
  248. if Options.options.systemd_unit:
  249. conf.recurse('systemd')
  250. else:
  251. conf.env['SYSTEMD_USER_UNIT_DIR'] = None
  252. conf.recurse('example-clients')
  253. # test for the availability of ucontext, and how it should be used
  254. for t in ['gp_regs', 'uc_regs', 'mc_gregs', 'gregs']:
  255. fragment = '#include <ucontext.h>\n'
  256. fragment += 'int main() { ucontext_t *ucontext; return (int) ucontext->uc_mcontext.%s[0]; }' % t
  257. confvar = 'HAVE_UCONTEXT_%s' % t.upper()
  258. conf.check_cc(fragment=fragment, define_name=confvar, mandatory=False,
  259. msg='Checking for ucontext->uc_mcontext.%s' % t)
  260. if conf.is_defined(confvar):
  261. conf.define('HAVE_UCONTEXT', 1)
  262. fragment = '#include <ucontext.h>\n'
  263. fragment += 'int main() { return NGREG; }'
  264. conf.check_cc(fragment=fragment, define_name='HAVE_NGREG', mandatory=False,
  265. msg='Checking for NGREG')
  266. if conf.env['IS_QNX']:
  267. conf.env['LIB_PTHREAD'] = ['c']
  268. conf.env['LIB_SOCKET'] = ['socket']
  269. else:
  270. conf.env['LIB_PTHREAD'] = ['pthread']
  271. conf.env['LIB_DL'] = ['dl']
  272. conf.env['LIB_RT'] = ['rt']
  273. conf.env['LIB_M'] = ['m']
  274. conf.env['LIB_STDC++'] = ['stdc++']
  275. conf.env['JACK_API_VERSION'] = JACK_API_VERSION
  276. conf.env['JACK_VERSION'] = VERSION
  277. conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
  278. conf.env['BUILD_WITH_32_64'] = Options.options.mixed
  279. conf.env['BUILD_CLASSIC'] = Options.options.classic
  280. conf.env['BUILD_DEBUG'] = Options.options.debug
  281. if conf.env['BUILD_JACKDBUS']:
  282. conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
  283. else:
  284. conf.env['BUILD_JACKD'] = True
  285. conf.env['BINDIR'] = conf.env['PREFIX'] + '/bin'
  286. if Options.options.htmldir:
  287. conf.env['HTMLDIR'] = Options.options.htmldir
  288. else:
  289. # set to None here so that the doxygen code can find out the highest
  290. # directory to remove upon install
  291. conf.env['HTMLDIR'] = None
  292. if Options.options.libdir:
  293. conf.env['LIBDIR'] = Options.options.libdir
  294. else:
  295. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
  296. if Options.options.pkgconfigdir:
  297. conf.env['PKGCONFDIR'] = Options.options.pkgconfigdir
  298. else:
  299. conf.env['PKGCONFDIR'] = conf.env['LIBDIR'] + '/pkgconfig'
  300. if Options.options.mandir:
  301. conf.env['MANDIR'] = Options.options.mandir
  302. else:
  303. conf.env['MANDIR'] = conf.env['PREFIX'] + '/share/man/man1'
  304. if conf.env['BUILD_DEBUG']:
  305. conf.env.append_unique('CXXFLAGS', '-g')
  306. conf.env.append_unique('CFLAGS', '-g')
  307. conf.env.append_unique('LINKFLAGS', '-g')
  308. if not Options.options.autostart in ['default', 'classic', 'dbus', 'none']:
  309. conf.fatal('Invalid autostart value "' + Options.options.autostart + '"')
  310. if Options.options.autostart == 'default':
  311. if conf.env['BUILD_JACKD']:
  312. conf.env['AUTOSTART_METHOD'] = 'classic'
  313. else:
  314. conf.env['AUTOSTART_METHOD'] = 'dbus'
  315. else:
  316. conf.env['AUTOSTART_METHOD'] = Options.options.autostart
  317. if conf.env['AUTOSTART_METHOD'] == 'dbus' and not conf.env['BUILD_JACKDBUS']:
  318. conf.fatal('D-Bus autostart mode was specified but jackdbus will not be built')
  319. if conf.env['AUTOSTART_METHOD'] == 'classic' and not conf.env['BUILD_JACKD']:
  320. conf.fatal('Classic autostart mode was specified but jackd will not be built')
  321. if conf.env['AUTOSTART_METHOD'] == 'dbus':
  322. conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
  323. elif conf.env['AUTOSTART_METHOD'] == 'classic':
  324. conf.define('USE_CLASSIC_AUTOLAUNCH', 1)
  325. conf.define('CLIENT_NUM', Options.options.clients)
  326. conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
  327. if conf.env['IS_WINDOWS']:
  328. # we define this in the environment to maintain compatibility with
  329. # existing install paths that use ADDON_DIR rather than have to
  330. # have special cases for windows each time.
  331. conf.env['ADDON_DIR'] = conf.env['BINDIR'] + '/jack'
  332. # don't define ADDON_DIR in config.h, use the default 'jack' defined in
  333. # windows/JackPlatformPlug_os.h
  334. else:
  335. conf.env['ADDON_DIR'] = os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack'))
  336. conf.define('ADDON_DIR', conf.env['ADDON_DIR'])
  337. conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
  338. if not conf.env['IS_WINDOWS']:
  339. conf.define('USE_POSIX_SHM', 1)
  340. conf.define('JACKMP', 1)
  341. if conf.env['BUILD_JACKDBUS']:
  342. conf.define('JACK_DBUS', 1)
  343. if conf.env['BUILD_WITH_PROFILE']:
  344. conf.define('JACK_MONITOR', 1)
  345. conf.write_config_header('config.h', remove=False)
  346. svnrev = None
  347. try:
  348. f = open('svnversion.h')
  349. data = f.read()
  350. m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
  351. if m != None:
  352. svnrev = m.group(1)
  353. f.close()
  354. except IOError:
  355. pass
  356. if Options.options.mixed:
  357. conf.setenv(lib32, env=conf.env.derive())
  358. conf.env.append_unique('CFLAGS', '-m32')
  359. conf.env.append_unique('CXXFLAGS', '-m32')
  360. conf.env.append_unique('CXXFLAGS', '-DBUILD_WITH_32_64')
  361. conf.env.append_unique('LINKFLAGS', '-m32')
  362. if Options.options.libdir32:
  363. conf.env['LIBDIR'] = Options.options.libdir32
  364. else:
  365. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
  366. # libdb does not work in mixed mode
  367. conf.all_envs[lib32]['HAVE_DB'] = 0
  368. conf.all_envs[lib32]['HAVE_DB_H'] = 0
  369. conf.all_envs[lib32]['LIB_DB'] = []
  370. # no need for opus in 32bit mixed mode clients
  371. conf.all_envs[lib32]['LIB_OPUS'] = []
  372. # someone tell me where this file gets written please..
  373. conf.write_config_header('config.h')
  374. print()
  375. print('==================')
  376. version_msg = 'JACK ' + VERSION
  377. if svnrev:
  378. version_msg += ' exported from r' + svnrev
  379. else:
  380. version_msg += ' svn revision will checked and eventually updated during build'
  381. print(version_msg)
  382. conf.msg('Maximum JACK clients', Options.options.clients, color='NORMAL')
  383. conf.msg('Maximum ports per application', Options.options.application_ports, color='NORMAL')
  384. conf.msg('Install prefix', conf.env['PREFIX'], color='CYAN')
  385. conf.msg('Library directory', conf.all_envs['']['LIBDIR'], color='CYAN')
  386. if conf.env['BUILD_WITH_32_64']:
  387. conf.msg('32-bit library directory', conf.all_envs[lib32]['LIBDIR'], color='CYAN')
  388. conf.msg('Drivers directory', conf.env['ADDON_DIR'], color='CYAN')
  389. display_feature(conf, 'Build debuggable binaries', conf.env['BUILD_DEBUG'])
  390. tool_flags = [
  391. ('C compiler flags', ['CFLAGS', 'CPPFLAGS']),
  392. ('C++ compiler flags', ['CXXFLAGS', 'CPPFLAGS']),
  393. ('Linker flags', ['LINKFLAGS', 'LDFLAGS'])
  394. ]
  395. for name,vars in tool_flags:
  396. flags = []
  397. for var in vars:
  398. flags += conf.all_envs[''][var]
  399. conf.msg(name, repr(flags), color='NORMAL')
  400. if conf.env['BUILD_WITH_32_64']:
  401. conf.msg('32-bit C compiler flags', repr(conf.all_envs[lib32]['CFLAGS']))
  402. conf.msg('32-bit C++ compiler flags', repr(conf.all_envs[lib32]['CXXFLAGS']))
  403. conf.msg('32-bit linker flags', repr(conf.all_envs[lib32]['LINKFLAGS']))
  404. display_feature(conf, 'Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
  405. display_feature(conf, 'Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
  406. display_feature(conf, 'Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
  407. display_feature(conf, 'Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
  408. conf.msg('Autostart method', conf.env['AUTOSTART_METHOD'])
  409. if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
  410. print(Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs.colors.NORMAL)
  411. print(Logs.colors.RED + 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs.colors.NORMAL)
  412. conf.summarize_auto_options()
  413. if conf.env['BUILD_JACKDBUS']:
  414. conf.msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], color='CYAN')
  415. if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
  416. print()
  417. print(Logs.colors.RED + 'WARNING: D-Bus session services directory as reported by pkg-config is')
  418. print(Logs.colors.RED + 'WARNING:', end=' ')
  419. print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL'])
  420. print(Logs.colors.RED + 'WARNING: but service file will be installed in')
  421. print(Logs.colors.RED + 'WARNING:', end=' ')
  422. print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR'])
  423. print(Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus')
  424. print('WARNING: You can override dbus service install directory')
  425. print('WARNING: with --enable-pkg-config-dbus-service-dir option to this script')
  426. print(Logs.colors.NORMAL, end=' ')
  427. print()
  428. def init(ctx):
  429. for y in (BuildContext, CleanContext, InstallContext, UninstallContext):
  430. name = y.__name__.replace('Context','').lower()
  431. class tmp(y):
  432. cmd = name + '_' + lib32
  433. variant = lib32
  434. def obj_add_includes(bld, obj):
  435. if bld.env['BUILD_JACKDBUS']:
  436. obj.includes += ['dbus']
  437. if bld.env['IS_LINUX']:
  438. obj.includes += ['linux', 'posix']
  439. if bld.env['IS_MACOSX']:
  440. obj.includes += ['macosx', 'posix']
  441. if bld.env['IS_QNX']:
  442. obj.includes += ['qnx', 'posix']
  443. if bld.env['IS_SUN']:
  444. obj.includes += ['posix', 'solaris']
  445. if bld.env['IS_WINDOWS']:
  446. obj.includes += ['windows']
  447. # FIXME: Is SERVER_SIDE needed?
  448. def build_jackd(bld):
  449. jackd = bld(
  450. features = ['cxx', 'cxxprogram'],
  451. defines = ['HAVE_CONFIG_H','SERVER_SIDE'],
  452. includes = ['.', 'common', 'common/jack'],
  453. target = 'jackd',
  454. source = ['common/Jackdmp.cpp'],
  455. use = ['serverlib', 'SYSTEMD']
  456. )
  457. if bld.env['BUILD_JACKDBUS']:
  458. jackd.source += ['dbus/audio_reserve.c', 'dbus/reserve.c']
  459. jackd.use += ['DBUS-1']
  460. if bld.env['IS_LINUX']:
  461. jackd.use += ['DL', 'M', 'PTHREAD', 'RT', 'STDC++']
  462. if bld.env['IS_MACOSX']:
  463. jackd.use += ['DL', 'PTHREAD']
  464. jackd.framework = ['CoreFoundation']
  465. if bld.env['IS_QNX']:
  466. jackd.use += ['M', 'PTHREAD']
  467. if bld.env['IS_SUN']:
  468. jackd.use += ['DL', 'PTHREAD']
  469. obj_add_includes(bld, jackd)
  470. return jackd
  471. # FIXME: Is SERVER_SIDE needed?
  472. def create_driver_obj(bld, **kw):
  473. if 'use' in kw:
  474. kw['use'] += ['serverlib']
  475. else:
  476. kw['use'] = ['serverlib']
  477. driver = bld(
  478. features = ['c', 'cxx', 'cshlib', 'cxxshlib'],
  479. defines = ['HAVE_CONFIG_H', 'SERVER_SIDE'],
  480. includes = ['.', 'common', 'common/jack'],
  481. install_path = '${ADDON_DIR}/',
  482. **kw)
  483. if bld.env['IS_WINDOWS']:
  484. driver.env['cxxshlib_PATTERN'] = 'jack_%s.dll'
  485. else:
  486. driver.env['cxxshlib_PATTERN'] = 'jack_%s.so'
  487. obj_add_includes(bld, driver)
  488. return driver
  489. def build_drivers(bld):
  490. # Non-hardware driver sources. Lexically sorted.
  491. dummy_src = [
  492. 'common/JackDummyDriver.cpp'
  493. ]
  494. loopback_src = [
  495. 'common/JackLoopbackDriver.cpp'
  496. ]
  497. net_src = [
  498. 'common/JackNetDriver.cpp'
  499. ]
  500. netone_src = [
  501. 'common/JackNetOneDriver.cpp',
  502. 'common/netjack.c',
  503. 'common/netjack_packet.c'
  504. ]
  505. proxy_src = [
  506. 'common/JackProxyDriver.cpp'
  507. ]
  508. # Hardware driver sources. Lexically sorted.
  509. alsa_src = [
  510. 'common/memops.c',
  511. 'linux/alsa/JackAlsaDriver.cpp',
  512. 'linux/alsa/alsa_driver.c'
  513. ]
  514. if not bld.env['IS_QNX']:
  515. alsa_src += [
  516. 'linux/alsa/alsa_rawmidi.c',
  517. 'linux/alsa/alsa_seqmidi.c',
  518. 'linux/alsa/alsa_midi_jackmp.cpp',
  519. 'linux/alsa/generic_hw.c',
  520. 'linux/alsa/hdsp.c',
  521. 'linux/alsa/hammerfall.c',
  522. 'linux/alsa/ice1712.c'
  523. ]
  524. alsarawmidi_src = [
  525. 'linux/alsarawmidi/JackALSARawMidiDriver.cpp',
  526. 'linux/alsarawmidi/JackALSARawMidiInputPort.cpp',
  527. 'linux/alsarawmidi/JackALSARawMidiOutputPort.cpp',
  528. 'linux/alsarawmidi/JackALSARawMidiPort.cpp',
  529. 'linux/alsarawmidi/JackALSARawMidiReceiveQueue.cpp',
  530. 'linux/alsarawmidi/JackALSARawMidiSendQueue.cpp',
  531. 'linux/alsarawmidi/JackALSARawMidiUtil.cpp'
  532. ]
  533. boomer_src = [
  534. 'common/memops.c',
  535. 'solaris/oss/JackBoomerDriver.cpp'
  536. ]
  537. coreaudio_src = [
  538. 'macosx/coreaudio/JackCoreAudioDriver.mm',
  539. 'common/JackAC3Encoder.cpp'
  540. ]
  541. coremidi_src = [
  542. 'macosx/coremidi/JackCoreMidiInputPort.mm',
  543. 'macosx/coremidi/JackCoreMidiOutputPort.mm',
  544. 'macosx/coremidi/JackCoreMidiPhysicalInputPort.mm',
  545. 'macosx/coremidi/JackCoreMidiPhysicalOutputPort.mm',
  546. 'macosx/coremidi/JackCoreMidiVirtualInputPort.mm',
  547. 'macosx/coremidi/JackCoreMidiVirtualOutputPort.mm',
  548. 'macosx/coremidi/JackCoreMidiPort.mm',
  549. 'macosx/coremidi/JackCoreMidiUtil.mm',
  550. 'macosx/coremidi/JackCoreMidiDriver.mm'
  551. ]
  552. ffado_src = [
  553. 'linux/firewire/JackFFADODriver.cpp',
  554. 'linux/firewire/JackFFADOMidiInputPort.cpp',
  555. 'linux/firewire/JackFFADOMidiOutputPort.cpp',
  556. 'linux/firewire/JackFFADOMidiReceiveQueue.cpp',
  557. 'linux/firewire/JackFFADOMidiSendQueue.cpp'
  558. ]
  559. iio_driver_src = [
  560. 'linux/iio/JackIIODriver.cpp'
  561. ]
  562. oss_src = [
  563. 'common/memops.c',
  564. 'solaris/oss/JackOSSDriver.cpp'
  565. ]
  566. portaudio_src = [
  567. 'windows/portaudio/JackPortAudioDevices.cpp',
  568. 'windows/portaudio/JackPortAudioDriver.cpp',
  569. ]
  570. winmme_src = [
  571. 'windows/winmme/JackWinMMEDriver.cpp',
  572. 'windows/winmme/JackWinMMEInputPort.cpp',
  573. 'windows/winmme/JackWinMMEOutputPort.cpp',
  574. 'windows/winmme/JackWinMMEPort.cpp',
  575. ]
  576. # Create non-hardware driver objects. Lexically sorted.
  577. create_driver_obj(
  578. bld,
  579. target = 'dummy',
  580. source = dummy_src)
  581. create_driver_obj(
  582. bld,
  583. target = 'loopback',
  584. source = loopback_src)
  585. create_driver_obj(
  586. bld,
  587. target = 'net',
  588. source = net_src)
  589. create_driver_obj(
  590. bld,
  591. target = 'netone',
  592. source = netone_src,
  593. use = ['SAMPLERATE', 'CELT'])
  594. create_driver_obj(
  595. bld,
  596. target = 'proxy',
  597. source = proxy_src)
  598. # Create hardware driver objects. Lexically sorted after the conditional,
  599. # e.g. BUILD_DRIVER_ALSA.
  600. if bld.env['BUILD_DRIVER_ALSA']:
  601. create_driver_obj(
  602. bld,
  603. target = 'alsa',
  604. source = alsa_src,
  605. use = ['ALSA'])
  606. if not bld.env['IS_QNX']:
  607. create_driver_obj(
  608. bld,
  609. target = 'alsarawmidi',
  610. source = alsarawmidi_src,
  611. use = ['ALSA'])
  612. if bld.env['BUILD_DRIVER_FFADO']:
  613. create_driver_obj(
  614. bld,
  615. target = 'firewire',
  616. source = ffado_src,
  617. use = ['LIBFFADO'])
  618. if bld.env['BUILD_DRIVER_IIO']:
  619. create_driver_obj(
  620. bld,
  621. target = 'iio',
  622. source = iio_src,
  623. use = ['GTKIOSTREAM', 'EIGEN3'])
  624. if bld.env['BUILD_DRIVER_PORTAUDIO']:
  625. create_driver_obj(
  626. bld,
  627. target = 'portaudio',
  628. source = portaudio_src,
  629. use = ['PORTAUDIO'])
  630. if bld.env['BUILD_DRIVER_WINMME']:
  631. create_driver_obj(
  632. bld,
  633. target = 'winmme',
  634. source = winmme_src,
  635. use = ['WINMME'])
  636. if bld.env['IS_MACOSX']:
  637. create_driver_obj(
  638. bld,
  639. target = 'coreaudio',
  640. source = coreaudio_src,
  641. use = ['AFTEN'],
  642. framework = ['AudioUnit', 'CoreAudio', 'CoreServices'])
  643. create_driver_obj(
  644. bld,
  645. target = 'coremidi',
  646. source = coremidi_src,
  647. use = ['serverlib'], # FIXME: Is this needed?
  648. framework = ['AudioUnit', 'CoreMIDI', 'CoreServices', 'Foundation'])
  649. if bld.env['IS_SUN']:
  650. create_driver_obj(
  651. bld,
  652. target = 'boomer',
  653. source = boomer_src)
  654. create_driver_obj(
  655. bld,
  656. target = 'oss',
  657. source = oss_src)
  658. def build(bld):
  659. if not bld.variant and bld.env['BUILD_WITH_32_64']:
  660. Options.commands.append(bld.cmd + '_' + lib32)
  661. # process subfolders from here
  662. bld.recurse('common')
  663. if bld.variant:
  664. # only the wscript in common/ knows how to handle variants
  665. return
  666. bld.recurse('compat')
  667. if not os.access('svnversion.h', os.R_OK):
  668. def post_run(self):
  669. sg = Utils.h_file(self.outputs[0].abspath(self.env))
  670. #print sg.encode('hex')
  671. Build.bld.node_sigs[self.env.variant()][self.outputs[0].id] = sg
  672. script = bld.path.find_resource('svnversion_regenerate.sh')
  673. script = script.abspath()
  674. bld(
  675. rule = '%s ${TGT}' % script,
  676. name = 'svnversion',
  677. runnable_status = Task.RUN_ME,
  678. before = 'c cxx',
  679. color = 'BLUE',
  680. post_run = post_run,
  681. source = ['svnversion_regenerate.sh'],
  682. target = [bld.path.find_or_declare('svnversion.h')]
  683. )
  684. if bld.env['BUILD_JACKD']:
  685. build_jackd(bld)
  686. build_drivers(bld)
  687. bld.recurse('example-clients')
  688. if bld.env['IS_LINUX']:
  689. bld.recurse('man')
  690. bld.recurse('systemd')
  691. if not bld.env['IS_WINDOWS']:
  692. bld.recurse('tests')
  693. if bld.env['BUILD_JACKDBUS']:
  694. bld.recurse('dbus')
  695. if bld.env['BUILD_DOXYGEN_DOCS']:
  696. html_build_dir = bld.path.find_or_declare('html').abspath()
  697. bld(
  698. features = 'subst',
  699. source = 'doxyfile.in',
  700. target = 'doxyfile',
  701. HTML_BUILD_DIR = html_build_dir,
  702. SRCDIR = bld.srcnode.abspath(),
  703. VERSION = VERSION
  704. )
  705. # There are two reasons for logging to doxygen.log and using it as
  706. # target in the build rule (rather than html_build_dir):
  707. # (1) reduce the noise when running the build
  708. # (2) waf has a regular file to check for a timestamp. If the directory
  709. # is used instead waf will rebuild the doxygen target (even upon
  710. # install).
  711. def doxygen(task):
  712. doxyfile = task.inputs[0].abspath()
  713. logfile = task.outputs[0].abspath()
  714. cmd = '%s %s &> %s' % (task.env['DOXYGEN'][0], doxyfile, logfile)
  715. return task.exec_command(cmd)
  716. bld(
  717. rule = doxygen,
  718. source = 'doxyfile',
  719. target = 'doxygen.log'
  720. )
  721. # Determine where to install HTML documentation. Since share_dir is the
  722. # highest directory the uninstall routine should remove, there is no
  723. # better candidate for share_dir, but the requested HTML directory if
  724. # --htmldir is given.
  725. if bld.env['HTMLDIR']:
  726. html_install_dir = bld.options.destdir + bld.env['HTMLDIR']
  727. share_dir = html_install_dir
  728. else:
  729. share_dir = bld.options.destdir + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
  730. html_install_dir = share_dir + '/reference/html/'
  731. if bld.cmd == 'install':
  732. if os.path.isdir(html_install_dir):
  733. Logs.pprint('CYAN', 'Removing old doxygen documentation installation...')
  734. shutil.rmtree(html_install_dir)
  735. Logs.pprint('CYAN', 'Removing old doxygen documentation installation done.')
  736. Logs.pprint('CYAN', 'Installing doxygen documentation...')
  737. shutil.copytree(html_build_dir, html_install_dir)
  738. Logs.pprint('CYAN', 'Installing doxygen documentation done.')
  739. elif bld.cmd =='uninstall':
  740. Logs.pprint('CYAN', 'Uninstalling doxygen documentation...')
  741. if os.path.isdir(share_dir):
  742. shutil.rmtree(share_dir)
  743. Logs.pprint('CYAN', 'Uninstalling doxygen documentation done.')
  744. elif bld.cmd =='clean':
  745. if os.access(html_build_dir, os.R_OK):
  746. Logs.pprint('CYAN', 'Removing doxygen generated documentation...')
  747. shutil.rmtree(html_build_dir)
  748. Logs.pprint('CYAN', 'Removing doxygen generated documentation done.')
  749. def dist(ctx):
  750. # This code blindly assumes it is working in the toplevel source directory.
  751. if not os.path.exists('svnversion.h'):
  752. os.system('./svnversion_regenerate.sh svnversion.h')
  753. from waflib import TaskGen
  754. @TaskGen.extension('.mm')
  755. def mm_hook(self, node):
  756. """Alias .mm files to be compiled the same as .cpp files, gcc will do the right thing."""
  757. return self.create_compiled_task('cxx', node)