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.

817 lines
33KB

  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. from __future__ import print_function
  4. import os
  5. import Utils
  6. import Options
  7. import subprocess
  8. g_maxlen = 40
  9. import shutil
  10. import Task
  11. import re
  12. import Logs
  13. import sys
  14. import waflib.Options
  15. from waflib.Build import BuildContext, CleanContext, InstallContext, UninstallContext
  16. VERSION='1.9.11'
  17. APPNAME='jack'
  18. JACK_API_VERSION = '0.1.0'
  19. # these variables are mandatory ('/' are converted automatically)
  20. top = '.'
  21. out = 'build'
  22. # lib32 variant name used when building in mixed mode
  23. lib32 = 'lib32'
  24. auto_options = []
  25. def display_msg(msg, status = None, color = None):
  26. sr = msg
  27. global g_maxlen
  28. g_maxlen = max(g_maxlen, len(msg))
  29. if status:
  30. Logs.pprint('NORMAL', "%s :" % msg.ljust(g_maxlen), sep=' ')
  31. Logs.pprint(color, status)
  32. else:
  33. print("%s" % msg.ljust(g_maxlen))
  34. def display_feature(msg, build):
  35. if build:
  36. display_msg(msg, "yes", 'GREEN')
  37. else:
  38. display_msg(msg, "no", 'YELLOW')
  39. # This function prints an error without stopping waf. The reason waf should not
  40. # be stopped is to be able to list all missing dependencies in one chunk.
  41. def print_error(msg):
  42. print(Logs.colors.RED + msg + Logs.colors.NORMAL)
  43. class AutoOption:
  44. """
  45. This class is the foundation for the auto options. It adds an option
  46. --foo=no|yes to the list of options and deals with all logic and checks for
  47. these options.
  48. Each option can have different dependencies that will be checked. If all
  49. dependencies are available and the user has not done any request the option
  50. will be enabled. If the user has requested to enable the option the class
  51. ensures that all dependencies are available and prints an error message
  52. otherwise. If the user disables the option, i.e. --foo=no, no checks are
  53. made.
  54. For each option it is possible to add packages that are required for the
  55. option using the add_package function. For dependency programs add_program
  56. should be used. For libraries (without pkg-config support) the add_library
  57. function should be used. For headers the add_header function exists. If
  58. there is another type of requirement or dependency the check hook (an
  59. external function called when configuring) can be used.
  60. When all checks have been made and the class has made a decision the result
  61. is saved in conf.env['NAME'] where 'NAME' by default is the uppercase of the
  62. name argument to __init__, but it can be changed with the conf_dest argument
  63. to __init__.
  64. The class will define a preprocessor symbol with the result. The default
  65. name is HAVE_NAME, but it can be changed using the define argument to
  66. __init__.
  67. """
  68. def __init__(self, opt, name, help, conf_dest=None, define=None):
  69. # check hook to call upon configuration
  70. self.check_hook = None
  71. self.check_hook_error = None
  72. self.check_hook_found = True
  73. # required libraries
  74. self.libs = [] # elements on the form [lib,uselib_store]
  75. self.libs_not_found = [] # elements on the form lib
  76. # required headers
  77. self.headers = []
  78. self.headers_not_found = []
  79. # required packages (checked with pkg-config)
  80. self.packages = [] # elements on the form [package,uselib_store,atleast_version]
  81. self.packages_not_found = [] # elements on the form [package,atleast_version]
  82. # required programs
  83. self.programs = [] # elements on the form [program,var]
  84. self.programs_not_found = [] # elements on the form program
  85. # the result of the configuration (should the option be enabled or not?)
  86. self.result = False
  87. self.help = help
  88. self.option = '--' + name
  89. self.dest = 'auto_option_' + name
  90. if conf_dest:
  91. self.conf_dest = conf_dest
  92. else:
  93. self.conf_dest = name.upper()
  94. if not define:
  95. self.define = 'HAVE_' + name.upper()
  96. else:
  97. self.define = define
  98. opt.add_option(self.option, type='string', default='auto', dest=self.dest, help=self.help+' (enabled by default if possible)', metavar='no|yes')
  99. def add_library(self, library, uselib_store=None):
  100. """
  101. Add a required library that should be checked during configuration. The
  102. library will be checked using the conf.check_cc function. If the
  103. uselib_store arugment is not given it defaults to LIBRARY (the uppercase
  104. of the library argument). The uselib_store argument will be passed to
  105. check_cc which means LIB_LIBRARY, CFLAGS_LIBRARY and DEFINES_LIBRARY,
  106. etc. will be defined if the option is enabled.
  107. """
  108. if not uselib_store:
  109. uselib_store = library.upper().replace('-', '_')
  110. self.libs.append([library, uselib_store])
  111. def add_header(self, header):
  112. """
  113. Add a required header that should be checked during configuration. The
  114. header will be checked using the conf.check_cc function which means
  115. HAVE_HEADER_H will be defined if found.
  116. """
  117. self.headers.append(header)
  118. def add_package(self, package, uselib_store=None, atleast_version=None):
  119. """
  120. Add a required package that should be checked using pkg-config during
  121. configuration. The package will be checked using the conf.check_cfg
  122. function and the uselib_store and atleast_version will be passed to
  123. check_cfg. If uselib_store is None it defaults to PACKAGE (uppercase of
  124. the package argument) with hyphens and dots replaced with underscores.
  125. If atleast_version is None it defaults to '0'.
  126. """
  127. if not uselib_store:
  128. uselib_store = package.upper().replace('-', '_').replace('.', '_')
  129. if not atleast_version:
  130. atleast_version = '0'
  131. self.packages.append([package, uselib_store, atleast_version])
  132. def add_program(self, program, var=None):
  133. """
  134. Add a required program that should be checked during configuration. If
  135. var is not given it defaults to PROGRAM (the uppercase of the program
  136. argument). If the option is enabled the program is saved in
  137. conf.env.PROGRAM.
  138. """
  139. if not var:
  140. var = program.upper().replace('-', '_')
  141. self.programs.append([program, var])
  142. def set_check_hook(self, check_hook, check_hook_error):
  143. """
  144. Set the check hook and the corresponding error printing function to the
  145. configure step. The check_hook argument is a function that should return
  146. True if the extra prerequisites were found and False if not. The
  147. check_hook_error argument is an error printing function that should
  148. print an error message telling the user that --foo was explicitly
  149. requested but cannot be built since the extra prerequisites were not
  150. found. Both function should take a single argument that is the waf
  151. configuration context.
  152. """
  153. self.check_hook = check_hook
  154. self.check_hook_error = check_hook_error
  155. def _check(self, conf):
  156. """
  157. This is an internal function that runs all necessary configure checks.
  158. It checks all dependencies (even if some dependency was not found) so
  159. that the user can install all missing dependencies in one go, instead
  160. of playing the infamous hit-configure-hit-configure game.
  161. This function returns True if all dependencies were found and False if
  162. not.
  163. """
  164. all_found = True
  165. # check for libraries
  166. for lib,uselib_store in self.libs:
  167. try:
  168. conf.check_cc(lib=lib, uselib_store=uselib_store)
  169. except conf.errors.ConfigurationError:
  170. all_found = False
  171. self.libs_not_found.append(lib)
  172. # check for headers
  173. for header in self.headers:
  174. try:
  175. conf.check_cc(header_name=header)
  176. except conf.errors.ConfigurationError:
  177. all_found = False
  178. self.headers_not_found.append(header)
  179. # check for packages
  180. for package,uselib_store,atleast_version in self.packages:
  181. try:
  182. conf.check_cfg(package=package, uselib_store=uselib_store, atleast_version=atleast_version, args='--cflags --libs')
  183. except conf.errors.ConfigurationError:
  184. all_found = False
  185. self.packages_not_found.append([package,atleast_version])
  186. # check for programs
  187. for program,var in self.programs:
  188. try:
  189. conf.find_program(program, var=var)
  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.tool_options('compiler_cxx')
  337. opt.tool_options('compiler_cc')
  338. # install directories
  339. opt.add_option('--htmldir', type='string', default=None, help="HTML documentation directory [Default: <prefix>/share/jack-audio-connection-kit/reference/html/")
  340. opt.add_option('--libdir', type='string', help="Library directory [Default: <prefix>/lib]")
  341. opt.add_option('--libdir32', type='string', help="32bit Library directory [Default: <prefix>/lib32]")
  342. opt.add_option('--mandir', type='string', help="Manpage directory [Default: <prefix>/share/man/man1]")
  343. # options affecting binaries
  344. opt.add_option('--dist-target', type='string', default='auto', help='Specify the target for cross-compiling [auto,mingw]')
  345. opt.add_option('--mixed', action='store_true', default=False, help='Build with 32/64 bits mixed mode')
  346. opt.add_option('--debug', action='store_true', default=False, dest='debug', help='Build debuggable binaries')
  347. # options affecting general jack functionality
  348. opt.add_option('--classic', action='store_true', default=False, help='Force enable standard JACK (jackd) even if D-Bus JACK (jackdbus) is enabled too')
  349. opt.add_option('--dbus', action='store_true', default=False, help='Enable D-Bus JACK (jackdbus)')
  350. opt.add_option('--autostart', type='string', default="default", help='Autostart method. Possible values: "default", "classic", "dbus", "none"')
  351. opt.add_option('--profile', action='store_true', default=False, help='Build with engine profiling')
  352. opt.add_option('--clients', default=64, type="int", dest="clients", help='Maximum number of JACK clients')
  353. opt.add_option('--ports-per-application', default=768, type="int", dest="application_ports", help='Maximum number of ports per application')
  354. # options with third party dependencies
  355. doxygen = add_auto_option(opt, 'doxygen', help='Build doxygen documentation', conf_dest='BUILD_DOXYGEN_DOCS')
  356. doxygen.add_program('doxygen')
  357. alsa = add_auto_option(opt, 'alsa', help='Enable ALSA driver', conf_dest='BUILD_DRIVER_ALSA')
  358. alsa.add_package('alsa', atleast_version='1.0.18')
  359. firewire = add_auto_option(opt, 'firewire', help='Enable FireWire driver (FFADO)', conf_dest='BUILD_DRIVER_FFADO')
  360. firewire.add_package('libffado', atleast_version='1.999.17')
  361. freebob = add_auto_option(opt, 'freebob', help='Enable FreeBob driver')
  362. freebob.add_package('libfreebob', atleast_version='1.0.0')
  363. iio = add_auto_option(opt, 'iio', help='Enable IIO driver', conf_dest='BUILD_DRIVER_IIO')
  364. iio.add_package('gtkIOStream', atleast_version='1.4.0')
  365. iio.add_package('eigen3', atleast_version='3.1.2')
  366. portaudio = add_auto_option(opt, 'portaudio', help='Enable Portaudio driver', conf_dest='BUILD_DRIVER_PORTAUDIO')
  367. portaudio.add_header('windows.h') # only build portaudio on windows
  368. portaudio.add_package('portaudio-2.0', uselib_store='PORTAUDIO', atleast_version='19')
  369. winmme = add_auto_option(opt, 'winmme', help='Enable WinMME driver', conf_dest='BUILD_DRIVER_WINMME')
  370. winmme.set_check_hook(check_for_mmsystem, check_for_mmsystem_error)
  371. celt = add_auto_option(opt, 'celt', help='Build with CELT')
  372. celt.set_check_hook(check_for_celt, check_for_celt_error)
  373. opus = add_auto_option(opt, 'opus', help='Build Opus netjack2')
  374. opus.add_header('opus/opus_custom.h')
  375. opus.add_package('opus', atleast_version='0.9.0')
  376. samplerate = add_auto_option(opt, 'samplerate', help='Build with libsamplerate')
  377. samplerate.add_package('samplerate')
  378. sndfile = add_auto_option(opt, 'sndfile', help='Build with libsndfile')
  379. sndfile.add_package('sndfile')
  380. readline = add_auto_option(opt, 'readline', help='Build with readline')
  381. readline.add_library('readline')
  382. readline.set_check_hook(check_for_readline, check_for_readline_error)
  383. # dbus options
  384. opt.sub_options('dbus')
  385. # this must be called before the configure phase
  386. auto_options_argv_hack()
  387. def configure(conf):
  388. conf.load('compiler_cxx')
  389. conf.load('compiler_cc')
  390. if Options.options.dist_target == 'auto':
  391. platform = sys.platform
  392. conf.env['IS_MACOSX'] = platform == 'darwin'
  393. conf.env['IS_LINUX'] = platform == 'linux' or platform == 'linux2' or platform == 'linux3' or platform == 'posix'
  394. conf.env['IS_SUN'] = platform == 'sunos'
  395. # GNU/kFreeBSD and GNU/Hurd are treated as Linux
  396. if platform.startswith('gnu0') or platform.startswith('gnukfreebsd'):
  397. conf.env['IS_LINUX'] = True
  398. elif Options.options.dist_target == 'mingw':
  399. conf.env['IS_WINDOWS'] = True
  400. if conf.env['IS_LINUX']:
  401. Logs.pprint('CYAN', "Linux detected")
  402. if conf.env['IS_MACOSX']:
  403. Logs.pprint('CYAN', "MacOS X detected")
  404. if conf.env['IS_SUN']:
  405. Logs.pprint('CYAN', "SunOS detected")
  406. if conf.env['IS_WINDOWS']:
  407. Logs.pprint('CYAN', "Windows detected")
  408. if conf.env['IS_LINUX']:
  409. conf.check_tool('compiler_cxx')
  410. conf.check_tool('compiler_cc')
  411. if conf.env['IS_MACOSX']:
  412. conf.check_tool('compiler_cxx')
  413. conf.check_tool('compiler_cc')
  414. # waf 1.5 : check_tool('compiler_cxx') and check_tool('compiler_cc') do not work correctly, so explicit use of gcc and g++
  415. if conf.env['IS_SUN']:
  416. conf.check_tool('g++')
  417. conf.check_tool('gcc')
  418. #if conf.env['IS_SUN']:
  419. # conf.check_tool('compiler_cxx')
  420. # conf.check_tool('compiler_cc')
  421. if conf.env['IS_WINDOWS']:
  422. conf.check_tool('compiler_cxx')
  423. conf.check_tool('compiler_cc')
  424. conf.env.append_unique('CCDEFINES', '_POSIX')
  425. conf.env.append_unique('CXXDEFINES', '_POSIX')
  426. conf.env.append_unique('CXXFLAGS', '-Wall')
  427. conf.env.append_unique('CFLAGS', '-Wall')
  428. # configure all auto options
  429. configure_auto_options(conf)
  430. conf.sub_config('common')
  431. if conf.env['IS_LINUX']:
  432. conf.sub_config('linux')
  433. if Options.options.dbus:
  434. conf.sub_config('dbus')
  435. if conf.env['BUILD_JACKDBUS'] != True:
  436. conf.fatal('jackdbus was explicitly requested but cannot be built')
  437. conf.sub_config('example-clients')
  438. conf.env['LIB_PTHREAD'] = ['pthread']
  439. conf.env['LIB_DL'] = ['dl']
  440. conf.env['LIB_RT'] = ['rt']
  441. conf.env['LIB_M'] = ['m']
  442. conf.env['LIB_STDC++'] = ['stdc++']
  443. conf.env['JACK_API_VERSION'] = JACK_API_VERSION
  444. conf.env['JACK_VERSION'] = VERSION
  445. conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
  446. conf.env['BUILD_WITH_32_64'] = Options.options.mixed
  447. conf.env['BUILD_CLASSIC'] = Options.options.classic
  448. conf.env['BUILD_DEBUG'] = Options.options.debug
  449. if conf.env['BUILD_JACKDBUS']:
  450. conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
  451. else:
  452. conf.env['BUILD_JACKD'] = True
  453. conf.env['BINDIR'] = conf.env['PREFIX'] + '/bin'
  454. if Options.options.htmldir:
  455. conf.env['HTMLDIR'] = Options.options.htmldir
  456. else:
  457. # set to None here so that the doxygen code can find out the highest
  458. # directory to remove upon install
  459. conf.env['HTMLDIR'] = None
  460. if Options.options.libdir:
  461. conf.env['LIBDIR'] = Options.options.libdir
  462. else:
  463. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
  464. if Options.options.mandir:
  465. conf.env['MANDIR'] = Options.options.mandir
  466. else:
  467. conf.env['MANDIR'] = conf.env['PREFIX'] + '/share/man/man1'
  468. if conf.env['BUILD_DEBUG']:
  469. conf.env.append_unique('CXXFLAGS', '-g')
  470. conf.env.append_unique('CFLAGS', '-g')
  471. conf.env.append_unique('LINKFLAGS', '-g')
  472. if not Options.options.autostart in ["default", "classic", "dbus", "none"]:
  473. conf.fatal("Invalid autostart value \"" + Options.options.autostart + "\"")
  474. if Options.options.autostart == "default":
  475. if conf.env['BUILD_JACKDBUS'] == True and conf.env['BUILD_JACKD'] == False:
  476. conf.env['AUTOSTART_METHOD'] = "dbus"
  477. else:
  478. conf.env['AUTOSTART_METHOD'] = "classic"
  479. else:
  480. conf.env['AUTOSTART_METHOD'] = Options.options.autostart
  481. if conf.env['AUTOSTART_METHOD'] == "dbus" and not conf.env['BUILD_JACKDBUS']:
  482. conf.fatal("D-Bus autostart mode was specified but jackdbus will not be built")
  483. if conf.env['AUTOSTART_METHOD'] == "classic" and not conf.env['BUILD_JACKD']:
  484. conf.fatal("Classic autostart mode was specified but jackd will not be built")
  485. if conf.env['AUTOSTART_METHOD'] == "dbus":
  486. conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
  487. elif conf.env['AUTOSTART_METHOD'] == "classic":
  488. conf.define('USE_CLASSIC_AUTOLAUNCH', 1)
  489. conf.define('CLIENT_NUM', Options.options.clients)
  490. conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
  491. if conf.env['IS_WINDOWS']:
  492. # we define this in the environment to maintain compatability with
  493. # existing install paths that use ADDON_DIR rather than have to
  494. # have special cases for windows each time.
  495. conf.env['ADDON_DIR'] = conf.env['BINDIR'] + '/jack'
  496. # don't define ADDON_DIR in config.h, use the default 'jack' defined in
  497. # windows/JackPlatformPlug_os.h
  498. else:
  499. conf.env['ADDON_DIR'] = os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack'))
  500. conf.define('ADDON_DIR', conf.env['ADDON_DIR'])
  501. conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
  502. if not conf.env['IS_WINDOWS']:
  503. conf.define('USE_POSIX_SHM', 1)
  504. conf.define('JACKMP', 1)
  505. if conf.env['BUILD_JACKDBUS'] == True:
  506. conf.define('JACK_DBUS', 1)
  507. if conf.env['BUILD_WITH_PROFILE'] == True:
  508. conf.define('JACK_MONITOR', 1)
  509. conf.write_config_header('config.h', remove=False)
  510. svnrev = None
  511. try:
  512. f = open('svnversion.h')
  513. data = f.read()
  514. m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
  515. if m != None:
  516. svnrev = m.group(1)
  517. f.close()
  518. except FileNotFoundError:
  519. pass
  520. if Options.options.mixed == True:
  521. conf.setenv(lib32, env=conf.env.derive())
  522. conf.env.append_unique('CXXFLAGS', '-m32')
  523. conf.env.append_unique('CFLAGS', '-m32')
  524. conf.env.append_unique('LINKFLAGS', '-m32')
  525. if Options.options.libdir32:
  526. conf.env['LIBDIR'] = Options.options.libdir32
  527. else:
  528. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
  529. conf.write_config_header('config.h')
  530. print()
  531. display_msg("==================")
  532. version_msg = "JACK " + VERSION
  533. if svnrev:
  534. version_msg += " exported from r" + svnrev
  535. else:
  536. version_msg += " svn revision will checked and eventually updated during build"
  537. print(version_msg)
  538. print("Build with a maximum of %d JACK clients" % Options.options.clients)
  539. print("Build with a maximum of %d ports per application" % Options.options.application_ports)
  540. display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
  541. display_msg("Library directory", conf.all_envs[""]['LIBDIR'], 'CYAN')
  542. if conf.env['BUILD_WITH_32_64'] == True:
  543. display_msg("32-bit library directory", conf.all_envs[lib32]['LIBDIR'], 'CYAN')
  544. display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
  545. display_feature('Build debuggable binaries', conf.env['BUILD_DEBUG'])
  546. display_msg('C compiler flags', repr(conf.all_envs[""]['CFLAGS']))
  547. display_msg('C++ compiler flags', repr(conf.all_envs[""]['CXXFLAGS']))
  548. display_msg('Linker flags', repr(conf.all_envs[""]['LINKFLAGS']))
  549. if conf.env['BUILD_WITH_32_64'] == True:
  550. display_msg('32-bit C compiler flags', repr(conf.all_envs[lib32]['CFLAGS']))
  551. display_msg('32-bit C++ compiler flags', repr(conf.all_envs[lib32]['CXXFLAGS']))
  552. display_msg('32-bit linker flags', repr(conf.all_envs[lib32]['LINKFLAGS']))
  553. display_feature('Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
  554. display_feature('Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
  555. display_feature('Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
  556. display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
  557. display_msg('Autostart method', conf.env['AUTOSTART_METHOD'])
  558. if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
  559. print(Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs.colors.NORMAL)
  560. print(Logs.colors.RED + 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs.colors.NORMAL)
  561. # display configuration result messages for auto options
  562. display_auto_options_messages()
  563. if conf.env['BUILD_JACKDBUS'] == True:
  564. display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
  565. #display_msg('Settings persistence', xxx)
  566. if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
  567. print()
  568. print(Logs.colors.RED + "WARNING: D-Bus session services directory as reported by pkg-config is")
  569. print(Logs.colors.RED + "WARNING:", end=' ')
  570. print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL'])
  571. print(Logs.colors.RED + 'WARNING: but service file will be installed in')
  572. print(Logs.colors.RED + "WARNING:", end=' ')
  573. print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR'])
  574. print(Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus')
  575. print('WARNING: You can override dbus service install directory')
  576. print('WARNING: with --enable-pkg-config-dbus-service-dir option to this script')
  577. print(Logs.colors.NORMAL, end=' ')
  578. print()
  579. def init(ctx):
  580. for y in (BuildContext, CleanContext, InstallContext, UninstallContext):
  581. name = y.__name__.replace('Context','').lower()
  582. class tmp(y):
  583. cmd = name + '_' + lib32
  584. variant = lib32
  585. def build(bld):
  586. if not bld.variant:
  587. out2 = out
  588. else:
  589. out2 = out + "/" + bld.variant
  590. print("make[1]: Entering directory `" + os.getcwd() + "/" + out2 + "'")
  591. if not bld.variant:
  592. if bld.env['BUILD_WITH_32_64'] == True:
  593. waflib.Options.commands.append(bld.cmd + '_' + lib32)
  594. # process subfolders from here
  595. bld.add_subdirs('common')
  596. if bld.variant:
  597. # only the wscript in common/ knows how to handle variants
  598. return
  599. if not os.access('svnversion.h', os.R_OK):
  600. def post_run(self):
  601. sg = Utils.h_file(self.outputs[0].abspath(self.env))
  602. #print sg.encode('hex')
  603. Build.bld.node_sigs[self.env.variant()][self.outputs[0].id] = sg
  604. script = bld.path.find_resource('svnversion_regenerate.sh')
  605. script = script.abspath()
  606. bld(
  607. rule = '%s ${TGT}' % script,
  608. name = 'svnversion',
  609. runnable_status = Task.RUN_ME,
  610. before = 'c cxx',
  611. color = 'BLUE',
  612. post_run = post_run,
  613. target = [bld.path.find_or_declare('svnversion.h')]
  614. )
  615. if bld.env['IS_LINUX']:
  616. bld.add_subdirs('linux')
  617. bld.add_subdirs('example-clients')
  618. bld.add_subdirs('tests')
  619. bld.add_subdirs('man')
  620. if bld.env['BUILD_JACKDBUS'] == True:
  621. bld.add_subdirs('dbus')
  622. if bld.env['IS_MACOSX']:
  623. bld.add_subdirs('macosx')
  624. bld.add_subdirs('example-clients')
  625. bld.add_subdirs('tests')
  626. if bld.env['BUILD_JACKDBUS'] == True:
  627. bld.add_subdirs('dbus')
  628. if bld.env['IS_SUN']:
  629. bld.add_subdirs('solaris')
  630. bld.add_subdirs('example-clients')
  631. bld.add_subdirs('tests')
  632. if bld.env['BUILD_JACKDBUS'] == True:
  633. bld.add_subdirs('dbus')
  634. if bld.env['IS_WINDOWS']:
  635. bld.add_subdirs('windows')
  636. bld.add_subdirs('example-clients')
  637. #bld.add_subdirs('tests')
  638. if bld.env['BUILD_DOXYGEN_DOCS'] == True:
  639. html_build_dir = bld.path.find_or_declare('html').abspath()
  640. bld(
  641. features = 'subst',
  642. source = 'doxyfile.in',
  643. target = 'doxyfile',
  644. HTML_BUILD_DIR = html_build_dir,
  645. SRCDIR = bld.srcnode.abspath(),
  646. VERSION = VERSION
  647. )
  648. # There are two reasons for logging to doxygen.log and using it as
  649. # target in the build rule (rather than html_build_dir):
  650. # (1) reduce the noise when running the build
  651. # (2) waf has a regular file to check for a timestamp. If the directory
  652. # is used instead waf will rebuild the doxygen target (even upon
  653. # install).
  654. def doxygen(task):
  655. doxyfile = task.inputs[0].abspath()
  656. logfile = task.outputs[0].abspath()
  657. cmd = '%s %s &> %s' % (task.env.DOXYGEN, doxyfile, logfile)
  658. return task.exec_command(cmd)
  659. bld(
  660. rule = doxygen,
  661. source = 'doxyfile',
  662. target = 'doxygen.log'
  663. )
  664. # Determine where to install HTML documentation. Since share_dir is the
  665. # highest directory the uninstall routine should remove, there is no
  666. # better candidate for share_dir, but the requested HTML directory if
  667. # --htmldir is given.
  668. if bld.env['HTMLDIR']:
  669. html_install_dir = bld.options.destdir + bld.env['HTMLDIR']
  670. share_dir = html_install_dir
  671. else:
  672. share_dir = bld.options.destdir + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
  673. html_install_dir = share_dir + '/reference/html/'
  674. if bld.cmd == 'install':
  675. if os.path.isdir(html_install_dir):
  676. Logs.pprint('CYAN', "Removing old doxygen documentation installation...")
  677. shutil.rmtree(html_install_dir)
  678. Logs.pprint('CYAN', "Removing old doxygen documentation installation done.")
  679. Logs.pprint('CYAN', "Installing doxygen documentation...")
  680. shutil.copytree(html_build_dir, html_install_dir)
  681. Logs.pprint('CYAN', "Installing doxygen documentation done.")
  682. elif bld.cmd =='uninstall':
  683. Logs.pprint('CYAN', "Uninstalling doxygen documentation...")
  684. if os.path.isdir(share_dir):
  685. shutil.rmtree(share_dir)
  686. Logs.pprint('CYAN', "Uninstalling doxygen documentation done.")
  687. elif bld.cmd =='clean':
  688. if os.access(html_build_dir, os.R_OK):
  689. Logs.pprint('CYAN', "Removing doxygen generated documentation...")
  690. shutil.rmtree(html_build_dir)
  691. Logs.pprint('CYAN', "Removing doxygen generated documentation done.")
  692. def dist(ctx):
  693. # This code blindly assumes it is working in the toplevel source directory.
  694. if not os.path.exists('svnversion.h'):
  695. os.system('./svnversion_regenerate.sh svnversion.h')