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.

880 lines
30KB

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