Use LV2_SUPPORT define instead of HAVE_SLV2.
[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_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         '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         'gain.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_playlist.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         'plugin.cc',
154         'plugin_insert.cc',
155         'plugin_manager.cc',
156         'port.cc',
157         'port_insert.cc',
158         'port_set.cc',
159         'process_thread.cc',
160         'processor.cc',
161         'progress.cc',
162         'quantize.cc',
163         'rc_configuration.cc',
164         'recent_sessions.cc',
165         'region_factory.cc',
166         'resampled_source.cc',
167         'region.cc',
168         'return.cc',
169         'reverse.cc',
170         'route.cc',
171         'route_group.cc',
172         'route_group_member.cc',
173         'rb_effect.cc',
174         'send.cc',
175         'session.cc',
176         'session_butler.cc',
177         'session_click.cc',
178         'session_command.cc',
179         'session_configuration.cc',
180         'session_directory.cc',
181         'session_events.cc',
182         'session_export.cc',
183         'session_handle.cc',
184         'session_metadata.cc',
185         'session_midi.cc',
186         'session_object.cc',
187         'session_playlists.cc',
188         'session_process.cc',
189         'session_rtevents.cc',
190         'session_state.cc',
191         'session_state_utils.cc',
192         'session_time.cc',
193         'session_transport.cc',
194         'session_utils.cc',
195         'slave.cc',
196         'smf_source.cc',
197         'sndfile_helpers.cc',
198         'sndfileimportable.cc',
199         'sndfilesource.cc',
200         'source.cc',
201         'source_factory.cc',
202         'speakers.cc',
203         'strip_silence.cc',
204         'svn_revision.cc',
205         'tape_file_matcher.cc',
206         'template_utils.cc',
207         'tempo.cc',
208         'tempo_map_importer.cc',
209         'thread_buffers.cc',
210         'ticker.cc',
211         'track.cc',
212         'transient_detector.cc',
213         'unknown_processor.cc',
214         'user_bundle.cc',
215         'utils.cc',
216         'version.cc'
217 ]
218
219 def flac_supported():
220     cmd = subprocess.Popen ("sndfile-info testfile.flac",
221                             stdout = subprocess.PIPE,
222                             stderr = subprocess.STDOUT, shell = True)
223     out = cmd.communicate()[0].decode('utf-8');
224     return re.search ('unknown format', out) == None
225
226 def ogg_supported():
227     cmd = subprocess.Popen ("sndfile-info testfile.ogg",
228                             stdout = subprocess.PIPE,
229                             stderr = subprocess.STDOUT, shell = True)
230     out = cmd.communicate()[0].decode('utf-8');
231     return re.search ('unknown format', out) == None
232
233 def set_options(opt):
234     autowaf.set_options(opt)
235
236 def configure(conf):
237     autowaf.build_version_files(path_prefix+'ardour/version.h', path_prefix+'version.cc',
238                     'libardour3', MAJOR, MINOR, MICRO)
239     autowaf.configure(conf)
240     conf.check_tool('compiler_cxx gas')
241     autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO', atleast_version='0.3.2')
242     autowaf.check_pkg(conf, 'jack', uselib_store='JACK', atleast_version='0.118.2')
243     autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
244     autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF', atleast_version='0.4.0')
245     autowaf.check_pkg(conf, 'samplerate', uselib_store='SAMPLERATE', atleast_version='0.1.0')
246     autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0')
247     autowaf.check_pkg(conf, 'slv2', uselib_store='SLV2', atleast_version='0.6.4', mandatory=False)
248     autowaf.check_pkg(conf, 'slv2', uselib_store='NEW_SLV2', atleast_version='0.7.0', mandatory=False)
249     autowaf.check_pkg(conf, 'suil', uselib_store='SUIL', atleast_version='0.1.0', mandatory=False)
250     autowaf.check_pkg(conf, 'rasqal', uselib_store='RASQAL', atleast_version='0.9.14', mandatory=False)
251     autowaf.check_pkg(conf, 'soundtouch-1.0', uselib_store='SOUNDTOUCH', mandatory=False)
252     autowaf.check_pkg(conf, 'cppunit', uselib_store='CPPUNIT', atleast_version='1.12.0', mandatory=False)
253     autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
254     autowaf.check_pkg(conf, 'flac', uselib_store='FLAC', atleast_version='1.2.1')
255     autowaf.check_pkg(conf, 'libcurl', uselib_store='CURL', atleast_version='7.0.0')
256
257     # we don't try to detect this, since its part of our source tree
258
259     conf.define('HAVE_RUBBERBAND', 1) # controls whether we think we have it
260     conf.define('USE_RUBBERBAND', 1)  # controls whether we actually use it
261
262     conf.define('CURRENT_SESSION_FILE_VERSION', CURRENT_SESSION_FILE_VERSION)
263
264     conf.check(header_name='sys/vfs.h', define_name='HAVE_SYS_VFS_H')
265     conf.check(header_name='wordexp.h', define_name='HAVE_WORDEXP')
266
267     conf.check(header_name='jack/session.h', uselib = [ 'JACK' ], define_name='HAVE_JACK_SESSION')
268
269     conf.check(header_name='unistd.h', define_name='HAVE_UNISTD')
270
271     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",
272                   uselib= [ 'JACK' ],
273                   msg = 'Checking for jack_on_info_shutdown',
274                   define_name = 'HAVE_JACK_ON_INFO_SHUTDOWN',
275                   okmsg = 'present')
276
277     missing_jack_message = 'missing - a version of JACK that supports jack_port_set_latency_range() is required to compile Ardour3\nCurrently this means using JACK version 0.120.1 from http://www.jackaudio.org/download\n'
278
279     conf.check_cc(fragment = "#include <jack/jack.h>\nint main(int argc, char **argv) { jack_port_t* p; jack_latency_range_t r; jack_port_set_latency_range (p, JackCaptureLatency, &r); return 0; }\n",
280                   uselib = [ 'JACK' ],
281                   msg = 'Checking for new JACK latency API',
282                   okmsg = 'present',
283                   mandatory = True,
284                   errmsg = missing_jack_message)
285
286     conf.check_cc(fragment = '#include <jack/jack.h>\nint main(int argc, char **argv) { jack_port_type_get_buffer_size ((jack_client_t*)0, ""); }\n',
287                   uselib = [ 'JACK' ],
288                   msg = 'Checking for new jack_port_type_get_buffer_size',
289                   okmsg = 'present',
290                   mandatory = True,
291                   errmsg = missing_jack_message)
292
293     if flac_supported():
294         conf.define ('HAVE_FLAC', 1)
295     if ogg_supported():
296         conf.define ('HAVE_OGG', 1)
297
298     if conf.env['HAVE_SLV2']:
299         conf.define ('LV2_SUPPORT', 1)
300     
301     conf.write_config_header('libardour-config.h')
302
303     # Boost headers
304     autowaf.check_header(conf, 'boost/shared_ptr.hpp')
305     autowaf.check_header(conf, 'boost/weak_ptr.hpp')
306     autowaf.check_header(conf, 'boost/scoped_ptr.hpp')
307     autowaf.check_header(conf, 'boost/ptr_container/ptr_list.hpp')
308
309
310 def build(bld):
311     # Library
312     obj              = bld.new_task_gen('cxx', 'shlib')
313     obj.source       = libardour_sources
314     obj.export_incdirs = ['.']
315     obj.includes     = ['.', '../surfaces/control_protocol', '..']
316     obj.name         = 'libardour'
317     obj.target       = 'ardour'
318     obj.uselib       = 'GLIBMM GTHREAD AUBIO SIGCPP XML UUID JACK SNDFILE SAMPLERATE LRDF AUDIOUNIT OSX BOOST CURL DL'
319     obj.uselib_local = 'libpbd libmidipp libevoral libvamphost libvampplugin libtaglib librubberband libaudiographer'
320     obj.vnum         = LIBARDOUR_LIB_VERSION
321     obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
322     obj.cxxflags     = ['-DPACKAGE="libardour3"']
323     obj.cxxflags     += ['-DDATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"']
324     obj.cxxflags     += ['-DCONFIG_DIR="' + os.path.normpath(bld.env['CONFIGDIR']) + '"']
325     obj.cxxflags     += ['-DMODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"']
326     obj.cxxflags     += ['-DLOCALEDIR="' + os.path.join(
327                     os.path.normpath(bld.env['DATADIR']), 'locale') + '"']
328     obj.cxxflags     += ['-DVAMP_DIR="' + os.path.join(
329                     os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"']
330     obj.cxxflags     += ['-DPROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"']
331
332     #obj.source += ' st_stretch.cc st_pitch.cc '
333     #obj.uselib += ' SOUNDTOUCH '
334     #obj.add_objects = 'default/libs/surfaces/control_protocol/smpte_1.o'
335
336     if bld.env['HAVE_SLV2']:
337         obj.source += [ 'lv2_plugin.cc', 'lv2_event_buffer.cc', 'uri_map.cc', 'rdff.c' ]
338         obj.uselib += ' SLV2 ' + ' RASQAL '
339         if bld.env['HAVE_SUIL']:
340             obj.uselib += ' SUIL '
341
342     if bld.env['VST_SUPPORT']:
343         obj.source += [ 'vst_plugin.cc', 'session_vst.cc' ]
344         obj.includes += [ '../fst' ]
345         obj.cxxflags += [ '-DVST_SUPPORT' ]
346
347     if bld.env['COREAUDIO']:
348         obj.source += [ 'coreaudiosource.cc', 'caimportable.cc' ]
349         obj.uselib_local += ' libappleutility'
350         obj.source += [ 'audio_unit.cc' ]
351
352     if bld.env['FPU_OPTIMIZATION']:
353         if bld.env['build_target'] == 'i386' or bld.env['build_target'] == 'i686':
354             obj.source += [ 'sse_functions_xmm.cc', 'sse_functions.s' ]
355         elif bld.env['build_target'] == 'x86_64':
356             obj.source += [ 'sse_functions_xmm.cc', 'sse_functions_64bit.s' ]
357
358     # i18n
359     if bld.env['ENABLE_NLS']:
360         mo_files = glob.glob (os.path.join (bld.get_curdir(), 'po/*.mo'))
361         for mo in mo_files:
362             lang = os.path.basename (mo).replace ('.mo', '')
363             bld.install_as (os.path.join (bld.env['PREFIX'], 'share', 'locale', lang, 'LC_MESSAGES', APPNAME + '.mo'), mo)
364
365     if bld.env['BUILD_TESTS'] and bld.env['HAVE_CPPUNIT']:
366         # Unit tests
367         testobj              = bld.new_task_gen('cxx', 'program')
368         testobj.source       = '''
369                 test/bbt_test.cpp
370                 test/interpolation_test.cpp
371                 test/midi_clock_slave_test.cpp
372                 test/resampled_source.cc
373                 test/mantis_3356.cc
374                 test/testrunner.cpp
375         '''.split()
376         testobj.includes     = obj.includes + ['test', '../pbd']
377         testobj.uselib       = 'CPPUNIT SIGCPP JACK GLIBMM GTHREAD SAMPLERATE XML LRDF COREAUDIO'
378         testobj.uselib_local = 'libpbd libmidipp libardour'
379         testobj.name         = 'libardour-tests'
380         testobj.target       = 'run-tests'
381         testobj.install_path = ''
382         testobj.cxxflags     = ['-DPACKAGE="libardour3test"']
383         testobj.cxxflags     += ['-DDATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"']
384         testobj.cxxflags     += ['-DCONFIG_DIR="' + os.path.normpath(bld.env['CONFIGDIR']) + '"']
385         testobj.cxxflags     += ['-DMODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"']
386         testobj.cxxflags     += ['-DLOCALEDIR="' + os.path.join(
387                         os.path.normpath(bld.env['DATADIR']), 'locale') + '"']
388         testobj.cxxflags     += ['-DVAMP_DIR="' + os.path.join(
389                         os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"']
390         if bld.env['FPU_OPTIMIZATION']:
391             testobj.source += [ 'sse_functions_xmm.cc' ]
392             if bld.env['build_target'] == 'i386' or bld.env['build_target'] == 'i686':
393                 testobj.source += [ 'sse_functions.s' ]
394             elif bld.env['build_target'] == 'x86_64':
395                 testobj.source += [ 'sse_functions_64bit.s' ]
396
397 def shutdown():
398     autowaf.shutdown()
399
400 def i18n(bld):
401     autowaf.build_i18n (bld, '..', 'libs/ardour', APPNAME, libardour_sources)