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