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