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.

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