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.

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