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.

831 lines
28KB

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