Prevent clipping during the import of files from sources that have
[ardour.git] / libs / ardour / wscript
1 #!/usr/bin/env python
2 import autowaf
3 import os
4 import glob
5 import Options
6 import re
7 import subprocess
8
9 # Version of this package (even if built as a child)
10 MAJOR = '3'
11 MINOR = '0'
12 MICRO = '0'
13 LIBARDOUR_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
14
15 # Library version (UNIX style major, minor, micro)
16 # major increment <=> incompatible changes
17 # minor increment <=> compatible changes (additions)
18 # micro increment <=> no interface changes
19 LIBARDOUR_LIB_VERSION = '3.0.0'
20
21 # default state file version for this build
22 CURRENT_SESSION_FILE_VERSION = 3000
23
24 # Variables for 'waf dist'
25 APPNAME = 'libardour'
26 VERSION = LIBARDOUR_VERSION
27
28 # Mandatory variables
29 srcdir = '.'
30 blddir = 'build'
31
32 path_prefix = 'libs/ardour/'
33
34 libardour_sources = [
35         'amp.cc',
36         'analyser.cc',
37         'audio_buffer.cc',
38         'audio_diskstream.cc',
39         'audio_library.cc',
40         'audio_playlist.cc',
41         'audio_playlist_importer.cc',
42         'audio_port.cc',
43         'audio_region_importer.cc',
44         'audio_track.cc',
45         'audio_track_importer.cc',
46         'audioanalyser.cc',
47         'audioengine.cc',
48         'audiofile_tagger.cc',
49         'audiofilesource.cc',
50         'audioregion.cc',
51         'audiosource.cc',
52         'auditioner.cc',
53         'automatable.cc',
54         'automation.cc',
55         'automation_control.cc',
56         'automation_list.cc',
57         'beats_frames_converter.cc',
58         'broadcast_info.cc',
59         'buffer.cc',
60         'buffer_set.cc',
61         'bundle.cc',
62         'butler.cc',
63         'chan_count.cc',
64         'chan_mapping.cc',
65         'configuration.cc',
66         'config_text.cc',
67         'control_protocol_manager.cc',
68         'control_protocol_search_path.cc',
69         'crossfade.cc',
70         'cycle_timer.cc',
71         'default_click.cc',
72         'debug.cc',
73         'delivery.cc',
74         'directory_names.cc',
75         'diskstream.cc',
76         'element_import_handler.cc',
77         'element_importer.cc',
78         'enums.cc',
79         'event_type_map.cc',
80         'export_channel.cc',
81         'export_channel_configuration.cc',
82         'export_filename.cc',
83         'export_format_base.cc',
84         'export_format_manager.cc',
85         'export_format_specification.cc',
86         'export_formats.cc',
87         'export_graph_builder.cc',
88         'export_handler.cc',
89         'export_preset.cc',
90         'export_profile_manager.cc',
91         'export_status.cc',
92         'export_timespan.cc',
93         'file_source.cc',
94         'filename_extensions.cc',
95         'filesystem_paths.cc',
96         'filter.cc',
97         'find_session.cc',
98         'gain.cc',
99         'globals.cc',
100         'import.cc',
101         'internal_return.cc',
102         'internal_send.cc',
103         'interpolation.cc',
104         'io.cc',
105         'io_processor.cc',
106         'jack_slave.cc',
107         'ladspa_plugin.cc',
108         'location.cc',
109         'location_importer.cc',
110         'meter.cc',
111         'midi_buffer.cc',
112         'midi_clock_slave.cc',
113         'midi_diskstream.cc',
114         'midi_model.cc',
115         'midi_patch_manager.cc',
116         'midi_playlist.cc',
117         'midi_port.cc',
118         'midi_region.cc',
119         'midi_ring_buffer.cc',
120         'midi_source.cc',
121         'midi_state_tracker.cc',
122         'midi_stretch.cc',
123         'midi_track.cc',
124         'midi_ui.cc',
125         'mix.cc',
126         'monitor_processor.cc',
127         'mtc_slave.cc',
128         'mtdm.cc',
129         'mute_master.cc',
130         'named_selection.cc',
131         'onset_detector.cc',
132         'panner.cc',
133         'pcm_utils.cc',
134         'pi_controller.cc',
135         'playlist.cc',
136         'playlist_factory.cc',
137         'plugin.cc',
138         'plugin_insert.cc',
139         'plugin_manager.cc',
140         'port.cc',
141         'port_insert.cc',
142         'port_set.cc',
143         'processor.cc',
144         'quantize.cc',
145         'rc_configuration.cc',
146         'recent_sessions.cc',
147         'region_factory.cc',
148         'resampled_source.cc',
149         'region.cc',
150         'return.cc',
151         'reverse.cc',
152         'route.cc',
153         'route_group.cc',
154         'route_group_member.cc',
155         'rb_effect.cc',
156         'send.cc',
157         'session.cc',
158         'session_butler.cc',
159         'session_click.cc',
160         'session_command.cc',
161         'session_configuration.cc',
162         'session_directory.cc',
163         'session_events.cc',
164         'session_export.cc',
165         'session_handle.cc',
166         'session_metadata.cc',
167         'session_midi.cc',
168         'session_object.cc',
169         'session_playlists.cc',
170         'session_process.cc',
171         'session_rtevents.cc',
172         'session_state.cc',
173         'session_state_utils.cc',
174         'session_time.cc',
175         'session_transport.cc',
176         'session_utils.cc',
177         'slave.cc',
178         'smf_source.cc',
179         'sndfile_helpers.cc',
180         'sndfileimportable.cc',
181         'sndfilesource.cc',
182         'source.cc',
183         'source_factory.cc',
184         'strip_silence.cc',
185         'svn_revision.cc',
186         'tape_file_matcher.cc',
187         'template_utils.cc',
188         'tempo.cc',
189         'tempo_map_importer.cc',
190         'ticker.cc',
191         'track.cc',
192         'transient_detector.cc',
193         'user_bundle.cc',
194         'utils.cc',
195         'version.cc'
196 ]
197
198 def flac_supported():
199         cmd = subprocess.Popen ("sndfile-info testfile.flac", 
200                                 stdout = subprocess.PIPE,
201                                 stderr = subprocess.STDOUT, shell = True)
202         out = cmd.communicate()[0];
203         return re.search ('unknown format', out) == None
204
205 def ogg_supported():
206         cmd = subprocess.Popen ("sndfile-info testfile.ogg", 
207                                 stdout = subprocess.PIPE,
208                                 stderr = subprocess.STDOUT, shell = True)
209         out = cmd.communicate()[0];
210         return re.search ('unknown format', out) == None
211
212 def set_options(opt):
213         autowaf.set_options(opt)
214
215 def configure(conf):
216         autowaf.build_version_files(path_prefix+'ardour/version.h', path_prefix+'version.cc',
217                         'libardour3', MAJOR, MINOR, MICRO)
218         autowaf.configure(conf)
219         conf.check_tool('compiler_cxx gas')
220         autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO', atleast_version='0.3.2')
221         autowaf.check_pkg(conf, 'jack', uselib_store='JACK', atleast_version='0.109.0')
222         autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
223         autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF', atleast_version='0.4.0')
224         autowaf.check_pkg(conf, 'samplerate', uselib_store='SAMPLERATE', atleast_version='0.1.0')
225         autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0')
226         autowaf.check_pkg(conf, 'slv2', uselib_store='SLV2', atleast_version='0.6.4', mandatory=False)
227         autowaf.check_pkg(conf, 'sndfile', uselib_store='SNDFILE', atleast_version='1.0.18')
228         autowaf.check_pkg(conf, 'soundtouch-1.0', uselib_store='SOUNDTOUCH', mandatory=False)
229         autowaf.check_pkg(conf, 'cppunit', uselib_store='CPPUNIT', atleast_version='1.12.0', mandatory=False)
230         autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
231         autowaf.check_pkg(conf, 'flac', uselib_store='FLAC', atleast_version='1.2.1')
232
233         # we don't try to detect this, since its part of our source tree
234
235         conf.define('HAVE_RUBBERBAND', 1) # controls whether we think we have it
236         conf.define('USE_RUBBERBAND', 1)  # controls whether we actually use it
237
238         conf.define('CURRENT_SESSION_FILE_VERSION', CURRENT_SESSION_FILE_VERSION)
239
240         conf.check(header_name='sys/vfs.h', define_name='HAVE_SYS_VFS_H')
241         conf.check(header_name='wordexp.h', define_name='HAVE_WORDEXP')
242
243         conf.check(header_name='jack/session.h', define_name='HAVE_JACK_SESSION')
244         
245         if flac_supported():
246                 conf.define ('HAVE_FLAC', 1)
247                 autowaf.display_msg(conf, 'Checking for FLAC support', True)
248         else:
249                 autowaf.display_msg(conf, 'Checking for FLAC support', False)
250         if ogg_supported():
251                 conf.define ('HAVE_OGG', 1)
252                 autowaf.display_msg(conf, 'Checking for Ogg/Vorbis support', True)
253         else:
254                 autowaf.display_msg(conf, 'Checking for Ogg/Vorbis Support', False)
255
256         conf.write_config_header('libardour-config.h')
257
258         # Boost headers
259         autowaf.check_header(conf, 'boost/shared_ptr.hpp')
260         autowaf.check_header(conf, 'boost/weak_ptr.hpp')
261         autowaf.check_header(conf, 'boost/scoped_ptr.hpp')
262         autowaf.check_header(conf, 'boost/ptr_container/ptr_list.hpp')
263
264
265 def build(bld):
266         # Library
267         obj              = bld.new_task_gen('cxx', 'shlib')
268         obj.source       = libardour_sources
269         obj.export_incdirs = ['.']
270         obj.includes     = ['.', '../surfaces/control_protocol', '..']
271         obj.name         = 'libardour'
272         obj.target       = 'ardour'
273         obj.uselib       = 'GLIBMM GTHREAD AUBIO SIGCPP XML UUID JACK SNDFILE SAMPLERATE LRDF OSX COREAUDIO'
274         obj.uselib_local = 'libpbd libmidipp libevoral libvamphost libvampplugin libtaglib librubberband libaudiographer'
275         obj.vnum         = LIBARDOUR_LIB_VERSION
276         obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
277         obj.cxxflags     = ['-DPACKAGE="libardour3"']
278         obj.cxxflags     += ['-DDATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"']
279         obj.cxxflags     += ['-DCONFIG_DIR="' + os.path.normpath(bld.env['CONFIGDIR']) + '"']
280         obj.cxxflags     += ['-DMODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"']
281         obj.cxxflags     += ['-DLOCALEDIR="' + os.path.join(
282                         os.path.normpath(bld.env['DATADIR']), 'locale') + '"']
283         obj.cxxflags     += ['-DVAMP_DIR="' + os.path.join(
284                         os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"']
285         obj.cxxflags     += ['-DPROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"']
286
287         #obj.source += ' st_stretch.cc st_pitch.cc '
288         #obj.uselib += ' SOUNDTOUCH '
289         #obj.add_objects = 'default/libs/surfaces/control_protocol/smpte_1.o'
290         
291         obj.env.append_value('LINKFLAGS', 'default/libs/surfaces/control_protocol/smpte_1.o')
292         #
293         #       TODO: The above is an ugly hack that shouldn't be needed.  We really need
294         #       to refactor SMPTE out of libardour_cp to get rid of that circular dependency
295         #       alltogether.
296         #
297         if bld.env['HAVE_SLV2']:
298                 obj.source += [ 'lv2_plugin.cc', 'lv2_event_buffer.cc', 'uri_map.cc' ]
299                 obj.uselib += ' SLV2 '
300                 
301         if bld.env['VST']:
302                 obj.source += [ 'vst_plugin.cc', 'session_vst.cc' ]
303
304         if bld.env['HAVE_COREAUDIO'] and bld.env['COREAUDIO']:
305                 obj.source += [ 'coreaudiosource.cc', 'caimportable.cc' ]
306
307         if bld.env['HAVE_AUDIOUNITS'] or bld.env['HAVE_COREAUDIO']:
308                 obj.uselib_local += ' libappleutility'  
309
310         if bld.env['HAVE_AUDIOUNITS'] and bld.env['AUDIOUNITS']:
311                 obj.source += [ 'audio_unit.cc' ]
312
313         if bld.env['FPU_OPTIMIZATION']:
314                 if bld.env['build_target'] == 'i386' or bld.env['build_target'] == 'i686':
315                         obj.source += [ 'sse_functions_xmm.cc', 'sse_functions.s' ]
316                 elif bld.env['build_target'] == 'x86_64':
317                         obj.source += [ 'sse_functions_xmm.cc', 'sse_functions_64bit.s' ]
318
319         # i18n
320         if bld.env['ENABLE_NLS']:
321                 mo_files = glob.glob (os.path.join (bld.get_curdir(), 'po/*.mo'))
322                 for mo in mo_files:
323                         lang = os.path.basename (mo).replace ('.mo', '')
324                         bld.install_as (os.path.join (bld.env['PREFIX'], 'share', 'locale', lang, 'LC_MESSAGES', APPNAME + '.mo'), mo)
325
326         if bld.env['BUILD_TESTS'] and bld.env['HAVE_CPPUNIT']:
327                 # Unit tests
328                 testobj              = bld.new_task_gen('cxx', 'program')
329                 testobj.source       = '''
330                         test/bbt_test.cpp
331                         test/interpolation_test.cpp
332                         test/midi_clock_slave_test.cpp
333                         test/resampled_source.cc
334                         test/testrunner.cpp
335                 '''.split()
336                 testobj.includes     = obj.includes + ['test', '../pbd']
337                 testobj.uselib       = 'CPPUNIT SIGCPP JACK GLIBMM GTHREAD SAMPLERATE XML LRDF COREAUDIO'
338                 testobj.uselib_local = 'libpbd libmidipp libardour'
339                 testobj.name         = 'libardour-tests'
340                 testobj.target       = 'run-tests'
341                 testobj.install_path = ''
342                 testobj.cxxflags     = ['-DPACKAGE="libardour3test"']
343                 testobj.cxxflags     += ['-DDATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"']
344                 testobj.cxxflags     += ['-DCONFIG_DIR="' + os.path.normpath(bld.env['CONFIGDIR']) + '"']
345                 testobj.cxxflags     += ['-DMODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"']
346                 testobj.cxxflags     += ['-DLOCALEDIR="' + os.path.join(
347                                 os.path.normpath(bld.env['DATADIR']), 'locale') + '"']
348                 testobj.cxxflags     += ['-DVAMP_DIR="' + os.path.join(
349                                 os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"']
350                 if bld.env['FPU_OPTIMIZATION']:
351                         testobj.source += [ 'sse_functions_xmm.cc' ]
352                         if bld.env['build_target'] == 'i386' or bld.env['build_target'] == 'i686':
353                                 testobj.source += [ 'sse_functions.s' ]
354                         elif bld.env['build_target'] == 'x86_64':
355                                 testobj.source += [ 'sse_functions_64bit.s' ]
356
357 def shutdown():
358         autowaf.shutdown()
359
360 def i18n(bld):
361         autowaf.build_i18n (bld, 'libs/ardour', APPNAME, libardour_sources)