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