Rework Patch-Change/Select Dialog
[ardour.git] / gtk2_ardour / wscript
1 #!/usr/bin/env python
2 from waflib.extras import autowaf as autowaf
3 from waflib import Options, TaskGen
4 import waflib.Logs as Logs, waflib.Utils as Utils
5 import os
6 import shutil
7 import sys
8 import re
9 import time
10 from waflib.Task import Task
11 from waflib.Tools import winres
12 import subprocess
13 import glob
14 import copy
15
16 # Mandatory variables
17 top = '.'
18 out = 'build'
19
20 from waflib import TaskGen
21 @TaskGen.extension('.m')
22 def m_hook(self, node):
23         """Alias .m files to be compiled the same as .c files, gcc will do the right thing."""
24         return self.create_compiled_task('c', node)
25
26 path_prefix = 'gtk2_ardour/'
27
28 gtk2_ardour_sources = [
29         'about.cc',
30         'actions.cc',
31         'add_route_dialog.cc',
32         'ambiguous_file_dialog.cc',
33         'analysis_window.cc',
34         'ardour_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 minor == 13:
338             return "\\n\\\"The Pearl\\\"" # 1984 Collaborative
339         elif minor == 14:
340             return "\\n\\\"Begegnungen\\\"" # 1984 Compilation
341     return "\\\"\\\""
342
343 def options(opt):
344     autowaf.set_options(opt)
345
346 def configure(conf):
347     conf.load('misc')
348     conf.load('compiler_cxx')
349     autowaf.configure(conf)
350
351     # TODO: Insert a sanity check for on OS X to ensure CoreAudio is present
352
353     autowaf.check_pkg(conf, 'fftw3f', uselib_store='FFTW3F',
354                       mandatory=True)
355     autowaf.check_pkg(conf, 'fftw3f', uselib_store='FFTW35F',
356                       atleast_version='3.3.5', mandatory=False)
357     autowaf.check_pkg(conf, 'flac', uselib_store='FLAC',
358                       atleast_version='1.2.1')
359     autowaf.check_pkg(conf, 'gthread-2.0', uselib_store='GTHREAD',
360                       atleast_version='2.10.1')
361     autowaf.check_pkg(conf, 'gtk+-2.0', uselib_store='GTK',
362                       atleast_version='2.18')
363     autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='GTKMM',
364                       atleast_version='2.18')
365     autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
366     autowaf.check_pkg(conf, 'x11', uselib_store='X11', atleast_version='1.1', mandatory=False)
367     autowaf.check_pkg(conf, 'pangoft2', uselib_store='PANGOFT2', atleast_version='1.36.8', mandatory=False)
368     autowaf.check_pkg(conf, 'fontconfig', uselib_store='FONTCONFIG')
369
370
371     if sys.platform == 'darwin':
372         retval = conf.run_c_code (code='#include <AppKit/NSWindow.h>\n\
373         int main(void) { (void) NSWindowWillStartLiveResizeNotification; return 0; }\n',
374                                   env = conf.env.derive (),
375                                   features = [ 'c' ],
376                                   compiler = 'cc',
377                                   compile_filename='test.m',
378                                   mandatory = False,
379             )
380
381         if retval == 0:
382             autowaf.display_msg (conf, 'Checking for Cocoa live resizing constants', 'ok')
383             conf.define ('HAVE_COCOA_LIVE_RESIZING', 1)
384         else:
385             autowaf.display_msg (conf, 'Checking for Cocoa live resizing constants', 'too old - AU plugin windows will be fixed size')
386
387     conf.write_config_header('gtk2ardour-config.h', remove=False)
388
389     bak = conf.env['define_key']
390     conf.define('VERSIONSTRING', str (conf.env['VERSION']))
391     conf.define('CODENAME', enoify(int(conf.env['MAJOR']), int(conf.env['MINOR'])))
392     conf.env['define_key'] = ['VERSIONSTRING', 'CODENAME' ]
393     conf.write_config_header('gtk2ardour-version.h')
394     conf.env['define_key'] = bak;
395
396     # Boost headers
397     autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp')
398     autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
399
400 # Add a waf `feature' to allow compilation of things using winegcc
401 from waflib.TaskGen import feature
402 @feature("wine")
403 def set_winegcc(self):
404     self.env.LINK_CXX = self.env.LINK_CC = 'wineg++'
405     self.env.CC = 'winegcc'
406
407 def _doPyp(infileName, deps = False):
408     outStr = ''
409     out = []
410     re_spaces = re.compile("\s+")
411
412     if infileName == '-':
413         fd = sys.stdin
414     else:
415         fd = open(infileName)
416     inLines = fd.readlines()
417     if fd != sys.stdin:
418         fd.close()
419
420
421     for line in inLines:
422         bits = re_spaces.split(line)
423         if bits[0] == '##include':
424             incName = bits[1]
425             if (deps):
426                 out += [ incName ]
427             else:
428                 # assume included file comes from same place as source file
429                 incName = os.path.join (os.path.dirname (infileName), incName);
430                 outStr += _doPyp(incName)
431         else:
432             if not deps:
433                 outStr += line
434
435     # done
436     if deps:
437         return out
438     else:
439         return outStr
440
441 def include_processor(task):
442     infileName = task.inputs[0].srcpath()
443     outfileName = os.path.join(out, task.outputs[0].bldpath())
444     fdOut = open (outfileName, "w")
445     fdOut.write (_doPyp(infileName))
446     fdOut.close ()
447
448
449 def build_color_scheme(path, prefix):
450     f = open (path, 'r')
451     color_scheme = ''
452     for line in f:
453         if re.search ('^#@color', line):
454             line.strip() # remove newline
455             words = line.split()
456             if len(color_scheme):
457                 color_scheme += ';'
458             color_scheme += prefix
459             color_scheme += '_'
460             color_scheme += words[1]
461             color_scheme += ':'
462             color_scheme += words[2]
463     f.close()
464     return color_scheme
465
466 def build(bld):
467
468     VERSION = "%s.%s" % (bld.env['MAJOR'], bld.env['MINOR'])
469     I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR']
470
471     # Tool to dump lua-bindings (of gtk2ardour + libs)
472     if re.search ("linux", sys.platform) != None and bld.env['LUABINDINGDOC']:
473         obj = bld (features = 'cxx c cxxprogram')
474         obj.install_path = None
475         obj.source    = list(gtk2_ardour_sources)
476         obj.target    = 'luadoc'
477         obj.includes  = ['.', '../libs']
478         obj.ldflags   = ['-no-undefined']
479         obj.use       = [
480                 'libpbd',
481                 'libardour',
482                 'libardour_cp',
483                 'libtimecode',
484                 'libmidipp',
485                 'libgtkmm2ext',
486                 'libcanvas',
487                 'libwaveview',
488                 'libwidgets',
489                 'libptformat',
490                 ]
491         obj.defines = [
492                 'NOMAIN',
493                 'PACKAGE="' + I18N_PACKAGE + '"',
494                 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
495                 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
496                 'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"',
497                 ]
498         obj.linkflags = ''
499         obj.uselib    = 'UUID FLAC FONTCONFIG GLIBMM GTHREAD GTK OGG CURL DL GTKMM CANVAS FFTW3F LO TAGLIB XML '
500         obj.source += [ 'luadoc.cc', 'bundle_env_linux.cc' ]
501         if bld.is_defined('HAVE_SUIL'):
502             obj.source += [ 'lv2_plugin_ui.cc' ]
503             obj.use += [ 'SUIL' ]
504         if bld.is_defined('LXVST_SUPPORT'):
505             obj.source += [ 'vst_plugin_ui.cc' ]
506             obj.source += [ 'linux_vst_gui_support.cc', 'lxvst_plugin_ui.cc' ]
507             obj.defines += [ 'LXVST_SUPPORT' ]
508             obj.use += [ 'X11' ]
509
510 #    # Tool to test libcanvas
511 #    if re.search ("linux", sys.platform) != None and bld.env['CANVASTESTUI']:
512 #        obj = bld (features = 'cxx c cxxprogram')
513 #        obj.install_path = None
514 #        obj.source    = list(gtk2_ardour_sources)
515 #        obj.source    = [ 'ardour_button.cc', 'ui_config.cc', 'tooltips.cc' ]
516 #        obj.target    = 'canvas_test'
517 #        obj.includes  = ['.', '../libs']
518 #        obj.ldflags   = ['-no-undefined']
519 #        obj.use       = [
520 #                'libpbd',
521 #                'libardour',
522 #                'libardour_cp',
523 #                'libtimecode',
524 #                'libmidipp',
525 #                'libgtkmm2ext',
526 #                'libcanvas',
527 #                'libptformat',
528 #                ]
529 #        obj.defines = [
530 #                'NOMAIN',
531 #                'PACKAGE="' + I18N_PACKAGE + '"',
532 #                'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
533 #                'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
534 #                'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"',
535 #                ]
536 #        obj.linkflags = ''
537 #        obj.uselib    = 'UUID FLAC FONTCONFIG GLIBMM GTHREAD GTK OGG CURL DL GTKMM CANVAS FFTW3F LO TAGLIB XML '
538 #        # obj.source += [ 'canvas_test.cc', ]
539 #        obj.source += [ 'toolbar_test.cc', 'enums.cc']
540
541
542     if bld.is_defined('WINDOWS_VST_SUPPORT') and bld.env['build_target'] != 'mingw':
543         # Windows VST support w/wine
544         # If we require VST support we build a stub main() and the FST library
545         # here using winegcc, and link it to the GTK front-end library
546         obj = bld (features = 'cxx c cxxprogram wine')
547         obj.source = ( '../libs/fst/vstwin.c', '../vst/winmain.c' )
548         #
549         # XXX do we really need to explicitly link to all of these for the wine executable?
550         #
551         obj.use          = [ 'libpbd',
552                              'libmidipp',
553                              'libardour',
554                              'libardour_cp',
555                              'libtimecode',
556                              'libmidipp',
557                              'libgtk2_ardour',
558                              'libgtkmm2ext',
559                              'libcanvas',
560                              'libwaveview',
561                              'libwidgets',
562                              'libptformat',
563                              ]
564         obj.target = 'ardour-' + str (bld.env['VERSION']) + '-vst.exe.so'
565         obj.includes  = [ '../libs/fst', '.' ]
566         obj.linkflags = ['-mwindows', '-Wl,--export-dynamic']
567         obj.linkflags += bld.env['LDFLAGS']
568         obj.defines = ['_POSIX_SOURCE', 'USE_WS_PREFIX']
569         obj.install_path = bld.env['DLLDIR']
570         # end of the wine executable
571
572         # now the shared library containing the GTK GUI for ardour
573         obj = bld (features = 'cxx c cxxshlib')
574         # operate on copy to avoid adding sources twice
575         obj.source    = list(gtk2_ardour_sources)
576         obj.includes  = [ '../libs/fst', '.' ]
577         obj.name      = 'libgtk2_ardour'
578         obj.target    = 'gtk2_ardour'
579         obj.cflags  = [ '-fPIC' ]
580
581     else:
582         # just the normal executable version of the GTK GUI
583         if bld.env['build_target'] == 'mingw':
584             obj = bld (features = 'cxx c cxxprogram winres')
585         else:
586             obj = bld (features = 'cxx c cxxprogram')
587         # operate on copy to avoid adding sources twice
588         obj.source    = list(gtk2_ardour_sources)
589         obj.target = 'ardour-' + str (bld.env['VERSION'])
590         obj.includes = ['.']
591         obj.ldflags = ['-no-undefined']
592
593         if bld.is_defined('WINDOWS_VST_SUPPORT'):
594         # Windows VST support mingw
595             obj.includes += [ '../libs/fst' ]
596
597     # at this point, "obj" refers to either the normal native executable
598     # OR the shared library built for use with wine on linux.
599
600     obj.use      = [ 'libpbd',
601                      'libardour',
602                      'libardour_cp',
603                      'libtimecode',
604                      'libmidipp',
605                      'libgtkmm2ext',
606                      'libcanvas',
607                      'libwaveview',
608                      'libwidgets',
609                      'libptformat',
610                      ]
611
612     obj.defines = [
613         'PACKAGE="' + I18N_PACKAGE + '"',
614         'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
615         'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
616         'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"',
617         ]
618     obj.install_path = bld.env['DLLDIR']
619     obj.linkflags    = ''
620     obj.uselib       = 'UUID FLAC FONTCONFIG GLIBMM GTHREAD GTK OGG CURL DL GTKMM CANVAS FFTW3F LO TAGLIB XML '
621
622     if sys.platform == 'darwin':
623         obj.uselib += ' AUDIOUNITS OSX '
624         obj.use    += ' libappleutility'
625         obj.source += [ 'cocoacarbon.mm', 'bundle_env_cocoa.cc' ]
626     elif bld.env['build_target'] == 'mingw':
627         obj.source += [ 'bundle_env_mingw.cc' ]
628         obj.source += [ 'windows_icon.rc' ]
629     else:
630         obj.source += [ 'bundle_env_linux.cc' ]
631
632     obj.includes += ['../libs']
633
634     obj.use += 'libptformat'
635
636     if bld.env['build_target'] == 'mingw':
637         obj.linkflags += ' -mwindows'
638         obj.use += [ 'PANGOFT2' ]
639
640     if bld.is_defined('HAVE_SUIL'):
641         obj.source += [ 'lv2_plugin_ui.cc' ]
642         obj.use += [ 'SUIL' ]
643
644     if bld.is_defined('HAVE_FFTW35F') and bld.env['build_target'] != 'mingw':
645         bld.env['LIB_FFTW3F'] += ['fftw3f_threads']
646
647     if bld.is_defined('NEED_INTL'):
648         obj.linkflags += ' -lintl'
649
650     if bld.is_defined('WINDOWS_VST_SUPPORT'):
651         obj.source += [ 'windows_vst_plugin_ui.cc' ]
652         obj.defines += [ 'WINDOWS_VST_SUPPORT' ]
653         if bld.env['build_target'] != 'mingw':
654             obj.use += [ 'X11' ]
655
656     if bld.is_defined('LXVST_SUPPORT'):
657         obj.source += [ 'linux_vst_gui_support.cc', 'lxvst_plugin_ui.cc' ]
658         obj.defines += [ 'LXVST_SUPPORT' ]
659         obj.use += [ 'X11' ]
660
661     if bld.is_defined('MACVST_SUPPORT'):
662         obj.source += [ 'mac_vst_plugin_ui.mm' ]
663         obj.defines += [ 'MACVST_SUPPORT' ]
664
665     if bld.is_defined('WINDOWS_VST_SUPPORT') or bld.is_defined('LXVST_SUPPORT') or bld.is_defined ('MACVST_SUPPORT'):
666         obj.source += [ 'vst_plugin_ui.cc' ]
667
668     if bld.is_defined('PHONE_HOME'):
669         obj.defines += [ 'PHONE_HOME' ]
670
671     if bld.is_defined('HAVE_COREAUDIO'):
672         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cc']
673         obj.use += ' libappleutility '
674
675     if bld.is_defined('AUDIOUNIT_SUPPORT'):
676         obj.source += [ 'au_pluginui.mm' ]
677
678     # Wrappers
679
680     wrapper_subst_dict = {
681             'INSTALL_PREFIX' : bld.env['PREFIX'],
682             'LIBDIR'         : os.path.normpath(bld.env['DLLDIR']),
683             'DATADIR'        : os.path.normpath(bld.env['DATADIR']),
684             'CONFDIR'        : os.path.normpath(bld.env['CONFDIR']),
685             'LIBS'           : 'build/libs',
686             'VERSION'        : str (bld.env['VERSION']),
687             'EXECUTABLE'     : 'build/gtk2_ardour/ardour-' + str (bld.env['VERSION'])
688     }
689
690     def set_subst_dict(obj, dict):
691         for i in dict:
692             setattr(obj, i, dict[i])
693
694     obj              = bld(features = 'subst')
695     obj.source       = 'ardev_common.sh.in'
696     obj.target       = 'ardev_common_waf.sh'
697     obj.chmod        = Utils.O755
698     obj.dict         = wrapper_subst_dict
699     set_subst_dict(obj, wrapper_subst_dict)
700
701     obj              = bld(features = 'subst')
702     obj.source       = 'ardour.sh.in'
703     obj.target       = 'ardour' + str (bld.env['MAJOR'])
704     obj.chmod        = Utils.O755
705     obj.dict         = wrapper_subst_dict
706     obj.install_path = bld.env['BINDIR']
707     set_subst_dict(obj, wrapper_subst_dict)
708
709     if bld.is_defined('WINDOWS_VST_SUPPORT'):
710         obj              = bld(features = 'subst')
711         obj.source       = '../vst/ardourvst.in'
712         obj.target       = 'ardourvst' + str (bld.env['MAJOR'])
713         obj.chmod        = Utils.O755
714         obj.dict         = wrapper_subst_dict
715         obj.install_path = bld.env['BINDIR']
716         set_subst_dict(obj, wrapper_subst_dict)
717
718     # Font configuration
719
720     font_subst_dict = {}
721     font_sizes      = {}
722     base_font       = ""
723
724     # Set up font sizes
725     if sys.platform == 'darwin':
726         basefont = ""
727         font_sizes = {
728                 'SMALLER' : '9',
729                 'SMALL' : '10',
730                 'NORMAL' : '11',
731                 'BIG' : '13',
732                 'BIGGER' : '17',
733                 'LARGE' : '18',
734                 'LARGER' : '28',
735                 'HUGER' : '36',
736                 'MASSIVE' : '60',
737         }
738         if bld.env['build_target'] in ['panther', 'tiger', 'leopard'] or (Options.options.ppc and bld.env['build_target'] == 'snowleopard'):
739             # CTFontManagerRegisterFontsForURL for ArdourMono is 10.6 or newer
740             # "Lucida Grande" is not mono-spaced, but works for most cases, except big-clock-window
741             font_names = {
742                     'MONOSPACE' : 'Monaco',
743                     'CLOCKFONT' : 'Lucida Grande',
744                     }
745         else:
746             font_names = {
747                     'MONOSPACE' : 'Monaco',
748                     'CLOCKFONT' : 'ArdourMono',
749                     }
750     else: # Linux/X11 & Windows fonts
751         basefont = '' # unspecified - use system defaults
752         font_sizes = {
753                 'SMALLER' : '6',
754                 'SMALL' : '7',
755                 'NORMAL' : '8',
756                 'BIG' : '11',
757                 'BIGGER' : '13.5',
758                 'LARGE' : '14.5',
759                 'LARGER' : '19',
760                 'HUGER' : '27',
761                 'MASSIVE' : '48',
762         }
763         font_names = {
764                 'MONOSPACE' : 'ArdourMono',
765                 'CLOCKFONT' : 'ArdourMono',
766         }
767
768     # Set up font substitution dictionary
769     # @FONT_XXXX@
770     for style in ['', 'BOLD', 'ITALIC']:
771         for sizename,points in iter(font_sizes.items()):
772             if (len (style)):
773                 key = "_".join (['FONT',style,sizename])
774                 fontstyle = " ".join ([basefont,style.lower(),points])
775             else:
776                 key = "_".join (['FONT',sizename])
777                 fontstyle = " ".join ([basefont,points])
778
779             font_subst_dict[key] = fontstyle
780
781     # @FONT_SIZE_XXXX@
782     for sizename,points in iter(font_sizes.items()):
783             key = "_".join (['FONT_SIZE',sizename])
784             font_subst_dict[key] = points
785
786     # various font names, eg @BOLD_MONOSPACE@
787     for font_sym,text in iter(font_names.items()):
788         key = font_sym
789         font_subst_dict[key] = text
790
791     # RC file
792
793     obj              = bld(features = 'subst')
794     obj.source       = [ 'clearlooks.rc.in' ]
795     obj.target       = 'clearlooks.rc'
796     obj.install_path = bld.env['CONFDIR']
797     set_subst_dict(obj, font_subst_dict)
798
799     obj              = bld(features = 'subst')
800     obj.source       = [ 'default_ui_config.in' ]
801     obj.target       = 'default_ui_config'
802     obj.install_path = bld.env['CONFDIR']
803     set_subst_dict(obj, font_subst_dict)
804
805     # Menus
806     menus_argv = []
807     if sys.platform == 'darwin':
808         menus_argv = [ '-E', '-P', '-D__APPLE__', '-' ]
809     else:
810         menus_argv = [ '-E', '-P' ]
811
812     if bld.is_defined('PTFORMAT'):
813         menus_argv += [ '-DPTFORMAT' ]
814
815     # always build all versions of the menu definitions
816     # so that we can try them out with different program builds.
817     for program in [ 'ardour', 'trx' ]:
818         obj = bld(features = 'command-output')
819         obj.command = 'cpp'
820         obj.command_is_external = True
821         obj.no_inputs = True
822         obj.argv = menus_argv
823         obj.dep_vars = ['PTFORMAT', 'GTKOSX', 'WINDOWS']
824         obj.stdin = program + '.menus.in'
825         obj.stdout = program + '.menus'
826         bld.install_files (bld.env['CONFDIR'], program + '.menus')
827
828     # Freedesktop
829     freedesktop_subst_dict = {
830                     'ARDOUR_EXEC' : str (bld.env['lwrcase_dirname']),
831                     'ARDOUR_ICON' : str (bld.env['lwrcase_dirname']),
832                     'VERSION': str (bld.env['VERSION']),
833     }
834
835     if bld.env['FREEDESKTOP']:
836         obj              = bld(features = 'subst')
837         obj.source       = 'ardour.desktop.in'
838         obj.target       = str (bld.env['lwrcase_dirname']) + '.desktop'
839         obj.chmod        = Utils.O644
840         obj.dict         = freedesktop_subst_dict
841         set_subst_dict(obj, freedesktop_subst_dict)
842
843         obj              = bld(features = 'subst')
844         obj.source       = 'ardour-mime-info.xml'
845         obj.target       = 'ardour.xml'
846         obj.chmod        = Utils.O644
847
848         # build appdata with translations
849         appdata_i18n_mo(bld)
850         appdata_i18n_xmlin(bld)
851         obj              = bld(features = 'subst')
852         obj.source       = 'ardour.appdata.xml.in'
853         obj.target       = str (bld.env['lwrcase_dirname']) + '.appdata.xml'
854         obj.chmod        = Utils.O644
855         obj.dict         = freedesktop_subst_dict
856         set_subst_dict(obj, freedesktop_subst_dict)
857
858     # Keybindings
859
860     # NATIVE ARDOUR BINDING FILES
861     # explicitly state the use of perl here so that it works on windows too
862     #
863     a_rule = 'perl ../tools/fmt-bindings --platform="%s" --winkey="%s" --accelmap ${SRC[0].abspath()} >${TGT}' % (sys.platform, bld.env['WINDOWS_KEY'] )
864     for b in [ 'ardour' ] :
865         obj = bld(
866             target = b + '.keys',
867             source = [ b + '.keys.in', 'mixer.bindings', 'processor_box.bindings', 'step_editing.bindings', 'monitor.bindings' ],
868             rule = a_rule
869             )
870         obj.install_path = bld.env['CONFDIR']
871
872     # Icons/Images
873     bld.install_files(os.path.join (bld.env['DATADIR'], 'icons'), bld.path.ant_glob('icons/*.png'))
874     bld.install_files(bld.env['DATADIR'], 'ArdourMono.ttf')
875
876     # Application/Product specific resources (icon, splash)
877     pgmname = bld.env['PROGRAM_NAME']
878     bld.install_files(os.path.join(bld.env['DATADIR'], 'resources'), bld.path.ant_glob('resources/' + pgmname + '*'))
879
880     if bld.env['build_target'] == 'mingw':
881         # These icons need to overwrite the files already installed in the icons
882         # directory above. Do this in the external packaging scripts for now.
883         #bld.install_files(os.path.join (bld.env['DATADIR'], 'icons'), bld.path.ant_glob('icons/cursor_square/*.png'))
884         bld.install_files(os.path.join (bld.env['DATADIR'], 'icons'), 'icons/cursor_square/hotspots')
885
886     # Default UI configuration
887     bld.install_files(bld.env['CONFDIR'], 'default_ui_config')
888     # Color Themes. Find each color file for this program only
889     # and install
890     bld.install_files (os.path.join(bld.env['DATADIR'], 'themes'), bld.path.ant_glob ('themes/*-' + pgmname.lower() + '.colors'));
891
892     # Default export stuff
893     bld.install_files(os.path.join(bld.env['CONFDIR'], 'export'), bld.path.ant_glob('export/*.format'))
894
895     # i18n
896     if bld.is_defined('ENABLE_NLS'):
897         mo_files = bld.path.ant_glob('po/*.mo')
898         for mo in mo_files:
899             lang = os.path.basename(mo.srcpath()).replace('.mo', '')
900             bld.install_as (os.path.join(os.path.normpath(bld.env['LOCALEDIR']), lang, 'LC_MESSAGES', I18N_PACKAGE + '.mo'),
901                             mo)
902
903 def i18n(bld):
904         I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR']
905         autowaf.build_i18n(bld, top, 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources,
906                            'Paul Davis')
907         appdata_i18n_pot(bld)
908         appdata_i18n_po(bld)
909
910 def i18n_pot(bld):
911         I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR']
912         autowaf.build_i18n_pot(bld, top, 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources,
913                                'Paul Davis')
914         appdata_i18n_pot(bld)
915
916 def i18n_po(bld):
917         I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR']
918         autowaf.build_i18n_po(bld, top, 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources,
919                               'Paul Davis')
920         appdata_i18n_po(bld)
921
922 def i18n_mo(bld):
923         I18N_PACKAGE = 'gtk2_ardour' + bld.env['MAJOR']
924         autowaf.build_i18n_mo(bld, top, 'gtk2_ardour', I18N_PACKAGE, gtk2_ardour_sources,
925                               'Paul Davis')
926
927 def appdata_i18n_pot(bld):
928     potfile = os.path.join(bld.top_dir, 'gtk2_ardour', 'appdata',
929             'ardour.appdata.pot')
930     if bld.cmd == 'i18n_pot':
931         Logs.info('Generating pot file from Ardour appdata')
932         itsfile = os.path.join(bld.top_dir, 'tools', 'as-metainfo.its')
933         adsource = os.path.join(bld.top_dir, 'gtk2_ardour',
934                 'ardour.appdata.xml.in.in')
935         Logs.info('Updating ' + potfile)
936         try:
937                 subprocess.call(('itstool', '-i', itsfile, '-o', potfile, adsource))
938         except:
939                 print ('Error processing appdata pot file - ignored')
940     elif bld.cmd == 'clean' and os.path.exists(potfile):
941         Logs.info('Removing Ardour appdata pot file')
942         os.remove(potfile)
943
944 def appdata_i18n_po(bld):
945     autowaf.build_i18n_po(bld, bld.top_dir, os.path.join(
946         'gtk2_ardour', 'appdata'), 'ardour.appdata', 'dummy', 'dummy')
947
948 def appdata_i18n_mo(bld):
949     autowaf.build_i18n_mo(bld, bld.top_dir, os.path.join(
950         'gtk2_ardour', 'appdata'), 'ardour.appdata', 'dummy', 'dummy')
951
952 def appdata_i18n_xmlin(bld):
953     adxmlinfile = os.path.join(bld.top_dir, 'gtk2_ardour',
954             'ardour.appdata.xml.in')
955     if bld.cmd == 'build':
956         itsfile = os.path.join(bld.top_dir, 'tools', 'as-metainfo.its')
957         adxmlininfile = os.path.join(bld.top_dir, 'gtk2_ardour',
958                 'ardour.appdata.xml.in.in')
959         mo_glob = os.path.join(bld.top_dir, 'gtk2_ardour', 'appdata', 'po', '*.mo')
960         mo_files = glob.glob(mo_glob)
961         Logs.info('Generating ' + adxmlinfile)
962         subprocess.call(['itstool', '-i', itsfile, '-o', adxmlinfile,
963             '-j', adxmlininfile] + mo_files)
964     elif bld.cmd == 'clean' and os.path.exists(adxmlinfile):
965         Logs.info('Removing ' + adxmlinfile)
966         os.remove(adxmlinfile)