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.

304 lines
12KB

  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.4'
  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('--dbus', action='store_true', default=False, help='Enable D-Bus JACK (jackdbus)')
  54. opt.add_option('--classic', action='store_true', default=False, help='Force enable standard JACK (jackd) even if D-Bus JACK (jackdbus) is enabled too')
  55. opt.add_option('--doxygen', action='store_true', default=False, help='Enable build of doxygen documentation')
  56. opt.add_option('--profile', action='store_true', default=False, help='Build with engine profiling')
  57. opt.add_option('--mixed', action='store_true', default=False, help='Build with 32/64 bits mixed mode')
  58. opt.add_option('--clients', default=64, type="int", dest="clients", help='Maximum number of JACK clients')
  59. opt.add_option('--ports-per-application', default=768, type="int", dest="application_ports", help='Maximum number of ports per application')
  60. opt.add_option('--debug', action='store_true', default=False, dest='debug', help="Build debuggable binaries")
  61. opt.sub_options('dbus')
  62. def configure(conf):
  63. platform = Utils.detect_platform()
  64. conf.env['IS_MACOSX'] = platform == 'darwin'
  65. conf.env['IS_LINUX'] = platform == 'linux'
  66. conf.env['IS_SUN'] = platform == 'sunos'
  67. if conf.env['IS_LINUX']:
  68. Utils.pprint('CYAN', "Linux detected")
  69. if conf.env['IS_MACOSX']:
  70. Utils.pprint('CYAN', "MacOS X detected")
  71. if conf.env['IS_SUN']:
  72. Utils.pprint('CYAN', "SunOS detected")
  73. if conf.env['IS_LINUX']:
  74. conf.check_tool('compiler_cxx')
  75. conf.check_tool('compiler_cc')
  76. if conf.env['IS_MACOSX']:
  77. conf.check_tool('compiler_cxx')
  78. conf.check_tool('compiler_cc')
  79. # waf 1.5 : check_tool('compiler_cxx') and check_tool('compiler_cc') do not work correctly, so explicit use of gcc and g++
  80. if conf.env['IS_SUN']:
  81. conf.check_tool('g++')
  82. conf.check_tool('gcc')
  83. #if conf.env['IS_SUN']:
  84. # conf.check_tool('compiler_cxx')
  85. # conf.check_tool('compiler_cc')
  86. conf.env.append_unique('CXXFLAGS', '-O3 -Wall')
  87. conf.env.append_unique('CCFLAGS', '-O3 -Wall')
  88. conf.sub_config('common')
  89. if conf.env['IS_LINUX']:
  90. conf.sub_config('linux')
  91. if Options.options.dbus:
  92. conf.sub_config('dbus')
  93. conf.sub_config('example-clients')
  94. if conf.check_cfg(package='celt', atleast_version='0.7.0', args='--cflags --libs'):
  95. conf.define('HAVE_CELT', 1)
  96. conf.define('HAVE_CELT_API_0_7', 1)
  97. conf.define('HAVE_CELT_API_0_5', 0)
  98. elif conf.check_cfg(package='celt', atleast_version='0.5.0', args='--cflags --libs', required=True):
  99. conf.define('HAVE_CELT', 1)
  100. conf.define('HAVE_CELT_API_0_5', 1)
  101. conf.define('HAVE_CELT_API_0_7', 0)
  102. else:
  103. conf.define('HAVE_CELT', 0)
  104. conf.define('HAVE_CELT_API_0_5', 0)
  105. conf.define('HAVE_CELT_API_0_7', 0)
  106. conf.env['LIB_PTHREAD'] = ['pthread']
  107. conf.env['LIB_DL'] = ['dl']
  108. conf.env['LIB_RT'] = ['rt']
  109. conf.env['JACK_API_VERSION'] = JACK_API_VERSION
  110. conf.env['JACK_VERSION'] = VERSION
  111. conf.env['BUILD_DOXYGEN_DOCS'] = Options.options.doxygen
  112. conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
  113. conf.env['BUILD_WITH_32_64'] = Options.options.mixed
  114. conf.env['BUILD_JACKDBUS'] = Options.options.dbus
  115. conf.env['BUILD_CLASSIC'] = Options.options.classic
  116. conf.env['BUILD_DEBUG'] = Options.options.debug
  117. if conf.env['BUILD_JACKDBUS']:
  118. conf.env['BUILD_JACKD'] = conf.env['BUILD_CLASSIC']
  119. else:
  120. conf.env['BUILD_JACKD'] = True
  121. if Options.options.libdir:
  122. conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir
  123. else:
  124. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib'
  125. if conf.env['BUILD_DEBUG']:
  126. conf.env.append_unique('CXXFLAGS', '-g')
  127. conf.env.append_unique('CCFLAGS', '-g')
  128. conf.env.append_unique('LINKFLAGS', '-g')
  129. conf.define('CLIENT_NUM', Options.options.clients)
  130. conf.define('PORT_NUM_FOR_CLIENT', Options.options.application_ports)
  131. conf.define('ADDON_DIR', os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack')))
  132. conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
  133. conf.define('USE_POSIX_SHM', 1)
  134. conf.define('JACKMP', 1)
  135. if conf.env['BUILD_JACKDBUS'] == True:
  136. conf.define('JACK_DBUS', 1)
  137. if conf.env['BUILD_JACKD'] == False:
  138. conf.define('USE_LIBDBUS_AUTOLAUNCH', 1)
  139. if conf.env['BUILD_WITH_PROFILE'] == True:
  140. conf.define('JACK_MONITOR', 1)
  141. if conf.env['BUILD_WITH_32_64'] == True:
  142. conf.define('JACK_32_64', 1)
  143. conf.write_config_header('config.h')
  144. svnrev = None
  145. if os.access('svnversion.h', os.R_OK):
  146. data = file('svnversion.h').read()
  147. m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
  148. if m != None:
  149. svnrev = m.group(1)
  150. print
  151. display_msg("==================")
  152. version_msg = "JACK " + VERSION
  153. if svnrev:
  154. version_msg += " exported from r" + svnrev
  155. else:
  156. version_msg += " svn revision will checked and eventually updated during build"
  157. print version_msg
  158. print "Build with a maximum of %d JACK clients" % conf.env['CLIENT_NUM']
  159. print "Build with a maximum of %d ports per application" % conf.env['PORT_NUM_FOR_CLIENT']
  160. display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
  161. display_msg("Library directory", conf.env['LIBDIR'], 'CYAN')
  162. display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
  163. display_feature('Build debuggable binaries', conf.env['BUILD_DEBUG'])
  164. display_feature('Build doxygen documentation', conf.env['BUILD_DOXYGEN_DOCS'])
  165. display_feature('Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
  166. display_feature('Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
  167. display_feature('Build standard JACK (jackd)', conf.env['BUILD_JACKD'])
  168. display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'])
  169. if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
  170. print Logs.colors.RED + 'WARNING !! mixing both jackd and jackdbus may cause issues!' + Logs.colors.NORMAL
  171. if conf.env['IS_LINUX']:
  172. display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True)
  173. display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True)
  174. display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True)
  175. if conf.env['BUILD_JACKDBUS'] == True:
  176. display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
  177. #display_msg('Settings persistence', xxx)
  178. if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
  179. print
  180. print Logs.colors.RED + "WARNING: D-Bus session services directory as reported by pkg-config is"
  181. print Logs.colors.RED + "WARNING:",
  182. print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL']
  183. print Logs.colors.RED + 'WARNING: but service file will be installed in'
  184. print Logs.colors.RED + "WARNING:",
  185. print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR']
  186. print Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
  187. print 'WARNING: You can override dbus service install directory'
  188. print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
  189. print Logs.colors.NORMAL,
  190. print
  191. if Options.options.mixed == True:
  192. env_variant2 = conf.env.copy()
  193. conf.set_env_name('lib32', env_variant2)
  194. env_variant2.set_variant('lib32')
  195. conf.setenv('lib32')
  196. conf.env.append_unique('CXXFLAGS', '-m32')
  197. conf.env.append_unique('CCFLAGS', '-m32')
  198. conf.env.append_unique('LINKFLAGS', '-m32')
  199. if Options.options.libdir32:
  200. conf.env['LIBDIR'] = conf.env['PREFIX'] + Options.options.libdir32
  201. else:
  202. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib32'
  203. conf.write_config_header('config.h')
  204. def build(bld):
  205. print ("make[1]: Entering directory `" + os.getcwd() + "/" + blddir + "'" )
  206. if not os.access('svnversion.h', os.R_OK):
  207. create_svnversion_task(bld)
  208. # process subfolders from here
  209. bld.add_subdirs('common')
  210. if bld.env['IS_LINUX']:
  211. bld.add_subdirs('linux')
  212. bld.add_subdirs('example-clients')
  213. bld.add_subdirs('tests')
  214. if bld.env['BUILD_JACKDBUS'] == True:
  215. bld.add_subdirs('dbus')
  216. if bld.env['IS_MACOSX']:
  217. bld.add_subdirs('macosx')
  218. bld.add_subdirs('example-clients')
  219. bld.add_subdirs('tests')
  220. if bld.env['BUILD_JACKDBUS'] == True:
  221. bld.add_subdirs('dbus')
  222. if bld.env['IS_SUN']:
  223. bld.add_subdirs('solaris')
  224. bld.add_subdirs('example-clients')
  225. bld.add_subdirs('tests')
  226. if bld.env['BUILD_JACKDBUS'] == True:
  227. bld.add_subdirs('dbus')
  228. if bld.env['BUILD_DOXYGEN_DOCS'] == True:
  229. share_dir = bld.env.get_destdir() + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
  230. html_docs_source_dir = "build/default/html"
  231. html_docs_install_dir = share_dir + '/reference/html/'
  232. if Options.commands['install']:
  233. if os.path.isdir(html_docs_install_dir):
  234. Utils.pprint('CYAN', "Removing old doxygen documentation installation...")
  235. shutil.rmtree(html_docs_install_dir)
  236. Utils.pprint('CYAN', "Removing old doxygen documentation installation done.")
  237. Utils.pprint('CYAN', "Installing doxygen documentation...")
  238. shutil.copytree(html_docs_source_dir, html_docs_install_dir)
  239. Utils.pprint('CYAN', "Installing doxygen documentation done.")
  240. elif Options.commands['uninstall']:
  241. Utils.pprint('CYAN', "Uninstalling doxygen documentation...")
  242. if os.path.isdir(share_dir):
  243. shutil.rmtree(share_dir)
  244. Utils.pprint('CYAN', "Uninstalling doxygen documentation done.")
  245. elif Options.commands['clean']:
  246. if os.access(html_docs_source_dir, os.R_OK):
  247. Utils.pprint('CYAN', "Removing doxygen generated documentation...")
  248. shutil.rmtree(html_docs_source_dir)
  249. Utils.pprint('CYAN', "Removing doxygen generated documentation done.")
  250. elif Options.commands['build']:
  251. if not os.access(html_docs_source_dir, os.R_OK):
  252. os.popen("doxygen").read()
  253. else:
  254. Utils.pprint('CYAN', "doxygen documentation already built.")
  255. def dist_hook():
  256. os.remove('svnversion_regenerate.sh')
  257. os.system('../svnversion_regenerate.sh svnversion.h')