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