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