introduce GUIObjectState; massive, pervasive changes in visibility and height managem...
[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_patch_change.cc',
59         'canvas-simpleline.c',
60         'canvas-simplerect.c',
61         'canvas-sysex.cc',
62         'canvas-waveview.c',
63         'clock_group.cc',
64         'configinfo.cc',
65         'control_point.cc',
66         'control_point_dialog.cc',
67         'crossfade_edit.cc',
68         'crossfade_view.cc',
69         'curvetest.cc',
70         'debug.cc',
71         'diamond.cc',
72         'edit_note_dialog.cc',
73         'editing.cc',
74         'editor.cc',
75         'editor_actions.cc',
76         'editor_audio_import.cc',
77         'editor_audiotrack.cc',
78         'editor_canvas.cc',
79         'editor_canvas_events.cc',
80         'editor_component.cc',
81         'editor_cursors.cc',
82         'editor_drag.cc',
83         'editor_route_groups.cc',
84         'editor_export_audio.cc',
85         'editor_group_tabs.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         'gui_object.cc',
124         'insert_time_dialog.cc',
125         'interthread_progress_window.cc',
126         'io_selector.cc',
127         'keyboard.cc',
128         'keyeditor.cc',
129         'latency_gui.cc',
130         'led.cc',
131         'level_meter.cc',
132         'lineset.cc',
133         'location_ui.cc',
134         'main.cc',
135         'marker.cc',
136         'midi_automation_line.cc',
137         'midi_channel_dialog.cc',
138         'midi_channel_selector.cc',
139         'midi_cut_buffer.cc',
140         'midi_list_editor.cc',
141         'midi_port_dialog.cc',
142         'midi_region_view.cc',
143         'midi_scroomer.cc',
144         'midi_streamview.cc',
145         'midi_time_axis.cc',
146         'midi_tracer.cc',
147         'missing_file_dialog.cc',
148         'missing_plugin_dialog.cc',
149         'mixer_group_tabs.cc',
150         'mixer_strip.cc',
151         'mixer_ui.cc',
152         'monitor_section.cc',
153         'mono_panner.cc',
154         'mouse_cursors.cc',
155         'nag.cc',
156         'new_plugin_preset_dialog.cc',
157         'normalize_dialog.cc',
158         'note_player.cc',
159         'option_editor.cc',
160         'opts.cc',
161         'panner2d.cc',
162         'panner_ui.cc',
163         'piano_roll_header.cc',
164         'playlist_selector.cc',
165         'plugin_eq_gui.cc',
166         'plugin_selector.cc',
167         'plugin_ui.cc',
168         'port_group.cc',
169         'port_insert_ui.cc',
170         'port_matrix.cc',
171         'port_matrix_body.cc',
172         'port_matrix_column_labels.cc',
173         'port_matrix_component.cc',
174         'port_matrix_grid.cc',
175         'port_matrix_labels.cc',
176         'port_matrix_row_labels.cc',
177         'processor_box.cc',
178         'patch_change_dialog.cc',
179         'progress_reporter.cc',
180         'prompter.cc',
181         'public_editor.cc',
182         'quantize_dialog.cc',
183         'rc_option_editor.cc',
184         'region_editor.cc',
185         'region_gain_line.cc',
186         'region_layering_order_editor.cc',
187         'region_selection.cc',
188         'region_view.cc',
189         'return_ui.cc',
190         'rhythm_ferret.cc',
191         'route_group_dialog.cc',
192         'route_group_menu.cc',
193         'route_params_ui.cc',
194         'route_processor_selection.cc',
195         'route_time_axis.cc',
196         'route_ui.cc',
197         'search_path_option.cc',
198         'selection.cc',
199         'send_ui.cc',
200         'session_import_dialog.cc',
201         'session_metadata_dialog.cc',
202         'session_option_editor.cc',
203         'sfdb_ui.cc',
204         'shuttle_control.cc',
205         'simpleline.cc',
206         'simplerect.cc',
207         'splash.cc',
208         'speaker_dialog.cc',
209         'startup.cc',
210         'step_editor.cc',
211         'step_entry.cc',
212         'stereo_panner.cc',
213         'streamview.cc',
214         'strip_silence_dialog.cc',
215         'tape_region_view.cc',
216         'tempo_dialog.cc',
217         'tempo_lines.cc',
218         'theme_manager.cc',
219         'time_axis_view.cc',
220         'time_axis_view_item.cc',
221         'time_fx_dialog.cc',
222         'time_info_box.cc',
223         'time_selection.cc',
224         'track_selection.cc',
225         'track_view_list.cc',
226         'transpose_dialog.cc',
227         'ui_config.cc',
228         'utils.cc',
229         'verbose_cursor.cc',
230         'version.cc',
231         'volume_controller.cc',
232         'waveview.cc',
233         'window_proxy.cc'
234 ]
235
236 def set_options(opt):
237     autowaf.set_options(opt)
238
239 def configure(conf):
240     autowaf.build_version_files(
241         path_prefix + 'version.h',
242         path_prefix + 'version.cc',
243         'gtk2_ardour', MAJOR, MINOR, MICRO)
244     autowaf.configure(conf)
245     conf.check_tool('compiler_cxx')
246
247     if re.search ("linux", sys.platform) != None:
248         autowaf.check_pkg(conf, 'alsa', uselib_store='ALSA')
249
250     # TODO: Insert a sanity check for on OS X to ensure CoreAudio is present
251
252     autowaf.check_pkg(conf, 'flac', uselib_store='FLAC',
253                       atleast_version='1.2.1')
254     autowaf.check_pkg(conf, 'gthread', uselib_store='GTHREAD',
255                       atleast_version='2.10.1')
256     autowaf.check_pkg(conf, 'gtk+-2.0', uselib_store='GTK',
257                       atleast_version='2.18')
258     autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='GTKMM',
259                       atleast_version='2.18')
260     autowaf.check_pkg(conf, 'libgnomecanvasmm-2.6',
261                       uselib_store='GNOMECANVASMM', atleast_version='2.16')
262     autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
263
264     conf.check_tool('misc') # subst tool
265
266     conf.write_config_header('gtk2ardour-config.h')
267
268     # Boost headers
269     autowaf.check_header(conf, 'boost/shared_ptr.hpp')
270     autowaf.check_header(conf, 'boost/weak_ptr.hpp')
271
272 # Add a waf `feature' to allow compilation of things using winegcc
273 from TaskGen import feature
274 @feature("wine")
275 def set_winegcc(self):
276     self.env.LINK_CXX = self.env.LINK_CC = 'wineg++'
277     self.env.CC = 'winegcc'
278
279 def build_color_scheme(path, prefix):
280     f = open (path, 'r')
281     color_scheme = ''
282     for line in f:
283         if re.search ('^#@color', line):
284             line.strip() # remove newline
285             words = line.split()
286             if len(color_scheme):
287                 color_scheme += ';'
288             color_scheme += prefix
289             color_scheme += '_'
290             color_scheme += words[1]
291             color_scheme += ':'
292             color_scheme += words[2]
293     f.close()
294     return color_scheme
295
296
297 def build(bld):
298     # GTK front-end; if we're using VST we build this as a shared library,
299     # otherwise it's a normal executabale
300     if bld.env['VST_SUPPORT']:
301         obj = bld.new_task_gen(features = 'cxx cc cshlib')
302     else:
303         obj = bld.new_task_gen(features = 'cxx cc cprogram')
304
305     obj.includes     = ['.']
306     obj.source       = gtk2_ardour_sources
307     obj.name         = 'gtk2_ardour'
308     if bld.env['VST_SUPPORT']:
309         obj.target = 'gtk2_ardour'
310         obj.includes += ['../libs/fst']
311     else:
312         obj.target = 'ardour-3.0'
313     obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
314     obj.uselib       = 'UUID FLAC GLIBMM GTHREAD GTK OGG ALSA CURL DL'
315     obj.uselib       += ' GTKMM GNOMECANVASMM '
316     obj.uselib       += ' AUDIOUNITS OSX GTKOSX '
317     obj.uselib_local = '''libpbd libmidipp libtaglib libardour libardour_cp
318                           libgtkmm2ext libtaglib libgnomecanvas-2'''
319     if sys.platform == 'darwin':
320         obj.uselib_local + ' libappleutility'
321     obj.defines     = [
322         'PACKAGE="gtk2_ardour"',
323         'VERSIONSTRING="' + bld.env['VERSION'] + '"',
324         'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
325         'CONFIG_DIR="' + os.path.normpath(bld.env['CONFIGDIR']) + '"',
326         'MODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"',
327         'LOCALEDIR="' + os.path.join(os.path.normpath(bld.env['DATADIR']),
328                                      'locale') + '"',
329         'PROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"'
330         ]
331     obj.includes += ['../libs']
332
333     if bld.env['HAVE_SUIL']:
334         obj.source += [ 'lv2_plugin_ui.cc' ]
335         obj.uselib += ' SUIL '
336     elif bld.env['HAVE_SLV2']:
337         obj.source += [ 'lv2_plugin_ui.cc' ]
338         obj.uselib += ' SLV2 '
339
340     if bld.env['FREESOUND']:
341         obj.source +=  [ 'sfdb_freesound_mootcher.cc' ]
342
343     if bld.env['VST_SUPPORT']:
344         obj.source += [ 'vst_pluginui.cc' ]
345         obj.defines += [ 'VST_SUPPORT' ]
346
347     if bld.env['PHONE_HOME']:
348         obj.defines += [ 'PHONE_HOME' ]
349
350     if bld.env['COREAUDIO']:
351         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cc']
352         obj.source += [ 'cocoacarbon.mm', 'au_pluginui.mm' ]
353         obj.uselib_local += ' libappleutility '
354
355     if bld.env['VST_SUPPORT']:
356         # If we require VST support we build a stub main() and the FST library
357         # here using winegcc, and link it to the GTK front-end library
358         obj = bld.new_task_gen (features = 'cxx cc cprogram wine')
359         obj.source = '''
360                 ../libs/fst/fst.c
361                 ../libs/fst/fstinfofile.c
362                 ../libs/fst/vsti.c
363                 ../libs/fst/vstwin.c
364                 ../vst/winmain.c
365         '''
366         obj.includes = '../libs/fst'
367         obj.target = 'ardour-3.0-vst'
368         obj.linkflags = ['-mwindows', '-Wl,--export-dynamic', '-lpthread']
369         obj.defines = ['_POSIX_SOURCE', 'USE_WS_PREFIX']
370         obj.uselib = 'ALSA'
371         obj.uselib_local = ['libpbd','libmidipp','libtaglib','libardour',
372                             'libardour_cp','libgtkmm2ext','libtaglib',
373                             'gtk2_ardour']
374
375     # Wrappers
376
377     wrapper_subst_dict = {
378             'INSTALL_PREFIX' : bld.env['PREFIX'],
379             'LIBDIR'         : os.path.normpath(bld.env['LIBDIRNAME']),
380             'LIBS'           : 'build/default/libs',
381             'VERSION'        : '3.0',
382             'EXECUTABLE'     : 'build/default/gtk2_ardour/ardour-3.0'
383     }
384
385     obj              = bld.new_task_gen('subst')
386     obj.source       = 'ardev_common.sh.in'
387     obj.target       = 'ardev_common_waf.sh'
388     obj.chmod        = 0755
389     obj.dict         = wrapper_subst_dict
390
391     obj              = bld.new_task_gen('subst')
392     obj.source       = 'ardour.sh.in'
393     obj.target       = 'ardour3'
394     obj.chmod        = 0755
395     obj.dict         = wrapper_subst_dict
396     obj.install_path = bld.env['BINDIR']
397
398     # Font configuration
399
400     dark_rc_subst_dict = {}
401     light_rc_subst_dict = {}
402     font_sizes      = {}
403     base_font       = ""
404
405     # Set up font sizes
406     if bld.env['IS_OSX']: # OS X fonts
407         basefont = "Lucida Grande"
408         font_sizes = {
409                 'TINY' : '7',
410                 'SMALLER' : '9',
411                 'SMALL' : '10',
412                 'NORMAL' : '11',
413                 'BIG' : '12',
414                 'BIGGER' : '14',
415                 'LARGE' : '18',
416                 'LARGER' : '28',
417                 'HUGER' : '36',
418                 'MASSIVE' : '60'
419         }
420     else: # Linux/X11 fonts
421         basefont = '' # unspecified - use system defaults
422         font_sizes = {
423                 'TINY' : '6',
424                 'SMALLER' : '8',
425                 'SMALL' : '9',
426                 'NORMAL' : '10',
427                 'BIG' : '14',
428                 'BIGGER' : '16',
429                 'LARGE' : '18',
430                 'LARGER' : '24',
431                 'HUGER' : '34',
432                 'MASSIVE' : '60'
433         }
434
435     # Set up font substitution dictionary
436     # @FONT_XXXX@
437     for style in ['', 'BOLD', 'ITALIC']:
438         for sizename,points in iter(font_sizes.items()):
439             if (len (style)):
440                 key = "_".join (['FONT',style,sizename])
441                 fontstyle = " ".join ([basefont,style.lower(),points])
442             else:
443                 key = "_".join (['FONT',sizename])
444                 fontstyle = " ".join ([basefont,points])
445
446             dark_rc_subst_dict[key] = fontstyle
447             light_rc_subst_dict[key] = fontstyle
448
449     # @FONT_SIZE_XXXX@
450     for sizename,points in iter(font_sizes.items()):
451             key = "_".join (['FONT_SIZE',sizename])
452             dark_rc_subst_dict[key] = points
453             light_rc_subst_dict[key] = points
454
455     # RC files
456     dark_rc_subst_dict['COLOR_SCHEME'] = build_color_scheme(
457         'gtk2_ardour/ardour3_ui_dark.rc.in', 'ARDOUR_DARK')
458     dark_rc_subst_dict['COLPREFIX'] = 'ARDOUR_DARK'
459     light_rc_subst_dict['COLOR_SCHEME'] = build_color_scheme(
460         'gtk2_ardour/ardour3_ui_light.rc.in', 'ARDOUR_LIGHT')
461     light_rc_subst_dict['COLPREFIX'] = 'ARDOUR_LIGHT'
462
463     obj              = bld.new_task_gen('subst')
464     obj.source       = [ 'ardour3_ui_dark.rc.in' ]
465     obj.target       = 'ardour3_ui_dark.rc'
466     obj.dict         = dark_rc_subst_dict
467     obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
468
469     obj              = bld.new_task_gen('subst')
470     obj.source       = [ 'ardour3_ui_light.rc.in' ]
471     obj.target       = 'ardour3_ui_light.rc'
472     obj.dict         = light_rc_subst_dict
473     obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
474
475     obj              = bld.new_task_gen('subst')
476     obj.source       = [ 'ardour3_styles.rc.in' ]
477     obj.target       = 'ardour3_dark_styles.rc'
478     obj.dict         = dark_rc_subst_dict
479     obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
480
481     obj              = bld.new_task_gen('subst')
482     obj.source       = [ 'ardour3_styles.rc.in' ]
483     obj.target       = 'ardour3_light_styles.rc'
484     obj.dict         = light_rc_subst_dict
485     obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
486
487     obj              = bld.new_task_gen('subst')
488     obj.source       = [ 'ardour3_fonts.rc.in' ]
489     obj.target       = 'ardour3_dark_fonts.rc'
490     obj.dict         = dark_rc_subst_dict
491     obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
492
493     obj              = bld.new_task_gen('subst')
494     obj.source       = [ 'ardour3_fonts.rc.in' ]
495     obj.target       = 'ardour3_light_fonts.rc'
496     obj.dict         = light_rc_subst_dict
497     obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
498
499     obj              = bld.new_task_gen('copy')
500     obj.source       = [ 'ardour3_widget_list.rc' ]
501     obj.target       = 'ardour3_widgets.rc'
502     obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
503
504     # Menus
505     menus_argv = []
506     if bld.env['GTKOSX']:
507         menus_argv = [ '-E', '-P', '-DGTKOSX' ]
508     else:
509         menus_argv = [ '-E', '-P' ]
510     obj = bld.new_task_gen('command-output')
511     obj.command = 'cpp'
512     obj.command_is_external = True
513     obj.no_inputs = True
514     obj.argv = menus_argv
515     obj.stdin = 'ardour.menus.in'
516     obj.stdout = 'ardour.menus'
517     bld.install_files(os.path.join(bld.env['CONFIGDIR'], 'ardour3'),
518                       'ardour.menus')
519
520     # Keybindings
521
522     # 'SAE-de-keypad', 'SAE-de-nokeypad', 'SAE-us-keypad',
523     # 'SAE-us-nokeypad', 'ergonomic-us'
524
525     for b in [ 'mnemonic-us' ] :
526         obj = bld.new_task_gen (
527             target = b + '.bindings',
528             source = b + '.bindings.in',
529             rule = '../tools/fmt-bindings --winkey="%s" --accelmap <${SRC} >${TGT}' % bld.env['WINDOWS_KEY']
530             )
531         obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
532
533     # not modified at present
534     bld.install_files(os.path.join(bld.env['CONFIGDIR'], 'ardour3'),
535                       'step_editing.bindings')
536
537     # Icons/Images
538     bld.install_files('${DATADIR}/ardour3/icons', 'icons/*.png')
539     bld.install_files('${DATADIR}/ardour3/pixmaps', 'pixmaps/*.xpm')
540     bld.install_files('${DATADIR}/ardour3', 'splash.png')
541
542     # Default UI configuration
543     bld.install_files('${CONFIGDIR}/ardour3', 'ardour3_ui_default.conf')
544     # Generic widget style mappings
545     bld.install_files('${CONFIGDIR}/ardour3', 'ardour3_widgets.rc')
546     
547     # Default export stuff
548     bld.install_files('${CONFIGDIR}/ardour3/export', 'export/*.format')
549
550     # i18n
551     if bld.env['ENABLE_NLS']:
552         mo_files = glob.glob (os.path.join (bld.get_curdir(), 'po/*.mo'))
553         for mo in mo_files:
554             lang = os.path.basename (mo).replace ('.mo', '')
555             bld.install_as (os.path.join(bld.env['PREFIX'], 'share', 'locale',
556                                          lang, 'LC_MESSAGES', APPNAME + '.mo'),
557                             mo)
558
559 def i18n(bld):
560     autowaf.build_i18n(bld, srcdir, 'gtk2_ardour', APPNAME, gtk2_ardour_sources)