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