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