wscript 9.01 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'
44
    process.defines  = ['HAVE_CONFIG_H','SERVER_SIDE']
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
        'JackShmMem.cpp',
        'shm.c',
        'JackGlobals.cpp',
        'JackDebugClient.cpp',
        'JackTransportEngine.cpp',
        'timestamps.c',
        'JackTools.cpp',
        'JackMessageBuffer.cpp',
        ]
88
89
90
91
92
93

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

    if bld.env()['IS_LINUX']:
        common_libsources += [
94
95
96
97
98
            '../posix/JackPosixThread.cpp',
            '../posix/JackPosixSemaphore.cpp',
            '../posix/JackFifo.cpp',
            '../posix/JackProcessSync.cpp',
            '../posix/JackSocket.cpp',
sletz's avatar
sletz committed
99
	    '../linux/JackLinuxTime.c',
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
            '../macosx/JackMachPort.cpp',
sletz's avatar
sletz committed
112
	    '../macosx/JackMachTime.c',
113
            ]
114
        includes = ['../macosx', '../macosx/RPC', '../posix'] + includes
115

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

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

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

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

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

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

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

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

sletz's avatar
sletz committed
207
208
    create_jack_process_obj(bld, 'netmanager', 'JackNetManager.cpp', serverlib)

209
    net_adapter_sources = [
sletz's avatar
sletz committed
210
211
        'JackResampler.cpp',
        'JackLibSampleRateResampler.cpp',
212
213
214
215
216
217
218
219
220
221
222
223
   	'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
224
        'JackAudioAdapterInterface.cpp',
225
        'JackAudioAdapterFactory.cpp',
sletz's avatar
sletz committed
226
        ]
sletz's avatar
sletz committed
227

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

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

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

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

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