Remove some unused code.
[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         '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         'mono_panner.cc',
152         'mouse_cursors.cc',
153         'nag.cc',
154         'new_plugin_preset_dialog.cc',
155         'normalize_dialog.cc',
156         'note_player.cc',
157         'option_editor.cc',
158         'opts.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         'patch_change_dialog.cc',
177         'progress_reporter.cc',
178         'prompter.cc',
179         'public_editor.cc',
180         'quantize_dialog.cc',
181         'rc_option_editor.cc',
182         'region_editor.cc',
183         'region_gain_line.cc',
184         'region_layering_order_editor.cc',
185         'region_selection.cc',
186         'region_view.cc',
187         'return_ui.cc',
188         'rhythm_ferret.cc',
189         'route_group_dialog.cc',
190         'route_group_menu.cc',
191         'route_params_ui.cc',
192         'route_processor_selection.cc',
193         'route_time_axis.cc',
194         'route_ui.cc',
195         'search_path_option.cc',
196         'selection.cc',
197         'send_ui.cc',
198         'session_import_dialog.cc',
199         'session_metadata_dialog.cc',
200         'session_option_editor.cc',
201         'sfdb_ui.cc',
202         'shuttle_control.cc',
203         'simpleline.cc',
204         'simplerect.cc',
205         'splash.cc',
206         'speaker_dialog.cc',
207         'startup.cc',
208         'step_editor.cc',
209         'step_entry.cc',
210         'stereo_panner.cc',
211         'streamview.cc',
212         'strip_silence_dialog.cc',
213         'tape_region_view.cc',
214         'tempo_dialog.cc',
215         'tempo_lines.cc',
216         'theme_manager.cc',
217         'time_axis_view.cc',
218         'time_axis_view_item.cc',
219         'time_fx_dialog.cc',
220         'time_selection.cc',
221         'track_selection.cc',
222         'track_view_list.cc',
223         'transpose_dialog.cc',
224         'ui_config.cc',
225         'utils.cc',
226         'verbose_cursor.cc',
227         'version.cc',
228         'volume_controller.cc',
229         'waveview.cc',
230         'window_proxy.cc'
231 ]
232
233 def set_options(opt):
234     autowaf.set_options(opt)
235
236 def configure(conf):
237     autowaf.build_version_files(
238         path_prefix + 'version.h',
239         path_prefix + 'version.cc',
240         'gtk2_ardour', MAJOR, MINOR, MICRO)
241     autowaf.configure(conf)
242     conf.check_tool('compiler_cxx')
243
244     if re.search ("linux", sys.platform) != None:
245         autowaf.check_pkg(conf, 'alsa', uselib_store='ALSA')
246
247     # TODO: Insert a sanity check for on OS X to ensure CoreAudio is present
248
249     autowaf.check_pkg(conf, 'flac', uselib_store='FLAC',
250                       atleast_version='1.2.1')
251     autowaf.check_pkg(conf, 'gthread', uselib_store='GTHREAD',
252                       atleast_version='2.10.1')
253     autowaf.check_pkg(conf, 'gtk+-2.0', uselib_store='GTK',
254                       atleast_version='2.18')
255     autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='GTKMM',
256                       atleast_version='2.18')
257     autowaf.check_pkg(conf, 'libgnomecanvasmm-2.6',
258                       uselib_store='GNOMECANVASMM', atleast_version='2.16')
259     autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
260
261     conf.check_tool('misc') # subst tool
262
263     conf.write_config_header('gtk2ardour-config.h')
264
265     # Boost headers
266     autowaf.check_header(conf, 'boost/shared_ptr.hpp')
267     autowaf.check_header(conf, 'boost/weak_ptr.hpp')
268
269 # Add a waf `feature' to allow compilation of things using winegcc
270 from TaskGen import feature
271 @feature("wine")
272 def set_winegcc(self):
273     self.env.LINK_CXX = self.env.LINK_CC = 'wineg++'
274     self.env.CC = 'winegcc'
275
276 def build_color_scheme(path, prefix):
277     f = open (path, 'r')
278     color_scheme = ''
279     for line in f:
280         if re.search ('^#@color', line):
281             line.strip() # remove newline
282             words = line.split()
283             if len(color_scheme):
284                 color_scheme += ';'
285             color_scheme += prefix
286             color_scheme += '_'
287             color_scheme += words[1]
288             color_scheme += ':'
289             color_scheme += words[2]
290     f.close()
291     return color_scheme
292
293
294 def build(bld):
295     # GTK front-end; if we're using VST we build this as a shared library,
296     # otherwise it's a normal executabale
297     if bld.env['VST_SUPPORT']:
298         obj = bld.new_task_gen(features = 'cxx cc cshlib')
299     else:
300         obj = bld.new_task_gen(features = 'cxx cc cprogram')
301
302     obj.includes     = ['.']
303     obj.source       = gtk2_ardour_sources
304     obj.name         = 'gtk2_ardour'
305     if bld.env['VST_SUPPORT']:
306         obj.target = 'gtk2_ardour'
307         obj.includes += ['../libs/fst']
308     else:
309         obj.target = 'ardour-3.0'
310     obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
311     obj.uselib       = 'UUID FLAC GLIBMM GTHREAD GTK OGG ALSA CURL DL'
312     obj.uselib       += ' GTKMM GNOMECANVASMM '
313     obj.uselib       += ' AUDIOUNITS OSX GTKOSX '
314     obj.uselib_local = '''libpbd libmidipp libtaglib libardour libardour_cp
315                           libgtkmm2ext libtaglib libgnomecanvas-2'''
316     if sys.platform == 'darwin':
317         obj.uselib_local + ' libappleutility'
318     obj.defines     = [
319         'PACKAGE="gtk2_ardour"',
320         'VERSIONSTRING="' + bld.env['VERSION'] + '"',
321         'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
322         'CONFIG_DIR="' + os.path.normpath(bld.env['CONFIGDIR']) + '"',
323         'MODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"',
324         'LOCALEDIR="' + os.path.join(os.path.normpath(bld.env['DATADIR']),
325                                      'locale') + '"',
326         'PROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"'
327         ]
328     obj.includes += ['../libs']
329
330     if bld.env['HAVE_SUIL']:
331         obj.source += [ 'lv2_plugin_ui.cc' ]
332         obj.uselib += ' SUIL '
333     elif bld.env['HAVE_SLV2']:
334         obj.source += [ 'lv2_plugin_ui.cc' ]
335         obj.uselib += ' SLV2 '
336
337     if bld.env['FREESOUND']:
338         obj.source +=  [ 'sfdb_freesound_mootcher.cc' ]
339
340     if bld.env['VST_SUPPORT']:
341         obj.source += [ 'vst_pluginui.cc' ]
342         obj.defines += [ 'VST_SUPPORT' ]
343
344     if bld.env['PHONE_HOME']:
345         obj.defines += [ 'PHONE_HOME' ]
346
347     if bld.env['COREAUDIO']:
348         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cc']
349         obj.source += [ 'cocoacarbon.mm', 'au_pluginui.mm' ]
350         obj.uselib_local += ' libappleutility '
351
352     if bld.env['VST_SUPPORT']:
353         # If we require VST support we build a stub main() and the FST library
354         # here using winegcc, and link it to the GTK front-end library
355         obj = bld.new_task_gen (features = 'cxx cc cprogram wine')
356         obj.source = '''
357                 ../libs/fst/fst.c
358                 ../libs/fst/fstinfofile.c
359                 ../libs/fst/vsti.c
360                 ../libs/fst/vstwin.c
361                 ../vst/winmain.c
362         '''
363         obj.includes = '../libs/fst'
364         obj.target = 'ardour-3.0-vst'
365         obj.linkflags = ['-mwindows', '-Wl,--export-dynamic', '-lpthread']
366         obj.defines = ['_POSIX_SOURCE', 'USE_WS_PREFIX']
367         obj.uselib = 'ALSA'
368         obj.uselib_local = ['libpbd','libmidipp','libtaglib','libardour',
369                             'libardour_cp','libgtkmm2ext','libtaglib',
370                             'gtk2_ardour']
371
372     # Wrappers
373
374     wrapper_subst_dict = {
375             'INSTALL_PREFIX' : bld.env['PREFIX'],
376             'LIBDIR'         : os.path.normpath(bld.env['LIBDIRNAME']),
377             'LIBS'           : 'build/default/libs',
378             'VERSION'        : '3.0',
379             'EXECUTABLE'     : 'build/default/gtk2_ardour/ardour-3.0'
380     }
381
382     obj              = bld.new_task_gen('subst')
383     obj.source       = 'ardev_common.sh.in'
384     obj.target       = 'ardev_common_waf.sh'
385     obj.chmod        = 0755
386     obj.dict         = wrapper_subst_dict
387
388     obj              = bld.new_task_gen('subst')
389     obj.source       = 'ardour.sh.in'
390     obj.target       = 'ardour3'
391     obj.chmod        = 0755
392     obj.dict         = wrapper_subst_dict
393     obj.install_path = bld.env['BINDIR']
394
395     # Font configuration
396
397     dark_rc_subst_dict = {}
398     light_rc_subst_dict = {}
399     font_sizes      = {}
400     base_font       = ""
401
402     # Set up font sizes
403     if bld.env['IS_OSX']: # OS X fonts
404         basefont = "Lucida Grande"
405         font_sizes = {
406                 'TINY' : '7',
407                 'SMALLER' : '9',
408                 'SMALL' : '10',
409                 'NORMAL' : '11',
410                 'BIG' : '12',
411                 'BIGGER' : '14',
412                 'LARGE' : '18',
413                 'LARGER' : '28',
414                 'HUGER' : '36',
415                 'MASSIVE' : '60'
416         }
417     else: # Linux/X11 fonts
418         basefont = '' # unspecified - use system defaults
419         font_sizes = {
420                 'TINY' : '6',
421                 'SMALLER' : '8',
422                 'SMALL' : '9',
423                 'NORMAL' : '10',
424                 'BIG' : '14',
425                 'BIGGER' : '16',
426                 'LARGE' : '18',
427                 'LARGER' : '24',
428                 'HUGER' : '34',
429                 'MASSIVE' : '60'
430         }
431
432  # Set up font substitution dictionary
433     for style in ['', 'BOLD', 'ITALIC']:
434         for sizename,points in iter(font_sizes.items()):
435             if (len (style)):
436                 key = "_".join (['FONT',style,sizename])
437                 fontstyle = " ".join ([basefont,style.lower(),points])
438             else:
439                 key = "_".join (['FONT',sizename])
440                 fontstyle = " ".join ([basefont,points])
441
442             dark_rc_subst_dict[key] = fontstyle
443             light_rc_subst_dict[key] = fontstyle
444
445     # RC files
446     dark_rc_subst_dict['COLOR_SCHEME'] = build_color_scheme(
447         'gtk2_ardour/ardour3_ui_dark.rc.in', 'ARDOUR_DARK')
448     dark_rc_subst_dict['COLPREFIX'] = 'ARDOUR_DARK'
449     light_rc_subst_dict['COLOR_SCHEME'] = build_color_scheme(
450         'gtk2_ardour/ardour3_ui_light.rc.in', 'ARDOUR_LIGHT')
451     light_rc_subst_dict['COLPREFIX'] = 'ARDOUR_LIGHT'
452
453     obj              = bld.new_task_gen('subst')
454     obj.source       = 'ardour3_ui_dark.rc.in'
455     obj.target       = 'ardour3_ui_dark.rc'
456     obj.dict         = dark_rc_subst_dict
457     obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
458
459     obj              = bld.new_task_gen('subst')
460     obj.source       = 'ardour3_ui_light.rc.in'
461     obj.target       = 'ardour3_ui_light.rc'
462     obj.dict         = light_rc_subst_dict
463     obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
464
465     # Menus
466     menus_argv = []
467     if bld.env['GTKOSX']:
468         menus_argv = [ '-E', '-P', '-DGTKOSX' ]
469     else:
470         menus_argv = [ '-E', '-P' ]
471     obj = bld.new_task_gen('command-output')
472     obj.command = 'cpp'
473     obj.command_is_external = True
474     obj.no_inputs = True
475     obj.argv = menus_argv
476     obj.stdin = 'ardour.menus.in'
477     obj.stdout = 'ardour.menus'
478     bld.install_files(os.path.join(bld.env['CONFIGDIR'], 'ardour3'),
479                       'ardour.menus')
480
481     # Keybindings
482
483     # 'SAE-de-keypad', 'SAE-de-nokeypad', 'SAE-us-keypad',
484     # 'SAE-us-nokeypad', 'ergonomic-us'
485
486     for b in [ 'mnemonic-us' ] :
487         obj = bld.new_task_gen (
488             target = b + '.bindings',
489             source = b + '.bindings.in',
490             rule = '../tools/fmt-bindings --winkey="%s" --accelmap <${SRC} >${TGT}' % bld.env['WINDOWS_KEY']
491             )
492         obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
493
494     # not modified at present
495     bld.install_files(os.path.join(bld.env['CONFIGDIR'], 'ardour3'),
496                       'step_editing.bindings')
497
498     # Icons/Images
499     bld.install_files('${DATADIR}/ardour3/icons', 'icons/*.png')
500     bld.install_files('${DATADIR}/ardour3/pixmaps', 'pixmaps/*.xpm')
501     bld.install_files('${DATADIR}/ardour3', 'splash.png')
502
503     # Default UI configuration
504     bld.install_files('${CONFIGDIR}/ardour3', 'ardour3_ui_default.conf')
505
506     # Default export stuff
507     bld.install_files('${CONFIGDIR}/ardour3/export', 'export/*.format')
508
509     # i18n
510     if bld.env['ENABLE_NLS']:
511         mo_files = glob.glob (os.path.join (bld.get_curdir(), 'po/*.mo'))
512         for mo in mo_files:
513             lang = os.path.basename (mo).replace ('.mo', '')
514             bld.install_as (os.path.join(bld.env['PREFIX'], 'share', 'locale',
515                                          lang, 'LC_MESSAGES', APPNAME + '.mo'),
516                             mo)
517
518 def i18n(bld):
519     autowaf.build_i18n(bld, srcdir, 'gtk2_ardour', APPNAME, gtk2_ardour_sources)