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