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