wscript 9.3 KB
Newer Older
1
2
3
#! /usr/bin/env python
# encoding: utf-8

nedko's avatar
nedko committed
4
5
6
import re
import os

7
8
def configure(conf):
    conf.check_tool('misc')
9
10
11
12
13
14
15
16
17
18
    e = conf.create_header_configurator()
    e.name = 'samplerate.h'
    e.define = 'HAVE_SAMPLERATE'
    e.run()
   
    if conf.is_defined('HAVE_SAMPLERATE'):
        conf.env['LIB_SAMPLERATE'] = ['samplerate']

    conf.env['BUILD_ADAPTER'] = conf.is_defined('HAVE_SAMPLERATE')

19

nedko's avatar
nedko committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# by default waf subst tool uses @VAR@ while scons legacy is ${VAR}
# so we use same template as scons for now
def subst_func(tsk):
    "Substitutes variables in a .in file"

    m4_re = re.compile('\$\{(\w+)\}', re.M)

    env = tsk.env()
    infile = tsk.m_inputs[0].abspath(env)
    outfile = tsk.m_outputs[0].abspath(env)

    file = open(infile, 'r')
    code = file.read()
    file.close()

    s = m4_re.sub(r'%(\1)s', code)

    dict = tsk.dict
    if not dict:
        names = m4_re.findall(code)
        for i in names:
            if env[i] and type(env[i]) is types.ListType :
                dict[i] = " ".join(env[i])
            else: dict[i] = env[i]

    file = open(outfile, 'w')
    file.write(s % dict)
    file.close()

    return 0

sletz's avatar
sletz committed
51
52
53
def create_jack_process_obj(bld, target, sources, uselib = None):
    process = bld.create_obj('cpp', 'shlib')
    process.env['shlib_PATTERN'] = '%s.so'
54
    process.defines  = ['HAVE_CONFIG_H','SERVER_SIDE']
55
    if bld.env()['IS_MACOSX']:
56
        env_includes = ['../macosx', '../posix', '../macosx/coreaudio']
57
58
59
    if bld.env()['IS_LINUX']:
	env_includes = ['../linux', '../posix', '../linux/alsa']
    process.includes = ['.'] + env_includes + ['jack', '..']
sletz's avatar
sletz committed
60
61
62
63
64
65
66
67
68
69
    process.name     = target
    process.target   = target
    process.source   = sources
    process.env.append_value("CPPFLAGS", "-fvisibility=hidden")
    if bld.env()['IS_MACOSX']:
        process.env.append_value("CPPFLAGS", "-mmacosx-version-min=10.4 -arch i386 -arch ppc")
        #process.env.append_value("LINKFLAGS", "-arch i386 -arch ppc")
        process.env.append_value("LINKFLAGS", "")
    process.inst_var = bld.env()['ADDON_DIR']
    process.inst_dir = '/'
sletz's avatar
sletz committed
70
    process.uselib_local = uselib.name
sletz's avatar
sletz committed
71
72
    return process

73
def build(bld):
nedko's avatar
nedko committed
74
    common_libsources = [
75
76
77
78
        'JackActivationCount.cpp',
        'JackAPI.cpp',
        'JackClient.cpp',
        'JackConnectionManager.cpp',
nedko's avatar
nedko committed
79
        'ringbuffer.c',
80
81
82
83
84
85
86
87
        'JackError.cpp',
        'JackFrameTimer.cpp',
        'JackGraphManager.cpp',
        'JackPort.cpp',
        'JackPortType.cpp',
        'JackAudioPort.cpp',
        'JackMidiPort.cpp',
        'JackMidiAPI.cpp',
nedko's avatar
nedko committed
88
        'JackEngineControl.cpp',
89
90
91
92
93
94
95
96
97
        'JackShmMem.cpp',
        'shm.c',
        'JackGlobals.cpp',
        'JackDebugClient.cpp',
        'JackTransportEngine.cpp',
        'timestamps.c',
        'JackTools.cpp',
        'JackMessageBuffer.cpp',
        ]
98
99
100
101
102
103

    includes = ['.', './jack', '..']
    uselib = ["PTHREAD"]

    if bld.env()['IS_LINUX']:
        common_libsources += [
104
105
106
107
108
            '../posix/JackPosixThread.cpp',
            '../posix/JackPosixSemaphore.cpp',
            '../posix/JackFifo.cpp',
            '../posix/JackProcessSync.cpp',
            '../posix/JackSocket.cpp',
sletz's avatar
sletz committed
109
	    '../linux/JackLinuxTime.c',
110
            ]
111
        includes = ['../linux', '../posix'] + includes
112
        uselib.append('RT')
113
        uselib.append('DL')
114
115
116

    if bld.env()['IS_MACOSX']:
        common_libsources += [
117
118
            '../posix/JackProcessSync.cpp',
            '../posix/JackPosixThread.cpp',
119
            '../macosx/JackMachThread.cpp',
120
            '../macosx/JackMachSemaphore.cpp',
121
            '../macosx/JackMachPort.cpp',
sletz's avatar
sletz committed
122
	    '../macosx/JackMachTime.c',
123
            ]
124
        includes = ['../macosx', '../macosx/RPC', '../posix'] + includes
125

nedko's avatar
nedko committed
126
127
    serverlib = bld.create_obj('cpp', 'shlib')
    serverlib.features.append('cc')
128
    serverlib.defines = ['HAVE_CONFIG_H','SERVER_SIDE']
129
    serverlib.includes = includes
nedko's avatar
nedko committed
130
131
    serverlib.name         = 'serverlib'
    serverlib.target       = 'jackserver'
132
    serverlib.uselib = uselib
nedko's avatar
nedko committed
133
134
135
136
137
138
139
140
141
142
143
    serverlib.source = [] + common_libsources
    serverlib.source += [
        'JackAudioDriver.cpp',
        'JackDriver.cpp',
        'JackEngine.cpp',
        'JackExternalClient.cpp',
        'JackFreewheelDriver.cpp',
        'JackInternalClient.cpp',
        'JackLoopbackDriver.cpp',
        'JackServer.cpp',
        'JackThreadedDriver.cpp',
144
145
	'JackRestartThreadedDriver.cpp',
	'JackWaitThreadedDriver.cpp',
nedko's avatar
nedko committed
146
147
148
        'JackServerAPI.cpp',
        'JackDriverLoader.cpp',
        'JackServerGlobals.cpp',
sletz's avatar
sletz committed
149
        'JackControlAPI.cpp',
150
        'JackNetTool.cpp',
moret's avatar
moret committed
151
        'JackNetInterface.cpp',
nedko's avatar
nedko committed
152
        ]
153
154
155

    if bld.env()['IS_LINUX']:
        serverlib.source += [
156
157
158
159
            '../posix/JackSocketServerChannel.cpp',
            '../posix/JackSocketNotifyChannel.cpp',
            '../posix/JackSocketServerNotifyChannel.cpp',
            '../posix/JackNetUnixSocket.cpp',
160
161
162
163
164
165
166
167
168
            ]

    if bld.env()['IS_MACOSX']:
        serverlib.source += [
            '../macosx/JackMachServerChannel.cpp',
            '../macosx/JackMachNotifyChannel.cpp',
            '../macosx/JackMachServerNotifyChannel.cpp',
            '../macosx/JackMacEngineRPC.cpp',
            '../macosx/RPC/JackRPCClientUser.c',
169
            '../posix/JackNetUnixSocket.cpp',
170
171
            ]

nedko's avatar
nedko committed
172
    serverlib.vnum = bld.env()['JACK_API_VERSION']
173
    serverlib.env.append_value("CPPFLAGS", "-fvisibility=hidden")
174
    if bld.env()['IS_MACOSX']:
sletz's avatar
sletz committed
175
        serverlib.env.append_value("CPPFLAGS", "-mmacosx-version-min=10.4 -arch i386 -arch ppc")
sletz's avatar
sletz committed
176
177
        #serverlib.env.append_value("LINKFLAGS", "-framework CoreAudio -framework vecLib -single_module -arch i386 -arch ppc")
        serverlib.env.append_value("LINKFLAGS", "-framework CoreAudio -framework vecLib -single_module")
sletz's avatar
sletz committed
178
	serverlib.env.append_value("LINKFLAGS", "-compatibility_version 1 -current_version 1")
nedko's avatar
nedko committed
179
180
181
182

    clientlib = bld.create_obj('cpp', 'shlib')
    clientlib.features.append('cc')
    clientlib.defines = 'HAVE_CONFIG_H'
183
    clientlib.uselib = uselib
184
    if bld.env()['BUILD_JACKDBUS'] == True:
nedko's avatar
nedko committed
185
        clientlib.uselib.append('DBUS-1')
186
    clientlib.includes = includes
nedko's avatar
nedko committed
187
188
189
190
191
192
193
    clientlib.name         = 'clientlib'
    clientlib.target       = 'jack'
    clientlib.source = [] + common_libsources
    clientlib.source += [
        'JackLibClient.cpp',
        'JackLibAPI.cpp',
        ]
194
195
196

    if bld.env()['IS_LINUX']:
        clientlib.source += [
197
            '../posix/JackSocketClientChannel.cpp',
sletz's avatar
sletz committed
198
            '../posix/JackPosixServerLaunch.cpp',
199
200
201
202
203
204
205
            ]

    if bld.env()['IS_MACOSX']:
        clientlib.source += [
            '../macosx/JackMachClientChannel.cpp',
            '../macosx/RPC/JackRPCEngineUser.c',
            '../macosx/JackMacLibClientRPC.cpp',
sletz's avatar
sletz committed
206
            '../posix/JackPosixServerLaunch.cpp',
207
208
            ]

nedko's avatar
nedko committed
209
    clientlib.vnum = bld.env()['JACK_API_VERSION']
210
    clientlib.env.append_value("CPPFLAGS", "-fvisibility=hidden")
211
    if bld.env()['IS_MACOSX']:
sletz's avatar
sletz committed
212
        clientlib.env.append_value("CPPFLAGS", "-mmacosx-version-min=10.4 -arch i386 -arch ppc")
sletz's avatar
sletz committed
213
214
        #clientlib.env.append_value("LINKFLAGS", "-framework CoreAudio -framework vecLib -single_module -arch i386 -arch ppc")
	clientlib.env.append_value("LINKFLAGS", "-framework CoreAudio -framework vecLib -single_module")
sletz's avatar
sletz committed
215
        clientlib.env.append_value("LINKFLAGS", "-compatibility_version 1 -current_version 1")
216

sletz's avatar
sletz committed
217
218
    create_jack_process_obj(bld, 'netmanager', 'JackNetManager.cpp', serverlib)

219
    net_adapter_sources = [
sletz's avatar
sletz committed
220
221
        'JackResampler.cpp',
        'JackLibSampleRateResampler.cpp',
222
223
224
225
226
   	'JackAudioAdapter.cpp',
        'JackAudioAdapterInterface.cpp',
        'JackNetAdapter.cpp',
        ]

227
228
229
    if bld.env()['BUILD_ADAPTER'] == True:
        process = create_jack_process_obj(bld, 'netadapter', net_adapter_sources, serverlib)
        process.uselib = 'SAMPLERATE'
230
231
232
233
234

    audio_adapter_sources = [
        'JackResampler.cpp',
        'JackLibSampleRateResampler.cpp',
	'JackAudioAdapter.cpp',
sletz's avatar
sletz committed
235
        'JackAudioAdapterInterface.cpp',
236
        'JackAudioAdapterFactory.cpp',
sletz's avatar
sletz committed
237
        ]
sletz's avatar
sletz committed
238

239
    if bld.env()['BUILD_ADAPTER'] and bld.env()['IS_MACOSX']:
240
         audio_adapter_sources += ['../macosx/coreaudio/JackCoreAudioAdapter.cpp']
241
         process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
242
243
         process.env.append_value("LINKFLAGS", "-framework CoreAudio -framework AudioUnit -framework AudioToolbox -framework CoreServices")
         process.uselib = 'SAMPLERATE'
moret's avatar
moret committed
244

245
    if bld.env()['BUILD_ADAPTER'] and bld.env()['IS_LINUX']:
246
247
         audio_adapter_sources += ['../linux/alsa/JackAlsaAdapter.cpp']
         process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
248
         process.uselib = ['ALSA', 'SAMPLERATE']
moret's avatar
moret committed
249

250
251
    #audio_adapter_sources += ['../windows/JackPortAudioAdapter.cpp']
    #process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
moret's avatar
moret committed
252

nedko's avatar
nedko committed
253
    install_files('PREFIX', 'include/jack', 'jack/*.h')
nedko's avatar
nedko committed
254
255
256
257
258
259
260
261
262
263
264
265
266
267

    # process jack.pc.in -> jack.pc
    obj = bld.create_obj('subst')
    obj.source = '../jack.pc.in'
    obj.target = 'jack.pc'
    obj.dict = {'PREFIX': bld.env()['PREFIX'],
                'LIBDIR': os.path.normpath(bld.env()['PREFIX'] + '/lib'),
                'INCLUDEDIR': os.path.normpath(bld.env()['PREFIX'] + '/include'),
                'SERVERLIB': serverlib.target,
                'JACK_VERSION': bld.env()['JACK_VERSION'],
                }
    obj.inst_var = bld.env()['PREFIX']
    obj.inst_dir = '/lib/pkgconfig/'
    obj.fun = subst_func # @VAR@ -> ${VAR}