use CoreSelection for track selection
[ardour.git] / gtk2_ardour / wscript
1 #!/usr/bin/env python
2 from waflib.extras import autowaf as autowaf
3 from waflib import Options, TaskGen
4 import waflib.Logs as Logs, waflib.Utils as Utils
5 import os
6 import shutil
7 import sys
8 import re
9 import time
10 from waflib.Task import Task
11 from waflib.Tools import winres
12 import subprocess
13 import glob
14 import copy
15
16 # Mandatory variables
17 top = '.'
18 out = 'build'
19
20 from waflib import TaskGen
21 @TaskGen.extension('.m')
22 def m_hook(self, node):
23         """Alias .m files to be compiled the same as .c files, gcc will do the right thing."""
24         return self.create_compiled_task('c', node)
25
26 path_prefix = 'gtk2_ardour/'
27
28 gtk2_ardour_sources = [
29         'about.cc',
30         'actions.cc',
31         'add_route_dialog.cc',
32         'ambiguous_file_dialog.cc',
33         'analysis_window.cc',
34         'ardour_button.cc',
35         'ardour_dialog.cc',
36         'ardour_display.cc',
37         'ardour_dropdown.cc',
38         'ardour_http.cc',
39         'ardour_knob.cc',
40         'ardour_spinner.cc',
41         'ardour_ui.cc',
42         'ardour_ui2.cc',
43         'ardour_ui_dependents.cc',
44         'ardour_ui_dialogs.cc',
45         'ardour_ui_ed.cc',
46         'ardour_ui_mixer.cc',
47         'ardour_ui_options.cc',
48         'ardour_window.cc',
49         'audio_clock.cc',
50         'audio_region_editor.cc',
51         'audio_region_view.cc',
52         'audio_streamview.cc',
53         'audio_time_axis.cc',
54         'automation_controller.cc',
55         'automation_line.cc',
56         'automation_region_view.cc',
57         'automation_streamview.cc',
58         'automation_time_axis.cc',
59         'axis_view.cc',
60         'big_clock_window.cc',
61         'bundle_manager.cc',
62         'button_joiner.cc',
63         'clock_group.cc',
64         'color_theme_manager.cc',
65         'configinfo.cc',
66         'control_point.cc',
67         'control_point_dialog.cc',
68         'control_slave_ui.cc',
69         'cursor_context.cc',
70         'curvetest.cc',
71         'debug.cc',
72         'duplicate_routes_dialog.cc',
73         'edit_note_dialog.cc',
74         'editing.cc',
75         'editor.cc',
76         'editor_actions.cc',
77         'editor_audio_import.cc',
78         'editor_pt_import.cc',
79         'editor_audiotrack.cc',
80         'editor_canvas.cc',
81         'editor_canvas_events.cc',
82         'editor_component.cc',
83         'editor_cursors.cc',
84         'editor_drag.cc',
85         'editor_route_groups.cc',
86         'editor_export_audio.cc',
87         'editor_group_tabs.cc',
88         'editor_keys.cc',
89         'editor_locations.cc',
90         'editor_markers.cc',
91         'editor_mixer.cc',
92         'editor_mouse.cc',
93         'editor_ops.cc',
94         'editor_regions.cc',
95         'editor_routes.cc',
96         'editor_rulers.cc',
97         'editor_selection.cc',
98         'editor_snapshots.cc',
99         'editor_summary.cc',
100         'editor_tempodisplay.cc',
101         'editor_timefx.cc',
102         'engine_dialog.cc',
103         'enums.cc',
104         'export_channel_selector.cc',
105         'export_dialog.cc',
106         'export_file_notebook.cc',
107         'export_filename_selector.cc',
108         'export_format_dialog.cc',
109         'export_format_selector.cc',
110         'export_preset_selector.cc',
111         'export_report.cc',
112         'export_timespan_selector.cc',
113         'fft.cc',
114         'fft_graph.cc',
115         'fft_result.cc',
116         'floating_text_entry.cc',
117         'sfdb_freesound_mootcher.cc',
118         'gain_meter.cc',
119         'generic_pluginui.cc',
120         'ghostregion.cc',
121         'global_port_matrix.cc',
122         'group_tabs.cc',
123         'gtk_pianokeyboard.c',
124         'gui_object.cc',
125         'idleometer.cc',
126         'insert_remove_time_dialog.cc',
127         'instrument_selector.cc',
128         'interthread_progress_window.cc',
129         'io_selector.cc',
130         'hit.cc',
131         'keyboard.cc',
132         'keyeditor.cc',
133         'latency_gui.cc',
134         'led.cc',
135         'level_meter.cc',
136         'location_ui.cc',
137         'lua_script_manager.cc',
138         'luadialog.cc',
139         'luainstance.cc',
140         'luawindow.cc',
141         'main.cc',
142         'main_clock.cc',
143         'marker.cc',
144         'midi_automation_line.cc',
145         'midi_channel_dialog.cc',
146         'midi_channel_selector.cc',
147         'midi_cut_buffer.cc',
148         'midi_export_dialog.cc',
149         'midi_list_editor.cc',
150         'midi_region_view.cc',
151         'midi_scroomer.cc',
152         'midi_selection.cc',
153         'midi_streamview.cc',
154         'midi_time_axis.cc',
155         'midi_tracer.cc',
156         'midi_velocity_dialog.cc',
157         'mini_timeline.cc',
158         'missing_file_dialog.cc',
159         'missing_plugin_dialog.cc',
160         'mixer_group_tabs.cc',
161         'mixer_strip.cc',
162         'mixer_ui.cc',
163         'meterbridge.cc',
164         'meter_strip.cc',
165         'meter_patterns.cc',
166         'monitor_section.cc',
167         'monitor_selector.cc',
168         'mono_panner.cc',
169         'mono_panner_editor.cc',
170         'mouse_cursors.cc',
171         'nag.cc',
172         'new_plugin_preset_dialog.cc',
173         'normalize_dialog.cc',
174         'note.cc',
175         'note_base.cc',
176         'note_player.cc',
177         'note_select_dialog.cc',
178         'nsm.cc',
179         'nsmclient.cc',
180         'option_editor.cc',
181         'opts.cc',
182         'panner2d.cc',
183         'panner_editor.cc',
184         'panner_interface.cc',
185         'panner_ui.cc',
186         'patch_change.cc',
187         'piano_roll_header.cc',
188         'pingback.cc',
189         'playlist_selector.cc',
190         'plugin_eq_gui.cc',
191         'plugin_pin_dialog.cc',
192         'plugin_setup_dialog.cc',
193         'plugin_selector.cc',
194         'plugin_ui.cc',
195         'port_group.cc',
196         'port_insert_ui.cc',
197         'port_matrix.cc',
198         'port_matrix_body.cc',
199         'port_matrix_column_labels.cc',
200         'port_matrix_component.cc',
201         'port_matrix_grid.cc',
202         'port_matrix_labels.cc',
203         'port_matrix_row_labels.cc',
204         'processor_box.cc',
205         'processor_selection.cc',
206         'patch_change_dialog.cc',
207         'progress_reporter.cc',
208         'prompter.cc',
209         'public_editor.cc',
210         'quantize_dialog.cc',
211         'rc_option_editor.cc',
212         'region_editor.cc',
213         'region_gain_line.cc',
214         'region_layering_order_editor.cc',
215         'region_selection.cc',
216         'region_view.cc',
217         'return_ui.cc',
218         'rhythm_ferret.cc',
219         'route_group_dialog.cc',
220         'route_group_menu.cc',
221         'route_params_ui.cc',
222         'route_processor_selection.cc',
223         'route_time_axis.cc',
224         'route_ui.cc',
225         'ruler_dialog.cc',
226         'save_as_dialog.cc',
227         'search_path_option.cc',
228         'script_selector.cc',
229         'selection.cc',
230         'selection_memento.cc',
231         'send_ui.cc',
232         'session_archive_dialog.cc',
233         'session_dialog.cc',
234         'session_import_dialog.cc',
235         'session_metadata_dialog.cc',
236         'session_option_editor.cc',
237         'sfdb_ui.cc',
238         'shuttle_control.cc',
239         'soundcloud_export_selector.cc',
240         'splash.cc',
241         'speaker_dialog.cc',
242         'startup.cc',
243         'step_editor.cc',
244         'step_entry.cc',
245         'stereo_panner.cc',
246         'stereo_panner_editor.cc',
247         'streamview.cc',
248         'strip_silence_dialog.cc',
249         'stripable_colorpicker.cc',
250         'sys_ex.cc',
251         'tape_region_view.cc',
252         'tempo_curve.cc',
253         'tempo_dialog.cc',
254         'tempo_lines.cc',
255         'time_axis_view.cc',
256         'time_axis_view_item.cc',
257         'time_fx_dialog.cc',
258         'time_info_box.cc',
259         'time_selection.cc',
260         'timers.cc',
261         'tooltips.cc',
262         'track_selection.cc',
263         'track_view_list.cc',
264         'transform_dialog.cc',
265         'transpose_dialog.cc',
266         'ui_config.cc',
267         'utils.cc',
268         'vca_master_strip.cc',
269         'verbose_cursor.cc',
270         'visibility_group.cc',
271         'window_manager.cc',
272 # video-timeline related sources:
273         'video_image_frame.cc',
274         'add_video_dialog.cc',
275         'editor_videotimeline.cc',
276         'vca_time_axis.cc',
277         'video_timeline.cc',
278         'video_monitor.cc',
279         'transcode_ffmpeg.cc',
280         'transcode_video_dialog.cc',
281         'video_server_dialog.cc',
282         'utils_videotl.cc',
283         'export_video_dialog.cc',
284         'export_video_infobox.cc',
285         'video_tool_paths.cc'
286 ]
287
288 def enoify (major, minor):
289     # Code names based on
290     # https://en.wikipedia.org/wiki/Brian_Eno_discography
291     #
292     # sort Studio albums + Collaborative albums + Compilation albums by Month/Year.
293     # (no Singles, no EPs, no Video Albums, no Production)
294     if major == 3:
295         return "\\n\\\"E-No\\\""
296     elif major == 4:
297         if minor == 0:
298             return "\\n\\\"No Pussyfooting\\\""
299         elif minor == 1:
300             return "\\n\\\"Here Come the Warm Jets\\\""
301         elif minor == 2:
302             return "\\n\\\"Taking Tiger Mountain\\\""
303         elif minor == 3:
304             return "\\n\\\"Lady June's Linguistic Leprosy\\\""
305         elif minor == 4:
306             return "\\n\\\"Discreet Music\\\""
307         elif minor == 5:
308             return "\\n\\\"Another Green World\\\""
309         elif minor == 6:
310             return "\\n\\\"Evening Star\\\""
311         elif minor == 7:
312             return "\\n\\\"Cluster and Eno\\\""
313     elif major == 5:
314         if minor == 0:
315             return "\\n\\\"Before and After Science\\\""
316         elif minor == 1:
317             return "\\n\\\"After the Heat\\\""
318         elif minor == 2:
319             return "\\n\\\"Music for Airports\\\""
320         elif minor == 3:
321             return "\\n\\\"Music for Films\\\""
322         elif minor == 4:
323             return "\\n\\\"In a Land of Clear Colours\\\""
324         elif minor == 5:
325             return "\\n\\\"The Plateaux of Mirror\\\""
326         elif minor == 6:
327             return "\\n\\\"Possible Musics\\\"" # 1980 Collaborative
328         elif minor == 7:
329             return "\\n\\\"My Life in the Bush of Ghosts\\\"" # 1981
330         elif minor == 8:
331             return "\\n\\\"Music for Airplay\\\"" # 1981 Compilation
332         elif minor == 9:
333             return "\\n\\\"On Land\\\"" # 1982
334         elif minor == 10:  # 6.0 ??
335             return "\\n\\\"Atmospheres and Soundtracks\\\"" # 1983
336         elif minor == 11:
337             return "\\n\\\"More Music for Films\\\"" # 1983
338         elif minor == 12:
339             return "\\n\\\"Working Backwards\\\"" # 1984 Compilation
340         elif minor == 13:
341             return "\\n\\\"The Pearl\\\"" # 1984 Collaborative
342         elif minor == 14:
343             return "\\n\\\"Begegnungen\\\"" # 1984 Compilation
344     return "\\\"\\\""
345
346 def options(opt):
347     autowaf.set_options(opt)
348
349 def configure(conf):
350     conf.load('misc')
351     conf.load('compiler_cxx')
352     autowaf.configure(conf)
353
354     # TODO: Insert a sanity check for on OS X to ensure CoreAudio is present
355
356     autowaf.check_pkg(conf, 'fftw3f', uselib_store='FFTW3F',
357                       mandatory=True)
358     autowaf.check_pkg(conf, 'fftw3f', uselib_store='FFTW35F',
359                       atleast_version='3.3.5', mandatory=False)
360     autowaf.check_pkg(conf, 'flac', uselib_store='FLAC',
361                       atleast_version='1.2.1')
362     autowaf.check_pkg(conf, 'gthread-2.0', uselib_store='GTHREAD',
363                       atleast_version='2.10.1')
364     autowaf.check_pkg(conf, 'gtk+-2.0', uselib_store='GTK',
365                       atleast_version='2.18')
366     autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='GTKMM',
367                       atleast_version='2.18')
368     autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
369     autowaf.check_pkg(conf, 'x11', uselib_store='X11', atleast_version='1.1', mandatory=False)
370     autowaf.check_pkg(conf, 'pangoft2', uselib_store='PANGOFT2', atleast_version='1.36.8', mandatory=False)
371     autowaf.check_pkg(conf, 'fontconfig', uselib_store='FONTCONFIG')
372
373
374     if sys.platform == 'darwin':
375         retval = conf.run_c_code (code='#include <AppKit/NSWindow.h>\n\
376         int main(void) { (void) NSWindowWillStartLiveResizeNotification; return 0; }\n',
377                                   env = conf.env.derive (),
378                                   features = [ 'c' ],
379                                   compiler = 'cc',
380                                   compile_filename='test.m',
381                                   mandatory = False,
382             )
383
384         if retval == 0:
385             autowaf.display_msg (conf, 'Checking for Cocoa live resizing constants', 'ok')
386             conf.define ('HAVE_COCOA_LIVE_RESIZING', 1)
387         else:
388             autowaf.display_msg (conf, 'Checking for Cocoa live resizing constants', 'too old - AU plugin windows will be fixed size')
389
390     conf.write_config_header('gtk2ardour-config.h', remove=False)
391
392     bak = conf.env['define_key']
393     conf.define('VERSIONSTRING', str (conf.env['VERSION']))
394     conf.define('CODENAME', enoify(int(conf.env['MAJOR']), int(conf.env['MINOR'])))
395     conf.env['define_key'] = ['VERSIONSTRING', 'CODENAME' ]
396     conf.write_config_header('gtk2ardour-version.h')
397     conf.env['define_key'] = bak;
398
399     # Boost headers
400     autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp')
401     autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
402
403 # Add a waf `feature' to allow compilation of things using winegcc
404 from waflib.TaskGen import feature
405 @feature("wine")
406 def set_winegcc(self):
407     self.env.LINK_CXX = self.env.LINK_CC = 'wineg++'
408     self.env.CC = 'winegcc'
409
410 def _doPyp(infileName, deps = False):
411     outStr = ''
412     out = []
413     re_spaces = re.compile("\s+")
414
415     if infileName == '-':
416         fd = sys.stdin
417     else:
418         fd = open(infileName)
419     inLines = fd.readlines()
420     if fd != sys.stdin:
421         fd.close()
422
423
424     for line in inLines:
425         bits = re_spaces.split(line)
426         if bits[0] == '##include':
427             incName = bits[1]
428             if (deps):
429                 out += [ incName ]
430             else:
431                 # assume included file comes from same place as source file
432                 incName = os.path.join (os.path.dirname (infileName), incName);
433                 outStr += _doPyp(incName)
434         else:
435             if not deps:
436                 outStr += line
437
438     # done
439     if deps:
440         return out
441     else:
442         return outStr
443
444 def include_processor(task):
445     infileName = task.inputs[0].srcpath()
446     outfileName = os.path.join(out, task.outputs[0].bldpath())
447     fdOut = open (outfileName, "w")
448     fdOut.write (_doPyp(infileName))
449     fdOut.close ()
450
451
452 def build_color_scheme(path, prefix):
453     f = open (path, 'r')
454     color_scheme = ''
455     for line in f:
456         if re.search ('^#@color', line):
457             line.strip() # remove newline
458             words = line.split()
459             if len(color_scheme):
460                 color_scheme += ';'
461             color_scheme += prefix
462             color_scheme += '_'
463             color_scheme += words[1]
464             color_scheme += ':'
465             color_scheme += words[2]
466     f.close()
467     return color_scheme
468
469 def build(bld):
470
471     VERSION = "%s.%s" % (bld.env['MAJOR'], bld.env['MINOR'])
472     I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR']
473
474     # Tool to dump lua-bindings (of gtk2ardour + libs)
475     if re.search ("linux", sys.platform) != None and bld.env['LUABINDINGDOC']:
476         obj = bld (features = 'cxx c cxxprogram')
477         obj.install_path = None
478         obj.source    = list(gtk2_ardour_sources)
479         obj.target    = 'luadoc'
480         obj.includes  = ['.', '../libs']
481         obj.ldflags   = ['-no-undefined']
482         obj.use       = [
483                 'libpbd',
484                 'libardour',
485                 'libardour_cp',
486                 'libtimecode',
487                 'libmidipp',
488                 'libgtkmm2ext',
489                 'libcanvas',
490                 'libptformat',
491                 ]
492         obj.defines = [
493                 'NOMAIN',
494                 'PACKAGE="' + I18N_PACKAGE + '"',
495                 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
496                 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
497                 'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"',
498                 ]
499         obj.linkflags = ''
500         obj.uselib    = 'UUID FLAC FONTCONFIG GLIBMM GTHREAD GTK OGG CURL DL GTKMM CANVAS FFTW3F LO TAGLIB XML '
501         obj.source += [ 'luadoc.cc', 'bundle_env_linux.cc' ]
502         if bld.is_defined('HAVE_SUIL'):
503             obj.source += [ 'lv2_plugin_ui.cc' ]
504             obj.use += [ 'SUIL' ]
505         if bld.is_defined('LXVST_SUPPORT'):
506             obj.source += [ 'vst_plugin_ui.cc' ]
507             obj.source += [ 'linux_vst_gui_support.cc', 'lxvst_plugin_ui.cc' ]
508             obj.defines += [ 'LXVST_SUPPORT' ]
509             obj.use += [ 'X11' ]
510
511     # Tool to test libcanvas
512     if re.search ("linux", sys.platform) != None and bld.env['CANVASTESTUI']:
513         obj = bld (features = 'cxx c cxxprogram')
514         obj.install_path = None
515         obj.source    = list(gtk2_ardour_sources)
516         obj.source    = [ 'ardour_button.cc', 'ui_config.cc', 'tooltips.cc' ]
517         obj.target    = 'canvas_test'
518         obj.includes  = ['.', '../libs']
519         obj.ldflags   = ['-no-undefined']
520         obj.use       = [
521                 'libpbd',
522                 'libardour',
523                 'libardour_cp',
524                 'libtimecode',
525                 'libmidipp',
526                 'libgtkmm2ext',
527                 'libcanvas',
528                 'libptformat',
529                 ]
530         obj.defines = [
531                 'NOMAIN',
532                 'PACKAGE="' + I18N_PACKAGE + '"',
533                 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
534                 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
535                 'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"',
536                 ]
537         obj.linkflags = ''
538         obj.uselib    = 'UUID FLAC FONTCONFIG GLIBMM GTHREAD GTK OGG CURL DL GTKMM CANVAS FFTW3F LO TAGLIB XML '
539         # obj.source += [ 'canvas_test.cc', ]
540         obj.source += [ 'toolbar_test.cc', 'enums.cc']
541
542
543     if bld.is_defined('WINDOWS_VST_SUPPORT') and bld.env['build_target'] != 'mingw':
544         # Windows VST support w/wine
545         # If we require VST support we build a stub main() and the FST library
546         # here using winegcc, and link it to the GTK front-end library
547         obj = bld (features = 'cxx c cxxprogram wine')
548         obj.source = ( '../libs/fst/vstwin.c', '../vst/winmain.c' )
549         #
550         # XXX do we really need to explicitly link to all of these for the wine executable?
551         #
552         obj.use          = [ 'libpbd',
553                              'libmidipp',
554                              'libardour',
555                              'libardour_cp',
556                              'libtimecode',
557                              'libmidipp',
558                              'libgtk2_ardour',
559                              'libgtkmm2ext',
560                              'libcanvas',
561                              'libptformat',
562                              ]
563         obj.target = 'ardour-' + str (bld.env['VERSION']) + '-vst.exe.so'
564         obj.includes  = [ '../libs/fst', '.' ]
565         obj.linkflags = ['-mwindows', '-Wl,--export-dynamic']
566         obj.linkflags += bld.env['LDFLAGS']
567         obj.defines = ['_POSIX_SOURCE', 'USE_WS_PREFIX']
568         obj.install_path = bld.env['DLLDIR']
569         # end of the wine executable
570
571         # now the shared library containing the GTK GUI for ardour
572         obj = bld (features = 'cxx c cxxshlib')
573         # operate on copy to avoid adding sources twice
574         obj.source    = list(gtk2_ardour_sources)
575         obj.includes  = [ '../libs/fst', '.' ]
576         obj.name      = 'libgtk2_ardour'
577         obj.target    = 'gtk2_ardour'
578         obj.cflags  = [ '-fPIC' ]
579
580     else:
581         # just the normal executable version of the GTK GUI
582         if bld.env['build_target'] == 'mingw':
583             obj = bld (features = 'cxx c cxxprogram winres')
584         else:
585             obj = bld (features = 'cxx c cxxprogram')
586         # operate on copy to avoid adding sources twice
587         obj.source    = list(gtk2_ardour_sources)
588         obj.target = 'ardour-' + str (bld.env['VERSION'])
589         obj.includes = ['.']
590         obj.ldflags = ['-no-undefined']
591
592         if bld.is_defined('WINDOWS_VST_SUPPORT'):
593         # Windows VST support mingw
594             obj.includes += [ '../libs/fst' ]
595
596     # at this point, "obj" refers to either the normal native executable
597     # OR the shared library built for use with wine on linux.
598
599     obj.use      = [ 'libpbd',
600                      'libardour',
601                      'libardour_cp',
602                      'libtimecode',
603                      'libmidipp',
604                      'libgtkmm2ext',
605                      'libcanvas',
606                      'libptformat',
607                      ]
608
609     obj.defines = [
610         'PACKAGE="' + I18N_PACKAGE + '"',
611         'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
612         'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
613         'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"',
614         ]
615     obj.install_path = bld.env['DLLDIR']
616     obj.linkflags    = ''
617     obj.uselib       = 'UUID FLAC FONTCONFIG GLIBMM GTHREAD GTK OGG CURL DL GTKMM CANVAS FFTW3F LO TAGLIB XML '
618
619     if sys.platform == 'darwin':
620         obj.uselib += ' AUDIOUNITS OSX '
621         obj.use    += ' libappleutility'
622         obj.source += [ 'cocoacarbon.mm', 'bundle_env_cocoa.cc' ]
623     elif bld.env['build_target'] == 'mingw':
624         obj.source += [ 'bundle_env_mingw.cc' ]
625         obj.source += [ 'windows_icon.rc' ]
626     else:
627         obj.source += [ 'bundle_env_linux.cc' ]
628
629     obj.includes += ['../libs']
630
631     obj.use += 'libptformat'
632
633     if bld.env['build_target'] == 'mingw':
634         obj.linkflags += ' -mwindows'
635         obj.use += [ 'PANGOFT2' ]
636
637     if bld.is_defined('HAVE_SUIL'):
638         obj.source += [ 'lv2_plugin_ui.cc' ]
639         obj.use += [ 'SUIL' ]
640
641     if bld.is_defined('HAVE_FFTW35F') and bld.env['build_target'] != 'mingw':
642         bld.env['LIB_FFTW3F'] += ['fftw3f_threads']
643
644     if bld.is_defined('NEED_INTL'):
645         obj.linkflags += ' -lintl'
646
647     if bld.is_defined('WINDOWS_VST_SUPPORT'):
648         obj.source += [ 'windows_vst_plugin_ui.cc' ]
649         obj.defines += [ 'WINDOWS_VST_SUPPORT' ]
650         if bld.env['build_target'] != 'mingw':
651             obj.use += [ 'X11' ]
652
653     if bld.is_defined('LXVST_SUPPORT'):
654         obj.source += [ 'linux_vst_gui_support.cc', 'lxvst_plugin_ui.cc' ]
655         obj.defines += [ 'LXVST_SUPPORT' ]
656         obj.use += [ 'X11' ]
657
658     if bld.is_defined('MACVST_SUPPORT'):
659         obj.source += [ 'mac_vst_plugin_ui.mm' ]
660         obj.defines += [ 'MACVST_SUPPORT' ]
661
662     if bld.is_defined('WINDOWS_VST_SUPPORT') or bld.is_defined('LXVST_SUPPORT') or bld.is_defined ('MACVST_SUPPORT'):
663         obj.source += [ 'vst_plugin_ui.cc' ]
664
665     if bld.is_defined('PHONE_HOME'):
666         obj.defines += [ 'PHONE_HOME' ]
667
668     if bld.is_defined('HAVE_COREAUDIO'):
669         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cc']
670         obj.use += ' libappleutility '
671
672     if bld.is_defined('AUDIOUNIT_SUPPORT'):
673         obj.source += [ 'au_pluginui.mm' ]
674
675     # Wrappers
676
677     wrapper_subst_dict = {
678             'INSTALL_PREFIX' : bld.env['PREFIX'],
679             'LIBDIR'         : os.path.normpath(bld.env['DLLDIR']),
680             'DATADIR'        : os.path.normpath(bld.env['DATADIR']),
681             'CONFDIR'        : os.path.normpath(bld.env['CONFDIR']),
682             'LIBS'           : 'build/libs',
683             'VERSION'        : str (bld.env['VERSION']),
684             'EXECUTABLE'     : 'build/gtk2_ardour/ardour-' + str (bld.env['VERSION'])
685     }
686
687     def set_subst_dict(obj, dict):
688         for i in dict:
689             setattr(obj, i, dict[i])
690
691     obj              = bld(features = 'subst')
692     obj.source       = 'ardev_common.sh.in'
693     obj.target       = 'ardev_common_waf.sh'
694     obj.chmod        = Utils.O755
695     obj.dict         = wrapper_subst_dict
696     set_subst_dict(obj, wrapper_subst_dict)
697
698     obj              = bld(features = 'subst')
699     obj.source       = 'ardour.sh.in'
700     obj.target       = 'ardour' + str (bld.env['MAJOR'])
701     obj.chmod        = Utils.O755
702     obj.dict         = wrapper_subst_dict
703     obj.install_path = bld.env['BINDIR']
704     set_subst_dict(obj, wrapper_subst_dict)
705
706     if bld.is_defined('WINDOWS_VST_SUPPORT'):
707         obj              = bld(features = 'subst')
708         obj.source       = '../vst/ardourvst.in'
709         obj.target       = 'ardourvst' + str (bld.env['MAJOR'])
710         obj.chmod        = Utils.O755
711         obj.dict         = wrapper_subst_dict
712         obj.install_path = bld.env['BINDIR']
713         set_subst_dict(obj, wrapper_subst_dict)
714
715     # Font configuration
716
717     font_subst_dict = {}
718     font_sizes      = {}
719     base_font       = ""
720
721     # Set up font sizes
722     if sys.platform == 'darwin':
723         basefont = ""
724         font_sizes = {
725                 'SMALLER' : '9',
726                 'SMALL' : '10',
727                 'NORMAL' : '11',
728                 'BIG' : '13',
729                 'BIGGER' : '17',
730                 'LARGE' : '18',
731                 'LARGER' : '28',
732                 'HUGER' : '36',
733                 'MASSIVE' : '60',
734         }
735
736         # There is no acceptable monospace font available on older versions of OS X
737         # and no API on those versions to load TTF files that will work with
738         # GTK/fontconfig/pango.
739         #
740         # In addition, the ArdourMono font gets clipped for some reason on OS X
741         #
742         # Moreover, Lucida Grande just seems to work even though it is not monospace
743         # so just use it.
744         #
745         font_names = {
746             'MONOSPACE' : 'Monaco',
747             'CLOCKFONT' : 'Lucida Grande',
748         }
749     else: # Linux/X11 fonts
750         basefont = '' # unspecified - use system defaults
751         font_sizes = {
752                 'SMALLER' : '6',
753                 'SMALL' : '7',
754                 'NORMAL' : '8',
755                 'BIG' : '11',
756                 'BIGGER' : '13.5',
757                 'LARGE' : '14.5',
758                 'LARGER' : '19',
759                 'HUGER' : '27',
760                 'MASSIVE' : '48',
761         }
762         font_names = {
763                 'MONOSPACE' : 'ArdourMono',
764                 'CLOCKFONT' : 'ArdourMono',
765         }
766
767     # Set up font substitution dictionary
768     # @FONT_XXXX@
769     for style in ['', 'BOLD', 'ITALIC']:
770         for sizename,points in iter(font_sizes.items()):
771             if (len (style)):
772                 key = "_".join (['FONT',style,sizename])
773                 fontstyle = " ".join ([basefont,style.lower(),points])
774             else:
775                 key = "_".join (['FONT',sizename])
776                 fontstyle = " ".join ([basefont,points])
777
778             font_subst_dict[key] = fontstyle
779
780     # @FONT_SIZE_XXXX@
781     for sizename,points in iter(font_sizes.items()):
782             key = "_".join (['FONT_SIZE',sizename])
783             font_subst_dict[key] = points
784
785     # various font names, eg @BOLD_MONOSPACE@
786     for font_sym,text in iter(font_names.items()):
787         key = font_sym
788         font_subst_dict[key] = text
789
790     # RC file
791
792     obj              = bld(features = 'subst')
793     obj.source       = [ 'clearlooks.rc.in' ]
794     obj.target       = 'clearlooks.rc'
795     obj.install_path = bld.env['CONFDIR']
796     set_subst_dict(obj, font_subst_dict)
797
798     obj              = bld(features = 'subst')
799     obj.source       = [ 'default_ui_config.in' ]
800     obj.target       = 'default_ui_config'
801     obj.install_path = bld.env['CONFDIR']
802     set_subst_dict(obj, font_subst_dict)
803
804     # Menus
805     menus_argv = []
806     if sys.platform == 'darwin':
807         menus_argv = [ '-E', '-P', '-D__APPLE__', '-' ]
808     else:
809         menus_argv = [ '-E', '-P' ]
810
811     if bld.is_defined('PTFORMAT'):
812         menus_argv += [ '-DPTFORMAT' ]
813
814     # always build all versions of the menu definitions
815     # so that we can try them out with different program builds.
816     for program in [ 'ardour', 'trx' ]:
817         obj = bld(features = 'command-output')
818         obj.command = 'cpp'
819         obj.command_is_external = True
820         obj.no_inputs = True
821         obj.argv = menus_argv
822         obj.dep_vars = ['PTFORMAT', 'GTKOSX', 'WINDOWS']
823         obj.stdin = program + '.menus.in'
824         obj.stdout = program + '.menus'
825         bld.install_files (bld.env['CONFDIR'], program + '.menus')
826
827     # Freedesktop
828     freedesktop_subst_dict = {
829                     'ARDOUR_EXEC' : str (bld.env['lwrcase_dirname']),
830                     'ARDOUR_ICON' : str (bld.env['lwrcase_dirname']),
831                     'VERSION': str (bld.env['VERSION']),
832     }
833
834     if bld.env['FREEDESKTOP']:
835         obj              = bld(features = 'subst')
836         obj.source       = 'ardour.desktop.in'
837         obj.target       = str (bld.env['lwrcase_dirname']) + '.desktop'
838         obj.chmod        = Utils.O644
839         obj.dict         = freedesktop_subst_dict
840         set_subst_dict(obj, freedesktop_subst_dict)
841
842         obj              = bld(features = 'subst')
843         obj.source       = 'ardour-mime-info.xml'
844         obj.target       = 'ardour.xml'
845         obj.chmod        = Utils.O644
846
847         # build appdata with translations
848         appdata_i18n_mo(bld)
849         appdata_i18n_xmlin(bld)
850         obj              = bld(features = 'subst')
851         obj.source       = 'ardour.appdata.xml.in'
852         obj.target       = str (bld.env['lwrcase_dirname']) + '.appdata.xml'
853         obj.chmod        = Utils.O644
854         obj.dict         = freedesktop_subst_dict
855         set_subst_dict(obj, freedesktop_subst_dict)
856
857     # Keybindings
858
859     # NATIVE ARDOUR BINDING FILES
860     # explicitly state the use of perl here so that it works on windows too
861     # 
862     a_rule = 'perl ../tools/fmt-bindings --platform="%s" --winkey="%s" --accelmap ${SRC[0].abspath()} >${TGT}' % (sys.platform, bld.env['WINDOWS_KEY'] )
863     for b in [ 'ardour' ] :
864         obj = bld(
865             target = b + '.keys',
866             source = [ b + '.keys.in', 'mixer.bindings', 'processor_box.bindings', 'step_editing.bindings', 'monitor.bindings' ],
867             rule = a_rule
868             )
869         obj.install_path = bld.env['CONFDIR']
870         
871     # Icons/Images
872     bld.install_files(os.path.join (bld.env['DATADIR'], 'icons'), bld.path.ant_glob('icons/*.png'))
873     bld.install_files(bld.env['DATADIR'], 'ArdourMono.ttf')
874
875     # Application/Product specific resources (icon, splash)
876     pgmname = bld.env['PROGRAM_NAME']
877     bld.install_files(os.path.join(bld.env['DATADIR'], 'resources'), bld.path.ant_glob('resources/' + pgmname + '*'))
878
879     if bld.env['build_target'] == 'mingw':
880         # These icons need to overwrite the files already installed in the icons
881         # directory above. Do this in the external packaging scripts for now.
882         #bld.install_files(os.path.join (bld.env['DATADIR'], 'icons'), bld.path.ant_glob('icons/cursor_square/*.png'))
883         bld.install_files(os.path.join (bld.env['DATADIR'], 'icons'), 'icons/cursor_square/hotspots')
884
885     # Default UI configuration
886     bld.install_files(bld.env['CONFDIR'], 'default_ui_config')
887     # Color Themes. Find each color file for this program only
888     # and install
889     bld.install_files (os.path.join(bld.env['DATADIR'], 'themes'), bld.path.ant_glob ('themes/*-' + pgmname.lower() + '.colors'));
890
891     # Default export stuff
892     bld.install_files(os.path.join(bld.env['CONFDIR'], 'export'), bld.path.ant_glob('export/*.format'))
893
894     # i18n
895     if bld.is_defined('ENABLE_NLS'):
896         mo_files = bld.path.ant_glob('po/*.mo')
897         for mo in mo_files:
898             lang = os.path.basename(mo.srcpath()).replace('.mo', '')
899             bld.install_as (os.path.join(os.path.normpath(bld.env['LOCALEDIR']), lang, 'LC_MESSAGES', I18N_PACKAGE + '.mo'),
900                             mo)
901
902 def i18n(bld):
903         I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR']
904         autowaf.build_i18n(bld, top, 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources,
905                            'Paul Davis')
906         appdata_i18n_pot(bld)
907         appdata_i18n_po(bld)
908
909 def i18n_pot(bld):
910         I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR']
911         autowaf.build_i18n_pot(bld, top, 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources,
912                                'Paul Davis')
913         appdata_i18n_pot(bld)
914
915 def i18n_po(bld):
916         I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR']
917         autowaf.build_i18n_po(bld, top, 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources,
918                               'Paul Davis')
919         appdata_i18n_po(bld)
920
921 def i18n_mo(bld):
922         I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR']
923         autowaf.build_i18n_mo(bld, top, 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources,
924                               'Paul Davis')
925
926 def appdata_i18n_pot(bld):
927     potfile = os.path.join(bld.top_dir, 'gtk2_ardour', 'appdata',
928             'ardour.appdata.pot')
929     if bld.cmd == 'i18n_pot':
930         Logs.info('Generating pot file from Ardour appdata')
931         itsfile = os.path.join(bld.top_dir, 'tools', 'as-metainfo.its')
932         adsource = os.path.join(bld.top_dir, 'gtk2_ardour',
933                 'ardour.appdata.xml.in.in')
934         Logs.info('Updating ' + potfile)
935         try:
936                 subprocess.call(('itstool', '-i', itsfile, '-o', potfile, adsource))
937         except:
938                 print ('Error processing appdata pot file - ignored')
939     elif bld.cmd == 'clean' and os.path.exists(potfile):
940         Logs.info('Removing Ardour appdata pot file')
941         os.remove(potfile)
942
943 def appdata_i18n_po(bld):
944     autowaf.build_i18n_po(bld, bld.top_dir, os.path.join(
945         'gtk2_ardour', 'appdata'), 'ardour.appdata', 'dummy', 'dummy')
946
947 def appdata_i18n_mo(bld):
948     autowaf.build_i18n_mo(bld, bld.top_dir, os.path.join(
949         'gtk2_ardour', 'appdata'), 'ardour.appdata', 'dummy', 'dummy')
950
951 def appdata_i18n_xmlin(bld):
952     adxmlinfile = os.path.join(bld.top_dir, 'gtk2_ardour',
953             'ardour.appdata.xml.in')
954     if bld.cmd == 'build':
955         itsfile = os.path.join(bld.top_dir, 'tools', 'as-metainfo.its')
956         adxmlininfile = os.path.join(bld.top_dir, 'gtk2_ardour',
957                 'ardour.appdata.xml.in.in')
958         mo_glob = os.path.join(bld.top_dir, 'gtk2_ardour', 'appdata', 'po', '*.mo')
959         mo_files = glob.glob(mo_glob)
960         Logs.info('Generating ' + adxmlinfile)
961         subprocess.call(['itstool', '-i', itsfile, '-o', adxmlinfile,
962             '-j', adxmlininfile] + mo_files)
963     elif bld.cmd == 'clean' and os.path.exists(adxmlinfile):
964         Logs.info('Removing ' + adxmlinfile)
965         os.remove(adxmlinfile)