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.

915 lines
30KB

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