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