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.

847 lines
29KB

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