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