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