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.

901 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.19'
  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 == 'msys':
  194. conf.env.append_value('INCLUDES', ['/mingw64/include'])
  195. conf.check(
  196. header_name='asio.h',
  197. includes='/opt/asiosdk/common',
  198. msg='Checking for ASIO SDK',
  199. define_name='HAVE_ASIO',
  200. mandatory=False)
  201. conf.env.append_unique('CFLAGS', '-Wall')
  202. conf.env.append_unique('CXXFLAGS', '-Wall')
  203. conf.env.append_unique('CXXFLAGS', '-std=gnu++11')
  204. if not conf.env['IS_MACOSX']:
  205. conf.env.append_unique('LDFLAGS', '-Wl,--no-undefined')
  206. else:
  207. conf.check(lib='aften', uselib='AFTEN', define_name='AFTEN')
  208. conf.check_cxx(
  209. fragment=''
  210. + '#include <aften/aften.h>\n'
  211. + 'int\n'
  212. + 'main(void)\n'
  213. + '{\n'
  214. + 'AftenContext fAftenContext;\n'
  215. + 'aften_set_defaults(&fAftenContext);\n'
  216. + 'unsigned char *fb;\n'
  217. + 'float *buf=new float[10];\n'
  218. + 'int res = aften_encode_frame(&fAftenContext, fb, buf, 1);\n'
  219. + '}\n',
  220. lib='aften',
  221. msg='Checking for aften_encode_frame()',
  222. define_name='HAVE_AFTEN_NEW_API',
  223. mandatory=False)
  224. # TODO
  225. conf.env.append_unique('CXXFLAGS', '-Wno-deprecated-register')
  226. conf.load('autooptions')
  227. conf.recurse('compat')
  228. # Check for functions.
  229. conf.check(
  230. fragment=''
  231. + '#define _GNU_SOURCE\n'
  232. + '#include <poll.h>\n'
  233. + '#include <signal.h>\n'
  234. + '#include <stddef.h>\n'
  235. + 'int\n'
  236. + 'main(void)\n'
  237. + '{\n'
  238. + ' ppoll(NULL, 0, NULL, NULL);\n'
  239. + '}\n',
  240. msg='Checking for ppoll',
  241. define_name='HAVE_PPOLL',
  242. mandatory=False)
  243. # Check for backtrace support
  244. conf.check(
  245. header_name='execinfo.h',
  246. define_name='HAVE_EXECINFO_H',
  247. mandatory=False)
  248. conf.recurse('common')
  249. if Options.options.dbus:
  250. conf.recurse('dbus')
  251. if conf.env['BUILD_JACKDBUS'] != True:
  252. conf.fatal('jackdbus was explicitly requested but cannot be built')
  253. if conf.env['IS_LINUX']:
  254. if Options.options.systemd_unit:
  255. conf.recurse('systemd')
  256. else:
  257. conf.env['SYSTEMD_USER_UNIT_DIR'] = None
  258. conf.recurse('example-clients')
  259. conf.recurse('tools')
  260. # test for the availability of ucontext, and how it should be used
  261. for t in ['gp_regs', 'uc_regs', 'mc_gregs', 'gregs']:
  262. fragment = '#include <ucontext.h>\n'
  263. fragment += 'int main() { ucontext_t *ucontext; return (int) ucontext->uc_mcontext.%s[0]; }' % t
  264. confvar = 'HAVE_UCONTEXT_%s' % t.upper()
  265. conf.check_cc(fragment=fragment, define_name=confvar, mandatory=False,
  266. msg='Checking for ucontext->uc_mcontext.%s' % t)
  267. if conf.is_defined(confvar):
  268. conf.define('HAVE_UCONTEXT', 1)
  269. fragment = '#include <ucontext.h>\n'
  270. fragment += 'int main() { return NGREG; }'
  271. conf.check_cc(fragment=fragment, define_name='HAVE_NGREG', mandatory=False,
  272. msg='Checking for NGREG')
  273. conf.env['LIB_PTHREAD'] = ['pthread']
  274. conf.env['LIB_DL'] = ['dl']
  275. conf.env['LIB_RT'] = ['rt']
  276. conf.env['LIB_M'] = ['m']
  277. conf.env['LIB_STDC++'] = ['stdc++']
  278. conf.env['JACK_API_VERSION'] = JACK_API_VERSION
  279. conf.env['JACK_VERSION'] = VERSION
  280. conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
  281. conf.env['BUILD_WITH_32_64'] = Options.options.mixed
  282. conf.env['BUILD_CLASSIC'] = Options.options.classic
  283. conf.env['BUILD_DEBUG'] = Options.options.debug
  284. conf.env['BUILD_STATIC'] = Options.options.static
  285. if conf.env['BUILD_JACKDBUS']:
  286. conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
  287. else:
  288. conf.env['BUILD_JACKD'] = True
  289. conf.env['BINDIR'] = conf.env['PREFIX'] + '/bin'
  290. if Options.options.htmldir:
  291. conf.env['HTMLDIR'] = Options.options.htmldir
  292. else:
  293. # set to None here so that the doxygen code can find out the highest
  294. # directory to remove upon install
  295. conf.env['HTMLDIR'] = None
  296. if Options.options.libdir:
  297. conf.env['LIBDIR'] = Options.options.libdir
  298. else:
  299. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
  300. if Options.options.pkgconfigdir:
  301. conf.env['PKGCONFDIR'] = Options.options.pkgconfigdir
  302. else:
  303. conf.env['PKGCONFDIR'] = conf.env['LIBDIR'] + '/pkgconfig'
  304. if Options.options.mandir:
  305. conf.env['MANDIR'] = Options.options.mandir
  306. else:
  307. conf.env['MANDIR'] = conf.env['PREFIX'] + '/share/man/man1'
  308. if conf.env['BUILD_DEBUG']:
  309. conf.env.append_unique('CXXFLAGS', '-g')
  310. conf.env.append_unique('CFLAGS', '-g')
  311. conf.env.append_unique('LINKFLAGS', '-g')
  312. if not Options.options.autostart in ['default', 'classic', 'dbus', 'none']:
  313. conf.fatal('Invalid autostart value "' + Options.options.autostart + '"')
  314. if Options.options.autostart == 'default':
  315. if conf.env['BUILD_JACKD']:
  316. conf.env['AUTOSTART_METHOD'] = 'classic'
  317. else:
  318. conf.env['AUTOSTART_METHOD'] = 'dbus'
  319. else:
  320. conf.env['AUTOSTART_METHOD'] = Options.options.autostart
  321. if conf.env['AUTOSTART_METHOD'] == 'dbus' and not conf.env['BUILD_JACKDBUS']:
  322. conf.fatal('D-Bus autostart mode was specified but jackdbus will not be built')
  323. if conf.env['AUTOSTART_METHOD'] == 'classic' and not conf.env['BUILD_JACKD']:
  324. conf.fatal('Classic autostart mode was specified but jackd will not be built')
  325. if conf.env['AUTOSTART_METHOD'] == 'dbus':
  326. conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
  327. elif conf.env['AUTOSTART_METHOD'] == 'classic':
  328. conf.define('USE_CLASSIC_AUTOLAUNCH', 1)
  329. conf.define('CLIENT_NUM', Options.options.clients)
  330. conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
  331. if conf.env['IS_WINDOWS']:
  332. # we define this in the environment to maintain compatibility with
  333. # existing install paths that use ADDON_DIR rather than have to
  334. # have special cases for windows each time.
  335. conf.env['ADDON_DIR'] = conf.env['LIBDIR'] + '/jack'
  336. if Options.options.platform == 'msys':
  337. conf.define('ADDON_DIR', 'jack')
  338. conf.define('__STDC_FORMAT_MACROS', 1) # for PRIu64
  339. else:
  340. # don't define ADDON_DIR in config.h, use the default 'jack' defined in
  341. # windows/JackPlatformPlug_os.h
  342. pass
  343. else:
  344. conf.env['ADDON_DIR'] = os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack'))
  345. conf.define('ADDON_DIR', conf.env['ADDON_DIR'])
  346. conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
  347. if not conf.env['IS_WINDOWS']:
  348. conf.define('USE_POSIX_SHM', 1)
  349. conf.define('JACKMP', 1)
  350. if conf.env['BUILD_JACKDBUS']:
  351. conf.define('JACK_DBUS', 1)
  352. if conf.env['BUILD_WITH_PROFILE']:
  353. conf.define('JACK_MONITOR', 1)
  354. conf.write_config_header('config.h', remove=False)
  355. svnrev = None
  356. try:
  357. f = open('svnversion.h')
  358. data = f.read()
  359. m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
  360. if m != None:
  361. svnrev = m.group(1)
  362. f.close()
  363. except IOError:
  364. pass
  365. if Options.options.mixed:
  366. conf.setenv(lib32, env=conf.env.derive())
  367. conf.env.append_unique('CFLAGS', '-m32')
  368. conf.env.append_unique('CXXFLAGS', '-m32')
  369. conf.env.append_unique('CXXFLAGS', '-DBUILD_WITH_32_64')
  370. conf.env.append_unique('LINKFLAGS', '-m32')
  371. if Options.options.libdir32:
  372. conf.env['LIBDIR'] = Options.options.libdir32
  373. else:
  374. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
  375. if conf.env['IS_WINDOWS'] and conf.env['BUILD_STATIC']:
  376. def replaceFor32bit(env):
  377. for e in env: yield e.replace('x86_64', 'i686', 1)
  378. for env in ('AR', 'CC', 'CXX', 'LINK_CC', 'LINK_CXX'):
  379. conf.all_envs[lib32][env] = list(replaceFor32bit(conf.all_envs[lib32][env]))
  380. conf.all_envs[lib32]['LIB_REGEX'] = ['tre32']
  381. # libdb does not work in mixed mode
  382. conf.all_envs[lib32]['HAVE_DB'] = 0
  383. conf.all_envs[lib32]['HAVE_DB_H'] = 0
  384. conf.all_envs[lib32]['LIB_DB'] = []
  385. # no need for opus in 32bit mixed mode clients
  386. conf.all_envs[lib32]['LIB_OPUS'] = []
  387. # someone tell me where this file gets written please..
  388. conf.write_config_header('config.h')
  389. print()
  390. print('==================')
  391. version_msg = 'JACK ' + VERSION
  392. if svnrev:
  393. version_msg += ' exported from r' + svnrev
  394. else:
  395. version_msg += ' svn revision will checked and eventually updated during build'
  396. print(version_msg)
  397. conf.msg('Maximum JACK clients', Options.options.clients, color='NORMAL')
  398. conf.msg('Maximum ports per application', Options.options.application_ports, color='NORMAL')
  399. conf.msg('Install prefix', conf.env['PREFIX'], color='CYAN')
  400. conf.msg('Library directory', conf.all_envs['']['LIBDIR'], color='CYAN')
  401. if conf.env['BUILD_WITH_32_64']:
  402. conf.msg('32-bit library directory', conf.all_envs[lib32]['LIBDIR'], color='CYAN')
  403. conf.msg('Drivers directory', conf.env['ADDON_DIR'], color='CYAN')
  404. display_feature(conf, 'Build debuggable binaries', conf.env['BUILD_DEBUG'])
  405. tool_flags = [
  406. ('C compiler flags', ['CFLAGS', 'CPPFLAGS']),
  407. ('C++ compiler flags', ['CXXFLAGS', 'CPPFLAGS']),
  408. ('Linker flags', ['LINKFLAGS', 'LDFLAGS'])
  409. ]
  410. for name,vars in tool_flags:
  411. flags = []
  412. for var in vars:
  413. flags += conf.all_envs[''][var]
  414. conf.msg(name, repr(flags), color='NORMAL')
  415. if conf.env['BUILD_WITH_32_64']:
  416. conf.msg('32-bit C compiler flags', repr(conf.all_envs[lib32]['CFLAGS']))
  417. conf.msg('32-bit C++ compiler flags', repr(conf.all_envs[lib32]['CXXFLAGS']))
  418. conf.msg('32-bit linker flags', repr(conf.all_envs[lib32]['LINKFLAGS']))
  419. display_feature(conf, 'Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
  420. display_feature(conf, 'Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
  421. display_feature(conf, 'Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
  422. display_feature(conf, 'Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
  423. conf.msg('Autostart method', conf.env['AUTOSTART_METHOD'])
  424. if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
  425. print(Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs.colors.NORMAL)
  426. print(Logs.colors.RED + 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs.colors.NORMAL)
  427. conf.summarize_auto_options()
  428. if conf.env['BUILD_JACKDBUS']:
  429. conf.msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], color='CYAN')
  430. if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
  431. print()
  432. print(Logs.colors.RED + 'WARNING: D-Bus session services directory as reported by pkg-config is')
  433. print(Logs.colors.RED + 'WARNING:', end=' ')
  434. print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL'])
  435. print(Logs.colors.RED + 'WARNING: but service file will be installed in')
  436. print(Logs.colors.RED + 'WARNING:', end=' ')
  437. print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR'])
  438. print(Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus')
  439. print('WARNING: You can override dbus service install directory')
  440. print('WARNING: with --enable-pkg-config-dbus-service-dir option to this script')
  441. print(Logs.colors.NORMAL, end=' ')
  442. print()
  443. def init(ctx):
  444. for y in (BuildContext, CleanContext, InstallContext, UninstallContext):
  445. name = y.__name__.replace('Context','').lower()
  446. class tmp(y):
  447. cmd = name + '_' + lib32
  448. variant = lib32
  449. def obj_add_includes(bld, obj):
  450. if bld.env['BUILD_JACKDBUS']:
  451. obj.includes += ['dbus']
  452. if bld.env['IS_LINUX']:
  453. obj.includes += ['linux', 'posix']
  454. if bld.env['IS_MACOSX']:
  455. obj.includes += ['macosx', 'posix']
  456. if bld.env['IS_SUN']:
  457. obj.includes += ['posix', 'solaris']
  458. if bld.env['IS_WINDOWS']:
  459. obj.includes += ['windows']
  460. # FIXME: Is SERVER_SIDE needed?
  461. def build_jackd(bld):
  462. jackd = bld(
  463. features = ['cxx', 'cxxprogram'],
  464. defines = ['HAVE_CONFIG_H','SERVER_SIDE'],
  465. includes = ['.', 'common', 'common/jack'],
  466. target = 'jackd',
  467. source = ['common/Jackdmp.cpp'],
  468. use = ['serverlib', 'SYSTEMD']
  469. )
  470. if bld.env['BUILD_JACKDBUS']:
  471. jackd.source += ['dbus/audio_reserve.c', 'dbus/reserve.c']
  472. jackd.use += ['DBUS-1']
  473. if bld.env['IS_LINUX']:
  474. jackd.use += ['DL', 'M', 'PTHREAD', 'RT', 'STDC++']
  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. 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. create_driver_obj(
  598. bld,
  599. target = 'netone',
  600. source = netone_src,
  601. use = ['SAMPLERATE', 'CELT'])
  602. create_driver_obj(
  603. bld,
  604. target = 'proxy',
  605. source = proxy_src)
  606. # Create hardware driver objects. Lexically sorted after the conditional,
  607. # e.g. BUILD_DRIVER_ALSA.
  608. if bld.env['BUILD_DRIVER_ALSA']:
  609. create_driver_obj(
  610. bld,
  611. target = 'alsa',
  612. source = alsa_src,
  613. use = ['ALSA'])
  614. create_driver_obj(
  615. bld,
  616. target = 'alsarawmidi',
  617. source = alsarawmidi_src,
  618. use = ['ALSA'])
  619. if bld.env['BUILD_DRIVER_FFADO']:
  620. create_driver_obj(
  621. bld,
  622. target = 'firewire',
  623. source = ffado_src,
  624. use = ['LIBFFADO'])
  625. if bld.env['BUILD_DRIVER_IIO']:
  626. create_driver_obj(
  627. bld,
  628. target = 'iio',
  629. source = iio_src,
  630. use = ['GTKIOSTREAM', 'EIGEN3'])
  631. if bld.env['BUILD_DRIVER_PORTAUDIO']:
  632. create_driver_obj(
  633. bld,
  634. target = 'portaudio',
  635. source = portaudio_src,
  636. use = ['PORTAUDIO'])
  637. if bld.env['BUILD_DRIVER_WINMME']:
  638. create_driver_obj(
  639. bld,
  640. target = 'winmme',
  641. source = winmme_src,
  642. use = ['WINMME'])
  643. if bld.env['IS_MACOSX']:
  644. create_driver_obj(
  645. bld,
  646. target = 'coreaudio',
  647. source = coreaudio_src,
  648. use = ['AFTEN'],
  649. framework = ['AudioUnit', 'CoreAudio', 'CoreServices'])
  650. create_driver_obj(
  651. bld,
  652. target = 'coremidi',
  653. source = coremidi_src,
  654. use = ['serverlib'], # FIXME: Is this needed?
  655. framework = ['AudioUnit', 'CoreMIDI', 'CoreServices', 'Foundation'])
  656. if bld.env['IS_SUN']:
  657. create_driver_obj(
  658. bld,
  659. target = 'boomer',
  660. source = boomer_src)
  661. create_driver_obj(
  662. bld,
  663. target = 'oss',
  664. source = oss_src)
  665. def build(bld):
  666. if not bld.variant and bld.env['BUILD_WITH_32_64']:
  667. Options.commands.append(bld.cmd + '_' + lib32)
  668. # process subfolders from here
  669. bld.recurse('common')
  670. if bld.variant:
  671. # only the wscript in common/ knows how to handle variants
  672. return
  673. bld.recurse('compat')
  674. if not os.access('svnversion.h', os.R_OK):
  675. def post_run(self):
  676. sg = Utils.h_file(self.outputs[0].abspath(self.env))
  677. #print sg.encode('hex')
  678. Build.bld.node_sigs[self.env.variant()][self.outputs[0].id] = sg
  679. script = bld.path.find_resource('svnversion_regenerate.sh')
  680. script = script.abspath()
  681. bld(
  682. rule = '%s ${TGT}' % script,
  683. name = 'svnversion',
  684. runnable_status = Task.RUN_ME,
  685. before = 'c cxx',
  686. color = 'BLUE',
  687. post_run = post_run,
  688. source = ['svnversion_regenerate.sh'],
  689. target = [bld.path.find_or_declare('svnversion.h')]
  690. )
  691. if bld.env['BUILD_JACKD']:
  692. build_jackd(bld)
  693. build_drivers(bld)
  694. bld.recurse('example-clients')
  695. bld.recurse('tools')
  696. if bld.env['IS_LINUX']:
  697. bld.recurse('man')
  698. bld.recurse('systemd')
  699. if not bld.env['IS_WINDOWS']:
  700. bld.recurse('tests')
  701. if bld.env['BUILD_JACKDBUS']:
  702. bld.recurse('dbus')
  703. if bld.env['BUILD_DOXYGEN_DOCS']:
  704. html_build_dir = bld.path.find_or_declare('html').abspath()
  705. bld(
  706. features = 'subst',
  707. source = 'doxyfile.in',
  708. target = 'doxyfile',
  709. HTML_BUILD_DIR = html_build_dir,
  710. SRCDIR = bld.srcnode.abspath(),
  711. VERSION = VERSION
  712. )
  713. # There are two reasons for logging to doxygen.log and using it as
  714. # target in the build rule (rather than html_build_dir):
  715. # (1) reduce the noise when running the build
  716. # (2) waf has a regular file to check for a timestamp. If the directory
  717. # is used instead waf will rebuild the doxygen target (even upon
  718. # install).
  719. def doxygen(task):
  720. doxyfile = task.inputs[0].abspath()
  721. logfile = task.outputs[0].abspath()
  722. cmd = '%s %s &> %s' % (task.env['DOXYGEN'][0], doxyfile, logfile)
  723. return task.exec_command(cmd)
  724. bld(
  725. rule = doxygen,
  726. source = 'doxyfile',
  727. target = 'doxygen.log'
  728. )
  729. # Determine where to install HTML documentation. Since share_dir is the
  730. # highest directory the uninstall routine should remove, there is no
  731. # better candidate for share_dir, but the requested HTML directory if
  732. # --htmldir is given.
  733. if bld.env['HTMLDIR']:
  734. html_install_dir = bld.options.destdir + bld.env['HTMLDIR']
  735. share_dir = html_install_dir
  736. else:
  737. share_dir = bld.options.destdir + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
  738. html_install_dir = share_dir + '/reference/html/'
  739. if bld.cmd == 'install':
  740. if os.path.isdir(html_install_dir):
  741. Logs.pprint('CYAN', 'Removing old doxygen documentation installation...')
  742. shutil.rmtree(html_install_dir)
  743. Logs.pprint('CYAN', 'Removing old doxygen documentation installation done.')
  744. Logs.pprint('CYAN', 'Installing doxygen documentation...')
  745. shutil.copytree(html_build_dir, html_install_dir)
  746. Logs.pprint('CYAN', 'Installing doxygen documentation done.')
  747. elif bld.cmd =='uninstall':
  748. Logs.pprint('CYAN', 'Uninstalling doxygen documentation...')
  749. if os.path.isdir(share_dir):
  750. shutil.rmtree(share_dir)
  751. Logs.pprint('CYAN', 'Uninstalling doxygen documentation done.')
  752. elif bld.cmd =='clean':
  753. if os.access(html_build_dir, os.R_OK):
  754. Logs.pprint('CYAN', 'Removing doxygen generated documentation...')
  755. shutil.rmtree(html_build_dir)
  756. Logs.pprint('CYAN', 'Removing doxygen generated documentation done.')
  757. def dist(ctx):
  758. # This code blindly assumes it is working in the toplevel source directory.
  759. if not os.path.exists('svnversion.h'):
  760. os.system('./svnversion_regenerate.sh svnversion.h')
  761. from waflib import TaskGen
  762. @TaskGen.extension('.mm')
  763. def mm_hook(self, node):
  764. """Alias .mm files to be compiled the same as .cpp files, gcc will do the right thing."""
  765. return self.create_compiled_task('cxx', node)