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