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. from waflib.Build import BuildContext, CleanContext, InstallContext, UninstallContext
  15. VERSION='1.9.11'
  16. APPNAME='jack'
  17. JACK_API_VERSION = '0.1.0'
  18. # these variables are mandatory ('/' are converted automatically)
  19. top = '.'
  20. out = 'build'
  21. # lib32 variant name used when building in mixed mode
  22. lib32 = 'lib32'
  23. auto_options = []
  24. def display_msg(msg, status = None, color = None):
  25. sr = msg
  26. global g_maxlen
  27. g_maxlen = max(g_maxlen, len(msg))
  28. if status:
  29. Logs.pprint('NORMAL', "%s :" % msg.ljust(g_maxlen), sep=' ')
  30. Logs.pprint(color, status)
  31. else:
  32. print("%s" % msg.ljust(g_maxlen))
  33. def display_feature(msg, build):
  34. if build:
  35. display_msg(msg, "yes", 'GREEN')
  36. else:
  37. display_msg(msg, "no", 'YELLOW')
  38. # This function prints an error without stopping waf. The reason waf should not
  39. # be stopped is to be able to list all missing dependencies in one chunk.
  40. def print_error(msg):
  41. print(Logs.colors.RED + msg + Logs.colors.NORMAL)
  42. class AutoOption:
  43. """
  44. This class is the foundation for the auto options. It adds an option
  45. --foo=no|yes to the list of options and deals with all logic and checks for
  46. these options.
  47. Each option can have different dependencies that will be checked. If all
  48. dependencies are available and the user has not done any request the option
  49. will be enabled. If the user has requested to enable the option the class
  50. ensures that all dependencies are available and prints an error message
  51. otherwise. If the user disables the option, i.e. --foo=no, no checks are
  52. made.
  53. For each option it is possible to add packages that are required for the
  54. option using the add_package function. For dependency programs add_program
  55. should be used. For libraries (without pkg-config support) the add_library
  56. function should be used. For headers the add_header function exists. If
  57. there is another type of requirement or dependency the check hook (an
  58. external function called when configuring) can be used.
  59. When all checks have been made and the class has made a decision the result
  60. is saved in conf.env['NAME'] where 'NAME' by default is the uppercase of the
  61. name argument to __init__, but it can be changed with the conf_dest argument
  62. to __init__.
  63. The class will define a preprocessor symbol with the result. The default
  64. name is HAVE_NAME, but it can be changed using the define argument to
  65. __init__.
  66. """
  67. def __init__(self, opt, name, help, conf_dest=None, define=None):
  68. # check hook to call upon configuration
  69. self.check_hook = None
  70. self.check_hook_error = None
  71. self.check_hook_found = True
  72. # required libraries
  73. self.libs = [] # elements on the form [lib,uselib_store]
  74. self.libs_not_found = [] # elements on the form lib
  75. # required headers
  76. self.headers = []
  77. self.headers_not_found = []
  78. # required packages (checked with pkg-config)
  79. self.packages = [] # elements on the form [package,uselib_store,atleast_version]
  80. self.packages_not_found = [] # elements on the form [package,atleast_version]
  81. # required programs
  82. self.programs = [] # elements on the form [program,var]
  83. self.programs_not_found = [] # elements on the form program
  84. # the result of the configuration (should the option be enabled or not?)
  85. self.result = False
  86. self.help = help
  87. self.option = '--' + name
  88. self.dest = 'auto_option_' + name
  89. if conf_dest:
  90. self.conf_dest = conf_dest
  91. else:
  92. self.conf_dest = name.upper()
  93. if not define:
  94. self.define = 'HAVE_' + name.upper()
  95. else:
  96. self.define = define
  97. opt.add_option(self.option, type='string', default='auto', dest=self.dest, help=self.help+' (enabled by default if possible)', metavar='no|yes')
  98. def add_library(self, library, uselib_store=None):
  99. """
  100. Add a required library that should be checked during configuration. The
  101. library will be checked using the conf.check_cc function. If the
  102. uselib_store arugment is not given it defaults to LIBRARY (the uppercase
  103. of the library argument). The uselib_store argument will be passed to
  104. check_cc which means LIB_LIBRARY, CFLAGS_LIBRARY and DEFINES_LIBRARY,
  105. etc. will be defined if the option is enabled.
  106. """
  107. if not uselib_store:
  108. uselib_store = library.upper().replace('-', '_')
  109. self.libs.append([library, uselib_store])
  110. def add_header(self, header):
  111. """
  112. Add a required header that should be checked during configuration. The
  113. header will be checked using the conf.check_cc function which means
  114. HAVE_HEADER_H will be defined if found.
  115. """
  116. self.headers.append(header)
  117. def add_package(self, package, uselib_store=None, atleast_version=None):
  118. """
  119. Add a required package that should be checked using pkg-config during
  120. configuration. The package will be checked using the conf.check_cfg
  121. function and the uselib_store and atleast_version will be passed to
  122. check_cfg. If uselib_store is None it defaults to PACKAGE (uppercase of
  123. the package argument) with hyphens and dots replaced with underscores.
  124. If atleast_version is None it defaults to '0'.
  125. """
  126. if not uselib_store:
  127. uselib_store = package.upper().replace('-', '_').replace('.', '_')
  128. if not atleast_version:
  129. atleast_version = '0'
  130. self.packages.append([package, uselib_store, atleast_version])
  131. def add_program(self, program, var=None):
  132. """
  133. Add a required program that should be checked during configuration. If
  134. var is not given it defaults to PROGRAM (the uppercase of the program
  135. argument). If the option is enabled the program is saved in
  136. conf.env.PROGRAM.
  137. """
  138. if not var:
  139. var = program.upper().replace('-', '_')
  140. self.programs.append([program, var])
  141. def set_check_hook(self, check_hook, check_hook_error):
  142. """
  143. Set the check hook and the corresponding error printing function to the
  144. configure step. The check_hook argument is a function that should return
  145. True if the extra prerequisites were found and False if not. The
  146. check_hook_error argument is an error printing function that should
  147. print an error message telling the user that --foo was explicitly
  148. requested but cannot be built since the extra prerequisites were not
  149. found. Both function should take a single argument that is the waf
  150. configuration context.
  151. """
  152. self.check_hook = check_hook
  153. self.check_hook_error = check_hook_error
  154. def _check(self, conf):
  155. """
  156. This is an internal function that runs all necessary configure checks.
  157. It checks all dependencies (even if some dependency was not found) so
  158. that the user can install all missing dependencies in one go, instead
  159. of playing the infamous hit-configure-hit-configure game.
  160. This function returns True if all dependencies were found and False if
  161. not.
  162. """
  163. all_found = True
  164. # check for libraries
  165. for lib,uselib_store in self.libs:
  166. try:
  167. conf.check_cc(lib=lib, uselib_store=uselib_store)
  168. except conf.errors.ConfigurationError:
  169. all_found = False
  170. self.libs_not_found.append(lib)
  171. # check for headers
  172. for header in self.headers:
  173. try:
  174. conf.check_cc(header_name=header)
  175. except conf.errors.ConfigurationError:
  176. all_found = False
  177. self.headers_not_found.append(header)
  178. # check for packages
  179. for package,uselib_store,atleast_version in self.packages:
  180. try:
  181. conf.check_cfg(package=package, uselib_store=uselib_store, atleast_version=atleast_version, args='--cflags --libs')
  182. except conf.errors.ConfigurationError:
  183. all_found = False
  184. self.packages_not_found.append([package,atleast_version])
  185. # check for programs
  186. for program,var in self.programs:
  187. try:
  188. conf.find_program(program, var=var)
  189. except conf.errors.ConfigurationError:
  190. all_found = False
  191. self.programs_not_found.append(program)
  192. # call hook (if specified)
  193. if self.check_hook:
  194. self.check_hook_found = self.check_hook(conf)
  195. if not self.check_hook_found:
  196. all_found = False
  197. return all_found
  198. def _configure_error(self, conf):
  199. """
  200. This is an internal function that prints errors for each missing
  201. dependency. The error messages tell the user that this option required
  202. some dependency, but it cannot be found.
  203. """
  204. for lib in self.libs_not_found:
  205. print_error('%s requires the %s library, but it cannot be found.' % (self.option, lib))
  206. for header in self.headers_not_found:
  207. print_error('%s requires the %s header, but it cannot be found.' % (self.option, header))
  208. for package,atleast_version in self.packages_not_found:
  209. string = package
  210. if atleast_version:
  211. string += ' >= ' + atleast_version
  212. print_error('%s requires the package %s, but it cannot be found.' % (self.option, string))
  213. for program in self.programs_not_found:
  214. print_error('%s requires the %s program, but it cannot be found.' % (self.option, program))
  215. if not self.check_hook_found:
  216. self.check_hook_error(conf)
  217. def configure(self, conf):
  218. """
  219. This function configures the option examining the argument given too
  220. --foo (where foo is this option). This function sets self.result to the
  221. result of the configuration; True if the option should be enabled or
  222. False if not. If not all dependencies were found self.result will shall
  223. be False. conf.env['NAME'] will be set to the same value aswell as a
  224. preprocessor symbol will be defined according to the result.
  225. If --foo[=yes] was given, but some dependency was not found an error
  226. message is printed (foreach missing dependency).
  227. This function returns True on success and False on error.
  228. """
  229. argument = getattr(Options.options, self.dest)
  230. if argument == 'no':
  231. self.result = False
  232. retvalue = True
  233. elif argument == 'yes':
  234. if self._check(conf):
  235. self.result = True
  236. retvalue = True
  237. else:
  238. self.result = False
  239. retvalue = False
  240. self._configure_error(conf)
  241. elif argument == 'auto':
  242. self.result = self._check(conf)
  243. retvalue = True
  244. else:
  245. print_error('Invalid argument "' + argument + '" to ' + self.option)
  246. self.result = False
  247. retvalue = False
  248. conf.env[self.conf_dest] = self.result
  249. if self.result:
  250. conf.define(self.define, 1)
  251. else:
  252. conf.define(self.define, 0)
  253. return retvalue
  254. def display_message(self):
  255. """
  256. This function displays a result message with the help text and the
  257. result of the configuration.
  258. """
  259. display_feature(self.help, self.result)
  260. # This function adds an option to the list of auto options and returns the newly
  261. # created option.
  262. def add_auto_option(opt, name, help, conf_dest=None, define=None):
  263. option = AutoOption(opt, name, help, conf_dest=conf_dest, define=define)
  264. auto_options.append(option)
  265. return option
  266. # This function applies a hack that for each auto option --foo=no|yes replaces
  267. # any occurence --foo in argv with --foo=yes, in effect interpreting --foo as
  268. # --foo=yes. The function has to be called before waf issues the option parser,
  269. # i.e. before the configure phase.
  270. def auto_options_argv_hack():
  271. for option in auto_options:
  272. for x in range(1, len(sys.argv)):
  273. if sys.argv[x] == option.option:
  274. sys.argv[x] += '=yes'
  275. # This function configures all auto options. It stops waf and prints an error
  276. # message if there were unsatisfied requirements.
  277. def configure_auto_options(conf):
  278. ok = True
  279. for option in auto_options:
  280. if not option.configure(conf):
  281. ok = False
  282. if not ok:
  283. conf.fatal('There were unsatisfied requirements.')
  284. # This function displays all options and the configuration results.
  285. def display_auto_options_messages():
  286. for option in auto_options:
  287. option.display_message()
  288. def check_for_celt(conf):
  289. found = False
  290. for version in ['11', '8', '7', '5']:
  291. define = 'HAVE_CELT_API_0_' + version
  292. if not found:
  293. try:
  294. conf.check_cfg(package='celt', atleast_version='0.' + version + '.0', args='--cflags --libs')
  295. found = True
  296. conf.define(define, 1)
  297. continue
  298. except conf.errors.ConfigurationError:
  299. pass
  300. conf.define(define, 0)
  301. return found
  302. def check_for_celt_error(conf):
  303. print_error('--celt requires the package celt, but it could not be found.')
  304. # The readline/readline.h header does not work if stdio.h is not included
  305. # before. Thus a fragment with both stdio.h and readline/readline.h need to be
  306. # test-compiled to find out whether readline is available.
  307. def check_for_readline(conf):
  308. try:
  309. conf.check_cc(fragment='''
  310. #include <stdio.h>
  311. #include <readline/readline.h>
  312. int main(void) { return 0; }''',
  313. execute=False,
  314. msg='Checking for header readline/readline.h')
  315. return True
  316. except conf.errors.ConfigurationError:
  317. return False
  318. def check_for_readline_error(conf):
  319. print_error('--readline requires the readline/readline.h header, but it cannot be found.')
  320. def check_for_mmsystem(conf):
  321. try:
  322. conf.check_cc(fragment='''
  323. #include <windows.h>
  324. #include <mmsystem.h>
  325. int main(void) { return 0; }''',
  326. execute=False,
  327. msg='Checking for header mmsystem.h')
  328. return True
  329. except conf.errors.ConfigurationError:
  330. return False
  331. def check_for_mmsystem_error(conf):
  332. print_error('--winmme requires the mmsystem.h header, but it cannot be found.')
  333. def options(opt):
  334. # options provided by the modules
  335. opt.tool_options('compiler_cxx')
  336. opt.tool_options('compiler_cc')
  337. # install directories
  338. opt.add_option('--htmldir', type='string', default=None, help="HTML documentation directory [Default: <prefix>/share/jack-audio-connection-kit/reference/html/")
  339. opt.add_option('--libdir', type='string', help="Library directory [Default: <prefix>/lib]")
  340. opt.add_option('--libdir32', type='string', help="32bit Library directory [Default: <prefix>/lib32]")
  341. opt.add_option('--mandir', type='string', help="Manpage directory [Default: <prefix>/share/man/man1]")
  342. # options affecting binaries
  343. opt.add_option('--dist-target', type='string', default='auto', help='Specify the target for cross-compiling [auto,mingw]')
  344. opt.add_option('--mixed', action='store_true', default=False, help='Build with 32/64 bits mixed mode')
  345. opt.add_option('--debug', action='store_true', default=False, dest='debug', help='Build debuggable binaries')
  346. # options affecting general jack functionality
  347. opt.add_option('--classic', action='store_true', default=False, help='Force enable standard JACK (jackd) even if D-Bus JACK (jackdbus) is enabled too')
  348. opt.add_option('--dbus', action='store_true', default=False, help='Enable D-Bus JACK (jackdbus)')
  349. opt.add_option('--autostart', type='string', default="default", help='Autostart method. Possible values: "default", "classic", "dbus", "none"')
  350. opt.add_option('--profile', action='store_true', default=False, help='Build with engine profiling')
  351. opt.add_option('--clients', default=64, type="int", dest="clients", help='Maximum number of JACK clients')
  352. opt.add_option('--ports-per-application', default=768, type="int", dest="application_ports", help='Maximum number of ports per application')
  353. # options with third party dependencies
  354. doxygen = add_auto_option(opt, 'doxygen', help='Build doxygen documentation', conf_dest='BUILD_DOXYGEN_DOCS')
  355. doxygen.add_program('doxygen')
  356. alsa = add_auto_option(opt, 'alsa', help='Enable ALSA driver', conf_dest='BUILD_DRIVER_ALSA')
  357. alsa.add_package('alsa', atleast_version='1.0.18')
  358. firewire = add_auto_option(opt, 'firewire', help='Enable FireWire driver (FFADO)', conf_dest='BUILD_DRIVER_FFADO')
  359. firewire.add_package('libffado', atleast_version='1.999.17')
  360. freebob = add_auto_option(opt, 'freebob', help='Enable FreeBob driver')
  361. freebob.add_package('libfreebob', atleast_version='1.0.0')
  362. iio = add_auto_option(opt, 'iio', help='Enable IIO driver', conf_dest='BUILD_DRIVER_IIO')
  363. iio.add_package('gtkIOStream', atleast_version='1.4.0')
  364. iio.add_package('eigen3', atleast_version='3.1.2')
  365. portaudio = add_auto_option(opt, 'portaudio', help='Enable Portaudio driver', conf_dest='BUILD_DRIVER_PORTAUDIO')
  366. portaudio.add_header('windows.h') # only build portaudio on windows
  367. portaudio.add_package('portaudio-2.0', uselib_store='PORTAUDIO', atleast_version='19')
  368. winmme = add_auto_option(opt, 'winmme', help='Enable WinMME driver', conf_dest='BUILD_DRIVER_WINMME')
  369. winmme.set_check_hook(check_for_mmsystem, check_for_mmsystem_error)
  370. celt = add_auto_option(opt, 'celt', help='Build with CELT')
  371. celt.set_check_hook(check_for_celt, check_for_celt_error)
  372. opus = add_auto_option(opt, 'opus', help='Build Opus netjack2')
  373. opus.add_header('opus/opus_custom.h')
  374. opus.add_package('opus', atleast_version='0.9.0')
  375. samplerate = add_auto_option(opt, 'samplerate', help='Build with libsamplerate')
  376. samplerate.add_package('samplerate')
  377. sndfile = add_auto_option(opt, 'sndfile', help='Build with libsndfile')
  378. sndfile.add_package('sndfile')
  379. readline = add_auto_option(opt, 'readline', help='Build with readline')
  380. readline.add_library('readline')
  381. readline.set_check_hook(check_for_readline, check_for_readline_error)
  382. # dbus options
  383. opt.sub_options('dbus')
  384. # this must be called before the configure phase
  385. auto_options_argv_hack()
  386. def configure(conf):
  387. conf.load('compiler_cxx')
  388. conf.load('compiler_cc')
  389. if Options.options.dist_target == 'auto':
  390. platform = sys.platform
  391. conf.env['IS_MACOSX'] = platform == 'darwin'
  392. conf.env['IS_LINUX'] = platform == 'linux' or platform == 'linux2' or platform == 'linux3' or platform == 'posix'
  393. conf.env['IS_SUN'] = platform == 'sunos'
  394. # GNU/kFreeBSD and GNU/Hurd are treated as Linux
  395. if platform.startswith('gnu0') or platform.startswith('gnukfreebsd'):
  396. conf.env['IS_LINUX'] = True
  397. elif Options.options.dist_target == 'mingw':
  398. conf.env['IS_WINDOWS'] = True
  399. if conf.env['IS_LINUX']:
  400. Logs.pprint('CYAN', "Linux detected")
  401. if conf.env['IS_MACOSX']:
  402. Logs.pprint('CYAN', "MacOS X detected")
  403. if conf.env['IS_SUN']:
  404. Logs.pprint('CYAN', "SunOS detected")
  405. if conf.env['IS_WINDOWS']:
  406. Logs.pprint('CYAN', "Windows detected")
  407. if conf.env['IS_LINUX']:
  408. conf.check_tool('compiler_cxx')
  409. conf.check_tool('compiler_cc')
  410. if conf.env['IS_MACOSX']:
  411. conf.check_tool('compiler_cxx')
  412. conf.check_tool('compiler_cc')
  413. # waf 1.5 : check_tool('compiler_cxx') and check_tool('compiler_cc') do not work correctly, so explicit use of gcc and g++
  414. if conf.env['IS_SUN']:
  415. conf.check_tool('g++')
  416. conf.check_tool('gcc')
  417. #if conf.env['IS_SUN']:
  418. # conf.check_tool('compiler_cxx')
  419. # conf.check_tool('compiler_cc')
  420. if conf.env['IS_WINDOWS']:
  421. conf.check_tool('compiler_cxx')
  422. conf.check_tool('compiler_cc')
  423. conf.env.append_unique('CCDEFINES', '_POSIX')
  424. conf.env.append_unique('CXXDEFINES', '_POSIX')
  425. conf.env.append_unique('CXXFLAGS', '-Wall')
  426. conf.env.append_unique('CFLAGS', '-Wall')
  427. # configure all auto options
  428. configure_auto_options(conf)
  429. conf.sub_config('common')
  430. if conf.env['IS_LINUX']:
  431. conf.sub_config('linux')
  432. if Options.options.dbus:
  433. conf.sub_config('dbus')
  434. if conf.env['BUILD_JACKDBUS'] != True:
  435. conf.fatal('jackdbus was explicitly requested but cannot be built')
  436. conf.sub_config('example-clients')
  437. conf.env['LIB_PTHREAD'] = ['pthread']
  438. conf.env['LIB_DL'] = ['dl']
  439. conf.env['LIB_RT'] = ['rt']
  440. conf.env['LIB_M'] = ['m']
  441. conf.env['LIB_STDC++'] = ['stdc++']
  442. conf.env['JACK_API_VERSION'] = JACK_API_VERSION
  443. conf.env['JACK_VERSION'] = VERSION
  444. conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
  445. conf.env['BUILD_WITH_32_64'] = Options.options.mixed
  446. conf.env['BUILD_CLASSIC'] = Options.options.classic
  447. conf.env['BUILD_DEBUG'] = Options.options.debug
  448. if conf.env['BUILD_JACKDBUS']:
  449. conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
  450. else:
  451. conf.env['BUILD_JACKD'] = True
  452. conf.env['BINDIR'] = conf.env['PREFIX'] + '/bin'
  453. if Options.options.htmldir:
  454. conf.env['HTMLDIR'] = Options.options.htmldir
  455. else:
  456. # set to None here so that the doxygen code can find out the highest
  457. # directory to remove upon install
  458. conf.env['HTMLDIR'] = None
  459. if Options.options.libdir:
  460. conf.env['LIBDIR'] = Options.options.libdir
  461. else:
  462. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
  463. if Options.options.mandir:
  464. conf.env['MANDIR'] = Options.options.mandir
  465. else:
  466. conf.env['MANDIR'] = conf.env['PREFIX'] + '/share/man/man1'
  467. if conf.env['BUILD_DEBUG']:
  468. conf.env.append_unique('CXXFLAGS', '-g')
  469. conf.env.append_unique('CFLAGS', '-g')
  470. conf.env.append_unique('LINKFLAGS', '-g')
  471. if not Options.options.autostart in ["default", "classic", "dbus", "none"]:
  472. conf.fatal("Invalid autostart value \"" + Options.options.autostart + "\"")
  473. if Options.options.autostart == "default":
  474. if conf.env['BUILD_JACKDBUS'] == True and conf.env['BUILD_JACKD'] == False:
  475. conf.env['AUTOSTART_METHOD'] = "dbus"
  476. else:
  477. conf.env['AUTOSTART_METHOD'] = "classic"
  478. else:
  479. conf.env['AUTOSTART_METHOD'] = Options.options.autostart
  480. if conf.env['AUTOSTART_METHOD'] == "dbus" and not conf.env['BUILD_JACKDBUS']:
  481. conf.fatal("D-Bus autostart mode was specified but jackdbus will not be built")
  482. if conf.env['AUTOSTART_METHOD'] == "classic" and not conf.env['BUILD_JACKD']:
  483. conf.fatal("Classic autostart mode was specified but jackd will not be built")
  484. if conf.env['AUTOSTART_METHOD'] == "dbus":
  485. conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
  486. elif conf.env['AUTOSTART_METHOD'] == "classic":
  487. conf.define('USE_CLASSIC_AUTOLAUNCH', 1)
  488. conf.define('CLIENT_NUM', Options.options.clients)
  489. conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
  490. if conf.env['IS_WINDOWS']:
  491. # we define this in the environment to maintain compatability with
  492. # existing install paths that use ADDON_DIR rather than have to
  493. # have special cases for windows each time.
  494. conf.env['ADDON_DIR'] = conf.env['BINDIR'] + '/jack'
  495. # don't define ADDON_DIR in config.h, use the default 'jack' defined in
  496. # windows/JackPlatformPlug_os.h
  497. else:
  498. conf.env['ADDON_DIR'] = os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack'))
  499. conf.define('ADDON_DIR', conf.env['ADDON_DIR'])
  500. conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
  501. if not conf.env['IS_WINDOWS']:
  502. conf.define('USE_POSIX_SHM', 1)
  503. conf.define('JACKMP', 1)
  504. if conf.env['BUILD_JACKDBUS'] == True:
  505. conf.define('JACK_DBUS', 1)
  506. if conf.env['BUILD_WITH_PROFILE'] == True:
  507. conf.define('JACK_MONITOR', 1)
  508. conf.write_config_header('config.h', remove=False)
  509. svnrev = None
  510. try:
  511. f = open('svnversion.h')
  512. data = f.read()
  513. m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
  514. if m != None:
  515. svnrev = m.group(1)
  516. f.close()
  517. except IOError:
  518. pass
  519. if Options.options.mixed == True:
  520. conf.setenv(lib32, env=conf.env.derive())
  521. conf.env.append_unique('CXXFLAGS', '-m32')
  522. conf.env.append_unique('CFLAGS', '-m32')
  523. conf.env.append_unique('LINKFLAGS', '-m32')
  524. if Options.options.libdir32:
  525. conf.env['LIBDIR'] = Options.options.libdir32
  526. else:
  527. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
  528. conf.write_config_header('config.h')
  529. print()
  530. display_msg("==================")
  531. version_msg = "JACK " + VERSION
  532. if svnrev:
  533. version_msg += " exported from r" + svnrev
  534. else:
  535. version_msg += " svn revision will checked and eventually updated during build"
  536. print(version_msg)
  537. print("Build with a maximum of %d JACK clients" % Options.options.clients)
  538. print("Build with a maximum of %d ports per application" % Options.options.application_ports)
  539. display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
  540. display_msg("Library directory", conf.all_envs[""]['LIBDIR'], 'CYAN')
  541. if conf.env['BUILD_WITH_32_64'] == True:
  542. display_msg("32-bit library directory", conf.all_envs[lib32]['LIBDIR'], 'CYAN')
  543. display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
  544. display_feature('Build debuggable binaries', conf.env['BUILD_DEBUG'])
  545. display_msg('C compiler flags', repr(conf.all_envs[""]['CFLAGS']))
  546. display_msg('C++ compiler flags', repr(conf.all_envs[""]['CXXFLAGS']))
  547. display_msg('Linker flags', repr(conf.all_envs[""]['LINKFLAGS']))
  548. if conf.env['BUILD_WITH_32_64'] == True:
  549. display_msg('32-bit C compiler flags', repr(conf.all_envs[lib32]['CFLAGS']))
  550. display_msg('32-bit C++ compiler flags', repr(conf.all_envs[lib32]['CXXFLAGS']))
  551. display_msg('32-bit linker flags', repr(conf.all_envs[lib32]['LINKFLAGS']))
  552. display_feature('Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
  553. display_feature('Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
  554. display_feature('Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
  555. display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
  556. display_msg('Autostart method', conf.env['AUTOSTART_METHOD'])
  557. if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
  558. print(Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs.colors.NORMAL)
  559. print(Logs.colors.RED + 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs.colors.NORMAL)
  560. # display configuration result messages for auto options
  561. display_auto_options_messages()
  562. if conf.env['BUILD_JACKDBUS'] == True:
  563. display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
  564. #display_msg('Settings persistence', xxx)
  565. if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
  566. print()
  567. print(Logs.colors.RED + "WARNING: D-Bus session services directory as reported by pkg-config is")
  568. print(Logs.colors.RED + "WARNING:", end=' ')
  569. print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL'])
  570. print(Logs.colors.RED + 'WARNING: but service file will be installed in')
  571. print(Logs.colors.RED + "WARNING:", end=' ')
  572. print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR'])
  573. print(Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus')
  574. print('WARNING: You can override dbus service install directory')
  575. print('WARNING: with --enable-pkg-config-dbus-service-dir option to this script')
  576. print(Logs.colors.NORMAL, end=' ')
  577. print()
  578. def init(ctx):
  579. for y in (BuildContext, CleanContext, InstallContext, UninstallContext):
  580. name = y.__name__.replace('Context','').lower()
  581. class tmp(y):
  582. cmd = name + '_' + lib32
  583. variant = lib32
  584. def build(bld):
  585. if not bld.variant:
  586. out2 = out
  587. else:
  588. out2 = out + "/" + bld.variant
  589. print("make[1]: Entering directory `" + os.getcwd() + "/" + out2 + "'")
  590. if not bld.variant:
  591. if bld.env['BUILD_WITH_32_64'] == True:
  592. Options.commands.append(bld.cmd + '_' + lib32)
  593. # process subfolders from here
  594. bld.add_subdirs('common')
  595. if bld.variant:
  596. # only the wscript in common/ knows how to handle variants
  597. return
  598. if not os.access('svnversion.h', os.R_OK):
  599. def post_run(self):
  600. sg = Utils.h_file(self.outputs[0].abspath(self.env))
  601. #print sg.encode('hex')
  602. Build.bld.node_sigs[self.env.variant()][self.outputs[0].id] = sg
  603. script = bld.path.find_resource('svnversion_regenerate.sh')
  604. script = script.abspath()
  605. bld(
  606. rule = '%s ${TGT}' % script,
  607. name = 'svnversion',
  608. runnable_status = Task.RUN_ME,
  609. before = 'c cxx',
  610. color = 'BLUE',
  611. post_run = post_run,
  612. source = ['svnversion_regenerate.sh'],
  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')