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