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.

785 lines
32KB

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