df46d8cc86cbf9678dece12a06439a5c06610c35
[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         '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         'cycle_timer.cc',
74         'data_type.cc',
75         'default_click.cc',
76         'debug.cc',
77         'delivery.cc',
78         'directory_names.cc',
79         'diskstream.cc',
80         'element_import_handler.cc',
81         'element_importer.cc',
82         'enums.cc',
83         'event_type_map.cc',
84         'export_channel.cc',
85         'export_channel_configuration.cc',
86         'export_failed.cc',
87         'export_filename.cc',
88         'export_format_base.cc',
89         'export_format_manager.cc',
90         'export_format_specification.cc',
91         'export_formats.cc',
92         'export_formats_search_path.cc',
93         'export_graph_builder.cc',
94         'export_handler.cc',
95         'export_preset.cc',
96         'export_profile_manager.cc',
97         'export_status.cc',
98         'export_timespan.cc',
99         'file_source.cc',
100         'filename_extensions.cc',
101         'filesystem_paths.cc',
102         'filter.cc',
103         'find_session.cc',
104         'globals.cc',
105         'graph.cc',
106         'graphnode.cc',
107         'import.cc',
108         'internal_return.cc',
109         'internal_send.cc',
110         'interpolation.cc',
111         'io.cc',
112         'io_processor.cc',
113         'jack_slave.cc',
114         'ladspa_plugin.cc',
115         'location.cc',
116         'location_importer.cc',
117         'meter.cc',
118         'midi_automation_list_binder.cc',
119         'midi_buffer.cc',
120         'midi_clock_slave.cc',
121         'midi_diskstream.cc',
122         'midi_model.cc',
123         'midi_patch_manager.cc',
124         'midi_patch_search_path.cc',
125         'midi_playlist.cc',
126         'midi_playlist_source.cc',
127         'midi_port.cc',
128         'midi_region.cc',
129         'midi_ring_buffer.cc',
130         'midi_source.cc',
131         'midi_state_tracker.cc',
132         'midi_stretch.cc',
133         'midi_track.cc',
134         'midi_ui.cc',
135         'mix.cc',
136         'monitor_processor.cc',
137         'mtc_slave.cc',
138         'mtdm.cc',
139         'mute_master.cc',
140         'named_selection.cc',
141         'onset_detector.cc',
142         'operations.cc',
143         'pan_controllable.cc',
144         'pannable.cc',
145         'panner.cc',
146         'panner_manager.cc',
147         'panner_search_path.cc',
148         'panner_shell.cc',
149         'pcm_utils.cc',
150         'pi_controller.cc',
151         'playlist.cc',
152         'playlist_factory.cc',
153         'playlist_source.cc',
154         'plugin.cc',
155         'plugin_insert.cc',
156         'plugin_manager.cc',
157         'port.cc',
158         'port_insert.cc',
159         'port_set.cc',
160         'process_thread.cc',
161         'processor.cc',
162         'progress.cc',
163         'quantize.cc',
164         'rc_configuration.cc',
165         'recent_sessions.cc',
166         'region_factory.cc',
167         'resampled_source.cc',
168         'region.cc',
169         'return.cc',
170         'reverse.cc',
171         'route.cc',
172         'route_graph.cc',
173         'route_group.cc',
174         'route_group_member.cc',
175         'rb_effect.cc',
176         'send.cc',
177         'session.cc',
178         'session_butler.cc',
179         'session_click.cc',
180         'session_command.cc',
181         'session_configuration.cc',
182         'session_directory.cc',
183         'session_events.cc',
184         'session_export.cc',
185         'session_handle.cc',
186         'session_metadata.cc',
187         'session_midi.cc',
188         'session_object.cc',
189         'session_playlists.cc',
190         'session_process.cc',
191         'session_rtevents.cc',
192         'session_state.cc',
193         'session_state_utils.cc',
194         'session_time.cc',
195         'session_transport.cc',
196         'session_utils.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, 'lilv-0', uselib_store='LILV',
260                           atleast_version='0.14.0', mandatory=False)
261         if conf.is_defined('HAVE_LILV'):
262             autowaf.check_pkg(conf, 'suil-0', uselib_store='SUIL',
263                               atleast_version='0.6.0', mandatory=False)
264
265 #    autowaf.check_pkg(conf, 'soundtouch-1.0', uselib_store='SOUNDTOUCH',
266 #                      mandatory=False)
267     autowaf.check_pkg(conf, 'cppunit', uselib_store='CPPUNIT',
268                       atleast_version='1.12.0', mandatory=False)
269     autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
270     autowaf.check_pkg(conf, 'flac', uselib_store='FLAC',
271                       atleast_version='1.2.1')
272     autowaf.check_pkg(conf, 'libcurl', uselib_store='CURL',
273                       atleast_version='7.0.0')
274
275     # we don't try to detect this, since its part of our source tree
276
277     conf.define('HAVE_RUBBERBAND', 1) # controls whether we think we have it
278     conf.define('USE_RUBBERBAND', 1)  # controls whether we actually use it
279
280     conf.define('CURRENT_SESSION_FILE_VERSION', CURRENT_SESSION_FILE_VERSION)
281
282     conf.check(header_name='sys/vfs.h', define_name='HAVE_SYS_VFS_H',mandatory=False)
283
284     conf.check(header_name='jack/session.h', uselib = [ 'JACK' ],
285                define_name='HAVE_JACK_SESSION')
286
287     conf.check(header_name='unistd.h', define_name='HAVE_UNISTD',mandatory=False)
288
289     conf.check_cc(fragment = '''
290 #include <jack/jack.h>
291 void callback(jack_status_t code, const char* reason, void* arg) { return; }
292 int main(int argc, char **argv) {
293     jack_client_t* c;
294     jack_on_info_shutdown(c, callback, (void*) 0);
295     return 0;
296 }''',
297                   uselib= [ 'JACK' ],
298                   msg = 'Checking for jack_on_info_shutdown',
299                   define_name = 'HAVE_JACK_ON_INFO_SHUTDOWN',
300                   okmsg = 'present')
301
302     missing_jack_message = 'missing - a version of JACK that supports jack_port_set_latency_range() is required to compile Ardour3.'
303
304     conf.check_cc(fragment = '''
305 #include <jack/jack.h>
306 int main(int argc, char **argv) {
307     jack_port_t* p;
308     jack_latency_range_t r;
309     jack_port_set_latency_range(p, JackCaptureLatency, &r);
310     return 0;
311 }''',
312                   uselib = [ 'JACK' ],
313                   msg = 'Checking for new JACK latency API',
314                   okmsg = 'present',
315                   mandatory = True,
316                   errmsg = missing_jack_message)
317
318     conf.check_cc(fragment = '''
319 #include <jack/jack.h>
320 int main(int argc, char **argv) {
321    jack_port_type_get_buffer_size((jack_client_t*)0, "");
322    return 0;
323 }''',
324                   uselib = [ 'JACK' ],
325                   msg = 'Checking for new jack_port_type_get_buffer_size',
326                   okmsg = 'present',
327                   mandatory = True,
328                   errmsg = missing_jack_message)
329
330     if flac_supported():
331         conf.define ('HAVE_FLAC', 1)
332     if ogg_supported():
333         conf.define ('HAVE_OGG', 1)
334
335     if Options.options.lv2 and conf.is_defined('HAVE_LILV'):
336         conf.define ('LV2_SUPPORT', 1)
337
338     conf.write_config_header('libardour-config.h', remove=False)
339
340     # Boost headers
341     autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp')
342     autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
343     autowaf.check_header(conf, 'cxx', 'boost/scoped_ptr.hpp')
344     autowaf.check_header(conf, 'cxx', 'boost/ptr_container/ptr_list.hpp')
345
346
347 def build(bld):
348     # Library
349     obj              = bld(features = 'c cxx cshlib cxxshlib')
350     obj.source       = libardour_sources
351     obj.export_includes = ['.']
352     obj.includes     = ['.', '../surfaces/control_protocol', '..']
353     obj.name         = 'libardour'
354     obj.target       = 'ardour'
355     obj.uselib       = ['GLIBMM','GTHREAD','AUBIO','SIGCPP','XML','UUID',
356                         'JACK','SNDFILE','SAMPLERATE','LRDF','AUDIOUNITS',
357                         'OSX','BOOST','CURL','DL']
358     obj.use          = ['libpbd','libmidipp','libevoral','libvamphost',
359                         'libvampplugin','libtaglib','librubberband',
360                         'libaudiographer']
361     obj.vnum         = LIBARDOUR_LIB_VERSION
362     obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
363     obj.defines      = [
364         'PACKAGE="' + I18N_PACKAGE + '"',
365         'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
366         'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
367         'MODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"',
368         'LOCALEDIR="' + os.path.join(
369             os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
370         'VAMP_DIR="' + os.path.join(
371             os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"',
372         'PROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"'
373         ]
374
375     #obj.source += ' st_stretch.cc st_pitch.cc '
376     #obj.uselib += ' SOUNDTOUCH '
377     #obj.add_objects = 'default/libs/surfaces/control_protocol/smpte_1.o'
378
379     if bld.is_defined('HAVE_LILV') :
380         obj.source += ['lv2_plugin.cc', 'lv2_evbuf.c', 'uri_map.cc'] 
381         obj.uselib += ['LILV']
382         if bld.is_defined('HAVE_SUIL'):
383             obj.uselib += ['SUIL']
384
385     if bld.is_defined('WINDOWS_VST_SUPPORT'):
386         obj.source += [ 'windows_vst_plugin.cc']
387         obj.includes += [ '../fst' ]
388         obj.defines += [ 'WINDOWS_VST_SUPPORT' ]
389
390     if bld.is_defined('LXVST_SUPPORT'):
391         obj.source += [ 'lxvst_plugin.cc', 'linux_vst_support.cc', 'linux_vst_info_file.cc' ]
392         obj.defines += [ 'LXVST_SUPPORT' ]
393
394     if bld.is_defined('WINDOWS_VST_SUPPORT') or bld.is_defined('LXVST_SUPPORT'):
395         obj.source += [ 'session_vst.cc', 'vst_plugin.cc' ]
396
397     if bld.is_defined('HAVE_COREAUDIO'):
398         obj.source += [ 'coreaudiosource.cc', 'caimportable.cc' ]
399         obj.use    += ['libappleutility']
400
401     if bld.is_defined('AUDIOUNIT_SUPPORT'):
402         obj.source += [ 'audio_unit.cc' ]
403
404     if Options.options.fpu_optimization:
405         if (bld.env['build_target'] == 'i386' or bld.env['build_target'] == 'i686'):
406             obj.source += [ 'sse_functions_xmm.cc', 'sse_functions.s' ]
407         elif bld.env['build_target'] == 'x86_64':
408             obj.source += [ 'sse_functions_xmm.cc', 'sse_functions_64bit.s' ]
409
410     # i18n
411     if bld.is_defined('ENABLE_NLS'):
412         mo_files = bld.path.ant_glob('po/*.mo')
413         for mo in mo_files:
414             lang = os.path.basename(mo.srcpath()).replace('.mo', '')
415             bld.install_as(os.path.join(bld.env['PREFIX'], 'share', 'locale',
416                                         lang, 'LC_MESSAGES', I18N_PACKAGE + '.mo'),
417                            mo)
418
419     if bld.env['BUILD_TESTS'] and bld.is_defined('HAVE_CPPUNIT'):
420         # Unit tests
421         testobj              = bld(features = 'cxx cxxprogram')
422         testobj.source       = '''
423                 test/dummy_lxvst.cc
424                 test/test_needing_session.cc
425                 test/test_needing_playlist_and_regions.cc
426                 test/test_globals.cc
427                 test/audio_region_test.cc
428                 test/bbt_test.cc
429                 test/tempo_test.cc
430                 test/interpolation_test.cc
431                 test/midi_clock_slave_test.cc
432                 test/resampled_source_test.cc
433                 test/framewalk_to_beats_test.cc
434                 test/framepos_plus_beats_test.cc
435                 test/framepos_minus_beats_test.cc
436                 test/playlist_layering_test.cc
437                 test/playlist_read_test.cc
438                 test/control_surfaces_test.cc
439                 test/testrunner.cc
440         '''.split()
441
442 # Tests that don't work
443 #                test/mantis_3356_test.cc
444
445         testobj.includes     = obj.includes + ['test', '../pbd']
446         testobj.uselib       = ['CPPUNIT','SIGCPP','JACK','GLIBMM','GTHREAD',
447                                 'SAMPLERATE','XML','LRDF','COREAUDIO']
448         testobj.use          = ['libpbd','libmidipp','libardour']
449         testobj.name         = 'libardour-tests'
450         testobj.target       = 'run-tests'
451         testobj.install_path = ''
452         testobj.defines      = [
453             'PACKAGE="libardour3test"',
454             'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
455             'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
456             'MODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"',
457             'LOCALEDIR="' + os.path.join(
458                 os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
459             'VAMP_DIR="' + os.path.join(
460                 os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"'
461             ]
462         if bld.env['FPU_OPTIMIZATION']:
463             testobj.source += [ 'sse_functions_xmm.cc' ]
464             if (bld.env['build_target'] == 'i386'
465                 or bld.env['build_target'] == 'i686'):
466                 testobj.source += [ 'sse_functions.s' ]
467             elif bld.env['build_target'] == 'x86_64':
468                 testobj.source += [ 'sse_functions_64bit.s' ]
469
470         # Profiling
471         profilingobj = bld(features = 'cxx cxxprogram')
472         profilingobj.source = '''
473                 test/dummy_lxvst.cc
474                 test/profiling/runpc.cc
475         '''.split()
476
477         profilingobj.includes  = obj.includes
478         profilingobj.uselib    = ['CPPUNIT','SIGCPP','JACK','GLIBMM','GTHREAD',
479                              'SAMPLERATE','XML','LRDF','COREAUDIO']
480         profilingobj.use       = ['libpbd','libmidipp','libardour']
481         profilingobj.name      = 'libardour-profiling'
482         profilingobj.target    = 'run-profiling'
483         profilingobj.install_path = ''
484         profilingobj.defines      = [
485             'PACKAGE="libardour3profile"',
486             'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
487             'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
488             'MODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"',
489             'LOCALEDIR="' + os.path.join(
490                 os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
491             'VAMP_DIR="' + os.path.join(
492                 os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"'
493             ]
494         if bld.env['FPU_OPTIMIZATION']:
495             profilingobj.source += [ 'sse_functions_xmm.cc' ]
496             if (bld.env['build_target'] == 'i386'
497                 or bld.env['build_target'] == 'i686'):
498                 profilingobj.source += [ 'sse_functions.s' ]
499             elif bld.env['build_target'] == 'x86_64':
500                 profilingobj.source += [ 'sse_functions_64bit.s' ]
501
502 def shutdown():
503     autowaf.shutdown()
504
505 def i18n(bld):
506     autowaf.build_i18n(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
507                        'Paul Davis')
508
509 def i18n_pot(bld):
510     autowaf.build_i18n(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
511                        'Paul Davis')
512
513 def i18n_po(bld):
514     autowaf.build_i18n_po(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
515                        'Paul Davis')
516
517 def i18n_mo(bld):
518     autowaf.build_i18n_mo(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
519                        'Paul Davis')