fix for OS X builds with new prototype C warning flags
[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.7', 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
285     # we don't try to detect this, since its part of our source tree
286
287     conf.define('HAVE_RUBBERBAND', 1) # controls whether we think we have it
288     conf.define('USE_RUBBERBAND', 1)  # controls whether we actually use it
289
290     conf.define('CURRENT_SESSION_FILE_VERSION', CURRENT_SESSION_FILE_VERSION)
291
292     conf.check(header_name='sys/vfs.h', define_name='HAVE_SYS_VFS_H',mandatory=False)
293     conf.check(header_name='sys/statvfs.h', define_name='HAVE_SYS_STATVFS_H',mandatory=False)
294
295     conf.check(header_name='jack/session.h', uselib = [ 'JACK' ],
296                define_name='HAVE_JACK_SESSION')
297
298     conf.check(header_name='unistd.h', define_name='HAVE_UNISTD',mandatory=False)
299
300     conf.check_cc(fragment = '''
301 #include <jack/jack.h>
302 void callback(jack_status_t code, const char* reason, void* arg);
303 void callback(jack_status_t code, const char* reason, void* arg) { return; }
304 int main(int argc, char **argv) {
305     jack_client_t* c;
306     jack_on_info_shutdown(c, callback, (void*) 0);
307     return 0;
308 }''',
309                   uselib= [ 'JACK' ],
310                   msg = 'Checking for jack_on_info_shutdown',
311                   define_name = 'HAVE_JACK_ON_INFO_SHUTDOWN',
312                   okmsg = 'present')
313
314     missing_jack_message = 'missing - a version of JACK that supports jack_port_set_latency_range() is required to compile Ardour3.'
315
316     conf.check_cc(fragment = '''
317 #include <jack/jack.h>
318 int main(int argc, char **argv) {
319     jack_port_t* p;
320     jack_latency_range_t r;
321     jack_port_set_latency_range(p, JackCaptureLatency, &r);
322     return 0;
323 }''',
324                   uselib = [ 'JACK' ],
325                   msg = 'Checking for new JACK latency API',
326                   okmsg = 'present',
327                   mandatory = True,
328                   errmsg = missing_jack_message)
329
330     conf.check_cc(fragment = '''
331 #include <jack/jack.h>
332 int main(int argc, char **argv) {
333    jack_port_type_get_buffer_size((jack_client_t*)0, "");
334    return 0;
335 }''',
336                   uselib = [ 'JACK' ],
337                   msg = 'Checking for new jack_port_type_get_buffer_size',
338                   okmsg = 'present',
339                   mandatory = True,
340                   errmsg = missing_jack_message)
341
342     if flac_supported():
343         conf.define ('HAVE_FLAC', 1)
344     if ogg_supported():
345         conf.define ('HAVE_OGG', 1)
346
347     conf.write_config_header('libardour-config.h', remove=False)
348
349     # Boost headers
350     autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp')
351     autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
352     autowaf.check_header(conf, 'cxx', 'boost/scoped_ptr.hpp')
353     autowaf.check_header(conf, 'cxx', 'boost/ptr_container/ptr_list.hpp')
354
355
356 def build(bld):
357     # Library
358     obj              = bld(features = 'c cxx cshlib cxxshlib')
359     obj.source       = libardour_sources
360     obj.export_includes = ['.']
361     obj.includes     = ['.', '../surfaces/control_protocol', '..']
362     obj.name         = 'libardour'
363     obj.target       = 'ardour'
364     obj.uselib       = ['GLIBMM','GTHREAD','AUBIO','SIGCPP','XML','UUID',
365                         'JACK','SNDFILE','SAMPLERATE','LRDF','AUDIOUNITS',
366                         'OSX','BOOST','CURL','DL']
367     obj.use          = ['libpbd','libmidipp','libevoral','libvamphost',
368                         'libvampplugin','libtaglib','librubberband',
369                         'libaudiographer']
370     obj.vnum         = LIBARDOUR_LIB_VERSION
371     obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
372     obj.defines      = [
373         'PACKAGE="' + I18N_PACKAGE + '"',
374         'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
375         'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
376         'LOCALEDIR="' + os.path.join(os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
377         'PROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"'
378         ]
379
380     #obj.source += ' st_stretch.cc st_pitch.cc '
381     #obj.uselib += ' SOUNDTOUCH '
382     #obj.add_objects = 'default/libs/surfaces/control_protocol/smpte_1.o'
383
384     if bld.is_defined('HAVE_LILV') :
385         obj.source += ['lv2_plugin.cc', 'lv2_evbuf.c', 'uri_map.cc'] 
386         obj.uselib += ['LILV']
387         if bld.is_defined('HAVE_SUIL'):
388             obj.uselib += ['SUIL']
389
390     if bld.is_defined('WINDOWS_VST_SUPPORT'):
391         obj.source += [ 'windows_vst_plugin.cc']
392         obj.includes += [ '../fst' ]
393         obj.defines += [ 'WINDOWS_VST_SUPPORT' ]
394
395     if bld.is_defined('LXVST_SUPPORT'):
396         obj.source += [ 'lxvst_plugin.cc', 'linux_vst_support.cc', 'linux_vst_info_file.cc' ]
397         obj.defines += [ 'LXVST_SUPPORT' ]
398
399     if bld.is_defined('WINDOWS_VST_SUPPORT') or bld.is_defined('LXVST_SUPPORT'):
400         obj.source += [ 'session_vst.cc', 'vst_plugin.cc' ]
401
402     if bld.is_defined('HAVE_COREAUDIO'):
403         obj.source += [ 'coreaudiosource.cc', 'caimportable.cc' ]
404         obj.use    += ['libappleutility']
405
406     if bld.is_defined('AUDIOUNIT_SUPPORT'):
407         obj.source += [ 'audio_unit.cc' ]
408
409     if Options.options.fpu_optimization:
410         if (bld.env['build_target'] == 'i386' or bld.env['build_target'] == 'i686'):
411             obj.source += [ 'sse_functions_xmm.cc', 'sse_functions.s' ]
412         elif bld.env['build_target'] == 'x86_64':
413             obj.source += [ 'sse_functions_xmm.cc', 'sse_functions_64bit.s' ]
414
415     # i18n
416     if bld.is_defined('ENABLE_NLS'):
417         mo_files = bld.path.ant_glob('po/*.mo')
418         for mo in mo_files:
419             lang = os.path.basename(mo.srcpath()).replace('.mo', '')
420             bld.install_as(os.path.join(bld.env['PREFIX'], 'share', 'locale',
421                                         lang, 'LC_MESSAGES', I18N_PACKAGE + '.mo'),
422                            mo)
423
424     if bld.env['BUILD_TESTS'] and bld.is_defined('HAVE_CPPUNIT'):
425         # Unit tests
426         testobj              = bld(features = 'cxx cxxprogram')
427         testobj.source       = '''
428                 test/dummy_lxvst.cc
429                 test/test_util.cc
430                 test/test_needing_session.cc
431                 test/audio_region_test.cc
432                 test/test_globals.cc
433                 test/audio_region_read_test.cc
434                 test/automation_list_property_test.cc
435                 test/bbt_test.cc
436                 test/tempo_test.cc
437                 test/interpolation_test.cc
438                 test/midi_clock_slave_test.cc
439                 test/resampled_source_test.cc
440                 test/framewalk_to_beats_test.cc
441                 test/framepos_plus_beats_test.cc
442                 test/framepos_minus_beats_test.cc
443                 test/playlist_layering_test.cc
444                 test/playlist_read_test.cc
445                 test/playlist_equivalent_regions_test.cc
446                 test/control_surfaces_test.cc
447                 test/combine_regions_test.cc
448                 test/region_naming_test.cc
449                 test/load_sessions_test.cc
450                 test/mtdm_test.cc
451                 test/testrunner.cc
452         '''.split()
453
454 # Tests that don't work
455 #                test/mantis_3356_test.cc
456
457         testobj.includes     = obj.includes + ['test', '../pbd']
458         testobj.uselib       = ['CPPUNIT','SIGCPP','JACK','GLIBMM','GTHREAD',
459                                 'SAMPLERATE','XML','LRDF','COREAUDIO']
460         testobj.use          = ['libpbd','libmidipp','libardour']
461         testobj.name         = 'libardour-tests'
462         testobj.target       = 'run-tests'
463         testobj.install_path = ''
464         testobj.defines      = [
465             'PACKAGE="libardour3test"',
466             'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
467             'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
468             'LOCALEDIR="' + os.path.join(
469                 os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
470             'VAMP_DIR="' + os.path.join(
471                 os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"'
472             ]
473         if bld.env['FPU_OPTIMIZATION']:
474             testobj.source += [ 'sse_functions_xmm.cc' ]
475             if (bld.env['build_target'] == 'i386'
476                 or bld.env['build_target'] == 'i686'):
477                 testobj.source += [ 'sse_functions.s' ]
478             elif bld.env['build_target'] == 'x86_64':
479                 testobj.source += [ 'sse_functions_64bit.s' ]
480
481         # Tester to just load a session
482         session_load_tester = bld(features = 'cxx cxxprogram')
483         session_load_tester.source = '''
484                     test/test_util.cc
485                     test/load_session.cc
486                     test/dummy_lxvst.cc
487             '''.split()
488
489         session_load_tester.includes  = obj.includes
490         session_load_tester.includes.append ('test')
491         session_load_tester.uselib    = ['CPPUNIT','SIGCPP','JACK','GLIBMM','GTHREAD',
492                              'SAMPLERATE','XML','LRDF','COREAUDIO']
493         session_load_tester.use       = ['libpbd','libmidipp','libardour']
494         session_load_tester.name      = 'libardour-session-load-tester'
495         session_load_tester.target    = 'load-session'
496         session_load_tester.install_path = ''
497         session_load_tester.defines      = [
498             'PACKAGE="libardour3profile"',
499             'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
500             'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
501             'LOCALEDIR="' + os.path.join(
502                 os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
503             'VAMP_DIR="' + os.path.join(
504                 os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"'
505             ]
506         if bld.env['FPU_OPTIMIZATION']:
507             session_load_tester.source += [ 'sse_functions_xmm.cc' ]
508             if (bld.env['build_target'] == 'i386'
509                 or bld.env['build_target'] == 'i686'):
510                 session_load_tester.source += [ 'sse_functions.s' ]
511             elif bld.env['build_target'] == 'x86_64':
512                 session_load_tester.source += [ 'sse_functions_64bit.s' ]
513
514         # Profiling
515         for p in ['runpc', 'lots_of_regions', 'load_session']:
516             profilingobj = bld(features = 'cxx cxxprogram')
517             profilingobj.source = '''
518                     test/dummy_lxvst.cc
519                     test/test_util.cc
520             '''.split()
521
522             profilingobj.source.append('test/profiling/%s.cc' % p)
523
524             profilingobj.includes  = obj.includes
525             profilingobj.includes.append ('test')
526             profilingobj.uselib    = ['CPPUNIT','SIGCPP','JACK','GLIBMM','GTHREAD',
527                              'SAMPLERATE','XML','LRDF','COREAUDIO']
528             profilingobj.use       = ['libpbd','libmidipp','libardour']
529             profilingobj.name      = 'libardour-profiling'
530             profilingobj.target    = p
531             profilingobj.install_path = ''
532             profilingobj.defines      = [
533                 'PACKAGE="libardour3profile"',
534                 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
535                 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
536                 'LOCALEDIR="' + os.path.join(
537                     os.path.normpath(bld.env['DATADIR']), 'locale') + '"',
538                 'VAMP_DIR="' + os.path.join(
539                     os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"'
540                 ]
541             if bld.env['FPU_OPTIMIZATION']:
542                 profilingobj.source += [ 'sse_functions_xmm.cc' ]
543                 if (bld.env['build_target'] == 'i386'
544                     or bld.env['build_target'] == 'i686'):
545                     profilingobj.source += [ 'sse_functions.s' ]
546                 elif bld.env['build_target'] == 'x86_64':
547                     profilingobj.source += [ 'sse_functions_64bit.s' ]
548
549 def shutdown():
550     autowaf.shutdown()
551
552 def i18n(bld):
553     autowaf.build_i18n(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
554                        'Paul Davis')
555
556 def i18n_pot(bld):
557     autowaf.build_i18n(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
558                        'Paul Davis')
559
560 def i18n_po(bld):
561     autowaf.build_i18n_po(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
562                        'Paul Davis')
563
564 def i18n_mo(bld):
565     autowaf.build_i18n_mo(bld, top, 'libs/ardour', I18N_PACKAGE, libardour_sources,
566                        'Paul Davis')