97ad05cb68710c0815a8cb6d2b51582e2dcf0378
[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 from w18n import build_i18n
9
10 # Version of this package (even if built as a child)
11 MAJOR = '3'
12 MINOR = '0'
13 MICRO = '0'
14 LIBARDOUR_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
15
16 # Library version (UNIX style major, minor, micro)
17 # major increment <=> incompatible changes
18 # minor increment <=> compatible changes (additions)
19 # micro increment <=> no interface changes
20 LIBARDOUR_LIB_VERSION = '3.0.0'
21
22 # default state file version for this build
23 CURRENT_SESSION_FILE_VERSION = 3000
24
25 # Variables for 'waf dist'
26 APPNAME = 'libardour'
27 VERSION = LIBARDOUR_VERSION
28
29 # Mandatory variables
30 srcdir = '.'
31 blddir = 'build'
32
33 path_prefix = 'libs/ardour/'
34
35 libardour_sources = [
36         'amp.cc',
37         'analyser.cc',
38         'audio_buffer.cc',
39         'audio_diskstream.cc',
40         'audio_library.cc',
41         'audio_playlist.cc',
42         'audio_playlist_importer.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_set.cc',
62         'bundle.cc',
63         'butler.cc',
64         'chan_count.cc',
65         'chan_mapping.cc',
66         'configuration.cc',
67         'control_protocol_manager.cc',
68         'control_protocol_search_path.cc',
69         'crossfade.cc',
70         'cycle_timer.cc',
71         'default_click.cc',
72         'debug.cc',
73         'delivery.cc',
74         'directory_names.cc',
75         'diskstream.cc',
76         'element_import_handler.cc',
77         'element_importer.cc',
78         'enums.cc',
79         'event_type_map.cc',
80         'export_channel.cc',
81         'export_channel_configuration.cc',
82         'export_file_io.cc',
83         'export_filename.cc',
84         'export_format_base.cc',
85         'export_format_manager.cc',
86         'export_format_specification.cc',
87         'export_formats.cc',
88         'export_handler.cc',
89         'export_preset.cc',
90         'export_processor.cc',
91         'export_profile_manager.cc',
92         'export_status.cc',
93         'export_timespan.cc',
94         'export_utilities.cc',
95         'file_source.cc',
96         'filename_extensions.cc',
97         'filesystem_paths.cc',
98         'filter.cc',
99         'find_session.cc',
100         'gain.cc',
101         'gdither.cc',
102         'globals.cc',
103         'import.cc',
104         'internal_return.cc',
105         'internal_send.cc',
106         'interpolation.cc',
107         'io.cc',
108         'io_processor.cc',
109         'jack_slave.cc',
110         'ladspa_plugin.cc',
111         'location.cc',
112         'location_importer.cc',
113         'meter.cc',
114         'midi_buffer.cc',
115         'midi_clock_slave.cc',
116         'midi_diskstream.cc',
117         'midi_model.cc',
118         'midi_patch_manager.cc',
119         'midi_playlist.cc',
120         'midi_port.cc',
121         'midi_region.cc',
122         'midi_ring_buffer.cc',
123         'midi_source.cc',
124         'midi_state_tracker.cc',
125         'midi_stretch.cc',
126         'midi_track.cc',
127         'midi_ui.cc',
128         'mix.cc',
129         'mtc_slave.cc',
130         'mtdm.cc',
131         'mute_master.cc',
132         'named_selection.cc',
133         'onset_detector.cc',
134         'panner.cc',
135         'pcm_utils.cc',
136         'pi_controller.cc',
137         'playlist.cc',
138         'playlist_factory.cc',
139         'plugin.cc',
140         'plugin_insert.cc',
141         'plugin_manager.cc',
142         'port.cc',
143         'port_insert.cc',
144         'port_set.cc',
145         'processor.cc',
146         'quantize.cc',
147         'rc_configuration.cc',
148         'recent_sessions.cc',
149         'region.cc',
150         'region_factory.cc',
151         'resampled_source.cc',
152         'return.cc',
153         'reverse.cc',
154         'route.cc',
155         'route_group.cc',
156         'route_group_member.cc',
157         'rb_effect.cc',
158         'send.cc',
159         'session.cc',
160         'session_butler.cc',
161         'session_click.cc',
162         'session_command.cc',
163         'session_configuration.cc',
164         'session_directory.cc',
165         'session_events.cc',
166         'session_export.cc',
167         'session_handle.cc',
168         'session_metadata.cc',
169         'session_midi.cc',
170         'session_playlists.cc',
171         'session_process.cc',
172         'session_rtevents.cc',
173         'session_state.cc',
174         'session_state_utils.cc',
175         'session_time.cc',
176         'session_transport.cc',
177         'session_utils.cc',
178         'slave.cc',
179         'smf_source.cc',
180         'sndfile_helpers.cc',
181         'sndfileimportable.cc',
182         'sndfilesource.cc',
183         'source.cc',
184         'source_factory.cc',
185         'strip_silence.cc',
186         'svn_revision.cc',
187         'tape_file_matcher.cc',
188         'template_utils.cc',
189         'tempo.cc',
190         'tempo_map_importer.cc',
191         'ticker.cc',
192         'track.cc',
193         'transient_detector.cc',
194         'user_bundle.cc',
195         'utils.cc',
196         'version.cc'
197 ]
198
199 def flac_supported():
200         cmd = subprocess.Popen ("sndfile-info testfile.flac", 
201                                 stdout = subprocess.PIPE,
202                                 stderr = subprocess.STDOUT, shell = True)
203         out = cmd.communicate()[0];
204         return re.search ('unknown format', out) == None
205
206 def ogg_supported():
207         cmd = subprocess.Popen ("sndfile-info testfile.ogg", 
208                                 stdout = subprocess.PIPE,
209                                 stderr = subprocess.STDOUT, shell = True)
210         out = cmd.communicate()[0];
211         return re.search ('unknown format', out) == None
212
213 def set_options(opt):
214         autowaf.set_options(opt)
215
216 def configure(conf):
217         autowaf.build_version_files(path_prefix+'ardour/version.h', path_prefix+'version.cc',
218                         'libardour3', MAJOR, MINOR, MICRO)
219         autowaf.configure(conf)
220         conf.check_tool('compiler_cxx gas')
221         autowaf.check_pkg(conf, 'aubio', uselib_store='AUBIO', atleast_version='0.3.2')
222         autowaf.check_pkg(conf, 'jack', uselib_store='JACK', atleast_version='0.109.0')
223         autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
224         autowaf.check_pkg(conf, 'lrdf', uselib_store='LRDF', atleast_version='0.4.0')
225         autowaf.check_pkg(conf, 'samplerate', uselib_store='SAMPLERATE', atleast_version='0.1.0')
226         autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0')
227         autowaf.check_pkg(conf, 'slv2', uselib_store='SLV2', atleast_version='0.6.4', mandatory=False)
228         autowaf.check_pkg(conf, 'sndfile', uselib_store='SNDFILE', atleast_version='1.0.18')
229         autowaf.check_pkg(conf, 'soundtouch-1.0', uselib_store='SOUNDTOUCH', mandatory=False)
230         autowaf.check_pkg(conf, 'cppunit', uselib_store='CPPUNIT', atleast_version='1.12.0', mandatory=False)
231         autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
232         autowaf.check_pkg(conf, 'flac', uselib_store='FLAC', atleast_version='1.2.1')
233
234         # we don't try to detect this, since its part of our source tree
235
236         conf.define('HAVE_RUBBERBAND', 1) # controls whether we think we have it
237         conf.define('USE_RUBBERBAND', 1)  # controls whether we actually use it
238
239         conf.define('CURRENT_SESSION_FILE_VERSION', CURRENT_SESSION_FILE_VERSION)
240
241         conf.check(header_name='sys/vfs.h', define_name='HAVE_SYS_VFS_H')
242         conf.check(header_name='wordexp.h', define_name='HAVE_WORDEXP')
243         
244         if flac_supported():
245                 conf.define ('HAVE_FLAC', 1)
246                 autowaf.display_msg(conf, 'Checking for FLAC support', True)
247         else:
248                 autowaf.display_msg(conf, 'Checking for FLAC support', False)
249         if ogg_supported():
250                 conf.define ('HAVE_OGG', 1)
251                 autowaf.display_msg(conf, 'Checking for Ogg/Vorbis support', True)
252         else:
253                 autowaf.display_msg(conf, 'Checking for Ogg/Vorbis Support', False)
254
255         conf.write_config_header('libardour-config.h')
256
257         # Boost headers
258         autowaf.check_header(conf, 'boost/shared_ptr.hpp')
259         autowaf.check_header(conf, 'boost/weak_ptr.hpp')
260
261
262 def build(bld):
263         # Library
264         obj              = bld.new_task_gen('cxx', 'shlib')
265         obj.source       = libardour_sources
266         obj.export_incdirs = ['.']
267         obj.includes     = ['.', '../surfaces/control_protocol', '..']
268         obj.name         = 'libardour'
269         obj.target       = 'ardour'
270         obj.uselib       = 'GLIBMM GTHREAD AUBIO SIGCPP XML UUID JACK SNDFILE SAMPLERATE LRDF OSX COREAUDIO'
271         obj.uselib_local = 'libpbd libmidipp libevoral libvamphost libvampplugin libtaglib librubberband'
272         obj.vnum         = LIBARDOUR_LIB_VERSION
273         obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
274         obj.cxxflags     = ['-DPACKAGE="libardour3"']
275         obj.cxxflags     += ['-DDATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"']
276         obj.cxxflags     += ['-DCONFIG_DIR="' + os.path.normpath(bld.env['CONFIGDIR']) + '"']
277         obj.cxxflags     += ['-DMODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"']
278         obj.cxxflags     += ['-DLOCALEDIR="' + os.path.join(
279                         os.path.normpath(bld.env['DATADIR']), 'locale') + '"']
280         obj.cxxflags     += ['-DVAMP_DIR="' + os.path.join(
281                         os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"']
282         #obj.source += ' st_stretch.cc st_pitch.cc '
283         #obj.uselib += ' SOUNDTOUCH '
284         #obj.add_objects = 'default/libs/surfaces/control_protocol/smpte_1.o'
285         
286         obj.env.append_value('LINKFLAGS', 'default/libs/surfaces/control_protocol/smpte_1.o')
287         #
288         #       TODO: The above is an ugly hack that shouldn't be needed.  We really need
289         #       to refactor SMPTE out of libardour_cp to get rid of that circular dependency
290         #       alltogether.
291         #
292         if bld.env['HAVE_SLV2']:
293                 obj.source += [ 'lv2_plugin.cc', 'lv2_event_buffer.cc', 'uri_map.cc' ]
294                 obj.uselib += ' SLV2 '
295                 
296         if bld.env['VST']:
297                 obj.source += [ 'vst_plugin.cc', 'session_vst.cc' ]
298
299         if bld.env['HAVE_COREAUDIO'] and bld.env['COREAUDIO']:
300                 obj.source += [ 'coreaudiosource.cc', 'caimportable.cc' ]
301
302         if bld.env['HAVE_AUDIOUNITS'] or bld.env['HAVE_COREAUDIO']:
303                 obj.uselib_local += ' libappleutility'  
304
305         if bld.env['HAVE_AUDIOUNITS'] and bld.env['AUDIOUNITS']:
306                 obj.source += [ 'audio_unit.cc' ]
307
308         if bld.env['FPU_OPTIMIZATION']:
309                 obj.source += [ 'sse_functions_xmm.cc' ]
310                 if bld.env['build_target'] == 'i386' or bld.env['build_target'] == 'i686':
311                         obj.source += [ 'sse_functions.s' ]
312                 elif bld.env['build_target'] == 'x86_64':
313                         obj.source += [ 'sse_functions_64bit.s' ]
314
315         # i18n
316         if bld.env['ENABLE_NLS']:
317                 mo_files = glob.glob (os.path.join (bld.get_curdir(), 'po/*.mo'))
318                 for mo in mo_files:
319                         lang = os.path.basename (mo).replace ('.mo', '')
320                         bld.install_as (os.path.join (bld.env['PREFIX'], 'share', 'locale', lang, 'LC_MESSAGES', APPNAME + '.mo'), mo)
321
322         if bld.env['BUILD_TESTS'] and bld.env['HAVE_CPPUNIT']:
323                 # Unit tests
324                 testobj              = bld.new_task_gen('cxx', 'program')
325                 testobj.source       = '''
326                         test/BBTTest.cpp
327                         test/InterpolationTest.cpp
328                         test/testrunner.cpp
329                 '''.split()
330                 testobj.includes     = obj.includes + ['../pbd/']
331                 testobj.uselib       = 'CPPUNIT SIGCPP JACK GLIBMM GTHREAD SAMPLERATE XML LRDF COREAUDIO'
332                 testobj.uselib_local = 'libpbd libmidipp libardour'
333                 testobj.name         = 'libardour-tests'
334                 testobj.target       = 'run-tests'
335                 testobj.install_path = ''
336                 testobj.cxxflags     = ['-DPACKAGE="libardour3test"']
337                 testobj.cxxflags     += ['-DDATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"']
338                 testobj.cxxflags     += ['-DCONFIG_DIR="' + os.path.normpath(bld.env['CONFIGDIR']) + '"']
339                 testobj.cxxflags     += ['-DMODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"']
340                 testobj.cxxflags     += ['-DLOCALEDIR="' + os.path.join(
341                                 os.path.normpath(bld.env['DATADIR']), 'locale') + '"']
342                 testobj.cxxflags     += ['-DVAMP_DIR="' + os.path.join(
343                                 os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"']
344                 if bld.env['FPU_OPTIMIZATION']:
345                         testobj.source += [ 'sse_functions_xmm.cc' ]
346                         if bld.env['build_target'] == 'i386' or bld.env['build_target'] == 'i686':
347                                 testobj.source += [ 'sse_functions.s' ]
348                         elif bld.env['build_target'] == 'x86_64':
349                                 testobj.source += [ 'sse_functions_64bit.s' ]
350
351 def shutdown():
352         autowaf.shutdown()
353
354 def i18n(bld):
355         build_i18n (bld, 'libs/ardour', APPNAME, libardour_sources)