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.

940 lines
31KB

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