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