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.

1081 lines
40KB

  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. from __future__ import print_function
  4. import os
  5. import subprocess
  6. g_maxlen = 40
  7. import shutil
  8. import re
  9. import sys
  10. from waflib import Logs, Options, Task, Utils
  11. from waflib.Build import BuildContext, CleanContext, InstallContext, UninstallContext
  12. VERSION='1.9.11'
  13. APPNAME='jack'
  14. JACK_API_VERSION = '0.1.0'
  15. # these variables are mandatory ('/' are converted automatically)
  16. top = '.'
  17. out = 'build'
  18. # lib32 variant name used when building in mixed mode
  19. lib32 = 'lib32'
  20. auto_options = []
  21. def display_msg(msg, status = None, color = None):
  22. sr = msg
  23. global g_maxlen
  24. g_maxlen = max(g_maxlen, len(msg))
  25. if status:
  26. Logs.pprint('NORMAL', "%s :" % msg.ljust(g_maxlen), sep=' ')
  27. Logs.pprint(color, status)
  28. else:
  29. print("%s" % msg.ljust(g_maxlen))
  30. def display_feature(msg, build):
  31. if build:
  32. display_msg(msg, "yes", 'GREEN')
  33. else:
  34. display_msg(msg, "no", 'YELLOW')
  35. # This function prints an error without stopping waf. The reason waf should not
  36. # be stopped is to be able to list all missing dependencies in one chunk.
  37. def print_error(msg):
  38. print(Logs.colors.RED + msg + Logs.colors.NORMAL)
  39. class AutoOption:
  40. """
  41. This class is the foundation for the auto options. It adds an option
  42. --foo=no|yes to the list of options and deals with all logic and checks for
  43. these options.
  44. Each option can have different dependencies that will be checked. If all
  45. dependencies are available and the user has not done any request the option
  46. will be enabled. If the user has requested to enable the option the class
  47. ensures that all dependencies are available and prints an error message
  48. otherwise. If the user disables the option, i.e. --foo=no, no checks are
  49. made.
  50. For each option it is possible to add packages that are required for the
  51. option using the add_package function. For dependency programs add_program
  52. should be used. For libraries (without pkg-config support) the add_library
  53. function should be used. For headers the add_header function exists. If
  54. there is another type of requirement or dependency the check hook (an
  55. external function called when configuring) can be used.
  56. When all checks have been made and the class has made a decision the result
  57. is saved in conf.env['NAME'] where 'NAME' by default is the uppercase of the
  58. name argument to __init__, but it can be changed with the conf_dest argument
  59. to __init__.
  60. The class will define a preprocessor symbol with the result. The default
  61. name is HAVE_NAME, but it can be changed using the define argument to
  62. __init__.
  63. """
  64. def __init__(self, opt, name, help, conf_dest=None, define=None):
  65. # check hook to call upon configuration
  66. self.check_hook = None
  67. self.check_hook_error = None
  68. self.check_hook_found = True
  69. # required libraries
  70. self.libs = [] # elements on the form [lib,uselib_store]
  71. self.libs_not_found = [] # elements on the form lib
  72. # required headers
  73. self.headers = []
  74. self.headers_not_found = []
  75. # required packages (checked with pkg-config)
  76. self.packages = [] # elements on the form [package,uselib_store,atleast_version]
  77. self.packages_not_found = [] # elements on the form [package,atleast_version]
  78. # required programs
  79. self.programs = [] # elements on the form [program,var]
  80. self.programs_not_found = [] # elements on the form program
  81. # the result of the configuration (should the option be enabled or not?)
  82. self.result = False
  83. self.help = help
  84. self.option = '--' + name
  85. self.dest = 'auto_option_' + name
  86. if conf_dest:
  87. self.conf_dest = conf_dest
  88. else:
  89. self.conf_dest = name.upper()
  90. if not define:
  91. self.define = 'HAVE_' + name.upper()
  92. else:
  93. self.define = define
  94. opt.add_option(self.option, type='string', default='auto', dest=self.dest, help=self.help+' (enabled by default if possible)', metavar='no|yes')
  95. def add_library(self, library, uselib_store=None):
  96. """
  97. Add a required library that should be checked during configuration. The
  98. library will be checked using the conf.check_cc function. If the
  99. uselib_store arugment is not given it defaults to LIBRARY (the uppercase
  100. of the library argument). The uselib_store argument will be passed to
  101. check_cc which means LIB_LIBRARY, CFLAGS_LIBRARY and DEFINES_LIBRARY,
  102. etc. will be defined if the option is enabled.
  103. """
  104. if not uselib_store:
  105. uselib_store = library.upper().replace('-', '_')
  106. self.libs.append([library, uselib_store])
  107. def add_header(self, header):
  108. """
  109. Add a required header that should be checked during configuration. The
  110. header will be checked using the conf.check_cc function which means
  111. HAVE_HEADER_H will be defined if found.
  112. """
  113. self.headers.append(header)
  114. def add_package(self, package, uselib_store=None, atleast_version=None):
  115. """
  116. Add a required package that should be checked using pkg-config during
  117. configuration. The package will be checked using the conf.check_cfg
  118. function and the uselib_store and atleast_version will be passed to
  119. check_cfg. If uselib_store is None it defaults to PACKAGE (uppercase of
  120. the package argument) with hyphens and dots replaced with underscores.
  121. If atleast_version is None it defaults to '0'.
  122. """
  123. if not uselib_store:
  124. uselib_store = package.upper().replace('-', '_').replace('.', '_')
  125. if not atleast_version:
  126. atleast_version = '0'
  127. self.packages.append([package, uselib_store, atleast_version])
  128. def add_program(self, program, var=None):
  129. """
  130. Add a required program that should be checked during configuration. If
  131. var is not given it defaults to PROGRAM (the uppercase of the program
  132. argument). If the option is enabled the program is saved as a list (?!)
  133. in conf.env['PROGRAM'].
  134. """
  135. if not var:
  136. var = program.upper().replace('-', '_')
  137. self.programs.append([program, var])
  138. def set_check_hook(self, check_hook, check_hook_error):
  139. """
  140. Set the check hook and the corresponding error printing function to the
  141. configure step. The check_hook argument is a function that should return
  142. True if the extra prerequisites were found and False if not. The
  143. check_hook_error argument is an error printing function that should
  144. print an error message telling the user that --foo was explicitly
  145. requested but cannot be built since the extra prerequisites were not
  146. found. Both function should take a single argument that is the waf
  147. configuration context.
  148. """
  149. self.check_hook = check_hook
  150. self.check_hook_error = check_hook_error
  151. def _check(self, conf):
  152. """
  153. This is an internal function that runs all necessary configure checks.
  154. It checks all dependencies (even if some dependency was not found) so
  155. that the user can install all missing dependencies in one go, instead
  156. of playing the infamous hit-configure-hit-configure game.
  157. This function returns True if all dependencies were found and False if
  158. not.
  159. """
  160. all_found = True
  161. # Use-variables that should be used when checking libraries, headers and
  162. # programs. The list will be populated when looking for packages.
  163. use = []
  164. # check for packages
  165. for package,uselib_store,atleast_version in self.packages:
  166. try:
  167. conf.check_cfg(package=package, uselib_store=uselib_store, atleast_version=atleast_version, args='--cflags --libs')
  168. use.append(uselib_store)
  169. except conf.errors.ConfigurationError:
  170. all_found = False
  171. self.packages_not_found.append([package,atleast_version])
  172. # check for libraries
  173. for lib,uselib_store in self.libs:
  174. try:
  175. conf.check_cc(lib=lib, uselib_store=uselib_store, use=use)
  176. except conf.errors.ConfigurationError:
  177. all_found = False
  178. self.libs_not_found.append(lib)
  179. # check for headers
  180. for header in self.headers:
  181. try:
  182. conf.check_cc(header_name=header, use=use)
  183. except conf.errors.ConfigurationError:
  184. all_found = False
  185. self.headers_not_found.append(header)
  186. # check for programs
  187. for program,var in self.programs:
  188. try:
  189. conf.find_program(program, var=var, use=use)
  190. except conf.errors.ConfigurationError:
  191. all_found = False
  192. self.programs_not_found.append(program)
  193. # call hook (if specified)
  194. if self.check_hook:
  195. self.check_hook_found = self.check_hook(conf)
  196. if not self.check_hook_found:
  197. all_found = False
  198. return all_found
  199. def _configure_error(self, conf):
  200. """
  201. This is an internal function that prints errors for each missing
  202. dependency. The error messages tell the user that this option required
  203. some dependency, but it cannot be found.
  204. """
  205. for lib in self.libs_not_found:
  206. print_error('%s requires the %s library, but it cannot be found.' % (self.option, lib))
  207. for header in self.headers_not_found:
  208. print_error('%s requires the %s header, but it cannot be found.' % (self.option, header))
  209. for package,atleast_version in self.packages_not_found:
  210. string = package
  211. if atleast_version:
  212. string += ' >= ' + atleast_version
  213. print_error('%s requires the package %s, but it cannot be found.' % (self.option, string))
  214. for program in self.programs_not_found:
  215. print_error('%s requires the %s program, but it cannot be found.' % (self.option, program))
  216. if not self.check_hook_found:
  217. self.check_hook_error(conf)
  218. def configure(self, conf):
  219. """
  220. This function configures the option examining the argument given too
  221. --foo (where foo is this option). This function sets self.result to the
  222. result of the configuration; True if the option should be enabled or
  223. False if not. If not all dependencies were found self.result will shall
  224. be False. conf.env['NAME'] will be set to the same value aswell as a
  225. preprocessor symbol will be defined according to the result.
  226. If --foo[=yes] was given, but some dependency was not found an error
  227. message is printed (foreach missing dependency).
  228. This function returns True on success and False on error.
  229. """
  230. argument = getattr(Options.options, self.dest)
  231. if argument == 'no':
  232. self.result = False
  233. retvalue = True
  234. elif argument == 'yes':
  235. if self._check(conf):
  236. self.result = True
  237. retvalue = True
  238. else:
  239. self.result = False
  240. retvalue = False
  241. self._configure_error(conf)
  242. elif argument == 'auto':
  243. self.result = self._check(conf)
  244. retvalue = True
  245. else:
  246. print_error('Invalid argument "' + argument + '" to ' + self.option)
  247. self.result = False
  248. retvalue = False
  249. conf.env[self.conf_dest] = self.result
  250. if self.result:
  251. conf.define(self.define, 1)
  252. else:
  253. conf.define(self.define, 0)
  254. return retvalue
  255. def display_message(self):
  256. """
  257. This function displays a result message with the help text and the
  258. result of the configuration.
  259. """
  260. display_feature(self.help, self.result)
  261. # This function adds an option to the list of auto options and returns the newly
  262. # created option.
  263. def add_auto_option(opt, name, help, conf_dest=None, define=None):
  264. option = AutoOption(opt, name, help, conf_dest=conf_dest, define=define)
  265. auto_options.append(option)
  266. return option
  267. # This function applies a hack that for each auto option --foo=no|yes replaces
  268. # any occurence --foo in argv with --foo=yes, in effect interpreting --foo as
  269. # --foo=yes. The function has to be called before waf issues the option parser,
  270. # i.e. before the configure phase.
  271. def auto_options_argv_hack():
  272. for option in auto_options:
  273. for x in range(1, len(sys.argv)):
  274. if sys.argv[x] == option.option:
  275. sys.argv[x] += '=yes'
  276. # This function configures all auto options. It stops waf and prints an error
  277. # message if there were unsatisfied requirements.
  278. def configure_auto_options(conf):
  279. ok = True
  280. for option in auto_options:
  281. if not option.configure(conf):
  282. ok = False
  283. if not ok:
  284. conf.fatal('There were unsatisfied requirements.')
  285. # This function displays all options and the configuration results.
  286. def display_auto_options_messages():
  287. for option in auto_options:
  288. option.display_message()
  289. def check_for_celt(conf):
  290. found = False
  291. for version in ['11', '8', '7', '5']:
  292. define = 'HAVE_CELT_API_0_' + version
  293. if not found:
  294. try:
  295. conf.check_cfg(package='celt', atleast_version='0.' + version + '.0', args='--cflags --libs')
  296. found = True
  297. conf.define(define, 1)
  298. continue
  299. except conf.errors.ConfigurationError:
  300. pass
  301. conf.define(define, 0)
  302. return found
  303. def check_for_celt_error(conf):
  304. print_error('--celt requires the package celt, but it could not be found.')
  305. # The readline/readline.h header does not work if stdio.h is not included
  306. # before. Thus a fragment with both stdio.h and readline/readline.h need to be
  307. # test-compiled to find out whether readline is available.
  308. def check_for_readline(conf):
  309. try:
  310. conf.check_cc(fragment='''
  311. #include <stdio.h>
  312. #include <readline/readline.h>
  313. int main(void) { return 0; }''',
  314. execute=False,
  315. msg='Checking for header readline/readline.h')
  316. return True
  317. except conf.errors.ConfigurationError:
  318. return False
  319. def check_for_readline_error(conf):
  320. print_error('--readline requires the readline/readline.h header, but it cannot be found.')
  321. def check_for_mmsystem(conf):
  322. try:
  323. conf.check_cc(fragment='''
  324. #include <windows.h>
  325. #include <mmsystem.h>
  326. int main(void) { return 0; }''',
  327. execute=False,
  328. msg='Checking for header mmsystem.h')
  329. return True
  330. except conf.errors.ConfigurationError:
  331. return False
  332. def check_for_mmsystem_error(conf):
  333. print_error('--winmme requires the mmsystem.h header, but it cannot be found.')
  334. def options(opt):
  335. # options provided by the modules
  336. opt.load('compiler_cxx')
  337. opt.load('compiler_c')
  338. opt.load('xcode')
  339. opt.load('xcode6')
  340. # install directories
  341. opt.add_option('--htmldir', type='string', default=None, help="HTML documentation directory [Default: <prefix>/share/jack-audio-connection-kit/reference/html/")
  342. opt.add_option('--libdir', type='string', help="Library directory [Default: <prefix>/lib]")
  343. opt.add_option('--libdir32', type='string', help="32bit Library directory [Default: <prefix>/lib32]")
  344. opt.add_option('--mandir', type='string', help="Manpage directory [Default: <prefix>/share/man/man1]")
  345. # options affecting binaries
  346. opt.add_option('--dist-target', type='string', default='auto', help='Specify the target for cross-compiling [auto,mingw]')
  347. opt.add_option('--mixed', action='store_true', default=False, help='Build with 32/64 bits mixed mode')
  348. opt.add_option('--debug', action='store_true', default=False, dest='debug', help='Build debuggable binaries')
  349. # options affecting general jack functionality
  350. opt.add_option('--classic', action='store_true', default=False, help='Force enable standard JACK (jackd) even if D-Bus JACK (jackdbus) is enabled too')
  351. opt.add_option('--dbus', action='store_true', default=False, help='Enable D-Bus JACK (jackdbus)')
  352. opt.add_option('--autostart', type='string', default="default", help='Autostart method. Possible values: "default", "classic", "dbus", "none"')
  353. opt.add_option('--profile', action='store_true', default=False, help='Build with engine profiling')
  354. opt.add_option('--clients', default=64, type="int", dest="clients", help='Maximum number of JACK clients')
  355. opt.add_option('--ports-per-application', default=768, type="int", dest="application_ports", help='Maximum number of ports per application')
  356. # options with third party dependencies
  357. doxygen = add_auto_option(opt, 'doxygen', help='Build doxygen documentation', conf_dest='BUILD_DOXYGEN_DOCS')
  358. doxygen.add_program('doxygen')
  359. alsa = add_auto_option(opt, 'alsa', help='Enable ALSA driver', conf_dest='BUILD_DRIVER_ALSA')
  360. alsa.add_package('alsa', atleast_version='1.0.18')
  361. firewire = add_auto_option(opt, 'firewire', help='Enable FireWire driver (FFADO)', conf_dest='BUILD_DRIVER_FFADO')
  362. firewire.add_package('libffado', atleast_version='1.999.17')
  363. freebob = add_auto_option(opt, 'freebob', help='Enable FreeBob driver')
  364. freebob.add_package('libfreebob', atleast_version='1.0.0')
  365. iio = add_auto_option(opt, 'iio', help='Enable IIO driver', conf_dest='BUILD_DRIVER_IIO')
  366. iio.add_package('gtkIOStream', atleast_version='1.4.0')
  367. iio.add_package('eigen3', atleast_version='3.1.2')
  368. portaudio = add_auto_option(opt, 'portaudio', help='Enable Portaudio driver', conf_dest='BUILD_DRIVER_PORTAUDIO')
  369. portaudio.add_header('windows.h') # only build portaudio on windows
  370. portaudio.add_package('portaudio-2.0', uselib_store='PORTAUDIO', atleast_version='19')
  371. winmme = add_auto_option(opt, 'winmme', help='Enable WinMME driver', conf_dest='BUILD_DRIVER_WINMME')
  372. winmme.set_check_hook(check_for_mmsystem, check_for_mmsystem_error)
  373. celt = add_auto_option(opt, 'celt', help='Build with CELT')
  374. celt.set_check_hook(check_for_celt, check_for_celt_error)
  375. opus = add_auto_option(opt, 'opus', help='Build Opus netjack2')
  376. opus.add_header('opus/opus_custom.h')
  377. opus.add_package('opus', atleast_version='0.9.0')
  378. samplerate = add_auto_option(opt, 'samplerate', help='Build with libsamplerate')
  379. samplerate.add_package('samplerate')
  380. sndfile = add_auto_option(opt, 'sndfile', help='Build with libsndfile')
  381. sndfile.add_package('sndfile')
  382. readline = add_auto_option(opt, 'readline', help='Build with readline')
  383. readline.add_library('readline')
  384. readline.set_check_hook(check_for_readline, check_for_readline_error)
  385. # dbus options
  386. opt.recurse('dbus')
  387. # this must be called before the configure phase
  388. auto_options_argv_hack()
  389. def configure(conf):
  390. conf.load('compiler_cxx')
  391. conf.load('compiler_c')
  392. if Options.options.dist_target == 'auto':
  393. platform = sys.platform
  394. conf.env['IS_MACOSX'] = platform == 'darwin'
  395. conf.env['IS_LINUX'] = platform == 'linux' or platform == 'linux2' or platform == 'linux3' or platform == 'posix'
  396. conf.env['IS_SUN'] = platform == 'sunos'
  397. # GNU/kFreeBSD and GNU/Hurd are treated as Linux
  398. if platform.startswith('gnu0') or platform.startswith('gnukfreebsd'):
  399. conf.env['IS_LINUX'] = True
  400. elif Options.options.dist_target == 'mingw':
  401. conf.env['IS_WINDOWS'] = True
  402. if conf.env['IS_LINUX']:
  403. Logs.pprint('CYAN', "Linux detected")
  404. if conf.env['IS_MACOSX']:
  405. Logs.pprint('CYAN', "MacOS X detected")
  406. if conf.env['IS_SUN']:
  407. Logs.pprint('CYAN', "SunOS detected")
  408. if conf.env['IS_WINDOWS']:
  409. Logs.pprint('CYAN', "Windows detected")
  410. if conf.env['IS_WINDOWS']:
  411. conf.env.append_unique('CCDEFINES', '_POSIX')
  412. conf.env.append_unique('CXXDEFINES', '_POSIX')
  413. conf.env.append_unique('CXXFLAGS', '-Wall')
  414. conf.env.append_unique('CFLAGS', '-Wall')
  415. # configure all auto options
  416. configure_auto_options(conf)
  417. # Check for functions.
  418. conf.check_cc(
  419. function_name='ppoll',
  420. header_name=['poll.h', 'signal.h'],
  421. defines=['_GNU_SOURCE'],
  422. mandatory=False)
  423. conf.recurse('common')
  424. if Options.options.dbus:
  425. conf.recurse('dbus')
  426. if conf.env['BUILD_JACKDBUS'] != True:
  427. conf.fatal('jackdbus was explicitly requested but cannot be built')
  428. conf.recurse('example-clients')
  429. conf.env['LIB_PTHREAD'] = ['pthread']
  430. conf.env['LIB_DL'] = ['dl']
  431. conf.env['LIB_RT'] = ['rt']
  432. conf.env['LIB_M'] = ['m']
  433. conf.env['LIB_STDC++'] = ['stdc++']
  434. conf.env['JACK_API_VERSION'] = JACK_API_VERSION
  435. conf.env['JACK_VERSION'] = VERSION
  436. conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
  437. conf.env['BUILD_WITH_32_64'] = Options.options.mixed
  438. conf.env['BUILD_CLASSIC'] = Options.options.classic
  439. conf.env['BUILD_DEBUG'] = Options.options.debug
  440. if conf.env['BUILD_JACKDBUS']:
  441. conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
  442. else:
  443. conf.env['BUILD_JACKD'] = True
  444. conf.env['BINDIR'] = conf.env['PREFIX'] + '/bin'
  445. if Options.options.htmldir:
  446. conf.env['HTMLDIR'] = Options.options.htmldir
  447. else:
  448. # set to None here so that the doxygen code can find out the highest
  449. # directory to remove upon install
  450. conf.env['HTMLDIR'] = None
  451. if Options.options.libdir:
  452. conf.env['LIBDIR'] = Options.options.libdir
  453. else:
  454. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
  455. if Options.options.mandir:
  456. conf.env['MANDIR'] = Options.options.mandir
  457. else:
  458. conf.env['MANDIR'] = conf.env['PREFIX'] + '/share/man/man1'
  459. if conf.env['BUILD_DEBUG']:
  460. conf.env.append_unique('CXXFLAGS', '-g')
  461. conf.env.append_unique('CFLAGS', '-g')
  462. conf.env.append_unique('LINKFLAGS', '-g')
  463. if not Options.options.autostart in ["default", "classic", "dbus", "none"]:
  464. conf.fatal("Invalid autostart value \"" + Options.options.autostart + "\"")
  465. if Options.options.autostart == "default":
  466. if conf.env['BUILD_JACKDBUS'] == True and conf.env['BUILD_JACKD'] == False:
  467. conf.env['AUTOSTART_METHOD'] = "dbus"
  468. else:
  469. conf.env['AUTOSTART_METHOD'] = "classic"
  470. else:
  471. conf.env['AUTOSTART_METHOD'] = Options.options.autostart
  472. if conf.env['AUTOSTART_METHOD'] == "dbus" and not conf.env['BUILD_JACKDBUS']:
  473. conf.fatal("D-Bus autostart mode was specified but jackdbus will not be built")
  474. if conf.env['AUTOSTART_METHOD'] == "classic" and not conf.env['BUILD_JACKD']:
  475. conf.fatal("Classic autostart mode was specified but jackd will not be built")
  476. if conf.env['AUTOSTART_METHOD'] == "dbus":
  477. conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
  478. elif conf.env['AUTOSTART_METHOD'] == "classic":
  479. conf.define('USE_CLASSIC_AUTOLAUNCH', 1)
  480. conf.define('CLIENT_NUM', Options.options.clients)
  481. conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
  482. if conf.env['IS_WINDOWS']:
  483. # we define this in the environment to maintain compatability with
  484. # existing install paths that use ADDON_DIR rather than have to
  485. # have special cases for windows each time.
  486. conf.env['ADDON_DIR'] = conf.env['BINDIR'] + '/jack'
  487. # don't define ADDON_DIR in config.h, use the default 'jack' defined in
  488. # windows/JackPlatformPlug_os.h
  489. else:
  490. conf.env['ADDON_DIR'] = os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack'))
  491. conf.define('ADDON_DIR', conf.env['ADDON_DIR'])
  492. conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
  493. if not conf.env['IS_WINDOWS']:
  494. conf.define('USE_POSIX_SHM', 1)
  495. conf.define('JACKMP', 1)
  496. if conf.env['BUILD_JACKDBUS'] == True:
  497. conf.define('JACK_DBUS', 1)
  498. if conf.env['BUILD_WITH_PROFILE'] == True:
  499. conf.define('JACK_MONITOR', 1)
  500. conf.write_config_header('config.h', remove=False)
  501. svnrev = None
  502. try:
  503. f = open('svnversion.h')
  504. data = f.read()
  505. m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
  506. if m != None:
  507. svnrev = m.group(1)
  508. f.close()
  509. except IOError:
  510. pass
  511. if Options.options.mixed == True:
  512. conf.setenv(lib32, env=conf.env.derive())
  513. conf.env.append_unique('CXXFLAGS', '-m32')
  514. conf.env.append_unique('CFLAGS', '-m32')
  515. conf.env.append_unique('LINKFLAGS', '-m32')
  516. if Options.options.libdir32:
  517. conf.env['LIBDIR'] = Options.options.libdir32
  518. else:
  519. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
  520. conf.write_config_header('config.h')
  521. print()
  522. display_msg("==================")
  523. version_msg = "JACK " + VERSION
  524. if svnrev:
  525. version_msg += " exported from r" + svnrev
  526. else:
  527. version_msg += " svn revision will checked and eventually updated during build"
  528. print(version_msg)
  529. print("Build with a maximum of %d JACK clients" % Options.options.clients)
  530. print("Build with a maximum of %d ports per application" % Options.options.application_ports)
  531. display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
  532. display_msg("Library directory", conf.all_envs[""]['LIBDIR'], 'CYAN')
  533. if conf.env['BUILD_WITH_32_64'] == True:
  534. display_msg("32-bit library directory", conf.all_envs[lib32]['LIBDIR'], 'CYAN')
  535. display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
  536. display_feature('Build debuggable binaries', conf.env['BUILD_DEBUG'])
  537. display_msg('C compiler flags', repr(conf.all_envs[""]['CFLAGS']))
  538. display_msg('C++ compiler flags', repr(conf.all_envs[""]['CXXFLAGS']))
  539. display_msg('Linker flags', repr(conf.all_envs[""]['LINKFLAGS']))
  540. if conf.env['BUILD_WITH_32_64'] == True:
  541. display_msg('32-bit C compiler flags', repr(conf.all_envs[lib32]['CFLAGS']))
  542. display_msg('32-bit C++ compiler flags', repr(conf.all_envs[lib32]['CXXFLAGS']))
  543. display_msg('32-bit linker flags', repr(conf.all_envs[lib32]['LINKFLAGS']))
  544. display_feature('Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
  545. display_feature('Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
  546. display_feature('Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
  547. display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
  548. display_msg('Autostart method', conf.env['AUTOSTART_METHOD'])
  549. if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
  550. print(Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs.colors.NORMAL)
  551. print(Logs.colors.RED + 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs.colors.NORMAL)
  552. # display configuration result messages for auto options
  553. display_auto_options_messages()
  554. if conf.env['BUILD_JACKDBUS'] == True:
  555. display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
  556. #display_msg('Settings persistence', xxx)
  557. if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
  558. print()
  559. print(Logs.colors.RED + "WARNING: D-Bus session services directory as reported by pkg-config is")
  560. print(Logs.colors.RED + "WARNING:", end=' ')
  561. print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL'])
  562. print(Logs.colors.RED + 'WARNING: but service file will be installed in')
  563. print(Logs.colors.RED + "WARNING:", end=' ')
  564. print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR'])
  565. print(Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus')
  566. print('WARNING: You can override dbus service install directory')
  567. print('WARNING: with --enable-pkg-config-dbus-service-dir option to this script')
  568. print(Logs.colors.NORMAL, end=' ')
  569. print()
  570. def init(ctx):
  571. for y in (BuildContext, CleanContext, InstallContext, UninstallContext):
  572. name = y.__name__.replace('Context','').lower()
  573. class tmp(y):
  574. cmd = name + '_' + lib32
  575. variant = lib32
  576. def obj_add_includes(bld, obj):
  577. if bld.env['BUILD_JACKDBUS']:
  578. obj.includes += ['dbus']
  579. if bld.env['IS_LINUX']:
  580. obj.includes += ['linux', 'posix']
  581. if bld.env['IS_MACOSX']:
  582. obj.includes += ['macosx', 'posix']
  583. if bld.env['IS_SUN']:
  584. obj.includes += ['posix', 'solaris']
  585. if bld.env['IS_WINDOWS']:
  586. obj.includes += ['windows']
  587. # FIXME: Is SERVER_SIDE needed?
  588. def build_jackd(bld):
  589. jackd = bld(
  590. features = ['cxx', 'cxxprogram'],
  591. defines = ['HAVE_CONFIG_H','SERVER_SIDE'],
  592. includes = ['.', 'common', 'common/jack'],
  593. target = 'jackd',
  594. source = ['common/Jackdmp.cpp'],
  595. use = ['serverlib'])
  596. if bld.env['BUILD_JACKDBUS']:
  597. jackd.source += ['dbus/audio_reserve.c', 'dbus/reserve.c']
  598. jackd.use += ['DBUS-1']
  599. if bld.env['IS_LINUX']:
  600. jackd.use += ['DL', 'M', 'PTHREAD', 'RT', 'STDC++']
  601. if bld.env['IS_MACOSX']:
  602. bld.framework = ['CoreFoundation']
  603. jackd.use += ['DL', 'PTHREAD']
  604. if bld.env['IS_SUN']:
  605. jackd.use += ['DL', 'PTHREAD']
  606. obj_add_includes(bld, jackd)
  607. return jackd
  608. # FIXME: Is SERVER_SIDE needed?
  609. def create_driver_obj(bld, **kw):
  610. if bld.env['IS_MACOSX'] or bld.env['IS_WINDOWS']:
  611. # On MacOSX this is necessary.
  612. # I do not know if this is necessary on Windows.
  613. # Note added on 2015-12-13 by lilrc.
  614. if 'use' in kw:
  615. kw['use'] += ['serverlib']
  616. else:
  617. kw['use'] = ['serverlib']
  618. driver = bld(
  619. features = ['c', 'cshlib', 'cxx', 'cxxshlib'],
  620. defines = ['HAVE_CONFIG_H', 'SERVER_SIDE'],
  621. includes = ['.', 'common', 'common/jack'],
  622. install_path = '${ADDON_DIR}/',
  623. **kw)
  624. if bld.env['IS_WINDOWS']:
  625. driver.env['cxxshlib_PATTERN'] = 'jack_%s.dll'
  626. else:
  627. driver.env['cxxshlib_PATTERN'] = 'jack_%s.so'
  628. obj_add_includes(bld, driver)
  629. return driver
  630. def build_drivers(bld):
  631. # Non-hardware driver sources. Lexically sorted.
  632. dummy_src = [
  633. 'common/JackDummyDriver.cpp'
  634. ]
  635. loopback_src = [
  636. 'common/JackLoopbackDriver.cpp'
  637. ]
  638. net_src = [
  639. 'common/JackNetDriver.cpp'
  640. ]
  641. netone_src = [
  642. 'common/JackNetOneDriver.cpp',
  643. 'common/netjack.c',
  644. 'common/netjack_packet.c'
  645. ]
  646. proxy_src = [
  647. 'common/JackProxyDriver.cpp'
  648. ]
  649. # Hardware driver sources. Lexically sorted.
  650. alsa_src = [
  651. 'common/memops.c',
  652. 'linux/alsa/JackAlsaDriver.cpp',
  653. 'linux/alsa/alsa_rawmidi.c',
  654. 'linux/alsa/alsa_seqmidi.c',
  655. 'linux/alsa/alsa_midi_jackmp.cpp',
  656. 'linux/alsa/generic_hw.c',
  657. 'linux/alsa/hdsp.c',
  658. 'linux/alsa/alsa_driver.c',
  659. 'linux/alsa/hammerfall.c',
  660. 'linux/alsa/ice1712.c'
  661. ]
  662. alsarawmidi_src = [
  663. 'linux/alsarawmidi/JackALSARawMidiDriver.cpp',
  664. 'linux/alsarawmidi/JackALSARawMidiInputPort.cpp',
  665. 'linux/alsarawmidi/JackALSARawMidiOutputPort.cpp',
  666. 'linux/alsarawmidi/JackALSARawMidiPort.cpp',
  667. 'linux/alsarawmidi/JackALSARawMidiReceiveQueue.cpp',
  668. 'linux/alsarawmidi/JackALSARawMidiSendQueue.cpp',
  669. 'linux/alsarawmidi/JackALSARawMidiUtil.cpp'
  670. ]
  671. boomer_src = [
  672. 'common/memops.c',
  673. 'solaris/oss/JackBoomerDriver.cpp'
  674. ]
  675. coreaudio_src = [
  676. 'macosx/coreaudio/JackCoreAudioDriver.cpp'
  677. ]
  678. coremidi_src = [
  679. 'macosx/coremidi/JackCoreMidiInputPort.cpp',
  680. 'macosx/coremidi/JackCoreMidiOutputPort.cpp',
  681. 'macosx/coremidi/JackCoreMidiPhysicalInputPort.cpp',
  682. 'macosx/coremidi/JackCoreMidiPhysicalOutputPort.cpp',
  683. 'macosx/coremidi/JackCoreMidiVirtualInputPort.cpp',
  684. 'macosx/coremidi/JackCoreMidiVirtualOutputPort.cpp',
  685. 'macosx/coremidi/JackCoreMidiPort.cpp',
  686. 'macosx/coremidi/JackCoreMidiUtil.cpp',
  687. 'macosx/coremidi/JackCoreMidiDriver.cpp'
  688. ]
  689. ffado_src = [
  690. 'linux/firewire/JackFFADODriver.cpp',
  691. 'linux/firewire/JackFFADOMidiInputPort.cpp',
  692. 'linux/firewire/JackFFADOMidiOutputPort.cpp',
  693. 'linux/firewire/JackFFADOMidiReceiveQueue.cpp',
  694. 'linux/firewire/JackFFADOMidiSendQueue.cpp'
  695. ]
  696. freebob_src = [
  697. 'linux/freebob/JackFreebobDriver.cpp'
  698. ]
  699. iio_driver_src = [
  700. 'linux/iio/JackIIODriver.cpp'
  701. ]
  702. oss_src = [
  703. 'common/memops.c',
  704. 'solaris/oss/JackOSSDriver.cpp'
  705. ]
  706. portaudio_src = [
  707. 'windows/portaudio/JackPortAudioDevices.cpp',
  708. 'windows/portaudio/JackPortAudioDriver.cpp',
  709. ]
  710. winmme_driver_src = [
  711. 'windows/winmme/JackWinMMEDriver.cpp',
  712. 'windows/winmme/JackWinMMEInputPort.cpp',
  713. 'windows/winmme/JackWinMMEOutputPort.cpp',
  714. 'windows/winmme/JackWinMMEPort.cpp',
  715. ]
  716. # Create non-hardware driver objects. Lexically sorted.
  717. create_driver_obj(
  718. bld,
  719. target = 'dummy',
  720. source = dummy_src)
  721. create_driver_obj(
  722. bld,
  723. target = 'loopback',
  724. source = loopback_src)
  725. create_driver_obj(
  726. bld,
  727. target = 'net',
  728. source = net_src)
  729. create_driver_obj(
  730. bld,
  731. target = 'netone',
  732. source = netone_src,
  733. use = ['SAMPLERATE', 'CELT'])
  734. create_driver_obj(
  735. bld,
  736. target = 'proxy',
  737. source = proxy_src)
  738. # Create hardware driver objects. Lexically sorted after the conditional,
  739. # e.g. BUILD_DRIVER_ALSA.
  740. if bld.env['BUILD_DRIVER_ALSA']:
  741. create_driver_obj(
  742. bld,
  743. target = 'alsa',
  744. source = alsa_src,
  745. use = ['ALSA'])
  746. create_driver_obj(
  747. bld,
  748. target = 'alsarawmidi',
  749. source = alsarawmidi_src,
  750. use = ['ALSA'])
  751. if bld.env['BUILD_DRIVER_FREEBOB']:
  752. create_driver_obj(
  753. bld,
  754. target = 'freebob',
  755. source = freebob_src,
  756. use = ['LIBFREEBOB'])
  757. if bld.env['BUILD_DRIVER_FFADO']:
  758. create_driver_obj(
  759. bld,
  760. target = 'firewire',
  761. source = ffado_src,
  762. use = ['LIBFFADO'])
  763. if bld.env['BUILD_DRIVER_IIO']:
  764. create_driver_obj(
  765. bld,
  766. target = 'iio',
  767. source = iio_src,
  768. use = ['GTKIOSTREAM', 'EIGEN3'])
  769. if bld.env['BUILD_DRIVER_PORTAUDIO']:
  770. create_driver_obj(
  771. bld,
  772. target = 'portaudio',
  773. source = portaudio_src,
  774. use = ['PORTAUDIO'])
  775. if bld.env['BUILD_DRIVER_WINMME']:
  776. create_driver_obj(
  777. bld,
  778. target = 'winmme',
  779. source = winmme_src,
  780. use = ['WINMME'])
  781. if bld.env['IS_MACOSX']:
  782. create_driver_obj(
  783. bld,
  784. target = 'coreaudio',
  785. source = coreaudio_src,
  786. framework = ['AudioUnit', 'CoreAudio', 'CoreServices'])
  787. create_driver_obj(
  788. bld,
  789. target = 'coremidi',
  790. source = coremidi_src,
  791. framework = ['AudioUnit', 'CoreMIDI', 'CoreServices'])
  792. if bld.env['IS_SUN']:
  793. create_driver_obj(
  794. bld,
  795. target = 'boomer',
  796. source = boomer_src)
  797. create_driver_obj(
  798. bld,
  799. target = 'oss',
  800. source = oss_src)
  801. def build(bld):
  802. if not bld.variant:
  803. out2 = out
  804. else:
  805. out2 = out + "/" + bld.variant
  806. print("make[1]: Entering directory `" + os.getcwd() + "/" + out2 + "'")
  807. if not bld.variant:
  808. if bld.env['BUILD_WITH_32_64'] == True:
  809. Options.commands.append(bld.cmd + '_' + lib32)
  810. # process subfolders from here
  811. bld.recurse('common')
  812. if bld.variant:
  813. # only the wscript in common/ knows how to handle variants
  814. return
  815. if not os.access('svnversion.h', os.R_OK):
  816. def post_run(self):
  817. sg = Utils.h_file(self.outputs[0].abspath(self.env))
  818. #print sg.encode('hex')
  819. Build.bld.node_sigs[self.env.variant()][self.outputs[0].id] = sg
  820. script = bld.path.find_resource('svnversion_regenerate.sh')
  821. script = script.abspath()
  822. bld(
  823. rule = '%s ${TGT}' % script,
  824. name = 'svnversion',
  825. runnable_status = Task.RUN_ME,
  826. before = 'c cxx',
  827. color = 'BLUE',
  828. post_run = post_run,
  829. source = ['svnversion_regenerate.sh'],
  830. target = [bld.path.find_or_declare('svnversion.h')]
  831. )
  832. if bld.env['BUILD_JACKD']:
  833. build_jackd(bld)
  834. build_drivers(bld)
  835. if bld.env['IS_LINUX']:
  836. bld.recurse('example-clients')
  837. bld.recurse('tests')
  838. bld.recurse('man')
  839. if bld.env['BUILD_JACKDBUS'] == True:
  840. bld.recurse('dbus')
  841. if bld.env['IS_MACOSX']:
  842. bld.recurse('example-clients')
  843. bld.recurse('tests')
  844. if bld.env['BUILD_JACKDBUS'] == True:
  845. bld.recurse('dbus')
  846. if bld.env['IS_SUN']:
  847. bld.recurse('example-clients')
  848. bld.recurse('tests')
  849. if bld.env['BUILD_JACKDBUS'] == True:
  850. bld.recurse('dbus')
  851. if bld.env['IS_WINDOWS']:
  852. bld.recurse('example-clients')
  853. #bld.recurse('tests')
  854. if bld.env['BUILD_DOXYGEN_DOCS'] == True:
  855. html_build_dir = bld.path.find_or_declare('html').abspath()
  856. bld(
  857. features = 'subst',
  858. source = 'doxyfile.in',
  859. target = 'doxyfile',
  860. HTML_BUILD_DIR = html_build_dir,
  861. SRCDIR = bld.srcnode.abspath(),
  862. VERSION = VERSION
  863. )
  864. # There are two reasons for logging to doxygen.log and using it as
  865. # target in the build rule (rather than html_build_dir):
  866. # (1) reduce the noise when running the build
  867. # (2) waf has a regular file to check for a timestamp. If the directory
  868. # is used instead waf will rebuild the doxygen target (even upon
  869. # install).
  870. def doxygen(task):
  871. doxyfile = task.inputs[0].abspath()
  872. logfile = task.outputs[0].abspath()
  873. cmd = '%s %s &> %s' % (task.env['DOXYGEN'][0], doxyfile, logfile)
  874. return task.exec_command(cmd)
  875. bld(
  876. rule = doxygen,
  877. source = 'doxyfile',
  878. target = 'doxygen.log'
  879. )
  880. # Determine where to install HTML documentation. Since share_dir is the
  881. # highest directory the uninstall routine should remove, there is no
  882. # better candidate for share_dir, but the requested HTML directory if
  883. # --htmldir is given.
  884. if bld.env['HTMLDIR']:
  885. html_install_dir = bld.options.destdir + bld.env['HTMLDIR']
  886. share_dir = html_install_dir
  887. else:
  888. share_dir = bld.options.destdir + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
  889. html_install_dir = share_dir + '/reference/html/'
  890. if bld.cmd == 'install':
  891. if os.path.isdir(html_install_dir):
  892. Logs.pprint('CYAN', "Removing old doxygen documentation installation...")
  893. shutil.rmtree(html_install_dir)
  894. Logs.pprint('CYAN', "Removing old doxygen documentation installation done.")
  895. Logs.pprint('CYAN', "Installing doxygen documentation...")
  896. shutil.copytree(html_build_dir, html_install_dir)
  897. Logs.pprint('CYAN', "Installing doxygen documentation done.")
  898. elif bld.cmd =='uninstall':
  899. Logs.pprint('CYAN', "Uninstalling doxygen documentation...")
  900. if os.path.isdir(share_dir):
  901. shutil.rmtree(share_dir)
  902. Logs.pprint('CYAN', "Uninstalling doxygen documentation done.")
  903. elif bld.cmd =='clean':
  904. if os.access(html_build_dir, os.R_OK):
  905. Logs.pprint('CYAN', "Removing doxygen generated documentation...")
  906. shutil.rmtree(html_build_dir)
  907. Logs.pprint('CYAN', "Removing doxygen generated documentation done.")
  908. def dist(ctx):
  909. # This code blindly assumes it is working in the toplevel source directory.
  910. if not os.path.exists('svnversion.h'):
  911. os.system('./svnversion_regenerate.sh svnversion.h')