779ab26d738dd68333509426e1381d396e6d24ce
[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_port.cc',
43         'audio_region_importer.cc',
44         'audio_track.cc',
45         'audio_track_importer.cc',
46         'audioanalyser.cc',
47         'audioengine.cc',
48         'audiofile_tagger.cc',
49         'audiofilesource.cc',
50         'audioregion.cc',
51         'audiosource.cc',
52         'auditioner.cc',
53         'automatable.cc',
54         'automation.cc',
55         'automation_control.cc',
56         'automation_list.cc',
57         'beats_frames_converter.cc',
58         'broadcast_info.cc',
59         'buffer.cc',
60         'buffer_manager.cc',
61         'buffer_set.cc',
62         'bundle.cc',
63         'butler.cc',
64         'callback.cc',
65         'capturing_processor.cc',
66         'chan_count.cc',
67         'chan_mapping.cc',
68         'configuration.cc',
69         'config_text.cc',
70         'control_protocol_manager.cc',
71         'control_protocol_search_path.cc',
72         'crossfade.cc',
73         'cycle_timer.cc',
74         'default_click.cc',
75         'debug.cc',
76         'delivery.cc',
77         'directory_names.cc',
78         'diskstream.cc',
79         'element_import_handler.cc',
80         'element_importer.cc',
81         'enums.cc',
82         'event_type_map.cc',
83         'export_channel.cc',
84         'export_channel_configuration.cc',
85         'export_failed.cc',
86         'export_filename.cc',
87         'export_format_base.cc',
88         'export_format_manager.cc',
89         'export_format_specification.cc',
90         'export_formats.cc',
91         'export_graph_builder.cc',
92         'export_handler.cc',
93         'export_preset.cc',
94         'export_profile_manager.cc',
95         'export_status.cc',
96         'export_timespan.cc',
97         'file_source.cc',
98         'filename_extensions.cc',
99         'filesystem_paths.cc',
100         'filter.cc',
101         'find_session.cc',
102         'gain.cc',
103         'globals.cc',
104         'graph.cc',
105         'graphnode.cc',
106         'import.cc',
107         'internal_return.cc',
108         'internal_send.cc',
109         'interpolation.cc',
110         'io.cc',
111         'io_processor.cc',
112         'jack_slave.cc',
113         'ladspa_plugin.cc',
114         'location.cc',
115         'location_importer.cc',
116         'meter.cc',
117         'midi_automation_list_binder.cc',
118         'midi_buffer.cc',
119         'midi_clock_slave.cc',
120         'midi_diskstream.cc',
121         'midi_model.cc',
122         'midi_patch_manager.cc',
123         'midi_playlist.cc',
124         'midi_port.cc',
125         'midi_region.cc',
126         'midi_ring_buffer.cc',
127         'midi_source.cc',
128         'midi_state_tracker.cc',
129         'midi_stretch.cc',
130         'midi_track.cc',
131         'midi_ui.cc',
132         'mix.cc',
133         'monitor_processor.cc',
134         'mtc_slave.cc',
135         'mtdm.cc',
136         'mute_master.cc',
137         'named_selection.cc',
138         'onset_detector.cc',
139         'panner.cc',
140         'pcm_utils.cc',
141         'pi_controller.cc',
142         'playlist.cc',
143         'playlist_factory.cc',
144         'plugin.cc',
145         'plugin_insert.cc',
146         'plugin_manager.cc',
147         'port.cc',
148         'port_insert.cc',
149         'port_set.cc',
150         'process_thread.cc',
151         'processor.cc',
152         'progress.cc',
153         'quantize.cc',
154         'rc_configuration.cc',
155         'recent_sessions.cc',
156         'region_factory.cc',
157         'resampled_source.cc',
158         'region.cc',
159         'return.cc',
160         'reverse.cc',
161         'route.cc',
162         'route_group.cc',
163         'route_group_member.cc',
164         'rb_effect.cc',
165         'send.cc',
166         'session.cc',
167         'session_butler.cc',
168         'session_click.cc',
169         'session_command.cc',
170         'session_configuration.cc',
171         'session_directory.cc',
172         'session_events.cc',
173         'session_export.cc',
174         'session_handle.cc',
175         'session_metadata.cc',
176         'session_midi.cc',
177         'session_object.cc',
178         'session_playlists.cc',
179         'session_process.cc',
180         'session_rtevents.cc',
181         'session_state.cc',
182         'session_state_utils.cc',
183         'session_time.cc',
184         'session_transport.cc',
185         'session_utils.cc',
186         'slave.cc',
187         'smf_source.cc',
188         'sndfile_helpers.cc',
189         'sndfileimportable.cc',
190         'sndfilesource.cc',
191         'source.cc',
192         'source_factory.cc',
193         'speakers.cc',
194         'strip_silence.cc',
195         'svn_revision.cc',
196         'tape_file_matcher.cc',
197         'template_utils.cc',
198         'tempo.cc',
199         'tempo_map_importer.cc',
200         'thread_buffers.cc',
201         'ticker.cc',
202         'track.cc',
203         'transient_detector.cc',
204         'unknown_processor.cc',
205         'user_bundle.cc',
206         'utils.cc',
207         'vbap.cc',
208         'vbap_speakers.cc',
209         'version.cc'
210 ]
211
212 def flac_supported():
213         cmd = subprocess.Popen ("sndfile-info testfile.flac", 
214                                 stdout = subprocess.PIPE,
215                                 stderr = subprocess.STDOUT, shell = True)
216         out = cmd.communicate()[0].decode('utf-8');
217         return re.search ('unknown format', out) == None
218
219 def ogg_supported():
220         cmd = subprocess.Popen ("sndfile-info testfile.ogg", 
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 set_options(opt):
227         autowaf.set_options(opt)
228
229 def configure(conf):
230         autowaf.build_version_files(path_prefix+'ardour/version.h', path_prefix+'version.cc',
231                         'libardour3', MAJOR, MINOR, MICRO)
232         autowaf.configure(conf)
233         conf.check_tool('compiler_cxx gas')
234         autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO', atleast_version='0.3.2')
235         autowaf.check_pkg(conf, 'jack', uselib_store='JACK', atleast_version='0.118.2')
236         autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
237         autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF', atleast_version='0.4.0')
238         autowaf.check_pkg(conf, 'samplerate', uselib_store='SAMPLERATE', atleast_version='0.1.0')
239         autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0')
240         autowaf.check_pkg(conf, 'slv2', uselib_store='SLV2', atleast_version='0.6.4', mandatory=False)
241         autowaf.check_pkg(conf, 'rasqal', uselib_store='RASQAL', atleast_version='0.9.14', mandatory=False)
242         autowaf.check_pkg(conf, 'soundtouch-1.0', uselib_store='SOUNDTOUCH', mandatory=False)
243         autowaf.check_pkg(conf, 'cppunit', uselib_store='CPPUNIT', atleast_version='1.12.0', mandatory=False)
244         autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
245         autowaf.check_pkg(conf, 'flac', uselib_store='FLAC', atleast_version='1.2.1')
246
247         # we don't try to detect this, since its part of our source tree
248
249         conf.define('HAVE_RUBBERBAND', 1) # controls whether we think we have it
250         conf.define('USE_RUBBERBAND', 1)  # controls whether we actually use it
251
252         conf.define('CURRENT_SESSION_FILE_VERSION', CURRENT_SESSION_FILE_VERSION)
253
254         conf.check(header_name='sys/vfs.h', define_name='HAVE_SYS_VFS_H')
255         conf.check(header_name='wordexp.h', define_name='HAVE_WORDEXP')
256
257         conf.check(header_name='jack/session.h', define_name='HAVE_JACK_SESSION')
258
259         conf.check(header_name='unistd.h', define_name='HAVE_UNISTD')
260         
261         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",
262                       linkflags = ['-ljack'],
263                       msg = 'Checking for jack_on_info_shutdown',
264                       define_name = 'HAVE_JACK_ON_INFO_SHUTDOWN',
265                       okmsg = 'ok')
266                       
267         if flac_supported():
268                 conf.define ('HAVE_FLAC', 1)
269         if ogg_supported():
270                 conf.define ('HAVE_OGG', 1)
271
272         conf.write_config_header('libardour-config.h')
273
274         # Boost headers
275         autowaf.check_header(conf, 'boost/shared_ptr.hpp')
276         autowaf.check_header(conf, 'boost/weak_ptr.hpp')
277         autowaf.check_header(conf, 'boost/scoped_ptr.hpp')
278         autowaf.check_header(conf, 'boost/ptr_container/ptr_list.hpp')
279
280
281 def build(bld):
282         # Library
283         obj              = bld.new_task_gen('cxx', 'shlib')
284         obj.source       = libardour_sources
285         obj.export_incdirs = ['.']
286         obj.includes     = ['.', '../surfaces/control_protocol', '..']
287         obj.name         = 'libardour'
288         obj.target       = 'ardour'
289         obj.uselib       = 'GLIBMM GTHREAD AUBIO SIGCPP XML UUID JACK SNDFILE SAMPLERATE LRDF AUDIOUNIT OSX BOOST CURL DL'
290         obj.uselib_local = 'libpbd libmidipp libevoral libvamphost libvampplugin libtaglib librubberband libaudiographer'
291         obj.vnum         = LIBARDOUR_LIB_VERSION
292         obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
293         obj.cxxflags     = ['-DPACKAGE="libardour3"']
294         obj.cxxflags     += ['-DDATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"']
295         obj.cxxflags     += ['-DCONFIG_DIR="' + os.path.normpath(bld.env['CONFIGDIR']) + '"']
296         obj.cxxflags     += ['-DMODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"']
297         obj.cxxflags     += ['-DLOCALEDIR="' + os.path.join(
298                         os.path.normpath(bld.env['DATADIR']), 'locale') + '"']
299         obj.cxxflags     += ['-DVAMP_DIR="' + os.path.join(
300                         os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"']
301         obj.cxxflags     += ['-DPROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"']
302
303         #obj.source += ' st_stretch.cc st_pitch.cc '
304         #obj.uselib += ' SOUNDTOUCH '
305         #obj.add_objects = 'default/libs/surfaces/control_protocol/smpte_1.o'
306         
307         if bld.env['HAVE_SLV2']:
308                 obj.source += [ 'lv2_plugin.cc', 'lv2_event_buffer.cc', 'uri_map.cc', 'lv2_pfile.c' ]
309                 obj.uselib += ' SLV2 ' + ' RASQAL '
310                 
311         if bld.env['VST_SUPPORT']:
312                 obj.source += [ 'vst_plugin.cc', 'session_vst.cc' ]
313                 obj.includes += [ '../fst' ]
314                 obj.cxxflags += [ '-DVST_SUPPORT' ]
315
316         if bld.env['COREAUDIO']:
317                 obj.source += [ 'coreaudiosource.cc', 'caimportable.cc' ]
318                 obj.uselib_local += ' libappleutility'  
319                 obj.source += [ 'audio_unit.cc' ]
320
321         if bld.env['FPU_OPTIMIZATION']:
322                 if bld.env['build_target'] == 'i386' or bld.env['build_target'] == 'i686':
323                         obj.source += [ 'sse_functions_xmm.cc', 'sse_functions.s' ]
324                 elif bld.env['build_target'] == 'x86_64':
325                         obj.source += [ 'sse_functions_xmm.cc', 'sse_functions_64bit.s' ]
326
327         # i18n
328         if bld.env['ENABLE_NLS']:
329                 mo_files = glob.glob (os.path.join (bld.get_curdir(), 'po/*.mo'))
330                 for mo in mo_files:
331                         lang = os.path.basename (mo).replace ('.mo', '')
332                         bld.install_as (os.path.join (bld.env['PREFIX'], 'share', 'locale', lang, 'LC_MESSAGES', APPNAME + '.mo'), mo)
333
334         if bld.env['BUILD_TESTS'] and bld.env['HAVE_CPPUNIT']:
335                 # Unit tests
336                 testobj              = bld.new_task_gen('cxx', 'program')
337                 testobj.source       = '''
338                         test/bbt_test.cpp
339                         test/interpolation_test.cpp
340                         test/midi_clock_slave_test.cpp
341                         test/resampled_source.cc
342                         test/mantis_3356.cc
343                         test/testrunner.cpp
344                 '''.split()
345                 testobj.includes     = obj.includes + ['test', '../pbd']
346                 testobj.uselib       = 'CPPUNIT SIGCPP JACK GLIBMM GTHREAD SAMPLERATE XML LRDF COREAUDIO'
347                 testobj.uselib_local = 'libpbd libmidipp libardour'
348                 testobj.name         = 'libardour-tests'
349                 testobj.target       = 'run-tests'
350                 testobj.install_path = ''
351                 testobj.cxxflags     = ['-DPACKAGE="libardour3test"']
352                 testobj.cxxflags     += ['-DDATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"']
353                 testobj.cxxflags     += ['-DCONFIG_DIR="' + os.path.normpath(bld.env['CONFIGDIR']) + '"']
354                 testobj.cxxflags     += ['-DMODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"']
355                 testobj.cxxflags     += ['-DLOCALEDIR="' + os.path.join(
356                                 os.path.normpath(bld.env['DATADIR']), 'locale') + '"']
357                 testobj.cxxflags     += ['-DVAMP_DIR="' + os.path.join(
358                                 os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"']
359                 if bld.env['FPU_OPTIMIZATION']:
360                         testobj.source += [ 'sse_functions_xmm.cc' ]
361                         if bld.env['build_target'] == 'i386' or bld.env['build_target'] == 'i686':
362                                 testobj.source += [ 'sse_functions.s' ]
363                         elif bld.env['build_target'] == 'x86_64':
364                                 testobj.source += [ 'sse_functions_64bit.s' ]
365
366 def shutdown():
367         autowaf.shutdown()
368
369 def i18n(bld):
370         autowaf.build_i18n (bld, '..', 'libs/ardour', APPNAME, libardour_sources)