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