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