wscript 8.87 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
9
def configure(conf):
    conf.check_tool('misc')

nedko's avatar
nedko committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 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
41
42
43
def create_jack_process_obj(bld, target, sources, uselib = None):
    process = bld.create_obj('cpp', 'shlib')
    process.env['shlib_PATTERN'] = '%s.so'
moret's avatar
moret committed
44
    process.defines  = 'HAVE_CONFIG_H'
45
    if bld.env()['IS_MACOSX']:
46
        env_includes = ['../macosx', '../posix', '../macosx/coreaudio']
47
48
49
    if bld.env()['IS_LINUX']:
	env_includes = ['../linux', '../posix', '../linux/alsa']
    process.includes = ['.'] + env_includes + ['jack', '..']
sletz's avatar
sletz committed
50
51
52
53
54
55
56
57
58
59
    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
60
    process.uselib_local = uselib.name
sletz's avatar
sletz committed
61
62
    return process

63
def build(bld):
nedko's avatar
nedko committed
64
    common_libsources = [
65
66
67
68
        'JackActivationCount.cpp',
        'JackAPI.cpp',
        'JackClient.cpp',
        'JackConnectionManager.cpp',
nedko's avatar
nedko committed
69
        'ringbuffer.c',
70
71
72
73
74
75
76
77
        'JackError.cpp',
        'JackFrameTimer.cpp',
        'JackGraphManager.cpp',
        'JackPort.cpp',
        'JackPortType.cpp',
        'JackAudioPort.cpp',
        'JackMidiPort.cpp',
        'JackMidiAPI.cpp',
nedko's avatar
nedko committed
78
        'JackEngineControl.cpp',
79
80
81
82
83
84
85
86
87
88
        'JackShmMem.cpp',
        'shm.c',
        'JackTime.c',
        'JackGlobals.cpp',
        'JackDebugClient.cpp',
        'JackTransportEngine.cpp',
        'timestamps.c',
        'JackTools.cpp',
        'JackMessageBuffer.cpp',
        ]
89
90
91
92
93
94

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

    if bld.env()['IS_LINUX']:
        common_libsources += [
95
96
97
98
99
            '../posix/JackPosixThread.cpp',
            '../posix/JackPosixSemaphore.cpp',
            '../posix/JackFifo.cpp',
            '../posix/JackProcessSync.cpp',
            '../posix/JackSocket.cpp',
100
            ]
101
        includes = ['../linux', '../posix'] + includes
102
        uselib.append('RT')
103
        uselib.append('DL')
104
105
106

    if bld.env()['IS_MACOSX']:
        common_libsources += [
107
108
            '../posix/JackProcessSync.cpp',
            '../posix/JackPosixThread.cpp',
109
            '../macosx/JackMachThread.cpp',
110
            '../macosx/JackMachSemaphore.cpp',
111
112
            '../macosx/JackMachPort.cpp',
            ]
113
        includes = ['../macosx', '../macosx/RPC', '../posix'] + includes
114

nedko's avatar
nedko committed
115
116
117
    serverlib = bld.create_obj('cpp', 'shlib')
    serverlib.features.append('cc')
    serverlib.defines = 'HAVE_CONFIG_H'
118
    serverlib.includes = includes
nedko's avatar
nedko committed
119
120
    serverlib.name         = 'serverlib'
    serverlib.target       = 'jackserver'
121
    serverlib.uselib = uselib
nedko's avatar
nedko committed
122
123
124
125
126
127
128
129
130
131
132
    serverlib.source = [] + common_libsources
    serverlib.source += [
        'JackAudioDriver.cpp',
        'JackDriver.cpp',
        'JackEngine.cpp',
        'JackExternalClient.cpp',
        'JackFreewheelDriver.cpp',
        'JackInternalClient.cpp',
        'JackLoopbackDriver.cpp',
        'JackServer.cpp',
        'JackThreadedDriver.cpp',
133
134
	'JackRestartThreadedDriver.cpp',
	'JackWaitThreadedDriver.cpp',
nedko's avatar
nedko committed
135
136
137
        'JackServerAPI.cpp',
        'JackDriverLoader.cpp',
        'JackServerGlobals.cpp',
sletz's avatar
sletz committed
138
        'JackControlAPI.cpp',
139
        'JackNetTool.cpp',
moret's avatar
moret committed
140
        'JackNetInterface.cpp',
nedko's avatar
nedko committed
141
        ]
142
143
144

    if bld.env()['IS_LINUX']:
        serverlib.source += [
145
146
147
148
            '../posix/JackSocketServerChannel.cpp',
            '../posix/JackSocketNotifyChannel.cpp',
            '../posix/JackSocketServerNotifyChannel.cpp',
            '../posix/JackNetUnixSocket.cpp',
149
150
151
152
153
154
155
156
157
            ]

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

nedko's avatar
nedko committed
161
    serverlib.vnum = bld.env()['JACK_API_VERSION']
162
    serverlib.env.append_value("CPPFLAGS", "-fvisibility=hidden")
163
    if bld.env()['IS_MACOSX']:
sletz's avatar
sletz committed
164
        serverlib.env.append_value("CPPFLAGS", "-mmacosx-version-min=10.4 -arch i386 -arch ppc")
sletz's avatar
sletz committed
165
166
        #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
167
	serverlib.env.append_value("LINKFLAGS", "-compatibility_version 1 -current_version 1")
nedko's avatar
nedko committed
168
169
170
171

    clientlib = bld.create_obj('cpp', 'shlib')
    clientlib.features.append('cc')
    clientlib.defines = 'HAVE_CONFIG_H'
172
    clientlib.uselib = uselib
173
    if bld.env()['BUILD_JACKDBUS'] == True:
nedko's avatar
nedko committed
174
        clientlib.uselib.append('DBUS-1')
175
    clientlib.includes = includes
nedko's avatar
nedko committed
176
177
178
179
180
181
    clientlib.name         = 'clientlib'
    clientlib.target       = 'jack'
    clientlib.source = [] + common_libsources
    clientlib.source += [
        'JackLibClient.cpp',
        'JackLibAPI.cpp',
182
        'JackServerLaunch.cpp',
nedko's avatar
nedko committed
183
        ]
184
185
186

    if bld.env()['IS_LINUX']:
        clientlib.source += [
187
            '../posix/JackSocketClientChannel.cpp',
188
189
190
191
192
193
194
195
196
            ]

    if bld.env()['IS_MACOSX']:
        clientlib.source += [
            '../macosx/JackMachClientChannel.cpp',
            '../macosx/RPC/JackRPCEngineUser.c',
            '../macosx/JackMacLibClientRPC.cpp',
            ]

nedko's avatar
nedko committed
197
    clientlib.vnum = bld.env()['JACK_API_VERSION']
198
    clientlib.env.append_value("CPPFLAGS", "-fvisibility=hidden")
199
    if bld.env()['IS_MACOSX']:
sletz's avatar
sletz committed
200
        clientlib.env.append_value("CPPFLAGS", "-mmacosx-version-min=10.4 -arch i386 -arch ppc")
sletz's avatar
sletz committed
201
202
        #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
203
        clientlib.env.append_value("LINKFLAGS", "-compatibility_version 1 -current_version 1")
204

sletz's avatar
sletz committed
205
206
    create_jack_process_obj(bld, 'netmanager', 'JackNetManager.cpp', serverlib)

207
    net_adapter_sources = [
sletz's avatar
sletz committed
208
209
        'JackResampler.cpp',
        'JackLibSampleRateResampler.cpp',
210
211
212
213
214
215
216
217
218
219
220
221
   	'JackAudioAdapter.cpp',
        'JackAudioAdapterInterface.cpp',
        'JackNetAdapter.cpp',
        ]

    process = create_jack_process_obj(bld, 'netadapter', net_adapter_sources, serverlib)
    process.env.append_value("LINKFLAGS", "-lsamplerate")

    audio_adapter_sources = [
        'JackResampler.cpp',
        'JackLibSampleRateResampler.cpp',
	'JackAudioAdapter.cpp',
sletz's avatar
sletz committed
222
        'JackAudioAdapterInterface.cpp',
223
        'JackAudioAdapterFactory.cpp',
sletz's avatar
sletz committed
224
        ]
sletz's avatar
sletz committed
225

sletz's avatar
sletz committed
226
    if bld.env()['IS_MACOSX']:
227
         audio_adapter_sources += ['../macosx/coreaudio/JackCoreAudioAdapter.cpp']
228
         process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
sletz's avatar
sletz committed
229
         process.env.append_value("LINKFLAGS", "../macosx/libportaudio.a -framework CoreAudio -framework AudioUnit -framework AudioToolbox -framework CoreServices")
moret's avatar
moret committed
230
231
         process.env.append_value("LINKFLAGS", "-lsamplerate")

sletz's avatar
sletz committed
232
    if bld.env()['IS_LINUX']:
233
234
         audio_adapter_sources += ['../linux/alsa/JackAlsaAdapter.cpp']
         process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
sletz's avatar
sletz committed
235
         process.env.append_value("LINKFLAGS", "-lasound -lsamplerate")
moret's avatar
moret committed
236

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

nedko's avatar
nedko committed
240
    install_files('PREFIX', 'include/jack', 'jack/*.h')
nedko's avatar
nedko committed
241
242
243
244
245
246
247
248
249
250
251
252
253
254

    # 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}