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.

518 lines
19KB

  1. #! /usr/bin/python3
  2. # encoding: utf-8
  3. import os
  4. def configure(conf):
  5. conf.env['BUILD_NETLIB'] = conf.env['SAMPLERATE']
  6. conf.env['BUILD_ADAPTER'] = conf.env['SAMPLERATE']
  7. if conf.env['IS_WINDOWS']:
  8. try:
  9. conf.check(header_name='regex.h', lib='regex', uselib_store='REGEX', define_name='HAVE_REGEX_H')
  10. except Exception:
  11. conf.check(header_name='tre/regex.h', lib='tre', uselib_store='REGEX', define_name='HAVE_TRE_REGEX_H')
  12. conf.check(header_name='winsock2.h', lib='ws2_32', uselib_store='WS2_32', define_name='HAVE_WINSOCK2_H')
  13. conf.check(
  14. header_name=['windows.h', 'mmsystem.h'], lib='winmm', uselib_store='WINMM', define_name='HAVE_MMSYSTEM_H'
  15. )
  16. conf.check(header_name=['windows.h', 'psapi.h'], lib='psapi', uselib_store='PSAPI', define_name='HAVE_PSAPI_H')
  17. def create_jack_process_obj(bld, target, sources, uselib=None, framework=None):
  18. process = bld(features=['cxx', 'cxxshlib'])
  19. if not bld.env['IS_WINDOWS']:
  20. process.env['cxxshlib_PATTERN'] = '%s.so'
  21. process.defines = ['HAVE_CONFIG_H', 'SERVER_SIDE']
  22. if bld.env['IS_MACOSX']:
  23. if framework:
  24. process.framework = framework
  25. env_includes = ['../macosx', '../posix', '../macosx/coreaudio']
  26. if bld.env['IS_LINUX']:
  27. env_includes = ['../linux', '../posix', '../linux/alsa']
  28. if bld.env['IS_FREEBSD']:
  29. env_includes = ['../freebsd', '../posix', '../solaris/oss']
  30. if bld.env['IS_SUN']:
  31. env_includes = ['../solaris', '../posix', '../solaris/oss']
  32. if bld.env['IS_WINDOWS']:
  33. env_includes = ['../windows', '../windows/portaudio']
  34. process.includes = ['.'] + env_includes + ['jack', '..']
  35. process.name = target
  36. process.target = target
  37. process.source = sources
  38. if bld.env['IS_LINUX'] or bld.env['IS_MACOSX'] or bld.env['IS_FREEBSD']:
  39. process.env.append_value('CPPFLAGS', '-fvisibility=hidden')
  40. process.install_path = '${ADDON_DIR}/'
  41. process.use = [uselib.name]
  42. return process
  43. def build(bld):
  44. common_libsources = [
  45. 'JackActivationCount.cpp',
  46. 'JackAPI.cpp',
  47. 'JackClient.cpp',
  48. 'JackConnectionManager.cpp',
  49. 'ringbuffer.c',
  50. 'JackError.cpp',
  51. 'JackException.cpp',
  52. 'JackFrameTimer.cpp',
  53. 'JackGraphManager.cpp',
  54. 'JackPort.cpp',
  55. 'JackPortType.cpp',
  56. 'JackAudioPort.cpp',
  57. 'JackMidiPort.cpp',
  58. 'JackMidiAPI.cpp',
  59. 'JackEngineControl.cpp',
  60. 'JackShmMem.cpp',
  61. 'JackGenericClientChannel.cpp',
  62. 'shm.c',
  63. 'JackGlobals.cpp',
  64. 'JackTransportEngine.cpp',
  65. 'JackTools.cpp',
  66. 'JackMessageBuffer.cpp',
  67. 'JackEngineProfiling.cpp',
  68. ]
  69. includes = ['.', './jack']
  70. if not bld.variant:
  71. includes.append('..')
  72. else:
  73. includes.append('../..')
  74. uselib = ['CELT', 'OPUS', 'DB', 'PTHREAD', 'SAMPLERATE']
  75. if bld.env['IS_LINUX']:
  76. common_libsources += [
  77. 'JackDebugClient.cpp',
  78. 'timestamps.c',
  79. 'promiscuous.c',
  80. '../posix/JackPosixThread.cpp',
  81. '../posix/JackPosixProcessSync.cpp',
  82. '../posix/JackPosixMutex.cpp',
  83. '../posix/JackSocket.cpp',
  84. '../linux/JackLinuxFutex.cpp',
  85. '../linux/JackLinuxTime.c',
  86. ]
  87. includes = ['../linux', '../posix'] + includes
  88. uselib.append('RT')
  89. uselib.append('DL')
  90. if bld.env['IS_FREEBSD']:
  91. common_libsources += [
  92. 'JackDebugClient.cpp',
  93. 'timestamps.c',
  94. 'promiscuous.c',
  95. '../posix/JackPosixThread.cpp',
  96. '../posix/JackPosixProcessSync.cpp',
  97. '../posix/JackPosixMutex.cpp',
  98. '../posix/JackPosixSemaphore.cpp',
  99. '../posix/JackSocket.cpp',
  100. '../posix/JackPosixTime.c',
  101. ]
  102. includes = ['../freebsd', '../posix'] + includes
  103. if bld.env['IS_SUN']:
  104. common_libsources += [
  105. 'JackDebugClient.cpp',
  106. 'timestamps.c',
  107. 'promiscuous.c',
  108. '../posix/JackPosixThread.cpp',
  109. '../posix/JackFifo.cpp',
  110. '../posix/JackPosixProcessSync.cpp',
  111. '../posix/JackPosixMutex.cpp',
  112. '../posix/JackSocket.cpp',
  113. '../solaris/JackSolarisTime.c',
  114. ]
  115. includes = ['../solaris', '../posix'] + includes
  116. uselib.append('RT')
  117. if bld.env['IS_MACOSX']:
  118. common_libsources += [
  119. 'JackDebugClient.cpp',
  120. 'timestamps.c',
  121. 'promiscuous.c',
  122. '../posix/JackPosixProcessSync.cpp',
  123. '../posix/JackPosixThread.cpp',
  124. '../posix/JackPosixMutex.cpp',
  125. '../macosx/JackMachThread.mm',
  126. '../macosx/JackMachSemaphore.mm',
  127. '../macosx/JackMachSemaphoreServer.mm',
  128. '../posix/JackSocket.cpp',
  129. '../macosx/JackMachTime.c',
  130. ]
  131. includes = ['../macosx', '../macosx/RPC', '../posix'] + includes
  132. if bld.env['IS_WINDOWS']:
  133. common_libsources += [
  134. '../windows/JackWinMutex.cpp',
  135. '../windows/JackWinProcessSync.cpp',
  136. '../windows/JackWinSemaphore.cpp',
  137. '../windows/JackWinThread.cpp',
  138. '../windows/JackWinTime.c',
  139. ]
  140. includes = ['../windows'] + includes
  141. libsuffix = "64" if (bld.env['DEST_CPU'] == "x86_64" and not bld.variant) else ""
  142. buildbindir = os.path.join('..', bld.path.get_bld().srcpath().rstrip(bld.path.srcpath()))
  143. staticbuild = bool('BUILD_STATIC' in bld.env and bld.env['BUILD_STATIC'])
  144. uselib.append('REGEX')
  145. uselib.append('WS2_32')
  146. uselib.append('PSAPI')
  147. uselib.append('WINMM')
  148. else:
  149. libsuffix = ""
  150. clientlib = bld(features=['c', 'cxx', 'cxxshlib', 'cshlib'])
  151. if bld.env['IS_MACOSX']:
  152. clientlib.framework = ['CoreAudio', 'Accelerate']
  153. clientlib.defines = 'HAVE_CONFIG_H'
  154. clientlib.includes = includes
  155. clientlib.name = 'clientlib'
  156. clientlib.target = 'jack'+libsuffix
  157. clientlib.install_path = '${LIBDIR}'
  158. clientlib.use = uselib
  159. if bld.env['IS_WINDOWS']:
  160. clientlib.env['cxxshlib_PATTERN'] = 'lib%s.dll'
  161. clientlib.env['cxxstlib_PATTERN'] = 'lib%s.a'
  162. clientlib.env['implib_PATTERN'] = 'lib%s.dll.a'
  163. if staticbuild:
  164. clientlib.env['SHLIB_MARKER'] = ''
  165. clientlib.env.append_value('LINKFLAGS', ['-static-libstdc++', '--disable-auto-import'])
  166. clientlib.env.append_value('LINKFLAGS', ['-Wl,--output-def,lib%s.def' % clientlib.target])
  167. bld.install_files(clientlib.install_path, [os.path.join(buildbindir, 'lib%s.def' % clientlib.target)])
  168. if bld.env['AUTOSTART_METHOD'] == 'dbus':
  169. clientlib.use.append('DBUS-1')
  170. clientlib.source = [] + common_libsources
  171. clientlib.source += [
  172. 'JackLibClient.cpp',
  173. 'JackLibAPI.cpp',
  174. 'JackMetadata.cpp',
  175. ]
  176. if bld.env['IS_LINUX']:
  177. clientlib.source += [
  178. '../posix/JackSocketClientChannel.cpp',
  179. '../posix/JackPosixServerLaunch.cpp',
  180. ]
  181. if bld.env['IS_FREEBSD']:
  182. clientlib.source += [
  183. '../posix/JackSocketClientChannel.cpp',
  184. '../posix/JackPosixServerLaunch.cpp',
  185. ]
  186. if bld.env['IS_SUN']:
  187. clientlib.source += [
  188. '../posix/JackSocketClientChannel.cpp',
  189. '../posix/JackPosixServerLaunch.cpp',
  190. ]
  191. if bld.env['IS_MACOSX']:
  192. clientlib.source += [
  193. '../posix/JackSocketClientChannel.cpp',
  194. '../posix/JackPosixServerLaunch.cpp',
  195. ]
  196. if bld.env['IS_WINDOWS']:
  197. clientlib.source += [
  198. '../windows/JackWinNamedPipe.cpp',
  199. '../windows/JackWinNamedPipeClientChannel.cpp',
  200. '../windows/JackWinServerLaunch.cpp',
  201. '../windows/JackMMCSS.cpp',
  202. ]
  203. if bld.env['IS_MACOSX']:
  204. clientlib.cnum = bld.env['JACK_API_VERSION']
  205. clientlib.vnum = bld.env['JACK_VERSION']
  206. elif not bld.env['IS_WINDOWS']:
  207. clientlib.vnum = bld.env['JACK_API_VERSION']
  208. if bld.env['IS_LINUX']:
  209. clientlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')
  210. if bld.env['IS_FREEBSD']:
  211. clientlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')
  212. if bld.env['IS_MACOSX']:
  213. clientlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')
  214. clientlib.env.append_value('LINKFLAGS', '-single_module')
  215. if bld.env['IS_SUN']:
  216. clientlib.env.append_value('LINKFLAGS', '-lnsl -lsocket')
  217. if bld.variant:
  218. # if there is variant defined, we expect it to be the 32bit client lib one
  219. # we don't want to build other stuff in this variant
  220. return
  221. serverlib = bld(features=['c', 'cxx', 'cxxshlib', 'cshlib'])
  222. if bld.env['IS_MACOSX']:
  223. serverlib.framework = ['CoreAudio', 'CoreFoundation', 'Accelerate']
  224. serverlib.defines = ['HAVE_CONFIG_H', 'SERVER_SIDE']
  225. serverlib.includes = includes
  226. serverlib.name = 'serverlib'
  227. serverlib.target = 'jackserver'+libsuffix
  228. serverlib.install_path = '${LIBDIR}'
  229. serverlib.use = uselib
  230. if bld.env['IS_WINDOWS']:
  231. serverlib.env['cxxshlib_PATTERN'] = 'lib%s.dll'
  232. serverlib.env['cxxstlib_PATTERN'] = 'lib%s.a'
  233. serverlib.env['implib_PATTERN'] = 'lib%s.dll.a'
  234. if staticbuild:
  235. serverlib.env['SHLIB_MARKER'] = ''
  236. serverlib.env.append_value('LINKFLAGS', ['-static-libstdc++', '--disable-auto-import'])
  237. serverlib.env.append_value('LINKFLAGS', ['-Wl,--output-def,lib%s.def' % serverlib.target])
  238. bld.install_files(serverlib.install_path, [os.path.join(buildbindir, 'lib%s.def' % serverlib.target)])
  239. serverlib.source = [] + common_libsources
  240. serverlib.source += [
  241. 'JackAudioDriver.cpp',
  242. 'JackTimedDriver.cpp',
  243. 'JackMidiDriver.cpp',
  244. 'JackDriver.cpp',
  245. 'JackEngine.cpp',
  246. 'JackExternalClient.cpp',
  247. 'JackFreewheelDriver.cpp',
  248. 'JackInternalClient.cpp',
  249. 'JackInternalSessionLoader.cpp',
  250. 'JackServer.cpp',
  251. 'JackThreadedDriver.cpp',
  252. 'JackRestartThreadedDriver.cpp',
  253. 'JackWaitThreadedDriver.cpp',
  254. 'JackWaitCallbackDriver.cpp',
  255. 'JackServerAPI.cpp',
  256. 'JackDriverLoader.cpp',
  257. 'JackServerGlobals.cpp',
  258. 'JackControlAPI.cpp',
  259. 'JackNetTool.cpp',
  260. 'JackNetInterface.cpp',
  261. 'JackArgParser.cpp',
  262. 'JackRequestDecoder.cpp',
  263. 'JackMidiAsyncQueue.cpp',
  264. 'JackMidiAsyncWaitQueue.cpp',
  265. 'JackMidiBufferReadQueue.cpp',
  266. 'JackMidiBufferWriteQueue.cpp',
  267. 'JackMidiRawInputWriteQueue.cpp',
  268. 'JackMidiRawOutputWriteQueue.cpp',
  269. 'JackMidiReadQueue.cpp',
  270. 'JackMidiReceiveQueue.cpp',
  271. 'JackMidiSendQueue.cpp',
  272. 'JackMidiUtil.cpp',
  273. 'JackMidiWriteQueue.cpp',
  274. 'JackMetadata.cpp',
  275. ]
  276. if bld.env['IS_LINUX']:
  277. serverlib.source += [
  278. '../posix/JackSocketServerChannel.cpp',
  279. '../posix/JackSocketNotifyChannel.cpp',
  280. '../posix/JackSocketServerNotifyChannel.cpp',
  281. '../posix/JackNetUnixSocket.cpp',
  282. ]
  283. if bld.env['IS_FREEBSD']:
  284. serverlib.source += [
  285. '../posix/JackSocketServerChannel.cpp',
  286. '../posix/JackSocketNotifyChannel.cpp',
  287. '../posix/JackSocketServerNotifyChannel.cpp',
  288. '../posix/JackNetUnixSocket.cpp',
  289. ]
  290. if bld.env['IS_SUN']:
  291. serverlib.source += [
  292. '../posix/JackSocketServerChannel.cpp',
  293. '../posix/JackSocketNotifyChannel.cpp',
  294. '../posix/JackSocketServerNotifyChannel.cpp',
  295. '../posix/JackNetUnixSocket.cpp',
  296. ]
  297. if bld.env['IS_MACOSX']:
  298. serverlib.source += [
  299. '../posix/JackSocketServerChannel.cpp',
  300. '../posix/JackSocketNotifyChannel.cpp',
  301. '../posix/JackSocketServerNotifyChannel.cpp',
  302. '../posix/JackNetUnixSocket.cpp',
  303. ]
  304. if bld.env['IS_WINDOWS']:
  305. serverlib.source += [
  306. '../windows/JackMMCSS.cpp',
  307. '../windows/JackWinNamedPipe.cpp',
  308. '../windows/JackWinNamedPipeServerChannel.cpp',
  309. '../windows/JackWinNamedPipeServerNotifyChannel.cpp',
  310. '../windows/JackWinNamedPipeNotifyChannel.cpp',
  311. '../windows/JackNetWinSocket.cpp',
  312. ]
  313. if bld.env['IS_MACOSX']:
  314. serverlib.cnum = bld.env['JACK_API_VERSION']
  315. serverlib.vnum = bld.env['JACK_VERSION']
  316. elif not bld.env['IS_WINDOWS']:
  317. serverlib.vnum = bld.env['JACK_API_VERSION']
  318. if bld.env['IS_LINUX']:
  319. serverlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')
  320. if bld.env['IS_MACOSX']:
  321. serverlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')
  322. serverlib.env.append_value('LINKFLAGS', '-single_module')
  323. if bld.env['IS_SUN']:
  324. serverlib.env.append_value('LINKFLAGS', '-lnsl -lsocket')
  325. if bld.env['BUILD_NETLIB']:
  326. netlib = bld(features=['c', 'cxx', 'cxxshlib', 'cshlib'])
  327. if bld.env['IS_MACOSX']:
  328. netlib.framework = ['CoreAudio']
  329. netlib.defines = ['HAVE_CONFIG_H', 'SERVER_SIDE']
  330. netlib.includes = includes
  331. netlib.name = 'netlib'
  332. netlib.target = 'jacknet'+libsuffix
  333. netlib.install_path = '${LIBDIR}'
  334. netlib.use = ['SAMPLERATE', 'CELT', 'OPUS', 'PTHREAD']
  335. if bld.env['IS_WINDOWS']:
  336. netlib.use += ['WS2_32', 'WINMM']
  337. netlib.env['cxxshlib_PATTERN'] = 'lib%s.dll'
  338. netlib.env['cxxstlib_PATTERN'] = 'lib%s.a'
  339. netlib.env['implib_PATTERN'] = 'lib%s.dll.a'
  340. if staticbuild:
  341. netlib.env['SHLIB_MARKER'] = ''
  342. netlib.env.append_value('LINKFLAGS', ['-static-libstdc++', '--disable-auto-import'])
  343. netlib.env.append_value('LINKFLAGS', ['-Wl,--output-def,lib%s.def' % netlib.target])
  344. bld.install_files(netlib.install_path, [os.path.join(buildbindir, 'lib%s.def' % netlib.target)])
  345. elif not bld.env['IS_MACOSX']:
  346. netlib.use += ['RT']
  347. netlib.source = [
  348. 'JackNetAPI.cpp',
  349. 'JackNetInterface.cpp',
  350. 'JackNetTool.cpp',
  351. 'JackException.cpp',
  352. 'JackAudioAdapterInterface.cpp',
  353. 'JackLibSampleRateResampler.cpp',
  354. 'JackResampler.cpp',
  355. 'JackGlobals.cpp',
  356. 'ringbuffer.c']
  357. if bld.env['IS_LINUX']:
  358. netlib.source += [
  359. '../posix/JackNetUnixSocket.cpp',
  360. '../posix/JackPosixThread.cpp',
  361. '../posix/JackPosixMutex.cpp',
  362. '../linux/JackLinuxTime.c',
  363. ]
  364. netlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')
  365. if bld.env['IS_FREEBSD']:
  366. netlib.source += [
  367. '../posix/JackNetUnixSocket.cpp',
  368. '../posix/JackPosixThread.cpp',
  369. '../posix/JackPosixMutex.cpp',
  370. '../linux/JackLinuxTime.c',
  371. ]
  372. netlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')
  373. if bld.env['IS_SUN']:
  374. netlib.source += [
  375. '../posix/JackNetUnixSocket.cpp',
  376. '../posix/JackPosixThread.cpp',
  377. '../posix/JackPosixMutex.cpp',
  378. '../solaris/JackSolarisTime.c',
  379. ]
  380. netlib.env.append_value('CPPFLAGS', '-fvisibility=hidden')
  381. if bld.env['IS_MACOSX']:
  382. netlib.source += [
  383. '../posix/JackNetUnixSocket.cpp',
  384. '../posix/JackPosixThread.cpp',
  385. '../posix/JackPosixMutex.cpp',
  386. '../macosx/JackMachThread.mm',
  387. '../macosx/JackMachTime.c',
  388. ]
  389. netlib.env.append_value('LINKFLAGS', '-single_module')
  390. if bld.env['IS_WINDOWS']:
  391. netlib.source += [
  392. '../windows/JackNetWinSocket.cpp',
  393. '../windows/JackWinThread.cpp',
  394. '../windows/JackMMCSS.cpp',
  395. '../windows/JackWinTime.c',
  396. ]
  397. if bld.env['IS_MACOSX']:
  398. netlib.cnum = bld.env['JACK_API_VERSION']
  399. netlib.vnum = bld.env['JACK_VERSION']
  400. elif not bld.env['IS_WINDOWS']:
  401. netlib.vnum = bld.env['JACK_API_VERSION']
  402. create_jack_process_obj(bld, 'netmanager', 'JackNetManager.cpp', serverlib)
  403. create_jack_process_obj(bld, 'profiler', 'JackProfiler.cpp', serverlib)
  404. net_adapter_sources = [
  405. 'JackResampler.cpp',
  406. 'JackLibSampleRateResampler.cpp',
  407. 'JackAudioAdapter.cpp',
  408. 'JackAudioAdapterInterface.cpp',
  409. 'JackNetAdapter.cpp',
  410. ]
  411. if bld.env['BUILD_ADAPTER']:
  412. process = create_jack_process_obj(bld, 'netadapter', net_adapter_sources, serverlib)
  413. process.use += ['SAMPLERATE']
  414. audio_adapter_sources = [
  415. 'JackResampler.cpp',
  416. 'JackLibSampleRateResampler.cpp',
  417. 'JackAudioAdapter.cpp',
  418. 'JackAudioAdapterInterface.cpp',
  419. 'JackAudioAdapterFactory.cpp',
  420. ]
  421. if bld.env['BUILD_ADAPTER'] and bld.env['IS_MACOSX']:
  422. audio_adapter_sources += ['../macosx/coreaudio/JackCoreAudioAdapter.mm']
  423. process = create_jack_process_obj(
  424. bld,
  425. 'audioadapter',
  426. audio_adapter_sources,
  427. serverlib,
  428. framework=[
  429. 'CoreAudio',
  430. 'AudioUnit',
  431. 'AudioToolbox',
  432. 'CoreServices',
  433. ]
  434. )
  435. process.use += ['SAMPLERATE']
  436. if bld.env['BUILD_ADAPTER'] and bld.env['IS_LINUX'] and bld.env['BUILD_DRIVER_ALSA']:
  437. audio_adapter_sources += ['../linux/alsa/JackAlsaAdapter.cpp']
  438. process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
  439. process.use += ['ALSA', 'SAMPLERATE']
  440. if bld.env['BUILD_ADAPTER'] and (bld.env['IS_SUN'] or bld.env['IS_FREEBSD']):
  441. audio_adapter_sources += ['../solaris/oss/JackOSSAdapter.cpp', 'memops.c']
  442. process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
  443. process.use += 'SAMPLERATE'
  444. if bld.env['BUILD_ADAPTER'] and bld.env['IS_WINDOWS']:
  445. audio_adapter_sources += [
  446. '../windows/portaudio/JackPortAudioAdapter.cpp',
  447. '../windows/portaudio/JackPortAudioDevices.cpp',
  448. ]
  449. process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
  450. process.use += ['SAMPLERATE', 'PORTAUDIO']
  451. bld.install_files('${PREFIX}/include/jack', bld.path.ant_glob('jack/*.h'))
  452. # process jack.pc.in -> jack.pc
  453. bld(
  454. features='subst_pc',
  455. source='../jack.pc.in',
  456. target='jack.pc',
  457. install_path='${PKGCONFDIR}',
  458. INCLUDEDIR=os.path.normpath(bld.env['PREFIX'] + '/include'),
  459. CLIENTLIB=clientlib.target,
  460. SERVERLIB=serverlib.target,
  461. )