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.

795 lines
33KB

  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. # check for libraries
  162. for lib,uselib_store in self.libs:
  163. try:
  164. conf.check_cc(lib=lib, uselib_store=uselib_store)
  165. except conf.errors.ConfigurationError:
  166. all_found = False
  167. self.libs_not_found.append(lib)
  168. # check for headers
  169. for header in self.headers:
  170. try:
  171. conf.check_cc(header_name=header)
  172. except conf.errors.ConfigurationError:
  173. all_found = False
  174. self.headers_not_found.append(header)
  175. # check for packages
  176. for package,uselib_store,atleast_version in self.packages:
  177. try:
  178. conf.check_cfg(package=package, uselib_store=uselib_store, atleast_version=atleast_version, args='--cflags --libs')
  179. except conf.errors.ConfigurationError:
  180. all_found = False
  181. self.packages_not_found.append([package,atleast_version])
  182. # check for programs
  183. for program,var in self.programs:
  184. try:
  185. conf.find_program(program, var=var)
  186. except conf.errors.ConfigurationError:
  187. all_found = False
  188. self.programs_not_found.append(program)
  189. # call hook (if specified)
  190. if self.check_hook:
  191. self.check_hook_found = self.check_hook(conf)
  192. if not self.check_hook_found:
  193. all_found = False
  194. return all_found
  195. def _configure_error(self, conf):
  196. """
  197. This is an internal function that prints errors for each missing
  198. dependency. The error messages tell the user that this option required
  199. some dependency, but it cannot be found.
  200. """
  201. for lib in self.libs_not_found:
  202. print_error('%s requires the %s library, but it cannot be found.' % (self.option, lib))
  203. for header in self.headers_not_found:
  204. print_error('%s requires the %s header, but it cannot be found.' % (self.option, header))
  205. for package,atleast_version in self.packages_not_found:
  206. string = package
  207. if atleast_version:
  208. string += ' >= ' + atleast_version
  209. print_error('%s requires the package %s, but it cannot be found.' % (self.option, string))
  210. for program in self.programs_not_found:
  211. print_error('%s requires the %s program, but it cannot be found.' % (self.option, program))
  212. if not self.check_hook_found:
  213. self.check_hook_error(conf)
  214. def configure(self, conf):
  215. """
  216. This function configures the option examining the argument given too
  217. --foo (where foo is this option). This function sets self.result to the
  218. result of the configuration; True if the option should be enabled or
  219. False if not. If not all dependencies were found self.result will shall
  220. be False. conf.env['NAME'] will be set to the same value aswell as a
  221. preprocessor symbol will be defined according to the result.
  222. If --foo[=yes] was given, but some dependency was not found an error
  223. message is printed (foreach missing dependency).
  224. This function returns True on success and False on error.
  225. """
  226. argument = getattr(Options.options, self.dest)
  227. if argument == 'no':
  228. self.result = False
  229. retvalue = True
  230. elif argument == 'yes':
  231. if self._check(conf):
  232. self.result = True
  233. retvalue = True
  234. else:
  235. self.result = False
  236. retvalue = False
  237. self._configure_error(conf)
  238. elif argument == 'auto':
  239. self.result = self._check(conf)
  240. retvalue = True
  241. else:
  242. print_error('Invalid argument "' + argument + '" to ' + self.option)
  243. self.result = False
  244. retvalue = False
  245. conf.env[self.conf_dest] = self.result
  246. if self.result:
  247. conf.define(self.define, 1)
  248. else:
  249. conf.define(self.define, 0)
  250. return retvalue
  251. def display_message(self):
  252. """
  253. This function displays a result message with the help text and the
  254. result of the configuration.
  255. """
  256. display_feature(self.help, self.result)
  257. # This function adds an option to the list of auto options and returns the newly
  258. # created option.
  259. def add_auto_option(opt, name, help, conf_dest=None, define=None):
  260. option = AutoOption(opt, name, help, conf_dest=conf_dest, define=define)
  261. auto_options.append(option)
  262. return option
  263. # This function applies a hack that for each auto option --foo=no|yes replaces
  264. # any occurence --foo in argv with --foo=yes, in effect interpreting --foo as
  265. # --foo=yes. The function has to be called before waf issues the option parser,
  266. # i.e. before the configure phase.
  267. def auto_options_argv_hack():
  268. for option in auto_options:
  269. for x in range(1, len(sys.argv)):
  270. if sys.argv[x] == option.option:
  271. sys.argv[x] += '=yes'
  272. # This function configures all auto options. It stops waf and prints an error
  273. # message if there were unsatisfied requirements.
  274. def configure_auto_options(conf):
  275. ok = True
  276. for option in auto_options:
  277. if not option.configure(conf):
  278. ok = False
  279. if not ok:
  280. conf.fatal('There were unsatisfied requirements.')
  281. # This function displays all options and the configuration results.
  282. def display_auto_options_messages():
  283. for option in auto_options:
  284. option.display_message()
  285. def check_for_celt(conf):
  286. found = False
  287. for version in ['11', '8', '7', '5']:
  288. define = 'HAVE_CELT_API_0_' + version
  289. if not found:
  290. try:
  291. conf.check_cfg(package='celt', atleast_version='0.' + version + '.0', args='--cflags --libs')
  292. found = True
  293. conf.define(define, 1)
  294. continue
  295. except conf.errors.ConfigurationError:
  296. pass
  297. conf.define(define, 0)
  298. return found
  299. def check_for_celt_error(conf):
  300. print_error('--celt requires the package celt, but it could not be found.')
  301. # The readline/readline.h header does not work if stdio.h is not included
  302. # before. Thus a fragment with both stdio.h and readline/readline.h need to be
  303. # test-compiled to find out whether readline is available.
  304. def check_for_readline(conf):
  305. try:
  306. conf.check_cc(fragment='''
  307. #include <stdio.h>
  308. #include <readline/readline.h>
  309. int main(void) { return 0; }''',
  310. execute=False,
  311. msg='Checking for header readline/readline.h')
  312. return True
  313. except conf.errors.ConfigurationError:
  314. return False
  315. def check_for_readline_error(conf):
  316. print_error('--readline requires the readline/readline.h header, but it cannot be found.')
  317. def check_for_mmsystem(conf):
  318. try:
  319. conf.check_cc(fragment='''
  320. #include <windows.h>
  321. #include <mmsystem.h>
  322. int main(void) { return 0; }''',
  323. execute=False,
  324. msg='Checking for header mmsystem.h')
  325. return True
  326. except conf.errors.ConfigurationError:
  327. return False
  328. def check_for_mmsystem_error(conf):
  329. print_error('--winmme requires the mmsystem.h header, but it cannot be found.')
  330. def options(opt):
  331. # options provided by the modules
  332. opt.load('compiler_cxx')
  333. opt.load('compiler_c')
  334. # install directories
  335. opt.add_option('--htmldir', type='string', default=None, help="HTML documentation directory [Default: <prefix>/share/jack-audio-connection-kit/reference/html/")
  336. opt.add_option('--libdir', type='string', help="Library directory [Default: <prefix>/lib]")
  337. opt.add_option('--libdir32', type='string', help="32bit Library directory [Default: <prefix>/lib32]")
  338. opt.add_option('--mandir', type='string', help="Manpage directory [Default: <prefix>/share/man/man1]")
  339. # options affecting binaries
  340. opt.add_option('--dist-target', type='string', default='auto', help='Specify the target for cross-compiling [auto,mingw]')
  341. opt.add_option('--mixed', action='store_true', default=False, help='Build with 32/64 bits mixed mode')
  342. opt.add_option('--debug', action='store_true', default=False, dest='debug', help='Build debuggable binaries')
  343. # options affecting general jack functionality
  344. opt.add_option('--classic', action='store_true', default=False, help='Force enable standard JACK (jackd) even if D-Bus JACK (jackdbus) is enabled too')
  345. opt.add_option('--dbus', action='store_true', default=False, help='Enable D-Bus JACK (jackdbus)')
  346. opt.add_option('--autostart', type='string', default="default", help='Autostart method. Possible values: "default", "classic", "dbus", "none"')
  347. opt.add_option('--profile', action='store_true', default=False, help='Build with engine profiling')
  348. opt.add_option('--clients', default=64, type="int", dest="clients", help='Maximum number of JACK clients')
  349. opt.add_option('--ports-per-application', default=768, type="int", dest="application_ports", help='Maximum number of ports per application')
  350. # options with third party dependencies
  351. doxygen = add_auto_option(opt, 'doxygen', help='Build doxygen documentation', conf_dest='BUILD_DOXYGEN_DOCS')
  352. doxygen.add_program('doxygen')
  353. alsa = add_auto_option(opt, 'alsa', help='Enable ALSA driver', conf_dest='BUILD_DRIVER_ALSA')
  354. alsa.add_package('alsa', atleast_version='1.0.18')
  355. firewire = add_auto_option(opt, 'firewire', help='Enable FireWire driver (FFADO)', conf_dest='BUILD_DRIVER_FFADO')
  356. firewire.add_package('libffado', atleast_version='1.999.17')
  357. freebob = add_auto_option(opt, 'freebob', help='Enable FreeBob driver')
  358. freebob.add_package('libfreebob', atleast_version='1.0.0')
  359. iio = add_auto_option(opt, 'iio', help='Enable IIO driver', conf_dest='BUILD_DRIVER_IIO')
  360. iio.add_package('gtkIOStream', atleast_version='1.4.0')
  361. iio.add_package('eigen3', atleast_version='3.1.2')
  362. portaudio = add_auto_option(opt, 'portaudio', help='Enable Portaudio driver', conf_dest='BUILD_DRIVER_PORTAUDIO')
  363. portaudio.add_header('windows.h') # only build portaudio on windows
  364. portaudio.add_package('portaudio-2.0', uselib_store='PORTAUDIO', atleast_version='19')
  365. winmme = add_auto_option(opt, 'winmme', help='Enable WinMME driver', conf_dest='BUILD_DRIVER_WINMME')
  366. winmme.set_check_hook(check_for_mmsystem, check_for_mmsystem_error)
  367. celt = add_auto_option(opt, 'celt', help='Build with CELT')
  368. celt.set_check_hook(check_for_celt, check_for_celt_error)
  369. opus = add_auto_option(opt, 'opus', help='Build Opus netjack2')
  370. opus.add_header('opus/opus_custom.h')
  371. opus.add_package('opus', atleast_version='0.9.0')
  372. samplerate = add_auto_option(opt, 'samplerate', help='Build with libsamplerate')
  373. samplerate.add_package('samplerate')
  374. sndfile = add_auto_option(opt, 'sndfile', help='Build with libsndfile')
  375. sndfile.add_package('sndfile')
  376. readline = add_auto_option(opt, 'readline', help='Build with readline')
  377. readline.add_library('readline')
  378. readline.set_check_hook(check_for_readline, check_for_readline_error)
  379. # dbus options
  380. opt.recurse('dbus')
  381. # this must be called before the configure phase
  382. auto_options_argv_hack()
  383. def configure(conf):
  384. conf.load('compiler_cxx')
  385. conf.load('compiler_c')
  386. if Options.options.dist_target == 'auto':
  387. platform = sys.platform
  388. conf.env['IS_MACOSX'] = platform == 'darwin'
  389. conf.env['IS_LINUX'] = platform == 'linux' or platform == 'linux2' or platform == 'linux3' or platform == 'posix'
  390. conf.env['IS_SUN'] = platform == 'sunos'
  391. # GNU/kFreeBSD and GNU/Hurd are treated as Linux
  392. if platform.startswith('gnu0') or platform.startswith('gnukfreebsd'):
  393. conf.env['IS_LINUX'] = True
  394. elif Options.options.dist_target == 'mingw':
  395. conf.env['IS_WINDOWS'] = True
  396. if conf.env['IS_LINUX']:
  397. Logs.pprint('CYAN', "Linux detected")
  398. if conf.env['IS_MACOSX']:
  399. Logs.pprint('CYAN', "MacOS X detected")
  400. if conf.env['IS_SUN']:
  401. Logs.pprint('CYAN', "SunOS detected")
  402. if conf.env['IS_WINDOWS']:
  403. Logs.pprint('CYAN', "Windows detected")
  404. if conf.env['IS_WINDOWS']:
  405. conf.env.append_unique('CCDEFINES', '_POSIX')
  406. conf.env.append_unique('CXXDEFINES', '_POSIX')
  407. conf.env.append_unique('CXXFLAGS', '-Wall')
  408. conf.env.append_unique('CFLAGS', '-Wall')
  409. # configure all auto options
  410. configure_auto_options(conf)
  411. conf.recurse('common')
  412. if conf.env['IS_LINUX']:
  413. conf.recurse('linux')
  414. if Options.options.dbus:
  415. conf.recurse('dbus')
  416. if conf.env['BUILD_JACKDBUS'] != True:
  417. conf.fatal('jackdbus was explicitly requested but cannot be built')
  418. conf.recurse('example-clients')
  419. conf.env['LIB_PTHREAD'] = ['pthread']
  420. conf.env['LIB_DL'] = ['dl']
  421. conf.env['LIB_RT'] = ['rt']
  422. conf.env['LIB_M'] = ['m']
  423. conf.env['LIB_STDC++'] = ['stdc++']
  424. conf.env['JACK_API_VERSION'] = JACK_API_VERSION
  425. conf.env['JACK_VERSION'] = VERSION
  426. conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
  427. conf.env['BUILD_WITH_32_64'] = Options.options.mixed
  428. conf.env['BUILD_CLASSIC'] = Options.options.classic
  429. conf.env['BUILD_DEBUG'] = Options.options.debug
  430. if conf.env['BUILD_JACKDBUS']:
  431. conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
  432. else:
  433. conf.env['BUILD_JACKD'] = True
  434. conf.env['BINDIR'] = conf.env['PREFIX'] + '/bin'
  435. if Options.options.htmldir:
  436. conf.env['HTMLDIR'] = Options.options.htmldir
  437. else:
  438. # set to None here so that the doxygen code can find out the highest
  439. # directory to remove upon install
  440. conf.env['HTMLDIR'] = None
  441. if Options.options.libdir:
  442. conf.env['LIBDIR'] = Options.options.libdir
  443. else:
  444. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
  445. if Options.options.mandir:
  446. conf.env['MANDIR'] = Options.options.mandir
  447. else:
  448. conf.env['MANDIR'] = conf.env['PREFIX'] + '/share/man/man1'
  449. if conf.env['BUILD_DEBUG']:
  450. conf.env.append_unique('CXXFLAGS', '-g')
  451. conf.env.append_unique('CFLAGS', '-g')
  452. conf.env.append_unique('LINKFLAGS', '-g')
  453. if not Options.options.autostart in ["default", "classic", "dbus", "none"]:
  454. conf.fatal("Invalid autostart value \"" + Options.options.autostart + "\"")
  455. if Options.options.autostart == "default":
  456. if conf.env['BUILD_JACKDBUS'] == True and conf.env['BUILD_JACKD'] == False:
  457. conf.env['AUTOSTART_METHOD'] = "dbus"
  458. else:
  459. conf.env['AUTOSTART_METHOD'] = "classic"
  460. else:
  461. conf.env['AUTOSTART_METHOD'] = Options.options.autostart
  462. if conf.env['AUTOSTART_METHOD'] == "dbus" and not conf.env['BUILD_JACKDBUS']:
  463. conf.fatal("D-Bus autostart mode was specified but jackdbus will not be built")
  464. if conf.env['AUTOSTART_METHOD'] == "classic" and not conf.env['BUILD_JACKD']:
  465. conf.fatal("Classic autostart mode was specified but jackd will not be built")
  466. if conf.env['AUTOSTART_METHOD'] == "dbus":
  467. conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
  468. elif conf.env['AUTOSTART_METHOD'] == "classic":
  469. conf.define('USE_CLASSIC_AUTOLAUNCH', 1)
  470. conf.define('CLIENT_NUM', Options.options.clients)
  471. conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
  472. if conf.env['IS_WINDOWS']:
  473. # we define this in the environment to maintain compatability with
  474. # existing install paths that use ADDON_DIR rather than have to
  475. # have special cases for windows each time.
  476. conf.env['ADDON_DIR'] = conf.env['BINDIR'] + '/jack'
  477. # don't define ADDON_DIR in config.h, use the default 'jack' defined in
  478. # windows/JackPlatformPlug_os.h
  479. else:
  480. conf.env['ADDON_DIR'] = os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack'))
  481. conf.define('ADDON_DIR', conf.env['ADDON_DIR'])
  482. conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
  483. if not conf.env['IS_WINDOWS']:
  484. conf.define('USE_POSIX_SHM', 1)
  485. conf.define('JACKMP', 1)
  486. if conf.env['BUILD_JACKDBUS'] == True:
  487. conf.define('JACK_DBUS', 1)
  488. if conf.env['BUILD_WITH_PROFILE'] == True:
  489. conf.define('JACK_MONITOR', 1)
  490. conf.write_config_header('config.h', remove=False)
  491. svnrev = None
  492. try:
  493. f = open('svnversion.h')
  494. data = f.read()
  495. m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
  496. if m != None:
  497. svnrev = m.group(1)
  498. f.close()
  499. except IOError:
  500. pass
  501. if Options.options.mixed == True:
  502. conf.setenv(lib32, env=conf.env.derive())
  503. conf.env.append_unique('CXXFLAGS', '-m32')
  504. conf.env.append_unique('CFLAGS', '-m32')
  505. conf.env.append_unique('LINKFLAGS', '-m32')
  506. if Options.options.libdir32:
  507. conf.env['LIBDIR'] = Options.options.libdir32
  508. else:
  509. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
  510. conf.write_config_header('config.h')
  511. print()
  512. display_msg("==================")
  513. version_msg = "JACK " + VERSION
  514. if svnrev:
  515. version_msg += " exported from r" + svnrev
  516. else:
  517. version_msg += " svn revision will checked and eventually updated during build"
  518. print(version_msg)
  519. print("Build with a maximum of %d JACK clients" % Options.options.clients)
  520. print("Build with a maximum of %d ports per application" % Options.options.application_ports)
  521. display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
  522. display_msg("Library directory", conf.all_envs[""]['LIBDIR'], 'CYAN')
  523. if conf.env['BUILD_WITH_32_64'] == True:
  524. display_msg("32-bit library directory", conf.all_envs[lib32]['LIBDIR'], 'CYAN')
  525. display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
  526. display_feature('Build debuggable binaries', conf.env['BUILD_DEBUG'])
  527. display_msg('C compiler flags', repr(conf.all_envs[""]['CFLAGS']))
  528. display_msg('C++ compiler flags', repr(conf.all_envs[""]['CXXFLAGS']))
  529. display_msg('Linker flags', repr(conf.all_envs[""]['LINKFLAGS']))
  530. if conf.env['BUILD_WITH_32_64'] == True:
  531. display_msg('32-bit C compiler flags', repr(conf.all_envs[lib32]['CFLAGS']))
  532. display_msg('32-bit C++ compiler flags', repr(conf.all_envs[lib32]['CXXFLAGS']))
  533. display_msg('32-bit linker flags', repr(conf.all_envs[lib32]['LINKFLAGS']))
  534. display_feature('Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
  535. display_feature('Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
  536. display_feature('Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
  537. display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
  538. display_msg('Autostart method', conf.env['AUTOSTART_METHOD'])
  539. if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
  540. print(Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs.colors.NORMAL)
  541. print(Logs.colors.RED + 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs.colors.NORMAL)
  542. # display configuration result messages for auto options
  543. display_auto_options_messages()
  544. if conf.env['BUILD_JACKDBUS'] == True:
  545. display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
  546. #display_msg('Settings persistence', xxx)
  547. if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
  548. print()
  549. print(Logs.colors.RED + "WARNING: D-Bus session services directory as reported by pkg-config is")
  550. print(Logs.colors.RED + "WARNING:", end=' ')
  551. print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL'])
  552. print(Logs.colors.RED + 'WARNING: but service file will be installed in')
  553. print(Logs.colors.RED + "WARNING:", end=' ')
  554. print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR'])
  555. print(Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus')
  556. print('WARNING: You can override dbus service install directory')
  557. print('WARNING: with --enable-pkg-config-dbus-service-dir option to this script')
  558. print(Logs.colors.NORMAL, end=' ')
  559. print()
  560. def init(ctx):
  561. for y in (BuildContext, CleanContext, InstallContext, UninstallContext):
  562. name = y.__name__.replace('Context','').lower()
  563. class tmp(y):
  564. cmd = name + '_' + lib32
  565. variant = lib32
  566. def build(bld):
  567. if not bld.variant:
  568. out2 = out
  569. else:
  570. out2 = out + "/" + bld.variant
  571. print("make[1]: Entering directory `" + os.getcwd() + "/" + out2 + "'")
  572. if not bld.variant:
  573. if bld.env['BUILD_WITH_32_64'] == True:
  574. Options.commands.append(bld.cmd + '_' + lib32)
  575. # process subfolders from here
  576. bld.recurse('common')
  577. if bld.variant:
  578. # only the wscript in common/ knows how to handle variants
  579. return
  580. if not os.access('svnversion.h', os.R_OK):
  581. def post_run(self):
  582. sg = Utils.h_file(self.outputs[0].abspath(self.env))
  583. #print sg.encode('hex')
  584. Build.bld.node_sigs[self.env.variant()][self.outputs[0].id] = sg
  585. script = bld.path.find_resource('svnversion_regenerate.sh')
  586. script = script.abspath()
  587. bld(
  588. rule = '%s ${TGT}' % script,
  589. name = 'svnversion',
  590. runnable_status = Task.RUN_ME,
  591. before = 'c cxx',
  592. color = 'BLUE',
  593. post_run = post_run,
  594. source = ['svnversion_regenerate.sh'],
  595. target = [bld.path.find_or_declare('svnversion.h')]
  596. )
  597. if bld.env['IS_LINUX']:
  598. bld.recurse('linux')
  599. bld.recurse('example-clients')
  600. bld.recurse('tests')
  601. bld.recurse('man')
  602. if bld.env['BUILD_JACKDBUS'] == True:
  603. bld.recurse('dbus')
  604. if bld.env['IS_MACOSX']:
  605. bld.recurse('macosx')
  606. bld.recurse('example-clients')
  607. bld.recurse('tests')
  608. if bld.env['BUILD_JACKDBUS'] == True:
  609. bld.recurse('dbus')
  610. if bld.env['IS_SUN']:
  611. bld.recurse('solaris')
  612. bld.recurse('example-clients')
  613. bld.recurse('tests')
  614. if bld.env['BUILD_JACKDBUS'] == True:
  615. bld.recurse('dbus')
  616. if bld.env['IS_WINDOWS']:
  617. bld.recurse('windows')
  618. bld.recurse('example-clients')
  619. #bld.recurse('tests')
  620. if bld.env['BUILD_DOXYGEN_DOCS'] == True:
  621. html_build_dir = bld.path.find_or_declare('html').abspath()
  622. bld(
  623. features = 'subst',
  624. source = 'doxyfile.in',
  625. target = 'doxyfile',
  626. HTML_BUILD_DIR = html_build_dir,
  627. SRCDIR = bld.srcnode.abspath(),
  628. VERSION = VERSION
  629. )
  630. # There are two reasons for logging to doxygen.log and using it as
  631. # target in the build rule (rather than html_build_dir):
  632. # (1) reduce the noise when running the build
  633. # (2) waf has a regular file to check for a timestamp. If the directory
  634. # is used instead waf will rebuild the doxygen target (even upon
  635. # install).
  636. def doxygen(task):
  637. doxyfile = task.inputs[0].abspath()
  638. logfile = task.outputs[0].abspath()
  639. cmd = '%s %s &> %s' % (task.env['DOXYGEN'][0], doxyfile, logfile)
  640. return task.exec_command(cmd)
  641. bld(
  642. rule = doxygen,
  643. source = 'doxyfile',
  644. target = 'doxygen.log'
  645. )
  646. # Determine where to install HTML documentation. Since share_dir is the
  647. # highest directory the uninstall routine should remove, there is no
  648. # better candidate for share_dir, but the requested HTML directory if
  649. # --htmldir is given.
  650. if bld.env['HTMLDIR']:
  651. html_install_dir = bld.options.destdir + bld.env['HTMLDIR']
  652. share_dir = html_install_dir
  653. else:
  654. share_dir = bld.options.destdir + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
  655. html_install_dir = share_dir + '/reference/html/'
  656. if bld.cmd == 'install':
  657. if os.path.isdir(html_install_dir):
  658. Logs.pprint('CYAN', "Removing old doxygen documentation installation...")
  659. shutil.rmtree(html_install_dir)
  660. Logs.pprint('CYAN', "Removing old doxygen documentation installation done.")
  661. Logs.pprint('CYAN', "Installing doxygen documentation...")
  662. shutil.copytree(html_build_dir, html_install_dir)
  663. Logs.pprint('CYAN', "Installing doxygen documentation done.")
  664. elif bld.cmd =='uninstall':
  665. Logs.pprint('CYAN', "Uninstalling doxygen documentation...")
  666. if os.path.isdir(share_dir):
  667. shutil.rmtree(share_dir)
  668. Logs.pprint('CYAN', "Uninstalling doxygen documentation done.")
  669. elif bld.cmd =='clean':
  670. if os.access(html_build_dir, os.R_OK):
  671. Logs.pprint('CYAN', "Removing doxygen generated documentation...")
  672. shutil.rmtree(html_build_dir)
  673. Logs.pprint('CYAN', "Removing doxygen generated documentation done.")
  674. def dist(ctx):
  675. # This code blindly assumes it is working in the toplevel source directory.
  676. if not os.path.exists('svnversion.h'):
  677. os.system('./svnversion_regenerate.sh svnversion.h')