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