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