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