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