Upgrade to waf 1.6.7 and autowaf r52.
[ardour.git] / gtk2_ardour / wscript
1 #!/usr/bin/env python
2 from waflib.extras import autowaf as autowaf
3 import waflib.Logs as Logs, waflib.Utils as Utils
4 import os
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 top = '.'
22 out = '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         'gui_object.cc',
124         'insert_time_dialog.cc',
125         'interthread_progress_window.cc',
126         'io_selector.cc',
127         'keyboard.cc',
128         'keyeditor.cc',
129         'latency_gui.cc',
130         'led.cc',
131         'level_meter.cc',
132         'lineset.cc',
133         'location_ui.cc',
134         'main.cc',
135         'marker.cc',
136         'midi_automation_line.cc',
137         'midi_channel_dialog.cc',
138         'midi_channel_selector.cc',
139         'midi_cut_buffer.cc',
140         'midi_list_editor.cc',
141         'midi_port_dialog.cc',
142         'midi_region_view.cc',
143         'midi_scroomer.cc',
144         'midi_streamview.cc',
145         'midi_time_axis.cc',
146         'midi_tracer.cc',
147         'missing_file_dialog.cc',
148         'missing_plugin_dialog.cc',
149         'mixer_group_tabs.cc',
150         'mixer_strip.cc',
151         'mixer_ui.cc',
152         'monitor_section.cc',
153         'mono_panner.cc',
154         'mouse_cursors.cc',
155         'nag.cc',
156         'new_plugin_preset_dialog.cc',
157         'normalize_dialog.cc',
158         'note_player.cc',
159         'option_editor.cc',
160         'opts.cc',
161         'panner2d.cc',
162         'panner_ui.cc',
163         'piano_roll_header.cc',
164         'playlist_selector.cc',
165         'plugin_eq_gui.cc',
166         'plugin_selector.cc',
167         'plugin_ui.cc',
168         'port_group.cc',
169         'port_insert_ui.cc',
170         'port_matrix.cc',
171         'port_matrix_body.cc',
172         'port_matrix_column_labels.cc',
173         'port_matrix_component.cc',
174         'port_matrix_grid.cc',
175         'port_matrix_labels.cc',
176         'port_matrix_row_labels.cc',
177         'processor_box.cc',
178         'patch_change_dialog.cc',
179         'progress_reporter.cc',
180         'prompter.cc',
181         'public_editor.cc',
182         'quantize_dialog.cc',
183         'rc_option_editor.cc',
184         'region_editor.cc',
185         'region_gain_line.cc',
186         'region_layering_order_editor.cc',
187         'region_selection.cc',
188         'region_view.cc',
189         'return_ui.cc',
190         'rhythm_ferret.cc',
191         'route_group_dialog.cc',
192         'route_group_menu.cc',
193         'route_params_ui.cc',
194         'route_processor_selection.cc',
195         'route_time_axis.cc',
196         'route_ui.cc',
197         'search_path_option.cc',
198         'selection.cc',
199         'send_ui.cc',
200         'session_import_dialog.cc',
201         'session_metadata_dialog.cc',
202         'session_option_editor.cc',
203         'sfdb_ui.cc',
204         'shuttle_control.cc',
205         'simpleline.cc',
206         'simplerect.cc',
207         'splash.cc',
208         'speaker_dialog.cc',
209         'startup.cc',
210         'step_editor.cc',
211         'step_entry.cc',
212         'stereo_panner.cc',
213         'streamview.cc',
214         'strip_silence_dialog.cc',
215         'tape_region_view.cc',
216         'tempo_dialog.cc',
217         'tempo_lines.cc',
218         'theme_manager.cc',
219         'time_axis_view.cc',
220         'time_axis_view_item.cc',
221         'time_fx_dialog.cc',
222         'time_info_box.cc',
223         'time_selection.cc',
224         'track_selection.cc',
225         'track_view_list.cc',
226         'transpose_dialog.cc',
227         'ui_config.cc',
228         'utils.cc',
229         'verbose_cursor.cc',
230         'version.cc',
231         'volume_controller.cc',
232         'waveview.cc',
233         'window_proxy.cc'
234 ]
235
236 def options(opt):
237     autowaf.set_options(opt)
238
239 def configure(conf):
240     conf.load('misc')
241     autowaf.build_version_files(
242         path_prefix + 'version.h',
243         path_prefix + 'version.cc',
244         'gtk2_ardour', MAJOR, MINOR, MICRO)
245     autowaf.configure(conf)
246     conf.check_tool('compiler_cxx')
247
248     if re.search ("linux", sys.platform) != None:
249         autowaf.check_pkg(conf, 'alsa', uselib_store='ALSA')
250
251     # TODO: Insert a sanity check for on OS X to ensure CoreAudio is present
252
253     autowaf.check_pkg(conf, 'flac', uselib_store='FLAC',
254                       atleast_version='1.2.1')
255     autowaf.check_pkg(conf, 'gthread', uselib_store='GTHREAD',
256                       atleast_version='2.10.1')
257     autowaf.check_pkg(conf, 'gtk+-2.0', uselib_store='GTK',
258                       atleast_version='2.18')
259     autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='GTKMM',
260                       atleast_version='2.18')
261     autowaf.check_pkg(conf, 'libgnomecanvasmm-2.6',
262                       uselib_store='GNOMECANVASMM', atleast_version='2.16')
263     autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
264
265     conf.write_config_header('gtk2ardour-config.h', remove=False)
266
267     # Boost headers
268     autowaf.check_header(conf, 'cxx', 'boost/shared_ptr.hpp')
269     autowaf.check_header(conf, 'cxx', 'boost/weak_ptr.hpp')
270
271 # Add a waf `feature' to allow compilation of things using winegcc
272 from TaskGen import feature
273 @feature("wine")
274 def set_winegcc(self):
275     self.env.LINK_CXX = self.env.LINK_CC = 'wineg++'
276     self.env.CC = 'winegcc'
277
278 #pre-processor-like operation to merge GTK RC files
279 re_spaces = re.compile("\s+")
280
281 def _doPyp(infileName):
282     """
283     Does the main work of preprocessing.
284     Takes 'infileName' as a filename, opens and processes it,
285     and returns the processed file as a string
286     
287     Note - this works recursively.
288     """
289     outStr = ''
290     if infileName == '-':
291         fd = sys.stdin
292     else:
293         fd = file(infileName)
294     inLines = fd.readlines()
295     if fd != sys.stdin:
296         fd.close()
297     
298     for line in inLines:
299         bits = re_spaces.split(line)
300         if bits[0] == '##include':
301             incName = bits[1]
302             # assume included file comes from same place as source file
303             incName = os.path.join (os.path.dirname (infileName), incName);
304             outStr += _doPyp(incName)
305         else:
306             outStr += line
307
308     # done
309     return outStr
310     
311 def include_processor(task):
312     infileName = task.inputs[0].srcpath()
313     outfileName = os.path.join(out, task.outputs[0].bldpath())
314     fdOut = file (outfileName, "w")
315     fdOut.write (_doPyp(infileName))
316     fdOut.close ()
317
318
319 def build_color_scheme(path, prefix):
320     f = open (path, 'r')
321     color_scheme = ''
322     for line in f:
323         if re.search ('^#@color', line):
324             line.strip() # remove newline
325             words = line.split()
326             if len(color_scheme):
327                 color_scheme += ';'
328             color_scheme += prefix
329             color_scheme += '_'
330             color_scheme += words[1]
331             color_scheme += ':'
332             color_scheme += words[2]
333     f.close()
334     return color_scheme
335
336
337 def build(bld):
338     # GTK front-end; if we're using VST we build this as a shared library,
339     # otherwise it's a normal executabale
340     if bld.env['VST_SUPPORT']:
341         obj = bld(features = 'cxx c cxxshlib')
342     else:
343         obj = bld(features = 'cxx c cxxprogram')
344
345     obj.includes     = ['.']
346     obj.source       = gtk2_ardour_sources
347     obj.name         = 'gtk2_ardour'
348     obj.linkflags    = []
349     if bld.env['VST_SUPPORT']:
350         obj.target = 'gtk2_ardour'
351         obj.includes += ['../libs/fst']
352     else:
353         obj.target = 'ardour-3.0'
354     obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
355     obj.uselib       = 'UUID FLAC GLIBMM GTHREAD GTK OGG ALSA CURL DL'
356     obj.uselib       += ' GTKMM GNOMECANVASMM '
357     obj.uselib       += ' AUDIOUNITS OSX GTKOSX '
358     obj.use          = '''libpbd libmidipp libtaglib libardour libardour_cp
359                           libgtkmm2ext libtaglib libgnomecanvas-2'''
360     if sys.platform == 'darwin':
361         obj.use += ' libappleutility'
362     obj.defines     = [
363         'PACKAGE="gtk2_ardour"',
364         'VERSIONSTRING="' + bld.env['VERSION'] + '"',
365         'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
366         'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
367         'MODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"',
368         'LOCALEDIR="' + os.path.join(os.path.normpath(bld.env['DATADIR']),
369                                      'locale') + '"',
370         'PROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"'
371         ]
372     obj.includes += ['../libs']
373
374     if bld.env['HAVE_SUIL']:
375         obj.source += [ 'lv2_plugin_ui.cc' ]
376         obj.uselib += ' SUIL '
377     elif bld.env['HAVE_SLV2']:
378         obj.source += [ 'lv2_plugin_ui.cc' ]
379         obj.uselib += ' SLV2 '
380
381     if bld.env['FREESOUND']:
382         obj.source +=  [ 'sfdb_freesound_mootcher.cc' ]
383
384     if bld.env['VST_SUPPORT']:
385         obj.source += [ 'vst_pluginui.cc' ]
386         obj.defines += [ 'VST_SUPPORT' ]
387         bld.env.append ('LINKFLAGS', '-lX11')
388
389     if bld.env['LXVST_SUPPORT']:
390         obj.source += [ 'lxvst_pluginui.cc' ]
391         obj.defines += [ 'LXVST_SUPPORT' ]
392         obj.linkflags += [ '-lX11' ]
393
394     if bld.env['PHONE_HOME']:
395         obj.defines += [ 'PHONE_HOME' ]
396
397     if bld.env['COREAUDIO']:
398         TaskGen.task_gen.mappings['.mm'] = TaskGen.task_gen.mappings['.cc']
399         obj.source += [ 'cocoacarbon.mm', 'au_pluginui.mm' ]
400         obj.use += ' libappleutility '
401
402     if bld.env['VST_SUPPORT']:
403         # If we require VST support we build a stub main() and the FST library
404         # here using winegcc, and link it to the GTK front-end library
405         obj = bld(features = 'cxx c cxxprogram wine')
406         obj.source = '''
407                 ../libs/fst/fst.c
408                 ../libs/fst/fstinfofile.c
409                 ../libs/fst/vsti.c
410                 ../libs/fst/vstwin.c
411                 ../vst/winmain.c
412         '''
413         obj.includes = '../libs/fst'
414         obj.target = 'ardour-3.0-vst'
415         obj.linkflags += ['-mwindows', '-Wl,--export-dynamic', '-lpthread']
416         obj.defines = ['_POSIX_SOURCE', 'USE_WS_PREFIX']
417         obj.uselib = 'ALSA'
418         obj.use = ['libpbd','libmidipp','libtaglib','libardour',
419                             'libardour_cp','libgtkmm2ext','libtaglib',
420                             'gtk2_ardour']
421
422     # Wrappers
423
424     wrapper_subst_dict = {
425             'INSTALL_PREFIX' : bld.env['PREFIX'],
426             'LIBDIR'         : os.path.normpath(bld.env['LIBDIR']),
427             'LIBS'           : 'build/libs',
428             'VERSION'        : '3.0',
429             'EXECUTABLE'     : 'build/gtk2_ardour/ardour-3.0'
430     }
431
432     def set_subst_dict(obj, dict):
433         for i in dict:
434             setattr(obj, i, dict[i])
435
436     obj              = bld(features = 'subst', rule= 'chmod 0755 ${TGT}')
437     obj.source       = 'ardev_common.sh.in'
438     obj.target       = 'ardev_common_waf.sh'
439     obj.chmod        = Utils.O755
440     obj.dict         = wrapper_subst_dict
441     set_subst_dict(obj, wrapper_subst_dict)
442
443     obj              = bld(features = 'subst')
444     obj.source       = 'ardour.sh.in'
445     obj.target       = 'ardour3'
446     obj.chmod        = Utils.O755
447     obj.dict         = wrapper_subst_dict
448     obj.install_path = bld.env['BINDIR']
449     set_subst_dict(obj, wrapper_subst_dict)
450
451     # Font configuration
452
453     dark_rc_subst_dict = {}
454     light_rc_subst_dict = {}
455     font_sizes      = {}
456     base_font       = ""
457
458     # Set up font sizes
459     if bld.env['IS_OSX']: # OS X fonts
460         basefont = "Lucida Grande"
461         font_sizes = {
462                 'TINY' : '7',
463                 'SMALLER' : '9',
464                 'SMALL' : '10',
465                 'NORMAL' : '11',
466                 'BIG' : '12',
467                 'BIGGER' : '14',
468                 'LARGE' : '18',
469                 'LARGER' : '28',
470                 'HUGER' : '36',
471                 'MASSIVE' : '60'
472         }
473     else: # Linux/X11 fonts
474         basefont = '' # unspecified - use system defaults
475         font_sizes = {
476                 'TINY' : '6',
477                 'SMALLER' : '8',
478                 'SMALL' : '9',
479                 'NORMAL' : '10',
480                 'BIG' : '14',
481                 'BIGGER' : '16',
482                 'LARGE' : '18',
483                 'LARGER' : '24',
484                 'HUGER' : '34',
485                 'MASSIVE' : '60'
486         }
487
488     # Set up font substitution dictionary
489     # @FONT_XXXX@
490     for style in ['', 'BOLD', 'ITALIC']:
491         for sizename,points in iter(font_sizes.items()):
492             if (len (style)):
493                 key = "_".join (['FONT',style,sizename])
494                 fontstyle = " ".join ([basefont,style.lower(),points])
495             else:
496                 key = "_".join (['FONT',sizename])
497                 fontstyle = " ".join ([basefont,points])
498
499             dark_rc_subst_dict[key] = fontstyle
500             light_rc_subst_dict[key] = fontstyle
501
502     # @FONT_SIZE_XXXX@
503     for sizename,points in iter(font_sizes.items()):
504             key = "_".join (['FONT_SIZE',sizename])
505             dark_rc_subst_dict[key] = points
506             light_rc_subst_dict[key] = points
507
508     # RC files
509     dark_rc_subst_dict['COLOR_SCHEME'] = build_color_scheme(
510         'gtk2_ardour/ardour3_ui_dark.rc.in', 'ARDOUR_DARK')
511     dark_rc_subst_dict['COLPREFIX'] = 'ARDOUR_DARK'
512     light_rc_subst_dict['COLOR_SCHEME'] = build_color_scheme(
513         'gtk2_ardour/ardour3_ui_light.rc.in', 'ARDOUR_LIGHT')
514     light_rc_subst_dict['COLPREFIX'] = 'ARDOUR_LIGHT'
515
516     obj              = bld(features = 'subst')
517     obj.source       = [ 'ardour3_ui_dark.rc.in' ]
518     obj.target       = 'ardour3_ui_dark.rc.pre'
519     obj.install_path = None
520     set_subst_dict(obj, dark_rc_subst_dict)
521
522     obj              = bld(features = 'subst')
523     obj.source       = [ 'ardour3_ui_light.rc.in' ]
524     obj.target       = 'ardour3_ui_light.rc.pre'
525     obj.install_path = None
526     set_subst_dict(obj, light_rc_subst_dict)
527
528     obj              = bld(features = 'subst')
529     obj.source       = [ 'ardour3_styles.rc.in' ]
530     obj.target       = 'ardour3_dark_styles.rc'
531     obj.install_path = None
532     set_subst_dict(obj, dark_rc_subst_dict)
533
534     obj              = bld(features = 'subst')
535     obj.source       = [ 'ardour3_styles.rc.in' ]
536     obj.target       = 'ardour3_light_styles.rc'
537     obj.install_path = None
538     set_subst_dict(obj, light_rc_subst_dict)
539
540     obj              = bld(features = 'subst')
541     obj.source       = [ 'ardour3_fonts.rc.in' ]
542     obj.target       = 'ardour3_dark_fonts.rc'
543     obj.install_path = None
544     set_subst_dict(obj, dark_rc_subst_dict)
545
546     obj              = bld(features = 'subst')
547     obj.source       = [ 'ardour3_fonts.rc.in' ]
548     obj.target       = 'ardour3_light_fonts.rc'
549     obj.install_path = None
550     set_subst_dict(obj, light_rc_subst_dict)
551
552     obj              = bld(rule = 'cp ${SRC} ${TGT}')
553     obj.source       = [ 'ardour3_widget_list.rc' ]
554     obj.target       = 'ardour3_widgets.rc'
555     obj.install_path = None
556
557     bld (
558         rule   = include_processor,
559         source = 'ardour3_ui_dark.rc.pre',
560         target = 'ardour3_ui_dark.rc'
561         )
562
563     bld (
564         rule   = include_processor,
565         source = 'ardour3_ui_light.rc.pre', 
566         target = 'ardour3_ui_light.rc'
567         )
568
569     # Menus
570     menus_argv = []
571     if bld.env['GTKOSX']:
572         menus_argv = [ '-E', '-P', '-DGTKOSX' ]
573     else:
574         menus_argv = [ '-E', '-P' ]
575     obj = bld(features = 'command-output')
576     obj.command = 'cpp'
577     obj.command_is_external = True
578     obj.no_inputs = True
579     obj.argv = menus_argv
580     obj.stdin = 'ardour.menus.in'
581     obj.stdout = 'ardour.menus'
582     bld.install_files(os.path.join(bld.env['SYSCONFDIR'], 'ardour3'),
583                       'ardour.menus')
584
585     # Keybindings
586
587     # 'SAE-de-keypad', 'SAE-de-nokeypad', 'SAE-us-keypad',
588     # 'SAE-us-nokeypad', 'ergonomic-us'
589
590     for b in [ 'mnemonic-us' ] :
591         obj = bld(
592             target = b + '.bindings',
593             source = b + '.bindings.in',
594             rule = '../tools/fmt-bindings --winkey="%s" --accelmap <${SRC} >${TGT}' % bld.env['WINDOWS_KEY']
595             )
596         obj.install_path = os.path.join(bld.env['SYSCONFDIR'], 'ardour3')
597
598     # not modified at present
599     bld.install_files(os.path.join(bld.env['SYSCONFDIR'], 'ardour3'),
600                       'step_editing.bindings')
601
602     # Icons/Images
603     bld.install_files('${DATADIR}/ardour3/icons', 'icons/*.png')
604     bld.install_files('${DATADIR}/ardour3/pixmaps', 'pixmaps/*.xpm')
605     bld.install_files('${DATADIR}/ardour3', 'splash.png')
606
607     # Default UI configuration
608     bld.install_files('${SYSCONFDIR}/ardour3', 'ardour3_ui_default.conf')
609     # Generic widget style mappings
610     bld.install_files('${SYSCONFDIR}/ardour3', 'ardour3_widgets.rc')
611     
612     # Default export stuff
613     bld.install_files('${SYSCONFDIR}/ardour3/export', 'export/*.format')
614
615     # i18n
616     if bld.env['ENABLE_NLS']:
617         mo_files = bld.path.ant_glob ('po/*.mo')
618         for mo in mo_files:
619             lang = os.path.basename (mo).replace ('.mo', '')
620             bld.install_as (os.path.join(bld.env['PREFIX'], 'share', 'locale',
621                                          lang, 'LC_MESSAGES', APPNAME + '.mo'),
622                             mo)
623
624 def i18n(bld):
625     autowaf.build_i18n(bld, srcdir, 'gtk2_ardour', APPNAME, gtk2_ardour_sources)