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.

327 lines
14KB

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