wscript 8.46 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
45
    process.defines  = 'HAVE_CONFIG_H'
    process.includes = ['./jack', '.', '..', '../macosx','../windows', '../linux/alsa']
sletz's avatar
sletz committed
46
47
48
49
50
51
52
53
54
55
    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
56
    process.uselib_local = uselib.name
sletz's avatar
sletz committed
57
58
    return process

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

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

    if bld.env()['IS_LINUX']:
        common_libsources += [
            'JackPosixSemaphore.cpp',
            'JackFifo.cpp',
            ]
        includes.append('../linux')
        uselib.append('RT')
99
        uselib.append('DL')
100
101
102
103
104
105
106
107
108

    if bld.env()['IS_MACOSX']:
        common_libsources += [
            '../macosx/JackMachSemaphore.cpp',
            '../macosx/JackMachThread.cpp',
            '../macosx/JackMachPort.cpp',
            ]
        includes += ['../macosx', '../macosx/RPC']

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

    if bld.env()['IS_LINUX']:
        serverlib.source += [
            'JackSocketServerChannel.cpp',
            'JackSocketNotifyChannel.cpp',
            'JackSocketServerNotifyChannel.cpp',
moret's avatar
moret committed
142
	    	'JackNetUnixSocket.cpp',
143
144
145
146
147
148
149
150
151
            ]

    if bld.env()['IS_MACOSX']:
        serverlib.source += [
            '../macosx/JackMachServerChannel.cpp',
            '../macosx/JackMachNotifyChannel.cpp',
            '../macosx/JackMachServerNotifyChannel.cpp',
            '../macosx/JackMacEngineRPC.cpp',
            '../macosx/RPC/JackRPCClientUser.c',
moret's avatar
moret committed
152
	    	'JackNetUnixSocket.cpp',
153
154
            ]

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

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

    if bld.env()['IS_LINUX']:
        clientlib.source += [
            'JackSocketClientChannel.cpp',
            ]

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

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

sletz's avatar
sletz committed
199
200
    create_jack_process_obj(bld, 'netmanager', 'JackNetManager.cpp', serverlib)

201
    net_adapter_sources = [
sletz's avatar
sletz committed
202
203
        'JackResampler.cpp',
        'JackLibSampleRateResampler.cpp',
204
205
206
207
208
209
210
211
212
213
214
215
   	'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
216
        'JackAudioAdapterInterface.cpp',
217
        'JackAudioAdapterFactory.cpp',
sletz's avatar
sletz committed
218
        ]
sletz's avatar
sletz committed
219

sletz's avatar
sletz committed
220
    if bld.env()['IS_MACOSX']:
221
222
         audio_adapter_sources += ['../macosx/JackCoreAudioAdapter.cpp']
         process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
sletz's avatar
sletz committed
223
         process.env.append_value("LINKFLAGS", "../macosx/libportaudio.a -framework CoreAudio -framework AudioUnit -framework AudioToolbox -framework CoreServices")
moret's avatar
moret committed
224
225
         process.env.append_value("LINKFLAGS", "-lsamplerate")

sletz's avatar
sletz committed
226
    if bld.env()['IS_LINUX']:
227
228
         audio_adapter_sources += ['../linux/alsa/JackAlsaAdapter.cpp']
         process = create_jack_process_obj(bld, 'audioadapter', audio_adapter_sources, serverlib)
sletz's avatar
sletz committed
229
         process.env.append_value("LINKFLAGS", "-lasound -lsamplerate")
moret's avatar
moret committed
230

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

nedko's avatar
nedko committed
234
    install_files('PREFIX', 'include/jack', 'jack/*.h')
nedko's avatar
nedko committed
235
236
237
238
239
240
241
242
243
244
245
246
247
248

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