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