skeleton framework for LTC-slave
[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 = 3001
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         'automation_watch.cc',
59         'beats_frames_converter.cc',
60         'broadcast_info.cc',
61         'buffer.cc',
62         'buffer_manager.cc',
63         'buffer_set.cc',
64         'bundle.cc',
65         'butler.cc',
66         'callback.cc',
67         'capturing_processor.cc',
68         'chan_count.cc',
69         'chan_mapping.cc',
70         'configuration.cc',
71         'config_text.cc',
72         'control_protocol_manager.cc',
73         'control_protocol_search_path.cc',
74         'cycle_timer.cc',
75         'data_type.cc',
76         'default_click.cc',
77         'debug.cc',
78         'delivery.cc',
79         'directory_names.cc',
80         'diskstream.cc',
81         'element_import_handler.cc',
82         'element_importer.cc',
83         'enums.cc',
84         'event_type_map.cc',
85         'export_channel.cc',
86         'export_channel_configuration.cc',
87         'export_failed.cc',
88         'export_filename.cc',
89         'export_format_base.cc',
90         'export_format_manager.cc',
91         'export_format_specification.cc',
92         'export_formats.cc',
93         'export_formats_search_path.cc',
94         'export_graph_builder.cc',
95         'export_handler.cc',
96         'export_preset.cc',
97         'export_profile_manager.cc',
98         'export_status.cc',
99         'export_timespan.cc',
100         'file_source.cc',
101         'filename_extensions.cc',
102         'filesystem_paths.cc',
103         'filter.cc',
104         'find_session.cc',
105         'globals.cc',
106         'graph.cc',
107         'graphnode.cc',
108         'import.cc',
109         'instrument_info.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         'onset_detector.cc',
143         'operations.cc',
144         'pan_controllable.cc',
145         'pannable.cc',
146         'panner.cc',
147         'panner_manager.cc',
148         'panner_search_path.cc',
149         'panner_shell.cc',
150         'pcm_utils.cc',
151         'pi_controller.cc',
152         'playlist.cc',
153         'playlist_factory.cc',
154         'playlist_source.cc',
155         'plugin.cc',
156         'plugin_insert.cc',
157         'plugin_manager.cc',
158         'port.cc',
159         'port_insert.cc',
160         'port_set.cc',
161         'process_thread.cc',
162         'processor.cc',
163         'progress.cc',
164         'quantize.cc',
165         'rc_configuration.cc',
166         'recent_sessions.cc',
167         'region_factory.cc',
168         'resampled_source.cc',
169         'region.cc',
170         'return.cc',
171         'reverse.cc',
172         'route.cc',
173         'route_graph.cc',
174         'route_group.cc',
175         'route_group_member.cc',
176         'rb_effect.cc',
177         'send.cc',
178         'session.cc',
179         'session_butler.cc',
180         'session_click.cc',
181         'session_command.cc',
182         'session_configuration.cc',
183         'session_directory.cc',
184         'session_events.cc',
185         'session_export.cc',
186         'session_handle.cc',
187         'session_metadata.cc',
188         'session_midi.cc',
189         'session_object.cc',
190         'session_playlists.cc',
191         'session_process.cc',
192         'session_rtevents.cc',
193         'session_state.cc',
194         'session_state_utils.cc',
195         'session_time.cc',
196         'session_transport.cc',
197         'slave.cc',
198         'smf_source.cc',
199         'sndfile_helpers.cc',
200         'sndfileimportable.cc',
201         'sndfilesource.cc',
202         'source.cc',
203         'source_factory.cc',
204         'speakers.cc',
205         'strip_silence.cc',
206         'svn_revision.cc',
207         'tape_file_matcher.cc',
208         'template_utils.cc',
209         'tempo.cc',
210         'tempo_map_importer.cc',
211         'thread_buffers.cc',
212         'ticker.cc',
213         'track.cc',
214         'transient_detector.cc',
215         'unknown_processor.cc',
216         'user_bundle.cc',
217         'utils.cc',
218         'version.cc',
219         'worker.cc',
220 ]
221
222 def flac_supported():
223     cmd = subprocess.Popen ("sndfile-info testfile.flac",
224                             stdout = subprocess.PIPE,
225                             stderr = subprocess.STDOUT, shell = True)
226     out = cmd.communicate()[0].decode('utf-8');
227     return re.search ('unknown format', out) == None
228
229 def ogg_supported():
230     cmd = subprocess.Popen ("sndfile-info testfile.ogg",
231                             stdout = subprocess.PIPE,
232                             stderr = subprocess.STDOUT, shell = True)
233     out = cmd.communicate()[0].decode('utf-8');
234     return re.search ('unknown format', out) == None
235
236 def options(opt):
237     autowaf.set_options(opt)
238
239 def configure(conf):
240     conf.load('compiler_cxx')
241     conf.load('gas')
242     autowaf.build_version_files(
243         path_prefix + 'ardour/version.h',
244         path_prefix + 'version.cc',
245         'libardour3', MAJOR, MINOR, MICRO)
246     autowaf.configure(conf)
247     autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO',
248                       atleast_version='0.3.2')
249     autowaf.check_pkg(conf, 'jack', uselib_store='JACK',
250                       atleast_version='0.118.2')
251     autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
252     autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF',
253                       atleast_version='0.4.0')
254     autowaf.check_pkg(conf, 'samplerate', uselib_store='SAMPLERATE',
255                       atleast_version='0.1.0')
256     autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP',
257                       atleast_version='2.0')
258     if Options.options.lv2:
259         autowaf.check_pkg(conf, 'lv2', uselib_store='LV2',
260                           atleast_version='1.0.0', mandatory=True)
261         autowaf.check_pkg(conf, 'lv2', uselib_store='NEW_LV2',
262                           atleast_version='1.0.15', mandatory=False)
263         autowaf.check_pkg(conf, 'serd-0', uselib_store='SERD',
264                           atleast_version='0.14.0', mandatory=True)
265         autowaf.check_pkg(conf, 'sord-0', uselib_store='SORD',
266                           atleast_version='0.8.0', mandatory=True)
267         autowaf.check_pkg(conf, 'sratom-0', uselib_store='SRATOM',
268                           atleast_version='0.2.0', mandatory=True)
269         autowaf.check_pkg(conf, 'lilv-0', uselib_store='LILV',
270                           atleast_version='0.14.0', mandatory=True)
271         autowaf.check_pkg(conf, 'suil-0', uselib_store='SUIL',
272                           atleast_version='0.6.0', mandatory=False)
273         conf.define ('LV2_SUPPORT', 1)
274
275 #    autowaf.check_pkg(conf, 'soundtouch-1.0', uselib_store='SOUNDTOUCH',
276 #                      mandatory=False)
277     autowaf.check_pkg(conf, 'cppunit', uselib_store='CPPUNIT',
278                       atleast_version='1.12.0', mandatory=False)
279     autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
280     autowaf.check_pkg(conf, 'flac', uselib_store='FLAC',
281                       atleast_version='1.2.1')
282     autowaf.check_pkg(conf, 'libcurl', uselib_store='CURL',
283                       atleast_version='7.0.0')
284     autowaf.check_pkg(conf, 'ltc', uselib_store='LTC',
285                       atleast_version='0.3.2', mandatory=False)
286
287     # we don't try to detect this, since its part of our source tree
288
289     conf.define('HAVE_RUBBERBAND', 1) # controls whether we think we have it
290     conf.define('USE_RUBBERBAND', 1)  # controls whether we actually use it
291
292     conf.define('CURRENT_SESSION_FILE_VERSION', CURRENT_SESSION_FILE_VERSION)
293
294     conf.check(header_name='sys/vfs.h', define_name='HAVE_SYS_VFS_H',mandatory=False)
295     conf.check(header_name='sys/statvfs.h', define_name='HAVE_SYS_STATVFS_H',mandatory=False)
296
297     conf.check(header_name='jack/session.h', uselib = [ 'JACK' ],
298                define_name='HAVE_JACK_SESSION')
299
300     conf.check(header_name='unistd.h', define_name='HAVE_UNISTD',mandatory=False)
301
302     conf.check_cc(fragment = '''
303 #include <jack/jack.h>
304 void callback(jack_status_t code, const char* reason, void* arg) { return; }
305 int main(int argc, char **argv) {
306     jack_client_t* c;
307     jack_on_info_shutdown(c, callback, (void*) 0);
308     return 0;
309 }''',
310                   uselib= [ 'JACK' ],
311                   msg = 'Checking for jack_on_info_shutdown',
312                   define_name = 'HAVE_JACK_ON_INFO_SHUTDOWN',
313                   okmsg = 'present')
314
315     missing_jack_message = 'missing - a version of JACK that supports jack_port_set_latency_range() is required to compile Ardour3.'
316
317     conf.check_cc(fragment = '''
318 #include <jack/jack.h>
319 int main(int argc, char **argv) {
320     jack_port_t* p;
321     jack_latency_range_t r;
322     jack_port_set_latency_range(p, JackCaptureLatency, &r);
323     return 0;
324 }''',
325                   uselib = [ 'JACK' ],
326                   msg = 'Checking for new JACK latency API',
327                   okmsg = 'present',
328                   mandatory = True,
329                   errmsg = missing_jack_message)
330
331     conf.check_cc(fragment = '''
332 #include <jack/jack.h>
333 int main(int argc, char **argv) {
334    jack_port_type_get_buffer_size((jack_client_t*)0, "");
335    return 0;
336 }''',
337                   uselib = [ 'JACK' ],
338                   msg = 'Checking for new jack_port_type_get_buffer_size',
339                   okmsg = 'present',
340                   mandatory = True,
341                   errmsg = missing_jack_message)
342
343     if flac_supported():
344         conf.define ('HAVE_FLAC', 1)
345     if ogg_supported():
346         conf.define ('HAVE_OGG', 1)
347
348     conf.write_config_header('libardour-config.h', remove=False)
349
350     # Boost headers
351     autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp')
352     autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
353     autowaf.check_header(conf, 'cxx', 'boost/scoped_ptr.hpp')
354     autowaf.check_header(conf, 'cxx', 'boost/ptr_container/ptr_list.hpp')
355
356
357 def build(bld):
358     # Library
359     obj              = bld(features = 'c cxx cshlib cxxshlib')
360     obj.source       = libardour_sources
361     obj.export_includes = ['.']
362     obj.includes     = ['.', '../surfaces/control_protocol', '..']
363     obj.name         = 'libardour'
364     obj.target       = 'ardour'
365     obj.uselib       = ['GLIBMM','GTHREAD','AUBIO','SIGCPP','XML','UUID',
366                         'JACK','SNDFILE','SAMPLERATE','LRDF','AUDIOUNITS',
367                         'OSX','BOOST','CURL','DL']
368     obj.use          = ['libpbd','libmidipp','libevoral','libvamphost',
369                         'libvampplugin','libtaglib','librubberband',
370                         'libaudiographer']
371     obj.vnum         = LIBARDOUR_LIB_VERSION
372     obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
373     obj.defines      = [
374         'PACKAGE="' + I18N_PACKAGE + '"',
375         'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
376         'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
377         'LOCALEDIR="' + os.path.join(os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
378         'PROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"',
379         'EVORAL_MIDI_XML=1' 
380         ]
381
382     #obj.source += ' st_stretch.cc st_pitch.cc '
383     #obj.uselib += ' SOUNDTOUCH '
384     #obj.add_objects = 'default/libs/surfaces/control_protocol/smpte_1.o'
385
386     if bld.is_defined('HAVE_LTC') :
387         obj.source += ['ltc_slave.cc']
388         obj.uselib += ['LTC']
389
390     if bld.is_defined('HAVE_LILV') :
391         obj.source += ['lv2_plugin.cc', 'lv2_evbuf.c', 'uri_map.cc'] 
392         obj.uselib += ['LILV']
393         if bld.is_defined('HAVE_SUIL'):
394             obj.uselib += ['SUIL']
395
396     if bld.is_defined('WINDOWS_VST_SUPPORT'):
397         obj.source += [ 'windows_vst_plugin.cc']
398         obj.includes += [ '../fst' ]
399         obj.defines += [ 'WINDOWS_VST_SUPPORT' ]
400
401     if bld.is_defined('LXVST_SUPPORT'):
402         obj.source += [ 'lxvst_plugin.cc', 'linux_vst_support.cc', 'linux_vst_info_file.cc' ]
403         obj.defines += [ 'LXVST_SUPPORT' ]
404
405     if bld.is_defined('WINDOWS_VST_SUPPORT') or bld.is_defined('LXVST_SUPPORT'):
406         obj.source += [ 'session_vst.cc', 'vst_plugin.cc' ]
407
408     if bld.is_defined('HAVE_COREAUDIO'):
409         obj.source += [ 'coreaudiosource.cc', 'caimportable.cc' ]
410         obj.use    += ['libappleutility']
411
412     if bld.is_defined('AUDIOUNIT_SUPPORT'):
413         obj.source += [ 'audio_unit.cc' ]
414
415     if Options.options.fpu_optimization:
416         if (bld.env['build_target'] == 'i386' or bld.env['build_target'] == 'i686'):
417             obj.source += [ 'sse_functions_xmm.cc', 'sse_functions.s' ]
418         elif bld.env['build_target'] == 'x86_64':
419             obj.source += [ 'sse_functions_xmm.cc', 'sse_functions_64bit.s' ]
420
421     # i18n
422     if bld.is_defined('ENABLE_NLS'):
423         mo_files = bld.path.ant_glob('po/*.mo')
424         for mo in mo_files:
425             lang = os.path.basename(mo.srcpath()).replace('.mo', '')
426             bld.install_as(os.path.join(bld.env['PREFIX'], 'share', 'locale',
427                                         lang, 'LC_MESSAGES', I18N_PACKAGE + '.mo'),
428                            mo)
429
430     if bld.env['BUILD_TESTS'] and bld.is_defined('HAVE_CPPUNIT'):
431         # Unit tests
432         testobj              = bld(features = 'cxx cxxprogram')
433         testobj.source       = '''
434                 test/dummy_lxvst.cc
435                 test/test_util.cc
436                 test/test_needing_session.cc
437                 test/audio_region_test.cc
438                 test/test_globals.cc
439                 test/audio_region_read_test.cc
440                 test/automation_list_property_test.cc
441                 test/bbt_test.cc
442                 test/tempo_test.cc
443                 test/interpolation_test.cc
444                 test/midi_clock_slave_test.cc
445                 test/resampled_source_test.cc
446                 test/framewalk_to_beats_test.cc
447                 test/framepos_plus_beats_test.cc
448                 test/framepos_minus_beats_test.cc
449                 test/playlist_layering_test.cc
450                 test/playlist_read_test.cc
451                 test/playlist_equivalent_regions_test.cc
452                 test/control_surfaces_test.cc
453                 test/combine_regions_test.cc
454                 test/region_naming_test.cc
455                 test/load_sessions_test.cc
456                 test/mtdm_test.cc
457                 test/testrunner.cc
458         '''.split()
459
460 # Tests that don't work
461 #                test/mantis_3356_test.cc
462
463         testobj.includes     = obj.includes + ['test', '../pbd']
464         testobj.uselib       = ['CPPUNIT','SIGCPP','JACK','GLIBMM','GTHREAD',
465                                 'SAMPLERATE','XML','LRDF','COREAUDIO']
466         testobj.use          = ['libpbd','libmidipp','libardour']
467         testobj.name         = 'libardour-tests'
468         testobj.target       = 'run-tests'
469         testobj.install_path = ''
470         testobj.defines      = [
471             'PACKAGE="libardour3test"',
472             'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
473             'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
474             'LOCALEDIR="' + os.path.join(
475                 os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
476             'VAMP_DIR="' + os.path.join(
477                 os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"'
478             ]
479         if bld.env['FPU_OPTIMIZATION']:
480             testobj.source += [ 'sse_functions_xmm.cc' ]
481             if (bld.env['build_target'] == 'i386'
482                 or bld.env['build_target'] == 'i686'):
483                 testobj.source += [ 'sse_functions.s' ]
484             elif bld.env['build_target'] == 'x86_64':
485                 testobj.source += [ 'sse_functions_64bit.s' ]
486
487         # Tester to just load a session
488         session_load_tester = bld(features = 'cxx cxxprogram')
489         session_load_tester.source = '''
490                     test/test_util.cc
491                     test/load_session.cc
492                     test/dummy_lxvst.cc
493             '''.split()
494
495         session_load_tester.includes  = obj.includes
496         session_load_tester.includes.append ('test')
497         session_load_tester.uselib    = ['CPPUNIT','SIGCPP','JACK','GLIBMM','GTHREAD',
498                              'SAMPLERATE','XML','LRDF','COREAUDIO']
499         session_load_tester.use       = ['libpbd','libmidipp','libardour']
500         session_load_tester.name      = 'libardour-session-load-tester'
501         session_load_tester.target    = 'load-session'
502         session_load_tester.install_path = ''
503         session_load_tester.defines      = [
504             'PACKAGE="libardour3profile"',
505             'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
506             'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
507             'LOCALEDIR="' + os.path.join(
508                 os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
509             'VAMP_DIR="' + os.path.join(
510                 os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"'
511             ]
512         if bld.env['FPU_OPTIMIZATION']:
513             session_load_tester.source += [ 'sse_functions_xmm.cc' ]
514             if (bld.env['build_target'] == 'i386'
515                 or bld.env['build_target'] == 'i686'):
516                 session_load_tester.source += [ 'sse_functions.s' ]
517             elif bld.env['build_target'] == 'x86_64':
518                 session_load_tester.source += [ 'sse_functions_64bit.s' ]
519
520         # Profiling
521         for p in ['runpc', 'lots_of_regions', 'load_session']:
522             profilingobj = bld(features = 'cxx cxxprogram')
523             profilingobj.source = '''
524                     test/dummy_lxvst.cc
525                     test/test_util.cc
526             '''.split()
527
528             profilingobj.source.append('test/profiling/%s.cc' % p)
529
530             profilingobj.includes  = obj.includes
531             profilingobj.includes.append ('test')
532             profilingobj.uselib    = ['CPPUNIT','SIGCPP','JACK','GLIBMM','GTHREAD',
533                              'SAMPLERATE','XML','LRDF','COREAUDIO']
534             profilingobj.use       = ['libpbd','libmidipp','libardour']
535             profilingobj.name      = 'libardour-profiling'
536             profilingobj.target    = p
537             profilingobj.install_path = ''
538             profilingobj.defines      = [
539                 'PACKAGE="libardour3profile"',
540                 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
541                 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
542                 'LOCALEDIR="' + os.path.join(
543                     os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
544                 'VAMP_DIR="' + os.path.join(
545                     os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"'
546                 ]
547             if bld.env['FPU_OPTIMIZATION']:
548                 profilingobj.source += [ 'sse_functions_xmm.cc' ]
549                 if (bld.env['build_target'] == 'i386'
550                     or bld.env['build_target'] == 'i686'):
551                     profilingobj.source += [ 'sse_functions.s' ]
552                 elif bld.env['build_target'] == 'x86_64':
553                     profilingobj.source += [ 'sse_functions_64bit.s' ]
554
555 def shutdown():
556     autowaf.shutdown()
557
558 def i18n(bld):
559     autowaf.build_i18n(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
560                        'Paul Davis')
561
562 def i18n_pot(bld):
563     autowaf.build_i18n(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
564                        'Paul Davis')
565
566 def i18n_po(bld):
567     autowaf.build_i18n_po(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
568                        'Paul Davis')
569
570 def i18n_mo(bld):
571     autowaf.build_i18n_mo(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
572                        'Paul Davis')