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