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.

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