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