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