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.

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