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