772f8474005e8ac3e69f4fd0bbcbfd71dad6b248
[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 = 'libardour'
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 chan_count.cc
31 diskstream.cc
32 track.cc
33 audio_diskstream.cc
34 audio_library.cc
35 audio_playlist.cc
36 audio_track.cc
37 audioengine.cc
38 port.cc
39 audio_port.cc
40 midi_port.cc
41 port_set.cc
42 buffer.cc
43 buffer_set.cc
44 meter.cc
45 amp.cc
46 panner.cc
47 audiofilesource.cc
48 audiofilter.cc
49 audioregion.cc
50 audiosource.cc
51 midi_source.cc
52 midi_diskstream.cc
53 midi_playlist.cc
54 midi_track.cc
55 midi_region.cc
56 smf_source.cc
57 auditioner.cc
58 automation.cc
59 automation_event.cc
60 configuration.cc
61 connection.cc
62 control_protocol_manager.cc
63 crossfade.cc
64 curve.cc
65 cycle_timer.cc
66 default_click.cc
67 enums.cc
68 gain.cc
69 gdither.cc
70 globals.cc
71 import.cc
72 insert.cc
73 io.cc
74 jack_slave.cc
75 ladspa_plugin.cc
76 location.cc
77 mtc_slave.cc
78 named_selection.cc
79 pcm_utils.cc
80 playlist.cc
81 playlist_factory.cc
82 plugin.cc
83 plugin_manager.cc
84 recent_sessions.cc
85 redirect.cc
86 region.cc
87 region_factory.cc
88 reverse.cc
89 route.cc
90 route_group.cc
91 send.cc
92 session.cc
93 session_butler.cc
94 session_click.cc
95 session_command.cc
96 session_events.cc
97 session_export.cc
98 session_midi.cc
99 session_process.cc
100 session_state.cc
101 session_time.cc
102 session_timefx.cc
103 session_transport.cc
104 silentfilesource.cc
105 sndfile_helpers.cc
106 sndfilesource.cc
107 source.cc
108 source_factory.cc
109 tempo.cc
110 utils.cc
111 version.cc
112 mix.cc
113 """)
114
115 arch_specific_objects = [ ]
116
117 osc_files = [ 'osc.cc' ]
118 vst_files = [ 'vst_plugin.cc', 'session_vst.cc' ]
119 audiounit_files = [ 'audio_unit.cc' ]
120 coreaudio_files = [ 'coreaudiosource.cc' ]
121 extra_sources = [ ]
122
123 if ardour['VST']:
124         extra_sources += vst_files
125         ardour.Append(CCFLAGS="-DVST_SUPPORT", CPPPATH="#libs/fst")
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="-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     # it is based on the (entirely reasonable) assumption that a system with CoreAudio is OS X
263     #
264     ardour.Append(LINKFLAGS='-undefined suppress -flat_namespace') 
265
266 ardour = conf.Finish ()
267
268 ardour.Merge ([
269              libraries['core'],
270              libraries['xml'],
271              libraries['sndfile-ardour'],
272              libraries['raptor'],
273              libraries['lrdf'],
274              libraries['samplerate'],
275              libraries['sigc2'],
276              libraries['pbd'],
277              libraries['soundtouch'],
278              libraries['midi++2'],
279              libraries['glib2'],
280              libraries['glibmm2']
281              ])
282
283 if ardour['LIBLO']:
284     ardour.Merge ([ libraries['lo'] ])
285
286 if ardour['COREAUDIO'] or ardour['AUDIOUNITS']:
287     ardour.Merge ([ libraries['appleutility'] ])
288
289 def SharedAsmObjectEmitter(target, source, env):
290     for tgt in target:
291         tgt.attributes.shared = 1
292     return (target, source)
293
294
295 env['BUILDERS']['SharedAsmObject'] = Builder (action = '$CXX -c -fPIC $SOURCE -o $TARGET',
296                                               emitter = SharedAsmObjectEmitter,
297                                               suffix = '$SHOBJSUFFIX',
298                                               src_suffix = '.s',
299                                               single_source = 1)
300 #
301 # handle objects that should always be compiled with -msse in their own
302 # special environment, which is exactly like "ardour" but unconditionally
303 # includes -msse
304
305
306
307 always_sse_objects = []
308 sse_env = ardour.Copy()
309 sse_env.Append (CXXFLAGS="-msse")
310
311 if env['FPU_OPTIMIZATION']:
312         if env['DIST_TARGET'] == "i386":
313                 arch_specific_objects = env.SharedAsmObject('sse_functions.os', 'sse_functions.s')
314                 always_sse_objects += [ sse_env.SharedObject (source = 'sse_functions_xmm.cc') ]
315         if env['DIST_TARGET'] == "i686":
316                 arch_specific_objects = env.SharedAsmObject('sse_functions.os', 'sse_functions.s')
317                 always_sse_objects += [ sse_env.SharedObject (source = 'sse_functions_xmm.cc') ]
318         if env['DIST_TARGET'] == "x86_64":
319                 arch_specific_objects = env.SharedAsmObject('sse_functions_64bit.os', 'sse_functions_64bit.s')
320                 always_sse_objects += [ sse_env.SharedObject (source = 'sse_functions_xmm.cc') ]
321                         
322 libardour = ardour.SharedLibrary('ardour', ardour_files + always_sse_objects + extra_sources + arch_specific_objects)
323
324 Default(libardour)
325
326 if env['NLS']:
327         i18n (ardour, ardour_files + vst_files + coreaudio_files + audiounit_files, env)
328
329
330 env.Alias('install', env.Install(os.path.join(install_prefix, env['LIBDIR'], 'ardour2'), libardour))
331
332 env.Alias('version', ardour.VersionBuild(['version.cc', 'ardour/version.h'], []))
333
334 env.Alias('tarball', env.Distribute (env['DISTTREE'],
335                                      [ 'SConscript', 'i18n.h', 'gettext.h', 'sse_functions_xmm.cc', 'sse_functions.s', 'sse_functions_64bit.s' ] +
336                                      ardour_files + osc_files + vst_files + coreaudio_files + audiounit_files +
337                                      glob.glob('po/*.po') + glob.glob('ardour/*.h')))