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.

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