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.

900 lines
31KB

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