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.

862 lines
30KB

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