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.

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