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.

220 lines
8.5KB

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