remove Glib::ustring from libardour; allow any characters except '/' and '\' in paths...
[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_manager.cc',
61         'buffer_set.cc',
62         'bundle.cc',
63         'butler.cc',
64         'callback.cc',
65         'chan_count.cc',
66         'chan_mapping.cc',
67         'configuration.cc',
68         'config_text.cc',
69         'control_protocol_manager.cc',
70         'control_protocol_search_path.cc',
71         'crossfade.cc',
72         'cycle_timer.cc',
73         'default_click.cc',
74         'debug.cc',
75         'delivery.cc',
76         'directory_names.cc',
77         'diskstream.cc',
78         'element_import_handler.cc',
79         'element_importer.cc',
80         'enums.cc',
81         'event_type_map.cc',
82         'export_channel.cc',
83         'export_channel_configuration.cc',
84         'export_failed.cc',
85         'export_filename.cc',
86         'export_format_base.cc',
87         'export_format_manager.cc',
88         'export_format_specification.cc',
89         'export_formats.cc',
90         'export_graph_builder.cc',
91         'export_handler.cc',
92         'export_preset.cc',
93         'export_profile_manager.cc',
94         'export_status.cc',
95         'export_timespan.cc',
96         'file_source.cc',
97         'filename_extensions.cc',
98         'filesystem_paths.cc',
99         'filter.cc',
100         'find_session.cc',
101         'gain.cc',
102         'globals.cc',
103         'graph.cc',
104         'graphnode.cc',
105         'import.cc',
106         'internal_return.cc',
107         'internal_send.cc',
108         'interpolation.cc',
109         'io.cc',
110         'io_processor.cc',
111         'jack_slave.cc',
112         'ladspa_plugin.cc',
113         'location.cc',
114         'location_importer.cc',
115         'meter.cc',
116         'midi_automation_list_binder.cc',
117         'midi_buffer.cc',
118         'midi_clock_slave.cc',
119         'midi_diskstream.cc',
120         'midi_model.cc',
121         'midi_patch_manager.cc',
122         'midi_playlist.cc',
123         'midi_port.cc',
124         'midi_region.cc',
125         'midi_ring_buffer.cc',
126         'midi_source.cc',
127         'midi_state_tracker.cc',
128         'midi_stretch.cc',
129         'midi_track.cc',
130         'midi_ui.cc',
131         'mix.cc',
132         'monitor_processor.cc',
133         'mtc_slave.cc',
134         'mtdm.cc',
135         'mute_master.cc',
136         'named_selection.cc',
137         'onset_detector.cc',
138         'panner.cc',
139         'pcm_utils.cc',
140         'pi_controller.cc',
141         'playlist.cc',
142         'playlist_factory.cc',
143         'plugin.cc',
144         'plugin_insert.cc',
145         'plugin_manager.cc',
146         'port.cc',
147         'port_insert.cc',
148         'port_set.cc',
149         'process_thread.cc',
150         'processor.cc',
151         'quantize.cc',
152         'rc_configuration.cc',
153         'recent_sessions.cc',
154         'region_factory.cc',
155         'resampled_source.cc',
156         'region.cc',
157         'return.cc',
158         'reverse.cc',
159         'route.cc',
160         'route_group.cc',
161         'route_group_member.cc',
162         'rb_effect.cc',
163         'send.cc',
164         'session.cc',
165         'session_butler.cc',
166         'session_click.cc',
167         'session_command.cc',
168         'session_configuration.cc',
169         'session_directory.cc',
170         'session_events.cc',
171         'session_export.cc',
172         'session_handle.cc',
173         'session_metadata.cc',
174         'session_midi.cc',
175         'session_object.cc',
176         'session_playlists.cc',
177         'session_process.cc',
178         'session_rtevents.cc',
179         'session_state.cc',
180         'session_state_utils.cc',
181         'session_time.cc',
182         'session_transport.cc',
183         'session_utils.cc',
184         'slave.cc',
185         'smf_source.cc',
186         'sndfile_helpers.cc',
187         'sndfileimportable.cc',
188         'sndfilesource.cc',
189         'source.cc',
190         'source_factory.cc',
191         'strip_silence.cc',
192         'svn_revision.cc',
193         'tape_file_matcher.cc',
194         'template_utils.cc',
195         'tempo.cc',
196         'tempo_map_importer.cc',
197         'thread_buffers.cc',
198         'ticker.cc',
199         'track.cc',
200         'transient_detector.cc',
201         'user_bundle.cc',
202         'utils.cc',
203         'version.cc'
204 ]
205
206 def flac_supported():
207         cmd = subprocess.Popen ("sndfile-info testfile.flac", 
208                                 stdout = subprocess.PIPE,
209                                 stderr = subprocess.STDOUT, shell = True)
210         out = cmd.communicate()[0];
211         return re.search ('unknown format', out) == None
212
213 def ogg_supported():
214         cmd = subprocess.Popen ("sndfile-info testfile.ogg", 
215                                 stdout = subprocess.PIPE,
216                                 stderr = subprocess.STDOUT, shell = True)
217         out = cmd.communicate()[0];
218         return re.search ('unknown format', out) == None
219
220 def set_options(opt):
221         autowaf.set_options(opt)
222
223 def configure(conf):
224         autowaf.build_version_files(path_prefix+'ardour/version.h', path_prefix+'version.cc',
225                         'libardour3', MAJOR, MINOR, MICRO)
226         autowaf.configure(conf)
227         conf.check_tool('compiler_cxx gas')
228         autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO', atleast_version='0.3.2')
229         autowaf.check_pkg(conf, 'jack', uselib_store='JACK', atleast_version='0.118.2')
230         autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
231         autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF', atleast_version='0.4.0')
232         autowaf.check_pkg(conf, 'samplerate', uselib_store='SAMPLERATE', atleast_version='0.1.0')
233         autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0')
234         autowaf.check_pkg(conf, 'slv2', uselib_store='SLV2', atleast_version='0.6.4', mandatory=False)
235         autowaf.check_pkg(conf, 'sndfile', uselib_store='SNDFILE', atleast_version='1.0.18')
236         autowaf.check_pkg(conf, 'soundtouch-1.0', uselib_store='SOUNDTOUCH', mandatory=False)
237         autowaf.check_pkg(conf, 'cppunit', uselib_store='CPPUNIT', atleast_version='1.12.0', mandatory=False)
238         autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
239         autowaf.check_pkg(conf, 'flac', uselib_store='FLAC', atleast_version='1.2.1')
240
241         # we don't try to detect this, since its part of our source tree
242
243         conf.define('HAVE_RUBBERBAND', 1) # controls whether we think we have it
244         conf.define('USE_RUBBERBAND', 1)  # controls whether we actually use it
245
246         conf.define('CURRENT_SESSION_FILE_VERSION', CURRENT_SESSION_FILE_VERSION)
247
248         conf.check(header_name='sys/vfs.h', define_name='HAVE_SYS_VFS_H')
249         conf.check(header_name='wordexp.h', define_name='HAVE_WORDEXP')
250
251         conf.check(header_name='jack/session.h', define_name='HAVE_JACK_SESSION')
252
253         conf.check(header_name='unistd.h', define_name='HAVE_UNISTD')
254         
255         conf.check_cc(fragment = "#include <jack/jack.h>\nvoid callback (int code, const char* reason, void* arg) { return; }\nint main(int argc, char **argv) { jack_client_t* c; jack_on_info_shutdown (c, callback, (void*) 0); return 0; }\n",
256                       linkflags = ['-ljack'],
257                       msg = 'Checking for jack_on_info_shutdown',
258                       define_name = 'HAVE_JACK_ON_INFO_SHUTDOWN',
259                       okmsg = 'ok')
260                       
261         if flac_supported():
262                 conf.define ('HAVE_FLAC', 1)
263         if ogg_supported():
264                 conf.define ('HAVE_OGG', 1)
265
266         conf.write_config_header('libardour-config.h')
267
268         # Boost headers
269         autowaf.check_header(conf, 'boost/shared_ptr.hpp')
270         autowaf.check_header(conf, 'boost/weak_ptr.hpp')
271         autowaf.check_header(conf, 'boost/scoped_ptr.hpp')
272         autowaf.check_header(conf, 'boost/ptr_container/ptr_list.hpp')
273
274
275 def build(bld):
276         # Library
277         obj              = bld.new_task_gen('cxx', 'shlib')
278         obj.source       = libardour_sources
279         obj.export_incdirs = ['.']
280         obj.includes     = ['.', '../surfaces/control_protocol', '..']
281         obj.name         = 'libardour'
282         obj.target       = 'ardour'
283         obj.uselib       = 'GLIBMM GTHREAD AUBIO SIGCPP XML UUID JACK SNDFILE SAMPLERATE LRDF OSX COREAUDIO CURL DL'
284         obj.uselib_local = 'libpbd libmidipp libevoral libvamphost libvampplugin libtaglib librubberband libaudiographer'
285         obj.vnum         = LIBARDOUR_LIB_VERSION
286         obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
287         obj.cxxflags     = ['-DPACKAGE="libardour3"']
288         obj.cxxflags     += ['-DDATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"']
289         obj.cxxflags     += ['-DCONFIG_DIR="' + os.path.normpath(bld.env['CONFIGDIR']) + '"']
290         obj.cxxflags     += ['-DMODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"']
291         obj.cxxflags     += ['-DLOCALEDIR="' + os.path.join(
292                         os.path.normpath(bld.env['DATADIR']), 'locale') + '"']
293         obj.cxxflags     += ['-DVAMP_DIR="' + os.path.join(
294                         os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"']
295         obj.cxxflags     += ['-DPROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"']
296
297         #obj.source += ' st_stretch.cc st_pitch.cc '
298         #obj.uselib += ' SOUNDTOUCH '
299         #obj.add_objects = 'default/libs/surfaces/control_protocol/smpte_1.o'
300         
301         obj.env.append_value('LINKFLAGS', 'default/libs/surfaces/control_protocol/smpte_1.o')
302         #
303         #       TODO: The above is an ugly hack that shouldn't be needed.  We really need
304         #       to refactor SMPTE out of libardour_cp to get rid of that circular dependency
305         #       alltogether.
306         #
307         if bld.env['HAVE_SLV2']:
308                 obj.source += [ 'lv2_plugin.cc', 'lv2_event_buffer.cc', 'uri_map.cc' ]
309                 obj.uselib += ' SLV2 '
310                 
311         if bld.env['VST_SUPPORT']:
312                 obj.source += [ 'vst_plugin.cc', 'session_vst.cc' ]
313                 obj.includes += [ '../fst' ]
314                 obj.cxxflags += [ '-DVST_SUPPORT' ]
315
316         if bld.env['HAVE_COREAUDIO'] and bld.env['COREAUDIO']:
317                 obj.source += [ 'coreaudiosource.cc', 'caimportable.cc' ]
318
319         if bld.env['HAVE_AUDIOUNITS'] or bld.env['HAVE_COREAUDIO']:
320                 obj.uselib_local += ' libappleutility'  
321
322         if bld.env['HAVE_AUDIOUNITS'] and bld.env['AUDIOUNITS']:
323                 obj.source += [ 'audio_unit.cc' ]
324
325         if bld.env['FPU_OPTIMIZATION']:
326                 if bld.env['build_target'] == 'i386' or bld.env['build_target'] == 'i686':
327                         obj.source += [ 'sse_functions_xmm.cc', 'sse_functions.s' ]
328                 elif bld.env['build_target'] == 'x86_64':
329                         obj.source += [ 'sse_functions_xmm.cc', 'sse_functions_64bit.s' ]
330
331         # i18n
332         if bld.env['ENABLE_NLS']:
333                 mo_files = glob.glob (os.path.join (bld.get_curdir(), 'po/*.mo'))
334                 for mo in mo_files:
335                         lang = os.path.basename (mo).replace ('.mo', '')
336                         bld.install_as (os.path.join (bld.env['PREFIX'], 'share', 'locale', lang, 'LC_MESSAGES', APPNAME + '.mo'), mo)
337
338         if bld.env['BUILD_TESTS'] and bld.env['HAVE_CPPUNIT']:
339                 # Unit tests
340                 testobj              = bld.new_task_gen('cxx', 'program')
341                 testobj.source       = '''
342                         test/bbt_test.cpp
343                         test/interpolation_test.cpp
344                         test/midi_clock_slave_test.cpp
345                         test/resampled_source.cc
346                         test/mantis_3356.cc
347                         test/testrunner.cpp
348                 '''.split()
349                 testobj.includes     = obj.includes + ['test', '../pbd']
350                 testobj.uselib       = 'CPPUNIT SIGCPP JACK GLIBMM GTHREAD SAMPLERATE XML LRDF COREAUDIO'
351                 testobj.uselib_local = 'libpbd libmidipp libardour'
352                 testobj.name         = 'libardour-tests'
353                 testobj.target       = 'run-tests'
354                 testobj.install_path = ''
355                 testobj.cxxflags     = ['-DPACKAGE="libardour3test"']
356                 testobj.cxxflags     += ['-DDATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"']
357                 testobj.cxxflags     += ['-DCONFIG_DIR="' + os.path.normpath(bld.env['CONFIGDIR']) + '"']
358                 testobj.cxxflags     += ['-DMODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"']
359                 testobj.cxxflags     += ['-DLOCALEDIR="' + os.path.join(
360                                 os.path.normpath(bld.env['DATADIR']), 'locale') + '"']
361                 testobj.cxxflags     += ['-DVAMP_DIR="' + os.path.join(
362                                 os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"']
363                 if bld.env['FPU_OPTIMIZATION']:
364                         testobj.source += [ 'sse_functions_xmm.cc' ]
365                         if bld.env['build_target'] == 'i386' or bld.env['build_target'] == 'i686':
366                                 testobj.source += [ 'sse_functions.s' ]
367                         elif bld.env['build_target'] == 'x86_64':
368                                 testobj.source += [ 'sse_functions_64bit.s' ]
369
370 def shutdown():
371         autowaf.shutdown()
372
373 def i18n(bld):
374         autowaf.build_i18n (bld, 'libs/ardour', APPNAME, libardour_sources)