Save and Delete buttons for plugin presets, remove largely useless edit plugin preset...
[ardour.git] / gtk2_ardour / wscript
1 #!/usr/bin/env python
2 import autowaf
3 import os
4 import glob
5 import Options
6 import sys
7 import TaskGen
8 import re
9
10 # Version of this package (even if built as a child)
11 MAJOR = '3'
12 MINOR = '0'
13 MICRO = '0'
14 GTK2_ARDOUR_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
15
16 # Variables for 'waf dist'
17 APPNAME = 'gtk2_ardour'
18 VERSION = GTK2_ARDOUR_VERSION
19
20 # Mandatory variables
21 srcdir = '.'
22 blddir = 'build'
23
24 path_prefix = 'gtk2_ardour/'
25
26 gtk2_ardour_sources = [
27         'about.cc',
28         'actions.cc',
29         'add_midi_cc_track_dialog.cc',
30         'add_route_dialog.cc',
31         'ambiguous_file_dialog.cc',
32         'analysis_window.cc',
33         'ardour_dialog.cc',
34         'ardour_ui.cc',
35         'ardour_ui2.cc',
36         'ardour_ui_dependents.cc',
37         'ardour_ui_dialogs.cc',
38         'ardour_ui_ed.cc',
39         'ardour_ui_mixer.cc',
40         'ardour_ui_options.cc',
41         'audio_clock.cc',
42         'audio_region_editor.cc',
43         'audio_region_view.cc',
44         'audio_streamview.cc',
45         'audio_time_axis.cc',
46         'automation_controller.cc',
47         'automation_line.cc',
48         'automation_region_view.cc',
49         'automation_streamview.cc',
50         'automation_time_axis.cc',
51         'axis_view.cc',
52         'bundle_manager.cc',
53         'cairo_widget.cc',
54         'canvas-flag.cc',
55         'canvas-hit.cc',
56         'canvas-note-event.cc',
57         'canvas-note.cc',
58         'canvas-program-change.cc',
59         'canvas-simpleline.c',
60         'canvas-simplerect.c',
61         'canvas-sysex.cc',
62         'canvas-waveview.c',
63         'configinfo.cc',
64         'control_point.cc',
65         'control_point_dialog.cc',
66         'crossfade_edit.cc',
67         'crossfade_view.cc',
68         'curvetest.cc',
69         'debug.cc',
70         'diamond.cc',
71         'edit_note_dialog.cc',
72         'editing.cc',
73         'editor.cc',
74         'editor_actions.cc',
75         'editor_audio_import.cc',
76         'editor_audiotrack.cc',
77         'editor_canvas.cc',
78         'editor_canvas_events.cc',
79         'editor_component.cc',
80         'editor_cursors.cc',
81         'editor_drag.cc',
82         'editor_route_groups.cc',
83         'editor_export_audio.cc',
84         'editor_group_tabs.cc',
85         'editor_keyboard.cc',
86         'editor_keys.cc',
87         'editor_locations.cc',
88         'editor_markers.cc',
89         'editor_mixer.cc',
90         'editor_mouse.cc',
91         'editor_nudge.cc',
92         'editor_ops.cc',
93         'editor_regions.cc',
94         'editor_routes.cc',
95         'editor_rulers.cc',
96         'editor_scrub.cc',
97         'editor_selection.cc',
98         'editor_snapshots.cc',
99         'editor_summary.cc',
100         'editor_tempodisplay.cc',
101         'editor_timefx.cc',
102         'engine_dialog.cc',
103         'enums.cc',
104         'export_channel_selector.cc',
105         'export_dialog.cc',
106         'export_file_notebook.cc',
107         'export_filename_selector.cc',
108         'export_format_dialog.cc',
109         'export_format_selector.cc',
110         'export_preset_selector.cc',
111         'export_timespan_selector.cc',
112         'fft.cc',
113         'fft_graph.cc',
114         'fft_result.cc',
115         'gain_meter.cc',
116         'generic_pluginui.cc',
117         'ghostregion.cc',
118         'global_port_matrix.cc',
119         'group_tabs.cc',
120         'gtk-custom-hruler.c',
121         'gtk-custom-ruler.c',
122         'gtk_pianokeyboard.c',
123         'insert_time_dialog.cc',
124         'interthread_progress_window.cc',
125         'io_selector.cc',
126         'keyboard.cc',
127         'keyeditor.cc',
128         'latency_gui.cc',
129         'led.cc',
130         'level_meter.cc',
131         'lineset.cc',
132         'location_ui.cc',
133         'main.cc',
134         'marker.cc',
135         'midi_automation_line.cc',
136         'midi_channel_selector.cc',
137         'midi_cut_buffer.cc',
138         'midi_list_editor.cc',
139         'midi_port_dialog.cc',
140         'midi_region_view.cc',
141         'midi_scroomer.cc',
142         'midi_streamview.cc',
143         'midi_time_axis.cc',
144         'midi_tracer.cc',
145         'missing_file_dialog.cc',
146         'missing_plugin_dialog.cc',
147         'mixer_group_tabs.cc',
148         'mixer_strip.cc',
149         'mixer_ui.cc',
150         'monitor_section.cc',
151         'mouse_cursors.cc',
152         'nag.cc',
153         'new_plugin_preset_dialog.cc',
154         'normalize_dialog.cc',
155         'note_player.cc',
156         'option_editor.cc',
157         'opts.cc',
158         'panner.cc',
159         'panner2d.cc',
160         'panner_ui.cc',
161         'piano_roll_header.cc',
162         'playlist_selector.cc',
163         'plugin_eq_gui.cc',
164         'plugin_selector.cc',
165         'plugin_ui.cc',
166         'port_group.cc',
167         'port_insert_ui.cc',
168         'port_matrix.cc',
169         'port_matrix_body.cc',
170         'port_matrix_column_labels.cc',
171         'port_matrix_component.cc',
172         'port_matrix_grid.cc',
173         'port_matrix_labels.cc',
174         'port_matrix_row_labels.cc',
175         'processor_box.cc',
176         'progress_reporter.cc',
177         'prompter.cc',
178         'public_editor.cc',
179         'quantize_dialog.cc',
180         'rc_option_editor.cc',
181         'region_editor.cc',
182         'region_gain_line.cc',
183         'region_layering_order_editor.cc',
184         'region_selection.cc',
185         'region_view.cc',
186         'return_ui.cc',
187         'rhythm_ferret.cc',
188         'route_group_dialog.cc',
189         'route_group_menu.cc',
190         'route_params_ui.cc',
191         'route_processor_selection.cc',
192         'route_time_axis.cc',
193         'route_ui.cc',
194         'search_path_option.cc',
195         'selection.cc',
196         'send_ui.cc',
197         'session_import_dialog.cc',
198         'session_metadata_dialog.cc',
199         'session_option_editor.cc',
200         'sfdb_ui.cc',
201         'simpleline.cc',
202         'simplerect.cc',
203         'splash.cc',
204         'startup.cc',
205         'step_editor.cc',
206         'step_entry.cc',
207         'stereo_panner.cc',
208         'streamview.cc',
209         'strip_silence_dialog.cc',
210         'tape_region_view.cc',
211         'tempo_dialog.cc',
212         'tempo_lines.cc',
213         'theme_manager.cc',
214         'time_axis_view.cc',
215         'time_axis_view_item.cc',
216         'time_fx_dialog.cc',
217         'time_selection.cc',
218         'track_selection.cc',
219         'track_view_list.cc',
220         'ui_config.cc',
221         'utils.cc',
222         'version.cc',
223         'volume_controller.cc',
224         'waveview.cc',
225         'window_proxy.cc'
226 ]
227
228 def set_options(opt):
229         autowaf.set_options(opt)
230
231 def configure(conf):
232         autowaf.build_version_files(path_prefix+'version.h', path_prefix+'version.cc',
233                         'gtk2_ardour', MAJOR, MINOR, MICRO)
234         autowaf.configure(conf)
235         conf.check_tool('compiler_cxx')
236
237         if re.search ("linux", sys.platform) != None:
238                 autowaf.check_pkg(conf, 'alsa', uselib_store='ALSA')
239                 #
240                 #       TODO: Insert a sanity check for on OS X
241                 #       to ensure that CoreAudio is present....
242                 #       Really shouldn't these checks be in AutoWaf?
243                 #
244         autowaf.check_pkg(conf, 'flac', uselib_store='FLAC', atleast_version='1.2.1')
245         autowaf.check_pkg(conf, 'gthread', uselib_store='GTHREAD', atleast_version='2.10.1')
246         autowaf.check_pkg(conf, 'gtk+-2.0', uselib_store='GTK', atleast_version='2.18')
247         autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='GTKMM', atleast_version='2.18')
248         autowaf.check_pkg(conf, 'libgnomecanvasmm-2.6', uselib_store='GNOMECANVASMM', atleast_version='2.16')
249         autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
250
251         conf.check_tool('misc') # subst tool
252
253         conf.write_config_header('gtk2ardour-config.h')
254         
255         # Boost headers
256         autowaf.check_header(conf, 'boost/shared_ptr.hpp')
257         autowaf.check_header(conf, 'boost/weak_ptr.hpp')
258
259 # Add a waf `feature' to allow compilation of things using winegcc
260 from TaskGen import feature
261 @feature("wine")
262 def set_winegcc(self):
263         self.env.LINK_CXX = self.env.LINK_CC = 'wineg++'
264         self.env.CC = 'winegcc'
265
266 def build(bld):
267         # GTK front-end; if we're using VST we build this as a shared library, otherwise
268         # it's a normal executabale
269         if bld.env['VST_SUPPORT']:
270                 obj = bld.new_task_gen(features = 'cxx cc cshlib')
271         else:
272                 obj = bld.new_task_gen(features = 'cxx cc cprogram')
273
274         obj.includes     = ['.']
275         obj.source       = gtk2_ardour_sources
276         obj.name         = 'gtk2_ardour'
277         if bld.env['VST_SUPPORT']:
278                 obj.target = 'gtk2_ardour'
279                 obj.includes += ['../libs/fst']
280         else:
281                 obj.target = 'ardour-3.0'
282         obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
283         obj.uselib       = 'UUID FLAC GLIBMM GTHREAD GTK OGG ALSA CURL DL'
284         obj.uselib       += ' GTKMM GNOMECANVASMM '
285         obj.uselib       += ' AUDIOUNITS OSX GTKOSX '
286         obj.uselib_local = '''libpbd libmidipp libtaglib libardour libardour_cp
287                               libgtkmm2ext libtaglib libgnomecanvas-2'''
288         if sys.platform == 'darwin':
289                 obj.uselib_local + ' libappleutility'
290         obj.cflags       = ['-DPACKAGE="gtk2_ardour"']
291         obj.cxxflags     = ['-DPACKAGE="gtk2_ardour"']
292         obj.cxxflags     += ['-DVERSIONSTRING="' + bld.env['VERSION'] + '"']
293         obj.cxxflags     += ['-DDATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"']
294         obj.cxxflags     += ['-DCONFIG_DIR="' + os.path.normpath(bld.env['CONFIGDIR']) + '"']
295         obj.cxxflags     += ['-DMODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"']
296         obj.cxxflags     += ['-DLOCALEDIR="' + os.path.join(
297                         os.path.normpath(bld.env['DATADIR']), 'locale') + '"']
298         obj.cxxflags     += ['-DPROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"']
299         obj.cxxflags     += ['-I../libs']
300
301         if bld.env['HAVE_SLV2']:
302                 obj.source += [ 'lv2_plugin_ui.cc' ]
303                 obj.uselib += ' SLV2 '
304
305         if bld.env['FREESOUND']:
306                 obj.source +=  [ 'sfdb_freesound_mootcher.cc' ]
307
308         if bld.env['VST_SUPPORT']:
309                 obj.source += [ 'vst_pluginui.cc' ]
310                 obj.cxxflags += [ '-DVST_SUPPORT' ]
311
312         if bld.env['PHONE_HOME']:
313                 obj.cxxflags += [ '-DPHONE_HOME' ]
314
315         if bld.env['COREAUDIO']:
316                 TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cc']
317                 obj.source += [ 'cocoacarbon.mm', 'au_pluginui.mm' ]
318                 obj.uselib_local += ' libappleutility '
319         else:
320                 obj.source += [ 'x11.cc' ]
321
322         if bld.env['VST_SUPPORT']:
323                 # If we require VST support we build a stub main() and the FST library here using
324                 # winegcc, and link it to the GTK front-end library
325                 obj = bld.new_task_gen (features = 'cxx cc cprogram wine')
326                 obj.source = '''
327                         ../libs/fst/fst.c
328                         ../libs/fst/fstinfofile.c
329                         ../libs/fst/vsti.c
330                         ../libs/fst/vstwin.c
331                         ../vst/winmain.c
332                 '''
333                 obj.includes = '../libs/fst'
334                 obj.target = 'ardour-3.0-vst'
335                 obj.linkflags = ['-mwindows', '-Wl,--export-dynamic', '-lpthread']
336                 obj.defines = ['_POSIX_SOURCE', 'USE_WS_PREFIX']
337                 obj.uselib = 'ALSA'
338                 obj.uselib_local = '''libpbd libmidipp libtaglib libardour libardour_cp libgtkmm2ext libtaglib gtk2_ardour'''
339
340         # Wrappers
341
342         wrapper_subst_dict = {
343                 'INSTALL_PREFIX' : bld.env['PREFIX'],
344                 'LIBDIR'         : os.path.normpath(bld.env['LIBDIRNAME']),
345                 'LIBS'           : 'build/default/libs',
346                 'VERSION'        : '3.0',
347                 'EXECUTABLE'     : 'build/default/gtk2_ardour/ardour-3.0'
348         }
349
350         obj              = bld.new_task_gen('subst')
351         obj.source       = 'ardev_common.sh.in'
352         obj.target       = 'ardev_common_waf.sh'
353         obj.chmod        = 0755
354         obj.dict         = wrapper_subst_dict
355
356         obj              = bld.new_task_gen('subst')
357         obj.source       = 'ardour.sh.in'
358         obj.target       = 'ardour3'
359         obj.chmod        = 0755
360         obj.dict         = wrapper_subst_dict
361         obj.install_path = bld.env['BINDIR']
362
363         # Font configuration
364
365         font_subst_dict = {}
366         font_sizes      = {}
367         base_font       = ""
368
369         # Set up font sizes
370         if bld.env['IS_OSX']: # OS X fonts
371                 basefont = "Lucida Grande"
372                 font_sizes = {
373                         'TINY' : '7',
374                         'SMALLER' : '9',
375                         'SMALL' : '10',
376                         'NORMAL' : '11',
377                         'BIG' : '12',
378                         'BIGGER' : '14',
379                         'LARGE' : '18',
380                         'LARGER' : '28',
381                         'HUGER' : '36',
382                         'MASSIVE' : '60'
383                 }
384         else: # Linux/X11 fonts
385                 basefont = "sans"
386                 font_sizes = {
387                         'TINY' : '6',
388                         'SMALLER' : '8',
389                         'SMALL' : '9',
390                         'NORMAL' : '10',
391                         'BIG' : '14',
392                         'BIGGER' : '16',
393                         'LARGE' : '18',
394                         'LARGER' : '24',
395                         'HUGER' : '34',
396                         'MASSIVE' : '60'
397                 }
398
399         # Set up font substitution dictionary
400         for style in ['', 'BOLD', 'ITALIC']:
401                 for sizename,points in iter(font_sizes.items()):
402                         if (len (style)):
403                                 key = "_".join (['FONT',style,sizename])
404                                 fontstyle = " ".join ([basefont,style.lower(),points])
405                         else:
406                                 key = "_".join (['FONT',sizename])
407                                 fontstyle = " ".join ([basefont,points])
408                                 
409                         font_subst_dict[key] = fontstyle
410
411         # add normal monospace to font dict
412         font_subst_dict['FONT_MONOSPACE_NORMAL'] = 'monospace 10'
413
414         # RC files
415         obj              = bld.new_task_gen('subst')
416         obj.source       = 'ardour3_ui_dark.rc.in'
417         obj.target       = 'ardour3_ui_dark.rc'
418         obj.dict         = font_subst_dict
419         obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
420
421         obj              = bld.new_task_gen('subst')
422         obj.source       = 'ardour3_ui_light.rc.in'
423         obj.target       = 'ardour3_ui_light.rc'
424         obj.dict         = font_subst_dict
425         obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
426
427         obj              = bld.new_task_gen('subst')
428         obj.source       = 'ardour3_ui_dark_sae.rc.in'
429         obj.target       = 'ardour3_ui_dark_sae.rc'
430         obj.dict         = font_subst_dict
431         obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
432
433         obj              = bld.new_task_gen('subst')
434         obj.source       = 'ardour3_ui_light_sae.rc.in'
435         obj.target       = 'ardour3_ui_light_sae.rc'
436         obj.dict         = font_subst_dict
437         obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
438
439         # Menus
440         menus_argv = []
441         if bld.env['GTKOSX']:
442                 menus_argv = [ '-E', '-P', '-DGTKOSX' ]
443         else:
444                 menus_argv = [ '-E', '-P' ]
445         obj = bld.new_task_gen('command-output')
446         obj.command = 'cpp'
447         obj.command_is_external = True
448         obj.no_inputs = True
449         obj.argv = menus_argv
450         obj.stdin = 'ardour.menus.in'
451         obj.stdout = 'ardour.menus'
452         bld.install_files(os.path.join(bld.env['CONFIGDIR'], 'ardour3'), 'ardour.menus')
453
454         # Keybindings
455
456         # 'SAE-de-keypad', 'SAE-de-nokeypad', 'SAE-us-keypad', 'SAE-us-nokeypad', 'ergonomic-us'
457
458         for b in [ 'mnemonic-us' ] :
459                 obj = bld.new_task_gen (
460                         target = b + '.bindings',
461                         source = b + '.bindings.in',
462                         rule = '../tools/fmt-bindings --winkey="%s" --accelmap <${SRC} >${TGT}' % bld.env['WINDOWS_KEY']
463                         )
464                 obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
465
466         # not modified at present
467         bld.install_files(os.path.join(bld.env['CONFIGDIR'], 'ardour3'), 'step_editing.bindings')
468
469         # Icons/Images
470         bld.install_files('${DATADIR}/ardour3/icons', 'icons/*.png')
471         bld.install_files('${DATADIR}/ardour3/pixmaps', 'pixmaps/*.xpm')
472         bld.install_files('${DATADIR}/ardour3', 'splash.png')
473
474         # Default UI configuration
475         bld.install_files('${CONFIGDIR}/ardour3', 'ardour3_ui_default.conf')
476         
477         # Default export stuff
478         bld.install_files('${CONFIGDIR}/ardour3/export', 'export/*.format')
479
480         # i18n
481         if bld.env['ENABLE_NLS']:
482                 mo_files = glob.glob (os.path.join (bld.get_curdir(), 'po/*.mo'))
483                 for mo in mo_files:
484                         lang = os.path.basename (mo).replace ('.mo', '')
485                         bld.install_as (os.path.join (bld.env['PREFIX'], 'share', 'locale', lang, 'LC_MESSAGES', APPNAME + '.mo'), mo)
486
487 def i18n(bld):
488         autowaf.build_i18n (bld, srcdir, 'gtk2_ardour', APPNAME, gtk2_ardour_sources)
489