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