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