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