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.

198 lines
5.9KB

  1. #
  2. # Copyright (C) 2007 Arnold Krille
  3. # Copyright (C) 2007 Pieter Palmers
  4. # Copyright (C) 2008 Marc-Olivier Barre
  5. #
  6. # This file originates from FFADO (www.ffado.org)
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. import os
  22. import glob
  23. from string import Template
  24. def pkg_config_get_value(module, args):
  25. return env.backtick('pkg-config ' + args + ' ' + module).strip()
  26. def merge_pkg_config_append_string(env, envvar, module, args):
  27. value = pkg_config_get_value(module, args)
  28. #print value
  29. if env._dict.has_key(envvar):
  30. env._dict[envvar] += value
  31. else:
  32. env._dict[envvar] = value
  33. def merge_pkg_config_libs(env, module):
  34. for lib in pkg_config_get_value(module, "--libs").split(' '):
  35. if lib[:2] == '-l':
  36. env._dict['LIBS'].append(lib[2:])
  37. elif lib[:2] == '-L':
  38. env._dict['LIBPATH'].append(lib[2:])
  39. def merge_pkg_config_variable(env, envvar, module, pkgvar):
  40. merge_pkg_config_append_string(env, envvar, module, '--variable=' + pkgvar)
  41. def merge_pkg_config_std(env, module):
  42. merge_pkg_config_append_string(env, 'CCFLAGS', module, '--cflags')
  43. merge_pkg_config_libs(env, module)
  44. Import('env')
  45. # Paths where include files can be found
  46. env.AppendUnique(CPPPATH=['#/', '#/common', '#/common/jack'])
  47. # Needed libraries
  48. env.AppendUnique(LIBS=['rt', 'pthread'])
  49. # HACK: this should not be here ideally
  50. env.AppendUnique(CPPPATH=['#/linux','#/macosx'])
  51. # A symlinking command for our libraries' names
  52. symlinkcmd = 'rm -f $TARGET;ln -nsf $SOURCE.name $TARGET'
  53. #
  54. # Source files section
  55. #
  56. srcfiles_common_serverlib = [
  57. 'JackActivationCount.cpp',
  58. 'JackAPI.cpp',
  59. 'JackAudioDriver.cpp',
  60. 'JackClient.cpp',
  61. 'JackConnectionManager.cpp',
  62. 'JackDriver.cpp',
  63. 'JackEngine.cpp',
  64. 'JackEngineControl.cpp',
  65. 'JackError.cpp',
  66. 'JackExternalClient.cpp',
  67. 'JackFrameTimer.cpp',
  68. 'JackFreewheelDriver.cpp',
  69. 'JackGraphManager.cpp',
  70. 'JackInternalClient.cpp',
  71. 'JackPort.cpp',
  72. 'JackPosixSemaphore.cpp',
  73. 'JackPosixThread.cpp',
  74. 'JackFifo.cpp',
  75. 'JackLoopbackDriver.cpp',
  76. 'JackPortType.cpp',
  77. 'JackAudioPort.cpp',
  78. 'JackMidiPort.cpp',
  79. 'JackMidiAPI.cpp',
  80. 'JackServer.cpp',
  81. 'JackShmMem.cpp',
  82. 'JackThreadedDriver.cpp',
  83. 'shm.c',
  84. 'JackSocket.cpp',
  85. 'JackSocketServerChannel.cpp',
  86. 'JackSocketNotifyChannel.cpp',
  87. 'JackSocketServerNotifyChannel.cpp',
  88. 'JackTime.c',
  89. 'JackServerAPI.cpp',
  90. 'JackGlobals.cpp',
  91. 'JackDriverLoader.cpp',
  92. 'JackDebugClient.cpp',
  93. 'JackTransportEngine.cpp',
  94. 'JackServerGlobals.cpp',
  95. 'timestamps.c',
  96. 'JackTools.cpp',
  97. 'ringbuffer.c',
  98. 'JackControl.cpp',
  99. 'JackMessageBuffer.cpp',
  100. 'JackProcessSync.cpp'
  101. ]
  102. srcfiles_common_clientlib = [
  103. 'JackActivationCount.cpp',
  104. 'JackAPI.cpp',
  105. 'JackClient.cpp',
  106. 'JackConnectionManager.cpp',
  107. 'ringbuffer.c',
  108. 'JackServerLaunch.cpp',
  109. 'JackError.cpp',
  110. 'JackFrameTimer.cpp',
  111. 'JackGraphManager.cpp',
  112. 'JackLibClient.cpp',
  113. 'JackLibAPI.cpp',
  114. 'JackPort.cpp',
  115. 'JackPosixSemaphore.cpp',
  116. 'JackFifo.cpp',
  117. 'JackPortType.cpp',
  118. 'JackAudioPort.cpp',
  119. 'JackMidiPort.cpp',
  120. 'JackMidiAPI.cpp',
  121. 'JackEngineControl.cpp',
  122. 'JackPosixThread.cpp',
  123. 'JackShmMem.cpp',
  124. 'shm.c',
  125. 'JackSocket.cpp',
  126. 'JackSocketClientChannel.cpp',
  127. 'JackTime.c',
  128. 'JackGlobals.cpp',
  129. 'JackDebugClient.cpp',
  130. 'JackTransportEngine.cpp',
  131. 'timestamps.c',
  132. 'JackTools.cpp',
  133. 'JackMessageBuffer.cpp',
  134. 'JackProcessSync.cpp'
  135. ]
  136. jack_headers = [
  137. 'intclient.h',
  138. 'jack.h',
  139. 'midiport.h',
  140. 'ringbuffer.h',
  141. 'statistics.h',
  142. 'thread.h',
  143. 'transport.h',
  144. 'types.h',
  145. 'control.h',
  146. 'jslist.h'
  147. ]
  148. #
  149. # Build/install section
  150. #
  151. # Libraries
  152. if env['ENABLE_DBUS']:
  153. merge_pkg_config_std(env, 'dbus-1') # actually we need this only for client lib
  154. # Each platform should get it's own environment
  155. libenv = env.Copy()
  156. if env['PLATFORM'] == 'posix':
  157. libenv.Append(SHLIBSUFFIX='.' + env['JACKAPI_VERSION'])
  158. libenv.Append(SHLINKFLAGS='-Wl,-soname,${str(TARGET.file).split(".")[0]}.so.' + str(env['JACKAPI_MAJOR_VERSION']))
  159. clientlib = libenv.SharedLibrary(env['CLIENTLIB'], srcfiles_common_clientlib)
  160. serverlib = libenv.SharedLibrary(env['SERVERLIB'], srcfiles_common_serverlib)
  161. env.Install( env['INSTALL_LIBDIR'], [clientlib, serverlib])
  162. env.Alias('install', env['INSTALL_LIBDIR'])
  163. # Handle the way we name libraries on a POSIX system
  164. if env['PLATFORM'] == 'posix':
  165. libs = [(env['CLIENTLIB'], clientlib), (env['SERVERLIB'], serverlib)]
  166. for lib_name, lib in libs:
  167. env.Command('#/common/lib' + lib_name + '.so.' + str(env['JACKAPI_MAJOR_VERSION']), lib, symlinkcmd)
  168. env.Command('#/common/lib' + lib_name + '.so', '#/common/lib' + lib_name + '.so.' + str(env['JACKAPI_MAJOR_VERSION']), symlinkcmd)
  169. env.Command(env['INSTALL_LIBDIR'] + '/lib' + lib_name + '.so.' + str(env['JACKAPI_MAJOR_VERSION']), env['INSTALL_LIBDIR'] + '/lib' + lib_name + '.so.' + env['JACKAPI_VERSION'], symlinkcmd)
  170. env.Command(env['INSTALL_LIBDIR'] + '/lib' + lib_name + '.so', env['INSTALL_LIBDIR'] + '/lib' + lib_name + '.so.' + str(env['JACKAPI_MAJOR_VERSION']), symlinkcmd)
  171. env.Alias('install', env['INSTALL_LIBDIR'] + '/lib' + lib_name + '.so.' + str(env['JACKAPI_MAJOR_VERSION']))
  172. # Headers
  173. for header in jack_headers:
  174. env.Install(env['INSTALL_INCLUDEDIR'], 'jack/' + header)