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.

175 lines
7.1KB

  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. VERSION='1.9.0'
  10. APPNAME='jack'
  11. JACK_API_VERSION = '0.1.0'
  12. # these variables are mandatory ('/' are converted automatically)
  13. srcdir = '.'
  14. blddir = 'build'
  15. def display_msg(msg, status = None, color = None):
  16. sr = msg
  17. global g_maxlen
  18. g_maxlen = max(g_maxlen, len(msg))
  19. if status:
  20. print "%s :" % msg.ljust(g_maxlen),
  21. Params.pprint(color, status)
  22. else:
  23. print "%s" % msg.ljust(g_maxlen)
  24. def display_feature(msg, build):
  25. if build:
  26. display_msg(msg, "yes", 'GREEN')
  27. else:
  28. display_msg(msg, "no", 'YELLOW')
  29. def fetch_svn_revision(path):
  30. svn_revision_file = "svnrev"
  31. if os.access(svn_revision_file, os.R_OK):
  32. f = open(svn_revision_file, 'r')
  33. return f.read()
  34. cmd = "LANG= "
  35. cmd += "svnversion "
  36. cmd += path
  37. return commands.getoutput(cmd)
  38. def set_options(opt):
  39. # options provided by the modules
  40. opt.tool_options('compiler_cxx')
  41. opt.tool_options('compiler_cc')
  42. opt.add_option('--dbus', action='store_true', default=False, help='Enable D-Bus JACK (jackdbus)')
  43. opt.add_option('--doxygen', action='store_true', default=False, help='Enable build of doxygen documentation')
  44. opt.add_option('--monitor', action='store_true', default=False, help='Build with monitoring records')
  45. opt.sub_options('linux/dbus')
  46. def configure(conf):
  47. platform = conf.detect_platform()
  48. conf.env['IS_MACOSX'] = platform == 'darwin'
  49. conf.env['IS_LINUX'] = platform == 'linux'
  50. if conf.env['IS_LINUX']:
  51. Params.pprint('CYAN', "Linux detected")
  52. if conf.env['IS_MACOSX']:
  53. Params.pprint('CYAN', "MacOS X detected")
  54. conf.check_tool('compiler_cxx')
  55. conf.check_tool('compiler_cc')
  56. conf.sub_config('common')
  57. if conf.env['IS_LINUX']:
  58. conf.sub_config('linux')
  59. if Params.g_options.dbus:
  60. conf.sub_config('linux/dbus')
  61. conf.sub_config('example-clients')
  62. conf.env['LIB_PTHREAD'] = ['pthread']
  63. conf.env['LIB_DL'] = ['dl']
  64. conf.env['LIB_RT'] = ['rt']
  65. conf.env['JACK_API_VERSION'] = JACK_API_VERSION
  66. conf.env['JACK_VERSION'] = VERSION
  67. conf.env['BUILD_DOXYGEN_DOCS'] = Params.g_options.doxygen
  68. conf.env['BUILD_WITH_MONITOR'] = Params.g_options.monitor
  69. conf.define('ADDON_DIR', os.path.normpath(conf.env['PREFIX'] + '/lib/jack'))
  70. conf.define('JACK_LOCATION', os.path.normpath(conf.env['PREFIX'] + '/bin'))
  71. if conf.env['IS_LINUX']:
  72. conf.define('SOCKET_RPC_FIFO_SEMA', 1)
  73. if conf.env['IS_MACOSX']:
  74. conf.define('MACH_RPC_MACH_SEMA', 1)
  75. conf.define('__SMP__', 1)
  76. conf.define('USE_POSIX_SHM', 1)
  77. conf.define('JACK_SVNREVISION', fetch_svn_revision('.'))
  78. conf.define('JACKMP', 1)
  79. if conf.env['BUILD_JACKDBUS'] == True:
  80. conf.define('JACK_DBUS', 1)
  81. if conf.env['BUILD_WITH_MONITOR'] == True:
  82. conf.define('JACK_MONITOR', 1)
  83. conf.write_config_header('config.h')
  84. display_msg("\n==================")
  85. display_msg("JACK %s %s" % (VERSION, conf.get_define('JACK_SVNREVISION')))
  86. print
  87. display_msg("Install prefix", conf.env['PREFIX'], 'CYAN')
  88. display_msg("Drivers directory", conf.env['ADDON_DIR'], 'CYAN')
  89. display_feature('Build doxygen documentation', conf.env['BUILD_DOXYGEN_DOCS'])
  90. display_feature('Build with monitoring records', conf.env['BUILD_WITH_MONITOR'])
  91. if conf.env['IS_LINUX']:
  92. display_feature('Build with ALSA support', conf.env['BUILD_DRIVER_ALSA'] == True)
  93. display_feature('Build with FireWire (FreeBob) support', conf.env['BUILD_DRIVER_FREEBOB'] == True)
  94. display_feature('Build with FireWire (FFADO) support', conf.env['BUILD_DRIVER_FFADO'] == True)
  95. display_feature('Build D-Bus JACK (jackdbus)', conf.env['BUILD_JACKDBUS'] == True)
  96. if conf.env['BUILD_JACKDBUS'] == True:
  97. display_msg('D-Bus service install directory', conf.env['DBUS_SERVICES_DIR'], 'CYAN')
  98. #display_msg('Settings persistence', xxx)
  99. if conf.env['DBUS_SERVICES_DIR'] != conf.env['DBUS-1_SESSION_BUS_SERVICES_DIR'][0]:
  100. print
  101. print Params.g_colors['RED'] + "WARNING: D-Bus session services directory as reported by pkg-config is"
  102. print Params.g_colors['RED'] + "WARNING:",
  103. print Params.g_colors['CYAN'] + conf.env['DBUS-1_SESSION_BUS_SERVICES_DIR'][0]
  104. print Params.g_colors['RED'] + 'WARNING: but service file will be installed in'
  105. print Params.g_colors['RED'] + "WARNING:",
  106. print Params.g_colors['CYAN'] + conf.env['DBUS_SERVICES_DIR']
  107. print Params.g_colors['RED'] + 'WARNING: You may need to adjust your D-Bus configuration after installing jackdbus'
  108. print 'WARNING: You can override dbus service install directory'
  109. print 'WARNING: with --enable-pkg-config-dbus-service-dir option to this script'
  110. print Params.g_colors['NORMAL'],
  111. print
  112. def build(bld):
  113. # process subfolders from here
  114. bld.add_subdirs('common')
  115. if bld.env()['IS_LINUX']:
  116. bld.add_subdirs('linux')
  117. if bld.env()['BUILD_JACKDBUS'] == True:
  118. bld.add_subdirs('linux/dbus')
  119. bld.add_subdirs('example-clients')
  120. bld.add_subdirs('tests')
  121. if bld.env()['IS_MACOSX']:
  122. bld.add_subdirs('macosx')
  123. bld.add_subdirs('example-clients')
  124. bld.add_subdirs('tests')
  125. if bld.env()['BUILD_JACKDBUS'] == True:
  126. bld.add_subdirs('linux/dbus')
  127. if bld.env()['BUILD_DOXYGEN_DOCS'] == True:
  128. share_dir = bld.env().get_destdir() + Params.g_build.env()['PREFIX'] + '/share/jack-audio-connection-kit'
  129. html_docs_source_dir = "build/default/html"
  130. html_docs_install_dir = share_dir + '/reference/html/'
  131. if Params.g_commands['install']:
  132. if os.path.isdir(html_docs_install_dir):
  133. Params.pprint('CYAN', "Removing old doxygen documentation installation...")
  134. shutil.rmtree(html_docs_install_dir)
  135. Params.pprint('CYAN', "Removing old doxygen documentation installation done.")
  136. Params.pprint('CYAN', "Installing doxygen documentation...")
  137. shutil.copytree(html_docs_source_dir, html_docs_install_dir)
  138. Params.pprint('CYAN', "Installing doxygen documentation done.")
  139. elif Params.g_commands['uninstall']:
  140. Params.pprint('CYAN', "Uninstalling doxygen documentation...")
  141. if os.path.isdir(share_dir):
  142. shutil.rmtree(share_dir)
  143. Params.pprint('CYAN', "Uninstalling doxygen documentation done.")
  144. elif Params.g_commands['clean']:
  145. if os.access(html_docs_source_dir, os.R_OK):
  146. Params.pprint('CYAN', "Removing doxygen generated documentation...")
  147. shutil.rmtree(html_docs_source_dir)
  148. Params.pprint('CYAN', "Removing doxygen generated documentation done.")
  149. elif Params.g_commands['build']:
  150. if not os.access(html_docs_source_dir, os.R_OK):
  151. os.popen("doxygen").read()
  152. else:
  153. Params.pprint('CYAN', "doxygen documentation already built.")