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