mp4chaps Lua script: don't clutter global environment
[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         'bundle_manager.cc',
57         'clock_group.cc',
58         'color_theme_manager.cc',
59         'configinfo.cc',
60         'control_point.cc',
61         'control_point_dialog.cc',
62         'control_slave_ui.cc',
63         'cursor_context.cc',
64         'curvetest.cc',
65         'debug.cc',
66         'duplicate_routes_dialog.cc',
67         'edit_note_dialog.cc',
68         'editing.cc',
69         'editor.cc',
70         'editor_actions.cc',
71         'editor_audio_import.cc',
72         'editor_pt_import.cc',
73         'editor_audiotrack.cc',
74         'editor_canvas.cc',
75         'editor_canvas_events.cc',
76         'editor_component.cc',
77         'editor_cursors.cc',
78         'editor_drag.cc',
79         'editor_route_groups.cc',
80         'editor_export_audio.cc',
81         'editor_group_tabs.cc',
82         'editor_keys.cc',
83         'editor_locations.cc',
84         'editor_markers.cc',
85         'editor_mixer.cc',
86         'editor_mouse.cc',
87         'editor_ops.cc',
88         'editor_regions.cc',
89         'editor_routes.cc',
90         'editor_rulers.cc',
91         'editor_selection.cc',
92         'editor_snapshots.cc',
93         'editor_summary.cc',
94         'editor_tempodisplay.cc',
95         'editor_timefx.cc',
96         'engine_dialog.cc',
97         'enums.cc',
98         'export_channel_selector.cc',
99         'export_dialog.cc',
100         'export_file_notebook.cc',
101         'export_filename_selector.cc',
102         'export_format_dialog.cc',
103         'export_format_selector.cc',
104         'export_preset_selector.cc',
105         'export_report.cc',
106         'export_timespan_selector.cc',
107         'fft.cc',
108         'fft_graph.cc',
109         'fft_result.cc',
110         'floating_text_entry.cc',
111         'sfdb_freesound_mootcher.cc',
112         'gain_meter.cc',
113         'generic_pluginui.cc',
114         'ghostregion.cc',
115         'global_port_matrix.cc',
116         'group_tabs.cc',
117         'gtk_pianokeyboard.c',
118         'gui_object.cc',
119         'idleometer.cc',
120         'insert_remove_time_dialog.cc',
121         'instrument_selector.cc',
122         'interthread_progress_window.cc',
123         'io_selector.cc',
124         'hit.cc',
125         'keyboard.cc',
126         'keyeditor.cc',
127         'latency_gui.cc',
128         'led.cc',
129         'level_meter.cc',
130         'location_ui.cc',
131         'lua_script_manager.cc',
132         'luadialog.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_region_view.cc',
145         'midi_scroomer.cc',
146         'midi_selection.cc',
147         'midi_streamview.cc',
148         'midi_time_axis.cc',
149         'midi_tracer.cc',
150         'midi_velocity_dialog.cc',
151         'mini_timeline.cc',
152         'missing_file_dialog.cc',
153         'missing_plugin_dialog.cc',
154         'mixer_group_tabs.cc',
155         'mixer_strip.cc',
156         'mixer_ui.cc',
157         'meterbridge.cc',
158         'meter_strip.cc',
159         'meter_patterns.cc',
160         'monitor_section.cc',
161         'monitor_selector.cc',
162         'mono_panner.cc',
163         'mono_panner_editor.cc',
164         'mouse_cursors.cc',
165         'nag.cc',
166         'new_plugin_preset_dialog.cc',
167         'normalize_dialog.cc',
168         'note.cc',
169         'note_base.cc',
170         'note_player.cc',
171         'note_select_dialog.cc',
172         'nsm.cc',
173         'nsmclient.cc',
174         'option_editor.cc',
175         'opts.cc',
176         'panner2d.cc',
177         'panner_editor.cc',
178         'panner_interface.cc',
179         'panner_ui.cc',
180         'patch_change.cc',
181         'piano_roll_header.cc',
182         'pingback.cc',
183         'playlist_selector.cc',
184         'plugin_display.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         'processor_selection.cc',
201         'patch_change_dialog.cc',
202         'progress_reporter.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         'save_template_dialog.cc',
222         'search_path_option.cc',
223         'script_selector.cc',
224         'selection.cc',
225         'selection_memento.cc',
226         'send_ui.cc',
227         'session_archive_dialog.cc',
228         'session_dialog.cc',
229         'session_import_dialog.cc',
230         'session_metadata_dialog.cc',
231         'session_option_editor.cc',
232         'sfdb_ui.cc',
233         'shuttle_control.cc',
234         'soundcloud_export_selector.cc',
235         'splash.cc',
236         'speaker_dialog.cc',
237         'startup.cc',
238         'step_editor.cc',
239         'step_entry.cc',
240         'stereo_panner.cc',
241         'stereo_panner_editor.cc',
242         'streamview.cc',
243         'strip_silence_dialog.cc',
244         'stripable_colorpicker.cc',
245         'stripable_time_axis.cc',
246         'sys_ex.cc',
247         'tape_region_view.cc',
248         'template_dialog.cc',
249         'tempo_curve.cc',
250         'tempo_dialog.cc',
251         'tempo_lines.cc',
252         'time_axis_view.cc',
253         'time_axis_view_item.cc',
254         'time_fx_dialog.cc',
255         'time_info_box.cc',
256         'time_selection.cc',
257         'timers.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\\\"" # 1980 Collaborative
324         elif minor == 7:
325             return "\\n\\\"My Life in the Bush of Ghosts\\\"" # 1981
326         elif minor == 8:
327             return "\\n\\\"Music for Airplay\\\"" # 1981 Compilation
328         elif minor == 9:
329             return "\\n\\\"On Land\\\"" # 1982
330         elif minor == 10:  # 6.0 ??
331             return "\\n\\\"Atmospheres and Soundtracks\\\"" # 1983
332         elif minor == 11:
333             return "\\n\\\"More Music for Films\\\"" # 1983
334         elif minor == 12:
335             return "\\n\\\"Working Backwards\\\"" # 1984 Compilation
336         elif minor == 13:
337             return "\\n\\\"The Pearl\\\"" # 1984 Collaborative
338         elif minor == 14:
339             return "\\n\\\"Begegnungen\\\"" # 1984 Compilation
340     return "\\\"\\\""
341
342 def options(opt):
343     autowaf.set_options(opt)
344
345 def configure(conf):
346     conf.load('misc')
347     conf.load('compiler_cxx')
348     autowaf.configure(conf)
349
350     # TODO: Insert a sanity check for on OS X to ensure CoreAudio is present
351
352     autowaf.check_pkg(conf, 'fftw3f', uselib_store='FFTW3F',
353                       mandatory=True)
354     autowaf.check_pkg(conf, 'fftw3f', uselib_store='FFTW35F',
355                       atleast_version='3.3.5', mandatory=False)
356     autowaf.check_pkg(conf, 'flac', uselib_store='FLAC',
357                       atleast_version='1.2.1')
358     autowaf.check_pkg(conf, 'gthread-2.0', uselib_store='GTHREAD',
359                       atleast_version='2.10.1')
360     autowaf.check_pkg(conf, 'gtk+-2.0', uselib_store='GTK',
361                       atleast_version='2.18')
362     autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='GTKMM',
363                       atleast_version='2.18')
364     autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
365     autowaf.check_pkg(conf, 'x11', uselib_store='X11', atleast_version='1.1', mandatory=False)
366     autowaf.check_pkg(conf, 'pangoft2', uselib_store='PANGOFT2', atleast_version='1.36.8', mandatory=False)
367     autowaf.check_pkg(conf, 'fontconfig', uselib_store='FONTCONFIG')
368
369
370     if sys.platform == 'darwin':
371         retval = conf.run_c_code (code='#include <AppKit/NSWindow.h>\n\
372         int main(void) { (void) NSWindowWillStartLiveResizeNotification; return 0; }\n',
373                                   env = conf.env.derive (),
374                                   features = [ 'c' ],
375                                   compiler = 'cc',
376                                   compile_filename='test.m',
377                                   mandatory = False,
378             )
379
380         if retval == 0:
381             autowaf.display_msg (conf, 'Checking for Cocoa live resizing constants', 'ok')
382             conf.define ('HAVE_COCOA_LIVE_RESIZING', 1)
383         else:
384             autowaf.display_msg (conf, 'Checking for Cocoa live resizing constants', 'too old - AU plugin windows will be fixed size')
385
386     conf.write_config_header('gtk2ardour-config.h', remove=False)
387
388     bak = conf.env['define_key']
389     conf.define('VERSIONSTRING', str (conf.env['VERSION']))
390     conf.define('CODENAME', enoify(int(conf.env['MAJOR']), int(conf.env['MINOR'])))
391     conf.env['define_key'] = ['VERSIONSTRING', 'CODENAME' ]
392     conf.write_config_header('gtk2ardour-version.h')
393     conf.env['define_key'] = bak;
394
395     # Boost headers
396     autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp')
397     autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
398
399 # Add a waf `feature' to allow compilation of things using winegcc
400 from waflib.TaskGen import feature
401 @feature("wine")
402 def set_winegcc(self):
403     self.env.LINK_CXX = self.env.LINK_CC = 'wineg++'
404     self.env.CC = 'winegcc'
405
406 def _doPyp(infileName, deps = False):
407     outStr = ''
408     out = []
409     re_spaces = re.compile("\s+")
410
411     if infileName == '-':
412         fd = sys.stdin
413     else:
414         fd = open(infileName)
415     inLines = fd.readlines()
416     if fd != sys.stdin:
417         fd.close()
418
419
420     for line in inLines:
421         bits = re_spaces.split(line)
422         if bits[0] == '##include':
423             incName = bits[1]
424             if (deps):
425                 out += [ incName ]
426             else:
427                 # assume included file comes from same place as source file
428                 incName = os.path.join (os.path.dirname (infileName), incName);
429                 outStr += _doPyp(incName)
430         else:
431             if not deps:
432                 outStr += line
433
434     # done
435     if deps:
436         return out
437     else:
438         return outStr
439
440 def include_processor(task):
441     infileName = task.inputs[0].srcpath()
442     outfileName = os.path.join(out, task.outputs[0].bldpath())
443     fdOut = open (outfileName, "w")
444     fdOut.write (_doPyp(infileName))
445     fdOut.close ()
446
447
448 def build_color_scheme(path, prefix):
449     f = open (path, 'r')
450     color_scheme = ''
451     for line in f:
452         if re.search ('^#@color', line):
453             line.strip() # remove newline
454             words = line.split()
455             if len(color_scheme):
456                 color_scheme += ';'
457             color_scheme += prefix
458             color_scheme += '_'
459             color_scheme += words[1]
460             color_scheme += ':'
461             color_scheme += words[2]
462     f.close()
463     return color_scheme
464
465 def build(bld):
466
467     VERSION = "%s.%s" % (bld.env['MAJOR'], bld.env['MINOR'])
468     I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR']
469
470     # Tool to dump lua-bindings (of gtk2ardour + libs)
471     if re.search ("linux", sys.platform) != None and bld.env['LUABINDINGDOC']:
472         obj = bld (features = 'cxx c cxxprogram')
473         obj.install_path = None
474         obj.source    = list(gtk2_ardour_sources)
475         obj.target    = 'luadoc'
476         obj.includes  = ['.', '../libs']
477         obj.ldflags   = ['-no-undefined']
478         obj.use       = [
479                 'libpbd',
480                 'libardour',
481                 'libardour_cp',
482                 'libtimecode',
483                 'libmidipp',
484                 'libgtkmm2ext',
485                 'libcanvas',
486                 'libwaveview',
487                 'libwidgets',
488                 'libptformat',
489                 ]
490         obj.defines = [
491                 'NOMAIN',
492                 'PACKAGE="' + I18N_PACKAGE + '"',
493                 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
494                 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
495                 'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"',
496                 ]
497         obj.linkflags = ''
498         obj.uselib    = 'UUID FLAC FONTCONFIG GLIBMM GTHREAD GTK OGG CURL DL GTKMM CANVAS FFTW3F LO TAGLIB XML '
499         obj.source += [ 'luadoc.cc', 'bundle_env_linux.cc' ]
500         if bld.is_defined('HAVE_SUIL'):
501             obj.source += [ 'lv2_plugin_ui.cc' ]
502             obj.use += [ 'SUIL' ]
503         if bld.is_defined('LXVST_SUPPORT'):
504             obj.source += [ 'vst_plugin_ui.cc' ]
505             obj.source += [ 'linux_vst_gui_support.cc', 'lxvst_plugin_ui.cc' ]
506             obj.defines += [ 'LXVST_SUPPORT' ]
507             obj.use += [ 'X11' ]
508
509 #    # Tool to test libcanvas
510 #    if re.search ("linux", sys.platform) != None and bld.env['CANVASTESTUI']:
511 #        obj = bld (features = 'cxx c cxxprogram')
512 #        obj.install_path = None
513 #        obj.source    = list(gtk2_ardour_sources)
514 #        obj.source    = [ 'ardour_button.cc', 'ui_config.cc', 'tooltips.cc' ]
515 #        obj.target    = 'canvas_test'
516 #        obj.includes  = ['.', '../libs']
517 #        obj.ldflags   = ['-no-undefined']
518 #        obj.use       = [
519 #                'libpbd',
520 #                'libardour',
521 #                'libardour_cp',
522 #                'libtimecode',
523 #                'libmidipp',
524 #                'libgtkmm2ext',
525 #                'libcanvas',
526 #                'libptformat',
527 #                ]
528 #        obj.defines = [
529 #                'NOMAIN',
530 #                'PACKAGE="' + I18N_PACKAGE + '"',
531 #                'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
532 #                'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
533 #                'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"',
534 #                ]
535 #        obj.linkflags = ''
536 #        obj.uselib    = 'UUID FLAC FONTCONFIG GLIBMM GTHREAD GTK OGG CURL DL GTKMM CANVAS FFTW3F LO TAGLIB XML '
537 #        # obj.source += [ 'canvas_test.cc', ]
538 #        obj.source += [ 'toolbar_test.cc', 'enums.cc']
539
540
541     if bld.is_defined('WINDOWS_VST_SUPPORT') and bld.env['build_target'] != 'mingw':
542         # Windows VST support w/wine
543         # If we require VST support we build a stub main() and the FST library
544         # here using winegcc, and link it to the GTK front-end library
545         obj = bld (features = 'cxx c cxxprogram wine')
546         obj.source = ( '../libs/fst/vstwin.c', '../vst/winmain.c' )
547         #
548         # XXX do we really need to explicitly link to all of these for the wine executable?
549         #
550         obj.use          = [ 'libpbd',
551                              'libmidipp',
552                              'libardour',
553                              'libardour_cp',
554                              'libtimecode',
555                              'libmidipp',
556                              'libgtk2_ardour',
557                              'libgtkmm2ext',
558                              'libcanvas',
559                              'libwaveview',
560                              'libwidgets',
561                              'libptformat',
562                              ]
563         obj.target = 'ardour-' + str (bld.env['VERSION']) + '-vst.exe.so'
564         obj.includes  = [ '../libs/fst', '.' ]
565         obj.linkflags = ['-mwindows', '-Wl,--export-dynamic']
566         obj.linkflags += bld.env['LDFLAGS']
567         obj.defines = ['_POSIX_SOURCE', 'USE_WS_PREFIX']
568         obj.install_path = bld.env['DLLDIR']
569         # end of the wine executable
570
571         # now the shared library containing the GTK GUI for ardour
572         obj = bld (features = 'cxx c cxxshlib')
573         # operate on copy to avoid adding sources twice
574         obj.source    = list(gtk2_ardour_sources)
575         obj.includes  = [ '../libs/fst', '.' ]
576         obj.name      = 'libgtk2_ardour'
577         obj.target    = 'gtk2_ardour'
578         obj.cflags  = [ '-fPIC' ]
579
580     else:
581         # just the normal executable version of the GTK GUI
582         if bld.env['build_target'] == 'mingw':
583             obj = bld (features = 'cxx c cxxprogram winres')
584         else:
585             obj = bld (features = 'cxx c cxxprogram')
586         # operate on copy to avoid adding sources twice
587         obj.source    = list(gtk2_ardour_sources)
588         obj.target = 'ardour-' + str (bld.env['VERSION'])
589         obj.includes = ['.']
590         obj.ldflags = ['-no-undefined']
591
592         if bld.is_defined('WINDOWS_VST_SUPPORT'):
593         # Windows VST support mingw
594             obj.includes += [ '../libs/fst' ]
595
596     # at this point, "obj" refers to either the normal native executable
597     # OR the shared library built for use with wine on linux.
598
599     obj.use      = [ 'libpbd',
600                      'libardour',
601                      'libardour_cp',
602                      'libtimecode',
603                      'libmidipp',
604                      'libgtkmm2ext',
605                      'libcanvas',
606                      'libwaveview',
607                      'libwidgets',
608                      'libptformat',
609                      ]
610
611     obj.defines = [
612         'PACKAGE="' + I18N_PACKAGE + '"',
613         'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
614         'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
615         'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"',
616         ]
617     obj.install_path = bld.env['DLLDIR']
618     obj.linkflags    = ''
619     obj.uselib       = 'UUID FLAC FONTCONFIG GLIBMM GTHREAD GTK OGG CURL DL GTKMM CANVAS FFTW3F LO TAGLIB XML '
620
621     if sys.platform == 'darwin':
622         obj.uselib += ' AUDIOUNITS OSX '
623         obj.use    += ' libappleutility'
624         obj.source += [ 'cocoacarbon.mm', 'bundle_env_cocoa.cc' ]
625     elif bld.env['build_target'] == 'mingw':
626         obj.source += [ 'bundle_env_mingw.cc' ]
627         obj.source += [ 'windows_icon.rc' ]
628     else:
629         obj.source += [ 'bundle_env_linux.cc' ]
630
631     obj.includes += ['../libs']
632
633     obj.use += 'libptformat'
634
635     if bld.env['build_target'] == 'mingw':
636         obj.linkflags += ' -mwindows'
637         obj.use += [ 'PANGOFT2' ]
638
639     if bld.is_defined('HAVE_SUIL'):
640         obj.source += [ 'lv2_plugin_ui.cc' ]
641         obj.use += [ 'SUIL' ]
642
643     if bld.is_defined('HAVE_FFTW35F') and bld.env['build_target'] != 'mingw':
644         bld.env['LIB_FFTW3F'] += ['fftw3f_threads']
645
646     if bld.is_defined('NEED_INTL'):
647         obj.linkflags += ' -lintl'
648
649     if bld.is_defined('WINDOWS_VST_SUPPORT'):
650         obj.source += [ 'windows_vst_plugin_ui.cc' ]
651         obj.defines += [ 'WINDOWS_VST_SUPPORT' ]
652         if bld.env['build_target'] != 'mingw':
653             obj.use += [ 'X11' ]
654
655     if bld.is_defined('LXVST_SUPPORT'):
656         obj.source += [ 'linux_vst_gui_support.cc', 'lxvst_plugin_ui.cc' ]
657         obj.defines += [ 'LXVST_SUPPORT' ]
658         obj.use += [ 'X11' ]
659
660     if bld.is_defined('MACVST_SUPPORT'):
661         obj.source += [ 'mac_vst_plugin_ui.mm' ]
662         obj.defines += [ 'MACVST_SUPPORT' ]
663
664     if bld.is_defined('WINDOWS_VST_SUPPORT') or bld.is_defined('LXVST_SUPPORT') or bld.is_defined ('MACVST_SUPPORT'):
665         obj.source += [ 'vst_plugin_ui.cc' ]
666
667     if bld.is_defined('PHONE_HOME'):
668         obj.defines += [ 'PHONE_HOME' ]
669
670     if bld.is_defined('HAVE_COREAUDIO'):
671         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cc']
672         obj.use += ' libappleutility '
673
674     if bld.is_defined('AUDIOUNIT_SUPPORT'):
675         obj.source += [ 'au_pluginui.mm' ]
676
677     # Wrappers
678
679     wrapper_subst_dict = {
680             'INSTALL_PREFIX' : bld.env['PREFIX'],
681             'LIBDIR'         : os.path.normpath(bld.env['DLLDIR']),
682             'DATADIR'        : os.path.normpath(bld.env['DATADIR']),
683             'CONFDIR'        : os.path.normpath(bld.env['CONFDIR']),
684             'LIBS'           : 'build/libs',
685             'VERSION'        : str (bld.env['VERSION']),
686             'EXECUTABLE'     : 'build/gtk2_ardour/ardour-' + str (bld.env['VERSION'])
687     }
688
689     def set_subst_dict(obj, dict):
690         for i in dict:
691             setattr(obj, i, dict[i])
692
693     obj              = bld(features = 'subst')
694     obj.source       = 'ardev_common.sh.in'
695     obj.target       = 'ardev_common_waf.sh'
696     obj.chmod        = Utils.O755
697     obj.dict         = wrapper_subst_dict
698     set_subst_dict(obj, wrapper_subst_dict)
699
700     obj              = bld(features = 'subst')
701     obj.source       = 'ardour.sh.in'
702     obj.target       = 'ardour' + str (bld.env['MAJOR'])
703     obj.chmod        = Utils.O755
704     obj.dict         = wrapper_subst_dict
705     obj.install_path = bld.env['BINDIR']
706     set_subst_dict(obj, wrapper_subst_dict)
707
708     if bld.is_defined('WINDOWS_VST_SUPPORT'):
709         obj              = bld(features = 'subst')
710         obj.source       = '../vst/ardourvst.in'
711         obj.target       = 'ardourvst' + str (bld.env['MAJOR'])
712         obj.chmod        = Utils.O755
713         obj.dict         = wrapper_subst_dict
714         obj.install_path = bld.env['BINDIR']
715         set_subst_dict(obj, wrapper_subst_dict)
716
717     # Font configuration
718
719     font_subst_dict = {}
720     font_sizes      = {}
721     base_font       = ""
722
723     # Set up font sizes
724     if sys.platform == 'darwin':
725         basefont = ""
726         font_sizes = {
727                 'SMALLER' : '9',
728                 'SMALL' : '10',
729                 'NORMAL' : '11',
730                 'BIG' : '13',
731                 'BIGGER' : '17',
732                 'LARGE' : '18',
733                 'LARGER' : '28',
734                 'HUGER' : '36',
735                 'MASSIVE' : '60',
736         }
737         if bld.env['build_target'] in ['panther', 'tiger', 'leopard'] or (Options.options.ppc and bld.env['build_target'] == 'snowleopard'):
738             # CTFontManagerRegisterFontsForURL for ArdourMono is 10.6 or newer
739             # "Lucida Grande" is not mono-spaced, but works for most cases, except big-clock-window
740             font_names = {
741                     'MONOSPACE' : 'Monaco',
742                     'CLOCKFONT' : 'Lucida Grande',
743                     }
744         else:
745             font_names = {
746                     'MONOSPACE' : 'Monaco',
747                     'CLOCKFONT' : 'ArdourMono',
748                     }
749     else: # Linux/X11 & Windows fonts
750         basefont = '' # unspecified - use system defaults
751         font_sizes = {
752                 'SMALLER' : '6',
753                 'SMALL' : '7',
754                 'NORMAL' : '8',
755                 'BIG' : '11',
756                 'BIGGER' : '13.5',
757                 'LARGE' : '14.5',
758                 'LARGER' : '19',
759                 'HUGER' : '27',
760                 'MASSIVE' : '48',
761         }
762         font_names = {
763                 'MONOSPACE' : 'ArdourMono',
764                 'CLOCKFONT' : 'ArdourMono',
765         }
766
767     # Set up font substitution dictionary
768     # @FONT_XXXX@
769     for style in ['', 'BOLD', 'ITALIC']:
770         for sizename,points in iter(font_sizes.items()):
771             if (len (style)):
772                 key = "_".join (['FONT',style,sizename])
773                 fontstyle = " ".join ([basefont,style.lower(),points])
774             else:
775                 key = "_".join (['FONT',sizename])
776                 fontstyle = " ".join ([basefont,points])
777
778             font_subst_dict[key] = fontstyle
779
780     # @FONT_SIZE_XXXX@
781     for sizename,points in iter(font_sizes.items()):
782             key = "_".join (['FONT_SIZE',sizename])
783             font_subst_dict[key] = points
784
785     # various font names, eg @BOLD_MONOSPACE@
786     for font_sym,text in iter(font_names.items()):
787         key = font_sym
788         font_subst_dict[key] = text
789
790     # RC file
791
792     obj              = bld(features = 'subst')
793     obj.source       = [ 'clearlooks.rc.in' ]
794     obj.target       = 'clearlooks.rc'
795     obj.install_path = bld.env['CONFDIR']
796     set_subst_dict(obj, font_subst_dict)
797
798     obj              = bld(features = 'subst')
799     obj.source       = [ 'default_ui_config.in' ]
800     obj.target       = 'default_ui_config'
801     obj.install_path = bld.env['CONFDIR']
802     set_subst_dict(obj, font_subst_dict)
803
804     # Menus
805     menus_argv = []
806     if sys.platform == 'darwin':
807         menus_argv = [ '-E', '-P', '-D__APPLE__', '-' ]
808     else:
809         menus_argv = [ '-E', '-P' ]
810
811     if bld.is_defined('PTFORMAT'):
812         menus_argv += [ '-DPTFORMAT' ]
813
814     # always build all versions of the menu definitions
815     # so that we can try them out with different program builds.
816     for program in [ 'ardour', 'trx' ]:
817         obj = bld(features = 'command-output')
818         obj.command = 'cpp'
819         obj.command_is_external = True
820         obj.no_inputs = True
821         obj.argv = menus_argv
822         obj.dep_vars = ['PTFORMAT', 'GTKOSX', 'WINDOWS']
823         obj.stdin = program + '.menus.in'
824         obj.stdout = program + '.menus'
825         bld.install_files (bld.env['CONFDIR'], program + '.menus')
826
827     # Freedesktop
828     freedesktop_subst_dict = {
829                     'ARDOUR_EXEC' : str (bld.env['lwrcase_dirname']),
830                     'ARDOUR_ICON' : str (bld.env['lwrcase_dirname']),
831                     'VERSION': str (bld.env['VERSION']),
832     }
833
834     if bld.env['FREEDESKTOP']:
835         obj              = bld(features = 'subst')
836         obj.source       = 'ardour.desktop.in'
837         obj.target       = str (bld.env['lwrcase_dirname']) + '.desktop'
838         obj.chmod        = Utils.O644
839         obj.dict         = freedesktop_subst_dict
840         set_subst_dict(obj, freedesktop_subst_dict)
841
842         obj              = bld(features = 'subst')
843         obj.source       = 'ardour-mime-info.xml'
844         obj.target       = 'ardour.xml'
845         obj.chmod        = Utils.O644
846
847         # build appdata with translations
848         appdata_i18n_mo(bld)
849         appdata_i18n_xmlin(bld)
850         obj              = bld(features = 'subst')
851         obj.source       = 'ardour.appdata.xml.in'
852         obj.target       = str (bld.env['lwrcase_dirname']) + '.appdata.xml'
853         obj.chmod        = Utils.O644
854         obj.dict         = freedesktop_subst_dict
855         set_subst_dict(obj, freedesktop_subst_dict)
856
857     # Keybindings
858
859     # NATIVE ARDOUR BINDING FILES
860     # explicitly state the use of perl here so that it works on windows too
861     #
862     a_rule = 'perl ../tools/fmt-bindings --platform="%s" --winkey="%s" --accelmap ${SRC[0].abspath()} >${TGT}' % (sys.platform, bld.env['WINDOWS_KEY'] )
863     for b in [ 'ardour' ] :
864         obj = bld(
865             target = b + '.keys',
866             source = [ b + '.keys.in', 'mixer.bindings', 'processor_box.bindings', 'step_editing.bindings', 'monitor.bindings' ],
867             rule = a_rule
868             )
869         obj.install_path = bld.env['CONFDIR']
870
871     # Icons/Images
872     bld.install_files(os.path.join (bld.env['DATADIR'], 'icons'), bld.path.ant_glob('icons/*.png'))
873     bld.install_files(bld.env['DATADIR'], 'ArdourMono.ttf')
874
875     # Application/Product specific resources (icon, splash)
876     pgmname = bld.env['PROGRAM_NAME']
877     bld.install_files(os.path.join(bld.env['DATADIR'], 'resources'), bld.path.ant_glob('resources/' + pgmname + '*'))
878
879     if bld.env['build_target'] == 'mingw':
880         # These icons need to overwrite the files already installed in the icons
881         # directory above. Do this in the external packaging scripts for now.
882         #bld.install_files(os.path.join (bld.env['DATADIR'], 'icons'), bld.path.ant_glob('icons/cursor_square/*.png'))
883         bld.install_files(os.path.join (bld.env['DATADIR'], 'icons'), 'icons/cursor_square/hotspots')
884
885     # Default UI configuration
886     bld.install_files(bld.env['CONFDIR'], 'default_ui_config')
887     # Color Themes. Find each color file for this program only
888     # and install
889     bld.install_files (os.path.join(bld.env['DATADIR'], 'themes'), bld.path.ant_glob ('themes/*-' + pgmname.lower() + '.colors'));
890
891     # Default export stuff
892     bld.install_files(os.path.join(bld.env['CONFDIR'], 'export'), bld.path.ant_glob('export/*.format'))
893
894     # i18n
895     if bld.is_defined('ENABLE_NLS'):
896         mo_files = bld.path.ant_glob('po/*.mo')
897         for mo in mo_files:
898             lang = os.path.basename(mo.srcpath()).replace('.mo', '')
899             bld.install_as (os.path.join(os.path.normpath(bld.env['LOCALEDIR']), lang, 'LC_MESSAGES', I18N_PACKAGE + '.mo'),
900                             mo)
901
902 def i18n(bld):
903         I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR']
904         autowaf.build_i18n(bld, top, 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources,
905                            'Paul Davis')
906         appdata_i18n_pot(bld)
907         appdata_i18n_po(bld)
908
909 def i18n_pot(bld):
910         I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR']
911         autowaf.build_i18n_pot(bld, top, 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources,
912                                'Paul Davis')
913         appdata_i18n_pot(bld)
914
915 def i18n_po(bld):
916         I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR']
917         autowaf.build_i18n_po(bld, top, 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources,
918                               'Paul Davis')
919         appdata_i18n_po(bld)
920
921 def i18n_mo(bld):
922         I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR']
923         autowaf.build_i18n_mo(bld, top, 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources,
924                               'Paul Davis')
925
926 def appdata_i18n_pot(bld):
927     potfile = os.path.join(bld.top_dir, 'gtk2_ardour', 'appdata',
928             'ardour.appdata.pot')
929     if bld.cmd == 'i18n_pot':
930         Logs.info('Generating pot file from Ardour appdata')
931         itsfile = os.path.join(bld.top_dir, 'tools', 'as-metainfo.its')
932         adsource = os.path.join(bld.top_dir, 'gtk2_ardour',
933                 'ardour.appdata.xml.in.in')
934         Logs.info('Updating ' + potfile)
935         try:
936                 subprocess.call(('itstool', '-i', itsfile, '-o', potfile, adsource))
937         except:
938                 print ('Error processing appdata pot file - ignored')
939     elif bld.cmd == 'clean' and os.path.exists(potfile):
940         Logs.info('Removing Ardour appdata pot file')
941         os.remove(potfile)
942
943 def appdata_i18n_po(bld):
944     autowaf.build_i18n_po(bld, bld.top_dir, os.path.join(
945         'gtk2_ardour', 'appdata'), 'ardour.appdata', 'dummy', 'dummy')
946
947 def appdata_i18n_mo(bld):
948     autowaf.build_i18n_mo(bld, bld.top_dir, os.path.join(
949         'gtk2_ardour', 'appdata'), 'ardour.appdata', 'dummy', 'dummy')
950
951 def appdata_i18n_xmlin(bld):
952     adxmlinfile = os.path.join(bld.top_dir, 'gtk2_ardour',
953             'ardour.appdata.xml.in')
954     if bld.cmd == 'build':
955         itsfile = os.path.join(bld.top_dir, 'tools', 'as-metainfo.its')
956         adxmlininfile = os.path.join(bld.top_dir, 'gtk2_ardour',
957                 'ardour.appdata.xml.in.in')
958         mo_glob = os.path.join(bld.top_dir, 'gtk2_ardour', 'appdata', 'po', '*.mo')
959         mo_files = glob.glob(mo_glob)
960         Logs.info('Generating ' + adxmlinfile)
961         subprocess.call(['itstool', '-i', itsfile, '-o', adxmlinfile,
962             '-j', adxmlininfile] + mo_files)
963     elif bld.cmd == 'clean' and os.path.exists(adxmlinfile):
964         Logs.info('Removing ' + adxmlinfile)
965         os.remove(adxmlinfile)