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.

263 lines
10KB

  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.3'
  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('--classic', action='store_true', default=False, help='Enable standard JACK (jackd)')
  53. opt.add_option('--dbus', action='store_true', default=False, help='Enable D-Bus JACK (jackdbus)')
  54. opt.add_option('--doxygen', action='store_true', default=False, help='Enable build of doxygen documentation')
  55. opt.add_option('--profile', action='store_true', default=False, help='Build with engine profiling')
  56. opt.add_option('--mixed', action='store_true', default=False, help='Build with 32/64 bits mixed mode')
  57. opt.add_option('--clients', default=64, type="int", dest="clients", help='Maximum number of JACK clients')
  58. opt.add_option('--ports', default=1024, type="int", dest="ports", help='Maximum number of ports')
  59. opt.add_option('--clients', default=64, type="int", dest="clients", help='Maximum number of JACK clients')
  60. opt.add_option('--ports', default=1024, type="int", dest="ports", help='Maximum number of ports')
  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. conf.env['LIB_PTHREAD'] = ['pthread']
  95. conf.env['LIB_DL'] = ['dl']
  96. conf.env['LIB_RT'] = ['rt']
  97. conf.env['JACK_API_VERSION'] = JACK_API_VERSION
  98. conf.env['JACK_VERSION'] = VERSION
  99. conf.env['BUILD_DOXYGEN_DOCS'] = Options.options.doxygen
  100. conf.env['BUILD_WITH_PROFILE'] = Options.options.profile
  101. conf.env['BUILD_WITH_32_64'] = Options.options.mixed
  102. conf.env['BUILD_JACKDBUS'] = Options.options.dbus
  103. conf.env['BUILD_JACKD'] = Options.options.classic
  104. if Options.options.libdir:
  105. conf.env['LIBDIR'] = Options.options.libdir
  106. else:
  107. conf.env['LIBDIR'] = conf.env['PREFIX'] + '/lib/'
  108. conf.define('CLIENT_NUM', Options.options.clients)
  109. conf.define('PORT_NUM', Options.options. ports)
  110. conf.define('ADDON_DIR', os.path.normpath(os.path.join(conf.env['LIBDIR'], 'jack')))
  111. conf.define('JACK_LOCATION', os.path.normpath(os.path.join(conf.env['PREFIX'], 'bin')))
  112. conf.define('USE_POSIX_SHM', 1)
  113. conf.define('JACKMP', 1)
  114. if conf.env['BUILD_JACKDBUS'] == True:
  115. conf.define('JACK_DBUS', 1)
  116. if conf.env['BUILD_WITH_PROFILE'] == True:
  117. conf.define('JACK_MONITOR', 1)
  118. if conf.env['BUILD_WITH_32_64'] == True:
  119. conf.define('JACK_32_64', 1)
  120. conf.write_config_header('config.h')
  121. svnrev = None
  122. if os.access('svnversion.h', os.R_OK):
  123. data = file('svnversion.h').read()
  124. m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
  125. if m != None:
  126. svnrev = m.group(1)
  127. print
  128. display_msg("==================")
  129. version_msg = "JACK " + VERSION
  130. if svnrev:
  131. version_msg += " exported from r" + svnrev
  132. else:
  133. version_msg += " svn revision will checked and eventually updated during build"
  134. print version_msg
  135. print "Build with a maximum of %d JACK clients" % conf.env['CLIENT_NUM']
  136. print "Build with a maximum of %d ports" % conf.env['PORT_NUM']
  137. display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
  138. display_msg("Library directory", conf.env['LIBDIR'], 'CYAN')
  139. display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
  140. display_feature('Build doxygen documentation', conf.env['BUILD_DOXYGEN_DOCS'])
  141. display_feature('Build with engine profiling', conf.env['BUILD_WITH_PROFILE'])
  142. display_feature('Build with 32/64 bits mixed mode', conf.env['BUILD_WITH_32_64'])
  143. if conf.env['BUILD_JACKDBUS'] and conf.env['BUILD_JACKD']:
  144. display_feature('Build standard (jackd) and D-Bus JACK (jackdbus) : WARNING !! mixing both program may cause issues...', True)
  145. elif conf.env['BUILD_JACKDBUS']:
  146. display_feature('Build D-Bus JACK (jackdbus)', True)
  147. else:
  148. conf.env['BUILD_JACKD'] = True; # jackd is always built be default
  149. display_feature('Build standard JACK (jackd)', True)
  150. if conf.env['IS_LINUX']:
  151. display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True)
  152. display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True)
  153. display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True)
  154. if conf.env['BUILD_JACKDBUS'] == True:
  155. display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
  156. #display_msg('Settings persistence', xxx)
  157. if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS_SERVICES_DIR_REAL']:
  158. print
  159. print Logs.colors.RED + "WARNING: D-Bus session services directory as reported by pkg-config is"
  160. print Logs.colors.RED + "WARNING:",
  161. print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR_REAL']
  162. print Logs.colors.RED + 'WARNING: but service file will be installed in'
  163. print Logs.colors.RED + "WARNING:",
  164. print Logs.colors.CYAN + conf.env['DBUS_SERVICES_DIR']
  165. print Logs.colors.RED + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
  166. print 'WARNING: You can override dbus service install directory'
  167. print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
  168. print Logs.colors.NORMAL,
  169. print
  170. def build(bld):
  171. if not os.access('svnversion.h', os.R_OK):
  172. create_svnversion_task(bld)
  173. # process subfolders from here
  174. bld.add_subdirs('common')
  175. if bld.env['IS_LINUX']:
  176. bld.add_subdirs('linux')
  177. bld.add_subdirs('example-clients')
  178. bld.add_subdirs('tests')
  179. if bld.env['BUILD_JACKDBUS'] == True:
  180. bld.add_subdirs('dbus')
  181. if bld.env['IS_MACOSX']:
  182. bld.add_subdirs('macosx')
  183. bld.add_subdirs('example-clients')
  184. bld.add_subdirs('tests')
  185. if bld.env['BUILD_JACKDBUS'] == True:
  186. bld.add_subdirs('dbus')
  187. if bld.env['IS_SUN']:
  188. bld.add_subdirs('solaris')
  189. bld.add_subdirs('example-clients')
  190. bld.add_subdirs('tests')
  191. if bld.env['BUILD_JACKDBUS'] == True:
  192. bld.add_subdirs('dbus')
  193. if bld.env['BUILD_DOXYGEN_DOCS'] == True:
  194. share_dir = bld.env.get_destdir() + bld.env['PREFIX'] + '/share/jack-audio-connection-kit'
  195. html_docs_source_dir = "build/default/html"
  196. html_docs_install_dir = share_dir + '/reference/html/'
  197. if Options.commands['install']:
  198. if os.path.isdir(html_docs_install_dir):
  199. Utils.pprint('CYAN', "Removing old doxygen documentation installation...")
  200. shutil.rmtree(html_docs_install_dir)
  201. Utils.pprint('CYAN', "Removing old doxygen documentation installation done.")
  202. Utils.pprint('CYAN', "Installing doxygen documentation...")
  203. shutil.copytree(html_docs_source_dir, html_docs_install_dir)
  204. Utils.pprint('CYAN', "Installing doxygen documentation done.")
  205. elif Options.commands['uninstall']:
  206. Utils.pprint('CYAN', "Uninstalling doxygen documentation...")
  207. if os.path.isdir(share_dir):
  208. shutil.rmtree(share_dir)
  209. Utils.pprint('CYAN', "Uninstalling doxygen documentation done.")
  210. elif Options.commands['clean']:
  211. if os.access(html_docs_source_dir, os.R_OK):
  212. Utils.pprint('CYAN', "Removing doxygen generated documentation...")
  213. shutil.rmtree(html_docs_source_dir)
  214. Utils.pprint('CYAN', "Removing doxygen generated documentation done.")
  215. elif Options.commands['build']:
  216. if not os.access(html_docs_source_dir, os.R_OK):
  217. os.popen("doxygen").read()
  218. else:
  219. Utils.pprint('CYAN', "doxygen documentation already built.")
  220. def dist_hook():
  221. os.remove('svnversion_regenerate.sh')
  222. os.system('../svnversion_regenerate.sh svnversion.h')