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