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.

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