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.

213 lines
8.3KB

  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. import os
  4. import Params
  5. import commands
  6. from Configure import g_maxlen
  7. #g_maxlen = 40
  8. import shutil
  9. import Task
  10. import re
  11. VERSION='1.9.0'
  12. APPNAME='jack'
  13. JACK_API_VERSION = '0.1.0'
  14. # these variables are mandatory ('/' are converted automatically)
  15. srcdir = '.'
  16. blddir = 'build'
  17. def display_msg(msg, status = None, color = None):
  18. sr = msg
  19. global g_maxlen
  20. g_maxlen = max(g_maxlen, len(msg))
  21. if status:
  22. print "%s :" % msg.ljust(g_maxlen),
  23. Params.pprint(color, status)
  24. else:
  25. print "%s" % msg.ljust(g_maxlen)
  26. def display_feature(msg, build):
  27. if build:
  28. display_msg(msg, "yes", 'GREEN')
  29. else:
  30. display_msg(msg, "no", 'YELLOW')
  31. def create_svnversion_gen(bld, header='svnversion.h', define=None):
  32. cmd = '../svnversion_regenerate.sh ${TGT}'
  33. if define:
  34. cmd += " " + define
  35. cls = Task.simple_task_type('svnversion', cmd, color='BLUE')
  36. cls.must_run = lambda self: True
  37. #cls.before = 'cxx'
  38. def sg(self):
  39. rt = Params.h_file(self.m_outputs[0].abspath(self.env()))
  40. return rt
  41. cls.signature = sg
  42. #def se(self):
  43. # r = sg(self)
  44. # return (r, r, r, r, r)
  45. #cls.cache_sig = property(sg, None)
  46. cls.cache_sig = None
  47. tsk = cls('svnversion', bld.env().copy())
  48. tsk.m_inputs = []
  49. tsk.m_outputs = [bld.path.find_or_declare(header)]
  50. tsk.prio = 1 # execute this task first
  51. def set_options(opt):
  52. # options provided by the modules
  53. opt.tool_options('compiler_cxx')
  54. opt.tool_options('compiler_cc')
  55. opt.add_option('--dbus', action='store_true', default=False, help='Enable D-Bus JACK (jackdbus)')
  56. opt.add_option('--doxygen', action='store_true', default=False, help='Enable build of doxygen documentation')
  57. opt.add_option('--monitor', action='store_true', default=False, help='Build with monitoring records')
  58. opt.add_option('--clients', default=64, type="int", dest="clients", help='Maximum number of JACK clients')
  59. opt.add_option('--ports', default=512, type="int", dest="ports", help='Maximum number of ports')
  60. opt.sub_options('dbus')
  61. def configure(conf):
  62. platform = conf.detect_platform()
  63. conf.env['IS_MACOSX'] = platform == 'darwin'
  64. conf.env['IS_LINUX'] = platform == 'linux'
  65. if conf.env['IS_LINUX']:
  66. Params.pprint('CYAN', "Linux detected")
  67. if conf.env['IS_MACOSX']:
  68. Params.pprint('CYAN', "MacOS X detected")
  69. conf.check_tool('compiler_cxx')
  70. conf.check_tool('compiler_cc')
  71. conf.sub_config('common')
  72. if conf.env['IS_LINUX']:
  73. conf.sub_config('linux')
  74. if Params.g_options.dbus:
  75. conf.sub_config('dbus')
  76. conf.sub_config('example-clients')
  77. conf.env['LIB_PTHREAD'] = ['pthread']
  78. conf.env['LIB_DL'] = ['dl']
  79. conf.env['LIB_RT'] = ['rt']
  80. conf.env['JACK_API_VERSION'] = JACK_API_VERSION
  81. conf.env['JACK_VERSION'] = VERSION
  82. conf.env['BUILD_DOXYGEN_DOCS'] = Params.g_options.doxygen
  83. conf.env['BUILD_WITH_MONITOR'] = Params.g_options.monitor
  84. conf.define('CLIENT_NUM', Params.g_options.clients)
  85. conf.define('PORT_NUM', Params.g_options. ports)
  86. conf.define('ADDON_DIR', os.path.normpath(conf.env['PREFIX'] + '/lib/jack'))
  87. conf.define('JACK_LOCATION', os.path.normpath(conf.env['PREFIX'] + '/bin'))
  88. conf.define('USE_POSIX_SHM', 1)
  89. conf.define('JACKMP', 1)
  90. if conf.env['BUILD_JACKDBUS'] == True:
  91. conf.define('JACK_DBUS', 1)
  92. if conf.env['BUILD_WITH_MONITOR'] == True:
  93. conf.define('JACK_MONITOR', 1)
  94. conf.write_config_header('config.h')
  95. svnrev = None
  96. if os.access('svnversion.h', os.R_OK):
  97. data = file('svnversion.h').read()
  98. m = re.match(r'^#define SVN_VERSION "([^"]*)"$', data)
  99. if m != None:
  100. svnrev = m.group(1)
  101. print
  102. display_msg("==================")
  103. version_msg = "JACK " + VERSION
  104. if svnrev:
  105. version_msg += " exported from r" + svnrev
  106. else:
  107. version_msg += " svn revision will checked and eventually updated during build"
  108. print version_msg
  109. print "Build with a maximum of %d JACK clients" % conf.env['CLIENT_NUM']
  110. print "Build with a maximum of %d ports" % conf.env['PORT_NUM']
  111. display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
  112. display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
  113. display_feature('Build doxygen documentation', conf.env['BUILD_DOXYGEN_DOCS'])
  114. display_feature('Build with monitoring records', conf.env['BUILD_WITH_MONITOR'])
  115. if conf.env['IS_LINUX']:
  116. display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True)
  117. display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True)
  118. display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True)
  119. display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'] == True)
  120. if conf.env['BUILD_JACKDBUS'] == True:
  121. display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
  122. #display_msg('Settings persistence', xxx)
  123. if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS-1_SESSION_BUS_SERVICES_DIR'][0]:
  124. print
  125. print Params.g_colors['RED'] + "WARNING: D-Bus session services directory as reported by pkg-config is"
  126. print Params.g_colors['RED'] + "WARNING:",
  127. print Params.g_colors['CYAN'] + conf.env['DBUS-1_SESSION_BUS_SERVICES_DIR'][0]
  128. print Params.g_colors['RED'] + 'WARNING: but service file will be installed in'
  129. print Params.g_colors['RED'] + "WARNING:",
  130. print Params.g_colors['CYAN'] + conf.env['DBUS_SERVICES_DIR']
  131. print Params.g_colors['RED'] + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
  132. print 'WARNING: You can override dbus service install directory'
  133. print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
  134. print Params.g_colors['NORMAL'],
  135. print
  136. def build(bld):
  137. if not os.access('svnversion.h', os.R_OK):
  138. create_svnversion_gen(bld)
  139. # process subfolders from here
  140. bld.add_subdirs('common')
  141. if bld.env()['IS_LINUX']:
  142. bld.add_subdirs('linux')
  143. if bld.env()['BUILD_JACKDBUS'] == True:
  144. bld.add_subdirs('dbus')
  145. bld.add_subdirs('example-clients')
  146. bld.add_subdirs('tests')
  147. if bld.env()['IS_MACOSX']:
  148. bld.add_subdirs('macosx')
  149. bld.add_subdirs('example-clients')
  150. bld.add_subdirs('tests')
  151. if bld.env()['BUILD_JACKDBUS'] == True:
  152. bld.add_subdirs('dbus')
  153. if bld.env()['BUILD_DOXYGEN_DOCS'] == True:
  154. share_dir = bld.env().get_destdir() + Params.g_build.env()['PREFIX'] + '/share/jack-audio-connection-kit'
  155. html_docs_source_dir = "build/default/html"
  156. html_docs_install_dir = share_dir + '/reference/html/'
  157. if Params.g_commands['install']:
  158. if os.path.isdir(html_docs_install_dir):
  159. Params.pprint('CYAN', "Removing old doxygen documentation installation...")
  160. shutil.rmtree(html_docs_install_dir)
  161. Params.pprint('CYAN', "Removing old doxygen documentation installation done.")
  162. Params.pprint('CYAN', "Installing doxygen documentation...")
  163. shutil.copytree(html_docs_source_dir, html_docs_install_dir)
  164. Params.pprint('CYAN', "Installing doxygen documentation done.")
  165. elif Params.g_commands['uninstall']:
  166. Params.pprint('CYAN', "Uninstalling doxygen documentation...")
  167. if os.path.isdir(share_dir):
  168. shutil.rmtree(share_dir)
  169. Params.pprint('CYAN', "Uninstalling doxygen documentation done.")
  170. elif Params.g_commands['clean']:
  171. if os.access(html_docs_source_dir, os.R_OK):
  172. Params.pprint('CYAN', "Removing doxygen generated documentation...")
  173. shutil.rmtree(html_docs_source_dir)
  174. Params.pprint('CYAN', "Removing doxygen generated documentation done.")
  175. elif Params.g_commands['build']:
  176. if not os.access(html_docs_source_dir, os.R_OK):
  177. os.popen("doxygen").read()
  178. else:
  179. Params.pprint('CYAN', "doxygen documentation already built.")
  180. def dist_hook():
  181. os.remove('svnversion_regenerate.sh')
  182. os.system('../svnversion_regenerate.sh svnversion.h')