1d96fd0777d927b3f9cfe52cb28ddb539db1ee6c
[ardour.git] / libs / ardour / SConscript
1 # -*- python -*-
2
3 import os
4 import os.path
5 import glob
6
7 Import('env final_prefix install_prefix final_config_prefix libraries i18n')
8
9 ardour = env.Clone()
10
11 #
12 # this defines the version number of libardour
13
14
15 domain = 'libardour2'
16
17 ardour.Append(DOMAIN = domain, MAJOR = 2, MINOR = 0, MICRO = 0)
18 ardour.Append(CXXFLAGS = "-DPACKAGE=\\\"" + domain + "\\\"")
19 ardour.Append(CXXFLAGS="-DLIBSIGC_DISABLE_DEPRECATED")
20 ardour.Append(PACKAGE = domain)
21 ardour.Append(POTFILE = domain + '.pot')
22
23 if ardour['IS_OSX']:
24         ardour.Append (LINKFLAGS="-Xlinker -headerpad -Xlinker 2048")
25
26
27 #
28 # explicitly reference the control protocol LGPL library for includes
29
30  
31 ardour.Append(CPPPATH = '#libs/surfaces/control_protocol')
32
33 ardour_files=Split("""
34 analyser.cc
35 audioanalyser.cc
36 audio_diskstream.cc
37 audioengine.cc
38 audiofilesource.cc
39 audiofilter.cc
40 audio_library.cc
41 audio_playlist.cc
42 audioregion.cc
43 audiosource.cc
44 audio_track.cc
45 auditioner.cc
46 automation.cc
47 automation_event.cc
48 configuration.cc
49 connection.cc
50 control_protocol_manager.cc
51 crossfade.cc
52 curve.cc
53 cycle_timer.cc
54 default_click.cc
55 diskstream.cc
56 enums.cc
57 gain.cc
58 gdither.cc
59 globals.cc
60 import.cc
61 insert.cc
62 io.cc
63 jack_slave.cc
64 ladspa_plugin.cc
65 location.cc
66 mix.cc
67 mtc_slave.cc
68 mtdm.cc
69 named_selection.cc
70 onset_detector.cc
71 panner.cc
72 pcm_utils.cc
73 playlist.cc
74 playlist_factory.cc
75 plugin.cc
76 plugin_manager.cc
77 port.cc
78 recent_sessions.cc
79 redirect.cc
80 region.cc
81 region_factory.cc
82 resampled_source.cc
83 reverse.cc
84 route.cc
85 route_group.cc
86 send.cc
87 session_butler.cc
88 session.cc
89 session_click.cc
90 session_command.cc
91 session_events.cc
92 session_export.cc
93 session_midi.cc
94 session_process.cc
95 session_state.cc
96 session_time.cc
97 session_transport.cc
98 silentfilesource.cc
99 sndfile_helpers.cc
100 sndfilesource.cc
101 sndfileimportable.cc
102 source.cc
103 source_factory.cc
104 svn_revision.cc
105 tempo.cc
106 track.cc
107 transient_detector.cc
108 utils.cc
109 version.cc
110 """)
111
112 arch_specific_objects = [ ]
113
114 osc_files = [ 'osc.cc' ]
115 vst_files = [ 'vst_plugin.cc', 'session_vst.cc' ]
116 lv2_files = [ 'lv2_plugin.cc' ]
117 audiounit_files = [ 'audio_unit.cc' ]
118 coreaudio_files = [ 'coreaudiosource.cc', 'caimportable.cc' ]
119 extra_sources = [ ]
120 timefx_sources = [ ]
121
122 if ardour['VST']:
123         extra_sources += vst_files
124         ardour.Append(CCFLAGS="-DVST_SUPPORT", CPPPATH="#libs/fst")
125
126 if ardour['LV2']:
127         extra_sources += lv2_files
128         ardour.Append(CCFLAGS="-DHAVE_SLV2")
129
130 if ardour['LIBLO']:
131     extra_sources += osc_files
132
133 ardour.Append(CCFLAGS="-D_REENTRANT -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE")
134 ardour.Append(CXXFLAGS="-DDATA_DIR=\\\"" + os.path.join (final_prefix, 'share') + "\\\"")
135 ardour.Append(CXXFLAGS="-DMODULE_DIR=\\\"" + os.path.join (final_prefix, env['LIBDIR']) + "\\\"")
136 ardour.Append(CXXFLAGS="-DVAMP_DIR=\\\"" + os.path.join (final_prefix, env['LIBDIR'], 'ardour2', 'vamp') + "\\\"")
137 ardour.Append(CXXFLAGS="-DCONFIG_DIR=\\\"" + final_config_prefix + "\\\"")
138 ardour.Append(CXXFLAGS="-DLOCALEDIR=\\\"" + os.path.join (final_prefix, 'share', 'locale') + "\\\"")
139
140 ardour.Merge ([ libraries['jack'] ])
141
142 #
143 # See if JACK supports jack_client_open()
144 #
145
146 jack_test_source_file = """
147 #include <jack/jack.h>
148 int main(int argc, char **argv)
149 {
150     jack_client_open ("foo", 0, 0);
151     return 0;
152 }
153 """
154 def CheckJackClientOpen(context):
155         context.Message('Checking for jack_client_open()...')
156         result = context.TryLink(jack_test_source_file, '.c')
157         context.Result(result)
158         return result
159
160 #
161 # See if JACK supports jack_recompute_total_latencies()
162 #
163
164 jack_test_source_file = """
165 #include <jack/jack.h>
166 int main(int argc, char **argv)
167 {
168     jack_recompute_total_latencies ((jack_client_t*) 0);
169     return 0;
170 }
171 """
172 def CheckJackRecomputeLatencies(context):
173         context.Message('Checking for jack_recompute_total_latencies()...')
174         result = context.TryLink(jack_test_source_file, '.c')
175         context.Result(result)
176         return result
177
178 jack_video_frame_offset_test = """
179 #include <jack/transport.h>
180 int main(int argc, char** argv)
181 {
182         jack_position_t pos;
183
184         pos.valid & JackVideoFrameOffset;
185         return 0;
186 }
187 """
188 def CheckJackVideoFrameOffset(context):
189         context.Message('Checking for JackVideoFrameOffset in jack_position_bits_t enum...')
190         result = context.TryLink(jack_video_frame_offset_test, '.c')
191         context.Result(result)
192         return result
193
194 #
195 # See if JACK supports jack_port_ensure_monitor_input()
196 #
197 jack_ensure_monitor_input_test = """
198 #include <jack/jack.h>
199 int main(int argc, char** argv)
200 {
201             jack_port_t **port;
202
203             jack_port_ensure_monitor (*port, 1);
204             return 0;
205
206 }
207 """
208
209 def CheckJackEnsureMonitorInput(context):
210         context.Message('Checking for jack_port_ensure_monitor_input()...')
211         result = context.TryLink(jack_ensure_monitor_input_test, '.c')
212         context.Result(result)
213         return result
214
215 conf = Configure(ardour, custom_tests = {
216         'CheckJackClientOpen' : CheckJackClientOpen,
217         'CheckJackRecomputeLatencies' : CheckJackRecomputeLatencies,
218         'CheckJackVideoFrameOffset' : CheckJackVideoFrameOffset,
219         'CheckJackEnsureMonitorInput' : CheckJackEnsureMonitorInput
220 })
221
222 if conf.CheckJackClientOpen():
223         ardour.Append(CXXFLAGS="-DHAVE_JACK_CLIENT_OPEN")
224
225 if conf.CheckJackRecomputeLatencies():
226     ardour.Append(CXXFLAGS="-DHAVE_JACK_RECOMPUTE_LATENCIES")
227
228 if conf.CheckJackVideoFrameOffset():
229         ardour.Append(CXXFLAGS="-DHAVE_JACK_VIDEO_SUPPORT")
230         
231 if conf.CheckJackEnsureMonitorInput():
232         ardour.Append(CXXFLAGS='-DHAVE_JACK_PORT_ENSURE_MONITOR')
233 else:
234     print '\nWARNING: You need at least svn revision 985 of jack for hardware monitoring to work correctly.\n'
235
236 #
237 # Optional header files
238 #
239
240 if conf.CheckCHeader('wordexp.h'):
241     ardour.Append(CXXFLAGS="-DHAVE_WORDEXP")
242
243 if conf.CheckCHeader('sys/vfs.h'):
244     ardour.Append(CXXFLAGS="-DHAVE_SYS_VFS_H")
245
246 if conf.CheckCHeader('/System/Library/Frameworks/CoreMIDI.framework/Headers/CoreMIDI.h'):
247     ardour.Append(LINKFLAGS="-framework CoreMIDI")
248
249 if conf.CheckCHeader('/System/Library/Frameworks/AudioToolbox.framework/Headers/ExtendedAudioFile.h'):
250     ardour.Append(LINKFLAGS="-framework AudioToolbox")
251
252 if conf.CheckCHeader('/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h'):
253     ardour.Append(CXXFLAGS="-DHAVE_WEAK_COREAUDIO")
254
255 if conf.CheckCHeader('/System/Library/Frameworks/AudioUnit.framework/Headers/AudioUnit.h') and ardour['AUDIOUNITS']:
256     ardour.Append(CXXFLAGS="-DHAVE_AUDIOUNITS")
257     ardour.Append(LINKFLAGS="-framework AudioUnit")
258     if ardour['AUSTATE']:
259             ardour.Append(CXXFLAGS="-DAU_STATE_SUPPORT")
260     extra_sources += audiounit_files
261  
262 if ardour['COREAUDIO']:
263     ardour.Append(CXXFLAGS="-DHAVE_COREAUDIO")    
264     extra_sources += coreaudio_files
265
266 if env['CONFIG_ARCH'] == 'apple':
267     # this next line avoids issues with circular dependencies between libardour and libardour_cp.
268     #
269     ardour.Append(LINKFLAGS='-undefined suppress -flat_namespace') 
270
271 ardour = conf.Finish ()
272
273 ardour.Merge ([
274              libraries['core'],
275              libraries['fftw3'],
276              libraries['fftw3f'],
277              libraries['glib2'],
278              libraries['glibmm2'],
279              libraries['lrdf'],
280              libraries['midi++2'],
281              libraries['pbd'],
282              libraries['raptor'],
283              libraries['samplerate'],
284              libraries['sigc2'],
285              libraries['sndfile'],
286              libraries['vamp'],
287              libraries['vamphost'],
288              libraries['xml']
289              ])
290
291 if ardour['RUBBERBAND']:
292         ardour.Merge ([ libraries['rubberband']])
293         timefx_sources += [ 'rb_effect.cc' ]
294 else:
295         ardour.Merge ([ libraries['soundtouch'] ])
296         timefx_sources += [ 'st_stretch.cc', 'st_pitch.cc' ]
297         
298 if ardour['LV2']:
299         ardour.Merge ([ libraries['slv2'] ])
300
301 if ardour['LIBLO']:
302         ardour.Merge ([ libraries['lo'] ])
303
304 if ardour['COREAUDIO'] or ardour['AUDIOUNITS']:
305         ardour.Merge ([ libraries['appleutility'] ])
306
307 def SharedAsmObjectEmitter(target, source, env):
308         for tgt in target:
309                 tgt.attributes.shared = 1
310         return (target, source)
311
312
313 env['BUILDERS']['SharedAsmObject'] = Builder (action = '$CXX -c -fPIC $SOURCE -o $TARGET',
314                                               emitter = SharedAsmObjectEmitter,
315                                               suffix = '$SHOBJSUFFIX',
316                                               src_suffix = '.s',
317                                               single_source = 1)
318 #
319 # handle objects that should always be compiled with -msse in their own
320 # special environment, which is exactly like "ardour" but unconditionally
321 # includes -msse
322
323
324
325 always_sse_objects = []
326 sse_env = ardour.Clone()
327 sse_env.Append (CXXFLAGS="-msse")
328
329 if env['FPU_OPTIMIZATION']:
330         if env['DIST_TARGET'] == "i386":
331                 arch_specific_objects = env.SharedAsmObject('sse_functions.os', 'sse_functions.s')
332                 always_sse_objects += [ sse_env.SharedObject (source = 'sse_functions_xmm.cc') ]
333         if env['DIST_TARGET'] == "i686":
334                 arch_specific_objects = env.SharedAsmObject('sse_functions.os', 'sse_functions.s')
335                 always_sse_objects += [ sse_env.SharedObject (source = 'sse_functions_xmm.cc') ]
336         if env['DIST_TARGET'] == "x86_64":
337                 arch_specific_objects = env.SharedAsmObject('sse_functions_64bit.os', 'sse_functions_64bit.s')
338                 always_sse_objects += [ sse_env.SharedObject (source = 'sse_functions_xmm.cc') ]
339                         
340 libardour = ardour.SharedLibrary('ardour', ardour_files + always_sse_objects + timefx_sources + extra_sources + arch_specific_objects)
341
342 Default(libardour)
343
344 if env['NLS']:
345         i18n (ardour, ardour_files + vst_files + coreaudio_files + timefx_sources + audiounit_files, env)
346
347
348 env.Alias('install', env.Install(os.path.join(install_prefix, env['LIBDIR'], 'ardour2'), libardour))
349
350 env.Alias('version', ardour.VersionBuild(['version.cc', 'ardour/version.h'], []))
351
352 env.Alias('tarball', env.Distribute (env['DISTTREE'],
353                                      [ 'SConscript', 'i18n.h', 'gettext.h' ] + 
354                                      [ 'sse_functions_xmm.cc', 'sse_functions.s', 'sse_functions_64bit.s' ] +
355                                      [ 'rb_effect.cc', 'st_stretch.cc', 'st_pitch.cc' ] +
356                                      ardour_files + 
357                                      osc_files + 
358                                      vst_files + 
359                                      coreaudio_files + 
360                                      audiounit_files +
361                                      lv2_files +
362                                      glob.glob('po/*.po') + glob.glob('ardour/*.h')))