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.

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