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.

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