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.

254 lines
9.9KB

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