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