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