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.

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