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