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