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.

355 lines
15KB

  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. VERSION='1.9.9'
  15. APPNAME='jack'
  16. JACK_API_VERSION = '0.1.0'
  17. # these variables are mandatory ('/' are converted automatically)
  18. top = '.'
  19. out = 'build'
  20. def display_msg(msg, status = None, color = None):
  21. sr = msg
  22. global g_maxlen
  23. g_maxlen = max(g_maxlen, len(msg))
  24. if status:
  25. Logs.pprint('NORMAL', "%s :" % msg.ljust(g_maxlen), sep=' ')
  26. Logs.pprint(color, status)
  27. else:
  28. print("%s" % msg.ljust(g_maxlen))
  29. def display_feature(msg, build):
  30. if build:
  31. display_msg(msg, "yes", 'GREEN')
  32. else:
  33. display_msg(msg, "no", 'YELLOW')
  34. def create_svnversion_task(bld, header='svnversion.h', define=None):
  35. cmd = '../svnversion_regenerate.sh ${TGT}'
  36. if define:
  37. cmd += " " + define
  38. def post_run(self):
  39. sg = Utils.h_file(self.outputs[0].abspath(self.env))
  40. #print sg.encode('hex')
  41. Build.bld.node_sigs[self.env.variant()][self.outputs[0].id] = sg
  42. bld(
  43. rule = cmd,
  44. name = 'svnversion',
  45. runnable_status = Task.RUN_ME,
  46. before = 'c',
  47. color = 'BLUE',
  48. post_run = post_run,
  49. target = [bld.path.find_or_declare(header)]
  50. )
  51. def options(opt):
  52. # options provided by the modules
  53. opt.tool_options('compiler_cxx')
  54. opt.tool_options('compiler_cc')
  55. opt.add_option('--libdir', type='string', help="Library directory [Default: <prefix>/lib]")
  56. opt.add_option('--libdir32', type='string', help="32bit Library directory [Default: <prefix>/lib32]")
  57. opt.add_option('--mandir', type='string', help="Manpage directory [Default: <prefix>/share/man/man1]")
  58. opt.add_option('--dbus', action='store_true', default=False, help='Enable D-Bus JACK (jackdbus)')
  59. opt.add_option('--classic', action='store_true', default=False, help='Force enable standard JACK (jackd) even if D-Bus JACK (jackdbus) is enabled too')
  60. opt.add_option('--doxygen', action='store_true', default=False, help='Enable build of doxygen documentation')
  61. opt.add_option('--profile', action='store_true', default=False, help='Build with engine profiling')
  62. opt.add_option('--mixed', action='store_true', default=False, help='Build with 32/64 bits mixed mode')
  63. opt.add_option('--clients', default=64, type="int", dest="clients", help='Maximum number of JACK clients')
  64. opt.add_option('--ports-per-application', default=768, type="int", dest="application_ports", help='Maximum number of ports per application')
  65. opt.add_option('--debug', action='store_true', default=False, dest='debug', help='Build debuggable binaries')
  66. opt.add_option('--firewire', action='store_true', default=False, help='Enable FireWire driver (FFADO)')
  67. opt.add_option('--freebob', action='store_true', default=False, help='Enable FreeBob driver')
  68. opt.add_option('--alsa', action='store_true', default=False, help='Enable ALSA driver')
  69. opt.sub_options('dbus')
  70. def configure(conf):
  71. platform = sys.platform
  72. conf.env['IS_MACOSX'] = platform == 'darwin'
  73. conf.env['IS_LINUX'] = platform == 'linux' or platform == 'linux2' or platform == 'posix'
  74. conf.env['IS_SUN'] = platform == 'sunos'
  75. if conf.env['IS_LINUX']:
  76. Logs.pprint('CYAN', "Linux detected")
  77. if conf.env['IS_MACOSX']:
  78. Logs.pprint('CYAN', "MacOS X detected")
  79. if conf.env['IS_SUN']:
  80. Logs.pprint('CYAN', "SunOS detected")
  81. if conf.env['IS_LINUX']:
  82. conf.check_tool('compiler_cxx')
  83. conf.check_tool('compiler_cc')
  84. if conf.env['IS_MACOSX']:
  85. conf.check_tool('compiler_cxx')
  86. conf.check_tool('compiler_cc')
  87. # waf 1.5 : check_tool('compiler_cxx') and check_tool('compiler_cc') do not work correctly, so explicit use of gcc and g++
  88. if conf.env['IS_SUN']:
  89. conf.check_tool('g++')
  90. conf.check_tool('gcc')
  91. #if conf.env['IS_SUN']:
  92. # conf.check_tool('compiler_cxx')
  93. # conf.check_tool('compiler_cc')
  94. conf.env.append_unique('CXXFLAGS', '-Wall')
  95. conf.env.append_unique('CCFLAGS', '-Wall')
  96. conf.sub_config('common')
  97. if conf.env['IS_LINUX']:
  98. conf.sub_config('linux')
  99. if Options.options.alsa and not conf.env['BUILD_DRIVER_ALSA']:
  100. conf.fatal('ALSA driver was explicitly requested but cannot be built')
  101. if Options.options.freebob and not conf.env['BUILD_DRIVER_FREEBOB']:
  102. conf.fatal('FreeBob driver was explicitly requested but cannot be built')
  103. if Options.options.firewire and not conf.env['BUILD_DRIVER_FFADO']:
  104. conf.fatal('FFADO driver was explicitly requested but cannot be built')
  105. conf.env['BUILD_DRIVER_ALSA'] = Options.options.alsa
  106. conf.env['BUILD_DRIVER_FFADO'] = Options.options.firewire
  107. conf.env['BUILD_DRIVER_FREEBOB'] = Options.options.freebob
  108. if Options.options.dbus:
  109. conf.sub_config('dbus')
  110. if conf.env['BUILD_JACKDBUS'] != True:
  111. conf.fatal('jackdbus was explicitly requested but cannot be built')
  112. conf.check_cc(header_name='samplerate.h', define_name="HAVE_SAMPLERATE")
  113. if conf.is_defined('HAVE_SAMPLERATE'):
  114. conf.env['LIB_SAMPLERATE'] = ['samplerate']
  115. conf.sub_config('example-clients')
  116. if conf.check_cfg(package='celt', atleast_version='0.11.0', args='--cflags --libs', mandatory=False):
  117. conf.define('HAVE_CELT', 1)
  118. conf.define('HAVE_CELT_API_0_11', 1)
  119. conf.define('HAVE_CELT_API_0_8', 0)
  120. conf.define('HAVE_CELT_API_0_7', 0)
  121. conf.define('HAVE_CELT_API_0_5', 0)
  122. elif conf.check_cfg(package='celt', atleast_version='0.8.0', args='--cflags --libs', mandatory=False):
  123. conf.define('HAVE_CELT', 1)
  124. conf.define('HAVE_CELT_API_0_11', 0)
  125. conf.define('HAVE_CELT_API_0_8', 1)
  126. conf.define('HAVE_CELT_API_0_7', 0)
  127. conf.define('HAVE_CELT_API_0_5', 0)
  128. elif conf.check_cfg(package='celt', atleast_version='0.7.0', args='--cflags --libs', mandatory=False):
  129. conf.define('HAVE_CELT', 1)
  130. conf.define('HAVE_CELT_API_0_11', 0)
  131. conf.define('HAVE_CELT_API_0_8', 0)
  132. conf.define('HAVE_CELT_API_0_7', 1)
  133. conf.define('HAVE_CELT_API_0_5', 0)
  134. elif conf.check_cfg(package='celt', atleast_version='0.5.0', args='--cflags --libs', mandatory=False):
  135. conf.define('HAVE_CELT', 1)
  136. conf.define('HAVE_CELT_API_0_11', 0)
  137. conf.define('HAVE_CELT_API_0_8', 0)
  138. conf.define('HAVE_CELT_API_0_7', 0)
  139. conf.define('HAVE_CELT_API_0_5', 1)
  140. else:
  141. conf.define('HAVE_CELT', 0)
  142. conf.define('HAVE_CELT_API_0_11', 0)
  143. conf.define('HAVE_CELT_API_0_8', 0)
  144. conf.define('HAVE_CELT_API_0_7', 0)
  145. conf.define('HAVE_CELT_API_0_5', 0)
  146. conf.env['LIB_PTHREAD'] = ['pthread']
  147. conf.env['LIB_DL'] = ['dl']
  148. conf.env['LIB_RT'] = ['rt']
  149. conf.env['JACK_API_VERSION'] = JACK_API_VERSION
  150. conf.env['JACK_VERSION'] = VERSION
  151. conf.env['BUILD_DOXYGEN_DOCS'] = Options.options.doxygen
  152. conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
  153. conf.env['BUILD_WITH_32_64'] = Options.options.mixed
  154. conf.env['BUILD_CLASSIC'] = Options.options.classic
  155. conf.env['BUILD_DEBUG'] = Options.options.debug
  156. if conf.env['BUILD_JACKDBUS']:
  157. conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
  158. else:
  159. conf.env['BUILD_JACKD'] = True
  160. if Options.options.libdir:
  161. conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir
  162. else:
  163. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
  164. if Options.options.mandir:
  165. conf.env['MANDIR'] = conf.env['PREFIX'] + Options.options.mandir
  166. else:
  167. conf.env['MANDIR'] = conf.env['PREFIX'] + '/share/man/man1'
  168. if conf.env['BUILD_DEBUG']:
  169. conf.env.append_unique('CXXFLAGS', '-g')
  170. conf.env.append_unique('CCFLAGS', '-g')
  171. conf.env.append_unique('LINKFLAGS', '-g')
  172. conf.define('CLIENT_NUM', Options.options.clients)
  173. conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
  174. conf.env['ADDON_DIR'] = os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack'))
  175. conf.define('ADDON_DIR', conf.env['ADDON_DIR'])
  176. conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
  177. conf.define('USE_POSIX_SHM', 1)
  178. conf.define('JACKMP', 1)
  179. if conf.env['BUILD_JACKDBUS'] == True:
  180. conf.define('JACK_DBUS', 1)
  181. if conf.env['BUILD_JACKD'] == False:
  182. conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
  183. if conf.env['BUILD_WITH_PROFILE'] == True:
  184. conf.define('JACK_MONITOR', 1)
  185. conf.write_config_header('config.h')
  186. svnrev = None
  187. if os.access('svnversion.h', os.R_OK):
  188. data = file('svnversion.h').read()
  189. m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
  190. if m != None:
  191. svnrev = m.group(1)
  192. conf.env.append_unique('LINKFLAGS', ['-lm', '-lstdc++'])
  193. if Options.options.mixed == True:
  194. env_variant2 = conf.env.copy()
  195. conf.set_env_name('lib32', env_variant2)
  196. env_variant2.set_variant('lib32')
  197. conf.setenv('lib32')
  198. conf.env.append_unique('CXXFLAGS', '-m32')
  199. conf.env.append_unique('CCFLAGS', '-m32')
  200. conf.env.append_unique('LINKFLAGS', '-m32')
  201. if Options.options.libdir32:
  202. conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir32
  203. else:
  204. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
  205. conf.write_config_header('config.h')
  206. print()
  207. display_msg("==================")
  208. version_msg = "JACK " + VERSION
  209. if svnrev:
  210. version_msg += " exported from r" + svnrev
  211. else:
  212. version_msg += " svn revision will checked and eventually updated during build"
  213. print(version_msg)
  214. print("Build with a maximum of %d JACK clients" % Options.options.clients)
  215. print("Build with a maximum of %d ports per application" % Options.options.application_ports)
  216. display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
  217. display_msg("Library directory", conf.env['LIBDIR'], 'CYAN')
  218. display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
  219. display_feature('Build debuggable binaries', conf.env['BUILD_DEBUG'])
  220. display_msg('C compiler flags', repr(conf.env['CCFLAGS']))
  221. display_msg('C++ compiler flags', repr(conf.env['CXXFLAGS']))
  222. display_msg('Linker flags', repr(conf.env['LINKFLAGS']))
  223. display_feature('Build doxygen documentation', conf.env['BUILD_DOXYGEN_DOCS'])
  224. display_feature('Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
  225. display_feature('Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
  226. display_feature('Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
  227. display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
  228. if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
  229. print(Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues:' + Logs.colors.NORMAL)
  230. print(Logs.colors.RED + 'WARNING !! jackdbus does not use .jackdrc nor qjackctl settings' + Logs.colors.NORMAL)
  231. if conf.env['IS_LINUX']:
  232. display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True)
  233. display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True)
  234. display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True)
  235. if conf.env['BUILD_JACKDBUS'] == True:
  236. display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
  237. #display_msg('Settings persistence', xxx)
  238. if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
  239. print()
  240. print(Logs.colors.RED + "WARNING: D-Bus session services directory as reported by pkg-config is")
  241. print(Logs.colors.RED + "WARNING:", end=' ')
  242. print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL'])
  243. print(Logs.colors.RED + 'WARNING: but service file will be installed in')
  244. print(Logs.colors.RED + "WARNING:", end=' ')
  245. print(Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR'])
  246. print(Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus')
  247. print('WARNING: You can override dbus service install directory')
  248. print('WARNING: with --enable-pkg-config-dbus-service-dir option to this script')
  249. print(Logs.colors.NORMAL, end=' ')
  250. print()
  251. def build(bld):
  252. print("make[1]: Entering directory `" + os.getcwd() + "/" + out + "'")
  253. if not os.access('svnversion.h', os.R_OK):
  254. create_svnversion_task(bld)
  255. # process subfolders from here
  256. bld.add_subdirs('common')
  257. if bld.env['IS_LINUX']:
  258. bld.add_subdirs('linux')
  259. bld.add_subdirs('example-clients')
  260. bld.add_subdirs('tests')
  261. bld.add_subdirs('man')
  262. if bld.env['BUILD_JACKDBUS'] == True:
  263. bld.add_subdirs('dbus')
  264. if bld.env['IS_MACOSX']:
  265. bld.add_subdirs('macosx')
  266. bld.add_subdirs('example-clients')
  267. bld.add_subdirs('tests')
  268. if bld.env['BUILD_JACKDBUS'] == True:
  269. bld.add_subdirs('dbus')
  270. if bld.env['IS_SUN']:
  271. bld.add_subdirs('solaris')
  272. bld.add_subdirs('example-clients')
  273. bld.add_subdirs('tests')
  274. if bld.env['BUILD_JACKDBUS'] == True:
  275. bld.add_subdirs('dbus')
  276. if bld.env['BUILD_DOXYGEN_DOCS'] == True:
  277. share_dir = bld.env.get_destdir() + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
  278. html_docs_source_dir = "build/default/html"
  279. html_docs_install_dir = share_dir + '/reference/html/'
  280. if Options.commands['install']:
  281. if os.path.isdir(html_docs_install_dir):
  282. Logs.pprint('CYAN', "Removing old doxygen documentation installation...")
  283. shutil.rmtree(html_docs_install_dir)
  284. Logs.pprint('CYAN', "Removing old doxygen documentation installation done.")
  285. Logs.pprint('CYAN', "Installing doxygen documentation...")
  286. shutil.copytree(html_docs_source_dir, html_docs_install_dir)
  287. Logs.pprint('CYAN', "Installing doxygen documentation done.")
  288. elif Options.commands['uninstall']:
  289. Logs.pprint('CYAN', "Uninstalling doxygen documentation...")
  290. if os.path.isdir(share_dir):
  291. shutil.rmtree(share_dir)
  292. Logs.pprint('CYAN', "Uninstalling doxygen documentation done.")
  293. elif Options.commands['clean']:
  294. if os.access(html_docs_source_dir, os.R_OK):
  295. Logs.pprint('CYAN', "Removing doxygen generated documentation...")
  296. shutil.rmtree(html_docs_source_dir)
  297. Logs.pprint('CYAN', "Removing doxygen generated documentation done.")
  298. elif Options.commands['build']:
  299. if not os.access(html_docs_source_dir, os.R_OK):
  300. os.popen("doxygen").read()
  301. else:
  302. Logs.pprint('CYAN', "doxygen documentation already built.")
  303. def dist_hook():
  304. os.remove('svnversion_regenerate.sh')
  305. os.system('../svnversion_regenerate.sh svnversion.h')