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