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.

201 lines
6.0KB

  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. 'JackGlobalsServer.cpp',
  70. 'JackGraphManager.cpp',
  71. 'JackInternalClient.cpp',
  72. 'JackPort.cpp',
  73. 'JackPosixSemaphore.cpp',
  74. 'JackPosixThread.cpp',
  75. 'JackFifo.cpp',
  76. 'JackLoopbackDriver.cpp',
  77. 'JackPortType.cpp',
  78. 'JackAudioPort.cpp',
  79. 'JackMidiPort.cpp',
  80. 'JackMidiAPI.cpp',
  81. 'JackServer.cpp',
  82. 'JackShmMem.cpp',
  83. 'JackThreadedDriver.cpp',
  84. 'shm.c',
  85. 'JackSocket.cpp',
  86. 'JackSocketServerChannel.cpp',
  87. 'JackSocketNotifyChannel.cpp',
  88. 'JackSocketServerNotifyChannel.cpp',
  89. 'JackTime.c',
  90. 'JackServerAPI.cpp',
  91. 'JackGlobals.cpp',
  92. 'JackDriverLoader.cpp',
  93. 'JackDebugClient.cpp',
  94. 'JackTransportEngine.cpp',
  95. 'JackServerGlobals.cpp',
  96. 'JackServerLaunch.cpp',
  97. 'timestamps.c',
  98. 'JackTools.cpp',
  99. 'ringbuffer.c',
  100. 'JackControl.cpp',
  101. 'JackMessageBuffer.cpp',
  102. 'JackProcessSync.cpp'
  103. ]
  104. srcfiles_common_clientlib = [
  105. 'JackActivationCount.cpp',
  106. 'JackAPI.cpp',
  107. 'JackClient.cpp',
  108. 'JackConnectionManager.cpp',
  109. 'ringbuffer.c',
  110. 'JackServerLaunch.cpp',
  111. 'JackError.cpp',
  112. 'JackFrameTimer.cpp',
  113. 'JackGlobalsClient.cpp',
  114. 'JackGraphManager.cpp',
  115. 'JackLibClient.cpp',
  116. 'JackLibAPI.cpp',
  117. 'JackPort.cpp',
  118. 'JackPosixSemaphore.cpp',
  119. 'JackFifo.cpp',
  120. 'JackPortType.cpp',
  121. 'JackAudioPort.cpp',
  122. 'JackMidiPort.cpp',
  123. 'JackMidiAPI.cpp',
  124. 'JackEngineControl.cpp',
  125. 'JackPosixThread.cpp',
  126. 'JackShmMem.cpp',
  127. 'shm.c',
  128. 'JackSocket.cpp',
  129. 'JackSocketClientChannel.cpp',
  130. 'JackTime.c',
  131. 'JackGlobals.cpp',
  132. 'JackDebugClient.cpp',
  133. 'JackTransportEngine.cpp',
  134. 'timestamps.c',
  135. 'JackTools.cpp',
  136. 'JackMessageBuffer.cpp',
  137. 'JackProcessSync.cpp'
  138. ]
  139. jack_headers = [
  140. 'intclient.h',
  141. 'jack.h',
  142. 'midiport.h',
  143. 'ringbuffer.h',
  144. 'statistics.h',
  145. 'thread.h',
  146. 'transport.h',
  147. 'types.h',
  148. 'control.h',
  149. 'jslist.h'
  150. ]
  151. #
  152. # Build/install section
  153. #
  154. # Libraries
  155. if env['ENABLE_DBUS']:
  156. merge_pkg_config_std(env, 'dbus-1') # actually we need this only for client lib
  157. # Each platform should get it's own environment
  158. libenv = env.Copy()
  159. if env['PLATFORM'] == 'posix':
  160. libenv.Append(SHLIBSUFFIX='.' + env['JACKAPI_VERSION'])
  161. libenv.Append(SHLINKFLAGS='-Wl,-soname,${str(TARGET.file).split(".")[0]}.so.' + str(env['JACKAPI_MAJOR_VERSION']))
  162. clientlib = libenv.SharedLibrary(env['CLIENTLIB'], srcfiles_common_clientlib)
  163. serverlib = libenv.SharedLibrary(env['SERVERLIB'], srcfiles_common_serverlib)
  164. env.Install( env['INSTALL_LIBDIR'], [clientlib, serverlib])
  165. env.Alias('install', env['INSTALL_LIBDIR'])
  166. # Handle the way we name libraries on a POSIX system
  167. if env['PLATFORM'] == 'posix':
  168. libs = [(env['CLIENTLIB'], clientlib), (env['SERVERLIB'], serverlib)]
  169. for lib_name, lib in libs:
  170. env.Command('#/common/lib' + lib_name + '.so.' + str(env['JACKAPI_MAJOR_VERSION']), lib, symlinkcmd)
  171. env.Command('#/common/lib' + lib_name + '.so', '#/common/lib' + lib_name + '.so.' + str(env['JACKAPI_MAJOR_VERSION']), symlinkcmd)
  172. 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)
  173. env.Command(env['INSTALL_LIBDIR'] + '/lib' + lib_name + '.so', env['INSTALL_LIBDIR'] + '/lib' + lib_name + '.so.' + str(env['JACKAPI_MAJOR_VERSION']), symlinkcmd)
  174. env.Alias('install', env['INSTALL_LIBDIR'] + '/lib' + lib_name + '.so.' + str(env['JACKAPI_MAJOR_VERSION']))
  175. # Headers
  176. for header in jack_headers:
  177. env.Install(env['INSTALL_INCLUDEDIR'], 'jack/' + header)