Implement ui:portIndex and ui:touch features.
[ardour.git] / libs / ardour / wscript
1 #!/usr/bin/env python
2 from waflib.extras import autowaf as autowaf
3 from waflib import Options
4 import os
5 import re
6 import subprocess
7
8 # Version of this package (even if built as a child)
9 MAJOR = '3'
10 MINOR = '0'
11 MICRO = '0'
12 LIBARDOUR_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
13
14 # Library version (UNIX style major, minor, micro)
15 # major increment <=> incompatible changes
16 # minor increment <=> compatible changes (additions)
17 # micro increment <=> no interface changes
18 LIBARDOUR_LIB_VERSION = '3.0.0'
19
20 # default state file version for this build
21 CURRENT_SESSION_FILE_VERSION = 3000
22
23 # Variables for 'waf dist'
24 APPNAME = 'libardour3'
25 VERSION = LIBARDOUR_VERSION
26 I18N_PACKAGE = 'libardour3'
27
28 # Mandatory variables
29 top = '.'
30 out = '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_playlist_source.cc',
43         'audio_port.cc',
44         'audio_region_importer.cc',
45         'audio_track.cc',
46         'audio_track_importer.cc',
47         'audioanalyser.cc',
48         'audioengine.cc',
49         'audiofile_tagger.cc',
50         'audiofilesource.cc',
51         'audioregion.cc',
52         'audiosource.cc',
53         'auditioner.cc',
54         'automatable.cc',
55         'automation.cc',
56         'automation_control.cc',
57         'automation_list.cc',
58         'beats_frames_converter.cc',
59         'broadcast_info.cc',
60         'buffer.cc',
61         'buffer_manager.cc',
62         'buffer_set.cc',
63         'bundle.cc',
64         'butler.cc',
65         'callback.cc',
66         'capturing_processor.cc',
67         'chan_count.cc',
68         'chan_mapping.cc',
69         'configuration.cc',
70         'config_text.cc',
71         'control_protocol_manager.cc',
72         'control_protocol_search_path.cc',
73         'crossfade.cc',
74         'crossfade_binder.cc',
75         'cycle_timer.cc',
76         'data_type.cc',
77         'default_click.cc',
78         'debug.cc',
79         'delivery.cc',
80         'directory_names.cc',
81         'diskstream.cc',
82         'element_import_handler.cc',
83         'element_importer.cc',
84         'enums.cc',
85         'event_type_map.cc',
86         'export_channel.cc',
87         'export_channel_configuration.cc',
88         'export_failed.cc',
89         'export_filename.cc',
90         'export_format_base.cc',
91         'export_format_manager.cc',
92         'export_format_specification.cc',
93         'export_formats.cc',
94         'export_formats_search_path.cc',
95         'export_graph_builder.cc',
96         'export_handler.cc',
97         'export_preset.cc',
98         'export_profile_manager.cc',
99         'export_status.cc',
100         'export_timespan.cc',
101         'file_source.cc',
102         'filename_extensions.cc',
103         'filesystem_paths.cc',
104         'filter.cc',
105         'find_session.cc',
106         'globals.cc',
107         'graph.cc',
108         'graphnode.cc',
109         'import.cc',
110         'internal_return.cc',
111         'internal_send.cc',
112         'interpolation.cc',
113         'io.cc',
114         'io_processor.cc',
115         'jack_slave.cc',
116         'ladspa_plugin.cc',
117         'location.cc',
118         'location_importer.cc',
119         'meter.cc',
120         'midi_automation_list_binder.cc',
121         'midi_buffer.cc',
122         'midi_clock_slave.cc',
123         'midi_diskstream.cc',
124         'midi_model.cc',
125         'midi_patch_manager.cc',
126         'midi_patch_search_path.cc',
127         'midi_playlist.cc',
128         'midi_playlist_source.cc',
129         'midi_port.cc',
130         'midi_region.cc',
131         'midi_ring_buffer.cc',
132         'midi_source.cc',
133         'midi_state_tracker.cc',
134         'midi_stretch.cc',
135         'midi_track.cc',
136         'midi_ui.cc',
137         'mix.cc',
138         'monitor_processor.cc',
139         'mtc_slave.cc',
140         'mtdm.cc',
141         'mute_master.cc',
142         'named_selection.cc',
143         'onset_detector.cc',
144         'operations.cc',
145         'pan_controllable.cc',
146         'pannable.cc',
147         'panner.cc',
148         'panner_manager.cc',
149         'panner_search_path.cc',
150         'panner_shell.cc',
151         'pcm_utils.cc',
152         'pi_controller.cc',
153         'playlist.cc',
154         'playlist_factory.cc',
155         'playlist_source.cc',
156         'plugin.cc',
157         'plugin_insert.cc',
158         'plugin_manager.cc',
159         'port.cc',
160         'port_insert.cc',
161         'port_set.cc',
162         'process_thread.cc',
163         'processor.cc',
164         'progress.cc',
165         'quantize.cc',
166         'rc_configuration.cc',
167         'recent_sessions.cc',
168         'region_factory.cc',
169         'resampled_source.cc',
170         'region.cc',
171         'return.cc',
172         'reverse.cc',
173         'route.cc',
174         'route_graph.cc',
175         'route_group.cc',
176         'route_group_member.cc',
177         'rb_effect.cc',
178         'send.cc',
179         'session.cc',
180         'session_butler.cc',
181         'session_click.cc',
182         'session_command.cc',
183         'session_configuration.cc',
184         'session_directory.cc',
185         'session_events.cc',
186         'session_export.cc',
187         'session_handle.cc',
188         'session_metadata.cc',
189         'session_midi.cc',
190         'session_object.cc',
191         'session_playlists.cc',
192         'session_process.cc',
193         'session_rtevents.cc',
194         'session_state.cc',
195         'session_state_utils.cc',
196         'session_time.cc',
197         'session_transport.cc',
198         'session_utils.cc',
199         'slave.cc',
200         'smf_source.cc',
201         'sndfile_helpers.cc',
202         'sndfileimportable.cc',
203         'sndfilesource.cc',
204         'source.cc',
205         'source_factory.cc',
206         'speakers.cc',
207         'strip_silence.cc',
208         'svn_revision.cc',
209         'tape_file_matcher.cc',
210         'template_utils.cc',
211         'tempo.cc',
212         'tempo_map_importer.cc',
213         'thread_buffers.cc',
214         'ticker.cc',
215         'track.cc',
216         'transient_detector.cc',
217         'unknown_processor.cc',
218         'user_bundle.cc',
219         'utils.cc',
220         'version.cc',
221         'worker.cc',
222 ]
223
224 def flac_supported():
225     cmd = subprocess.Popen ("sndfile-info testfile.flac",
226                             stdout = subprocess.PIPE,
227                             stderr = subprocess.STDOUT, shell = True)
228     out = cmd.communicate()[0].decode('utf-8');
229     return re.search ('unknown format', out) == None
230
231 def ogg_supported():
232     cmd = subprocess.Popen ("sndfile-info testfile.ogg",
233                             stdout = subprocess.PIPE,
234                             stderr = subprocess.STDOUT, shell = True)
235     out = cmd.communicate()[0].decode('utf-8');
236     return re.search ('unknown format', out) == None
237
238 def options(opt):
239     autowaf.set_options(opt)
240
241 def configure(conf):
242     conf.load('compiler_cxx')
243     conf.load('gas')
244     autowaf.build_version_files(
245         path_prefix + 'ardour/version.h',
246         path_prefix + 'version.cc',
247         'libardour3', MAJOR, MINOR, MICRO)
248     autowaf.configure(conf)
249     autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO',
250                       atleast_version='0.3.2')
251     autowaf.check_pkg(conf, 'jack', uselib_store='JACK',
252                       atleast_version='0.118.2')
253     autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
254     autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF',
255                       atleast_version='0.4.0')
256     autowaf.check_pkg(conf, 'samplerate', uselib_store='SAMPLERATE',
257                       atleast_version='0.1.0')
258     autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP',
259                       atleast_version='2.0')
260     if Options.options.lv2:
261         autowaf.check_pkg(conf, 'lilv-0', uselib_store='LILV',
262                           atleast_version='0.0.0', mandatory=False)
263         autowaf.check_pkg(conf, 'lilv-0', uselib_store='NEW_LILV',
264                           atleast_version='0.14.0', mandatory=False)
265         if conf.is_defined('HAVE_LILV'):
266             autowaf.check_pkg(conf, 'suil-0', uselib_store='SUIL',
267                               atleast_version='0.2.0', mandatory=False)
268             autowaf.check_pkg(conf, 'suil-0', uselib_store='NEW_SUIL',
269                               atleast_version='0.5.0', mandatory=False)
270
271 #    autowaf.check_pkg(conf, 'soundtouch-1.0', uselib_store='SOUNDTOUCH',
272 #                      mandatory=False)
273     autowaf.check_pkg(conf, 'cppunit', uselib_store='CPPUNIT',
274                       atleast_version='1.12.0', mandatory=False)
275     autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
276     autowaf.check_pkg(conf, 'flac', uselib_store='FLAC',
277                       atleast_version='1.2.1')
278     autowaf.check_pkg(conf, 'libcurl', uselib_store='CURL',
279                       atleast_version='7.0.0')
280
281     # we don't try to detect this, since its part of our source tree
282
283     conf.define('HAVE_RUBBERBAND', 1) # controls whether we think we have it
284     conf.define('USE_RUBBERBAND', 1)  # controls whether we actually use it
285
286     conf.define('CURRENT_SESSION_FILE_VERSION', CURRENT_SESSION_FILE_VERSION)
287
288     conf.check(header_name='sys/vfs.h', define_name='HAVE_SYS_VFS_H',mandatory=False)
289
290     conf.check(header_name='jack/session.h', uselib = [ 'JACK' ],
291                define_name='HAVE_JACK_SESSION')
292
293     conf.check(header_name='unistd.h', define_name='HAVE_UNISTD',mandatory=False)
294
295     conf.check_cc(fragment = '''
296 #include <jack/jack.h>
297 void callback(jack_status_t code, const char* reason, void* arg) { return; }
298 int main(int argc, char **argv) {
299     jack_client_t* c;
300     jack_on_info_shutdown(c, callback, (void*) 0);
301     return 0;
302 }''',
303                   uselib= [ 'JACK' ],
304                   msg = 'Checking for jack_on_info_shutdown',
305                   define_name = 'HAVE_JACK_ON_INFO_SHUTDOWN',
306                   okmsg = 'present')
307
308     missing_jack_message = 'missing - a version of JACK that supports jack_port_set_latency_range() is required to compile Ardour3.'
309
310     conf.check_cc(fragment = '''
311 #include <jack/jack.h>
312 int main(int argc, char **argv) {
313     jack_port_t* p;
314     jack_latency_range_t r;
315     jack_port_set_latency_range(p, JackCaptureLatency, &r);
316     return 0;
317 }''',
318                   uselib = [ 'JACK' ],
319                   msg = 'Checking for new JACK latency API',
320                   okmsg = 'present',
321                   mandatory = True,
322                   errmsg = missing_jack_message)
323
324     conf.check_cc(fragment = '''
325 #include <jack/jack.h>
326 int main(int argc, char **argv) {
327    jack_port_type_get_buffer_size((jack_client_t*)0, "");
328    return 0;
329 }''',
330                   uselib = [ 'JACK' ],
331                   msg = 'Checking for new jack_port_type_get_buffer_size',
332                   okmsg = 'present',
333                   mandatory = True,
334                   errmsg = missing_jack_message)
335
336     if flac_supported():
337         conf.define ('HAVE_FLAC', 1)
338     if ogg_supported():
339         conf.define ('HAVE_OGG', 1)
340
341     if Options.options.lv2 and conf.is_defined('HAVE_LILV'):
342         conf.define ('LV2_SUPPORT', 1)
343
344     conf.write_config_header('libardour-config.h', remove=False)
345
346     # Boost headers
347     autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp')
348     autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
349     autowaf.check_header(conf, 'cxx', 'boost/scoped_ptr.hpp')
350     autowaf.check_header(conf, 'cxx', 'boost/ptr_container/ptr_list.hpp')
351
352
353 def build(bld):
354     # Library
355     obj              = bld(features = 'c cxx cshlib cxxshlib')
356     obj.source       = libardour_sources
357     obj.export_includes = ['.']
358     obj.includes     = ['.', '../surfaces/control_protocol', '..']
359     obj.name         = 'libardour'
360     obj.target       = 'ardour'
361     obj.uselib       = ['GLIBMM','GTHREAD','AUBIO','SIGCPP','XML','UUID',
362                         'JACK','SNDFILE','SAMPLERATE','LRDF','AUDIOUNITS',
363                         'OSX','BOOST','CURL','DL']
364     obj.use          = ['libpbd','libmidipp','libevoral','libvamphost',
365                         'libvampplugin','libtaglib','librubberband',
366                         'libaudiographer']
367     obj.vnum         = LIBARDOUR_LIB_VERSION
368     obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
369     obj.defines      = [
370         'PACKAGE="' + I18N_PACKAGE + '"',
371         'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
372         'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
373         'MODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"',
374         'LOCALEDIR="' + os.path.join(
375             os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
376         'VAMP_DIR="' + os.path.join(
377             os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"',
378         'PROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"'
379         ]
380
381     #obj.source += ' st_stretch.cc st_pitch.cc '
382     #obj.uselib += ' SOUNDTOUCH '
383     #obj.add_objects = 'default/libs/surfaces/control_protocol/smpte_1.o'
384
385     if bld.is_defined('HAVE_LILV') :
386         obj.source += ['lv2_plugin.cc', 'lv2_evbuf.c', 'uri_map.cc'] 
387         obj.uselib += ['LILV']
388         if bld.is_defined('HAVE_SUIL'):
389             obj.uselib += ['SUIL']
390
391     if bld.is_defined('WINDOWS_VST_SUPPORT'):
392         obj.source += [ 'windows_vst_plugin.cc']
393         obj.includes += [ '../fst' ]
394         obj.defines += [ 'WINDOWS_VST_SUPPORT' ]
395
396     if bld.is_defined('LXVST_SUPPORT'):
397         obj.source += [ 'lxvst_plugin.cc', 'linux_vst_support.cc', 'linux_vst_info_file.cc' ]
398         obj.defines += [ 'LXVST_SUPPORT' ]
399
400     if bld.is_defined('WINDOWS_VST_SUPPORT') or bld.is_defined('LXVST_SUPPORT'):
401         obj.source += [ 'session_vst.cc', 'vst_plugin.cc' ]
402
403     if bld.is_defined('HAVE_COREAUDIO'):
404         obj.source += [ 'coreaudiosource.cc', 'caimportable.cc' ]
405         obj.use    += ['libappleutility']
406
407     if bld.is_defined('AUDIOUNIT_SUPPORT'):
408         obj.source += [ 'audio_unit.cc' ]
409
410     if Options.options.fpu_optimization:
411         if (bld.env['build_target'] == 'i386'
412             or bld.env['build_target'] == 'i686'):
413             obj.source += [ 'sse_functions_xmm.cc', 'sse_functions.s' ]
414         elif bld.env['build_target'] == 'x86_64':
415             obj.source += [ 'sse_functions_xmm.cc', 'sse_functions_64bit.s' ]
416
417     # i18n
418     if bld.is_defined('ENABLE_NLS'):
419         mo_files = bld.path.ant_glob('po/*.mo')
420         for mo in mo_files:
421             lang = os.path.basename(mo.srcpath()).replace('.mo', '')
422             bld.install_as(os.path.join(bld.env['PREFIX'], 'share', 'locale',
423                                         lang, 'LC_MESSAGES', I18N_PACKAGE + '.mo'),
424                            mo)
425
426     if bld.env['BUILD_TESTS'] and bld.is_defined('HAVE_CPPUNIT'):
427         # Unit tests
428         testobj              = bld(features = 'cxx cxxprogram')
429         testobj.source       = '''
430                 test/dummy_lxvst.cc
431                 test/test_needing_session.cc
432                 test/test_needing_playlist_and_regions.cc
433                 test/bbt_test.cc
434                 test/tempo_test.cc
435                 test/interpolation_test.cc
436                 test/midi_clock_slave_test.cc
437                 test/resampled_source_test.cc
438                 test/framewalk_to_beats_test.cc
439                 test/framepos_plus_beats_test.cc
440                 test/framepos_minus_beats_test.cc
441                 test/playlist_layering_test.cc
442                 test/testrunner.cc
443         '''.split()
444
445 # Tests that don't work
446 #                test/mantis_3356_test.cc
447
448         testobj.includes     = obj.includes + ['test', '../pbd']
449         testobj.uselib       = ['CPPUNIT','SIGCPP','JACK','GLIBMM','GTHREAD',
450                                 'SAMPLERATE','XML','LRDF','COREAUDIO']
451         testobj.use          = ['libpbd','libmidipp','libardour']
452         testobj.name         = 'libardour-tests'
453         testobj.target       = 'run-tests'
454         testobj.install_path = ''
455         testobj.defines      = [
456             'PACKAGE="libardour3test"',
457             'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
458             'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
459             'MODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"',
460             'LOCALEDIR="' + os.path.join(
461                 os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
462             'VAMP_DIR="' + os.path.join(
463                 os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"'
464             ]
465         if bld.env['FPU_OPTIMIZATION']:
466             testobj.source += [ 'sse_functions_xmm.cc' ]
467             if (bld.env['build_target'] == 'i386'
468                 or bld.env['build_target'] == 'i686'):
469                 testobj.source += [ 'sse_functions.s' ]
470             elif bld.env['build_target'] == 'x86_64':
471                 testobj.source += [ 'sse_functions_64bit.s' ]
472
473         # Profiling
474         profilingobj = bld(features = 'cxx cxxprogram')
475         profilingobj.source = '''
476                 test/dummy_lxvst.cc
477                 test/profiling/runpc.cc
478         '''.split()
479
480         profilingobj.includes  = obj.includes
481         profilingobj.uselib    = ['CPPUNIT','SIGCPP','JACK','GLIBMM','GTHREAD',
482                              'SAMPLERATE','XML','LRDF','COREAUDIO']
483         profilingobj.use       = ['libpbd','libmidipp','libardour']
484         profilingobj.name      = 'libardour-profiling'
485         profilingobj.target    = 'run-profiling'
486         profilingobj.install_path = ''
487         profilingobj.defines      = [
488             'PACKAGE="libardour3profile"',
489             'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
490             'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
491             'MODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"',
492             'LOCALEDIR="' + os.path.join(
493                 os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
494             'VAMP_DIR="' + os.path.join(
495                 os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"'
496             ]
497         if bld.env['FPU_OPTIMIZATION']:
498             profilingobj.source += [ 'sse_functions_xmm.cc' ]
499             if (bld.env['build_target'] == 'i386'
500                 or bld.env['build_target'] == 'i686'):
501                 profilingobj.source += [ 'sse_functions.s' ]
502             elif bld.env['build_target'] == 'x86_64':
503                 profilingobj.source += [ 'sse_functions_64bit.s' ]
504
505 def shutdown():
506     autowaf.shutdown()
507
508 def i18n(bld):
509     autowaf.build_i18n(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
510                        'Paul Davis')
511
512 def i18n_pot(bld):
513     autowaf.build_i18n(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
514                        'Paul Davis')
515
516 def i18n_po(bld):
517     autowaf.build_i18n_po(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
518                        'Paul Davis')
519
520 def i18n_mo(bld):
521     autowaf.build_i18n_mo(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
522                        'Paul Davis')