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