Use stdin/stdout for menu file generation so waf picks up on the dependency.
[ardour.git] / gtk2_ardour / wscript
1 #!/usr/bin/env python
2 import autowaf
3 import os
4 import glob
5
6 # Version of this package (even if built as a child)
7 MAJOR = '1'
8 MINOR = '0'
9 MICRO = '2'
10 GTK2_ARDOUR_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
11
12 # Variables for 'waf dist'
13 APPNAME = 'gtk2_ardour'
14 VERSION = GTK2_ARDOUR_VERSION
15
16 # Mandatory variables
17 srcdir = '.'
18 blddir = 'build'
19
20 path_prefix = 'gtk2_ardour/'
21
22 def set_options(opt):
23         autowaf.set_options(opt)
24
25 def configure(conf):
26         autowaf.build_version_files(path_prefix+'version.h', path_prefix+'version.cc',
27                         'gtk2_ardour', MAJOR, MINOR, MICRO)
28         autowaf.configure(conf)
29         autowaf.check_tool(conf, 'compiler_cxx')
30         
31         autowaf.check_pkg(conf, 'alsa', uselib_store='ALSA')
32         autowaf.check_pkg(conf, 'flac', uselib_store='FLAC', atleast_version='1.2.1')
33         autowaf.check_pkg(conf, 'gthread', uselib_store='GTHREAD', atleast_version='2.10.1')
34         autowaf.check_pkg(conf, 'gtk+-2.0', uselib_store='GTK', atleast_version='2.12.1')
35         autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='GTKMM', atleast_version='2.8')
36         autowaf.check_pkg(conf, 'libgnomecanvas-2.0', uselib_store='GNOMECANVAS', atleast_version='2.0')
37         autowaf.check_pkg(conf, 'libgnomecanvasmm-2.6', uselib_store='GNOMECANVASMM', atleast_version='2.12.0')
38         autowaf.check_pkg(conf, 'ogg', uselib_store='OGG', atleast_version='1.1.2')
39         
40         conf.check_tool('misc') # subst tool
41
42         conf.env.append_value('CCFLAGS', '-D_REENTRANT -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE')
43         conf.env.append_value('CXXFLAGS', '-DENABLE_NLS')
44         
45         conf.env.append_value('CXXFLAGS', '-DHAVE_WAFCONFIG_H')
46         conf.write_config_header('wafconfig.h')
47
48         # TODO
49         conf.define('WINDOWS_KEY', 'Mod4')
50
51         # Boost headers
52         autowaf.check_header(conf, 'boost/shared_ptr.hpp')
53         autowaf.check_header(conf, 'boost/weak_ptr.hpp')
54
55 def build(bld):
56         # Canvas library (plain C)
57         obj = bld.new_task_gen('cc', 'staticlib')
58         obj.source = '''
59                 canvas-simpleline.c
60                 canvas-simplerect.c
61                 canvas-waveview.c
62                 gtk-custom-hruler.c
63                 gtk-custom-ruler.c
64         '''
65         obj.includes     = ['.']
66         obj.name         = 'libgtk2_ardour_c'
67         obj.target       = 'gtk2_ardour_c'
68         obj.uselib       = 'GNOMECANVAS'
69         obj.uselib_local = 'libardour'
70         obj.install_path = ''
71         obj.cxxflags     = '-DVERSIONSTRING=\\\"' + GTK2_ARDOUR_VERSION + '\\\"'
72         obj.cxxflags     += ' -DPACKAGE=\\\"gtk2_ardour\\\"'
73         obj.cxxflags     += ' -DDATA_DIR=\\\"' + os.path.normpath(bld.env['DATADIRNAME']) + '\\\"'
74         obj.cxxflags     += ' -DCONFIG_DIR=\\\"' + os.path.normpath(bld.env['CONFIGDIRNAME']) + '\\\"'
75         obj.cxxflags     += ' -DMODULE_DIR=\\\"' + os.path.normpath(bld.env['LIBDIRNAME']) + '\\\"'
76         obj.cxxflags     += ' -DLOCALEDIR=\\\"' + os.path.join(
77                         os.path.normpath(bld.env['DATADIRNAME']), 'locale') + '\\\"'
78
79         # Program
80         obj = bld.new_task_gen('cxx', 'program')
81         obj.source = '''
82                 about.cc
83                 actions.cc
84                 add_midi_cc_track_dialog.cc
85                 add_route_dialog.cc
86                 analysis_window.cc
87                 ardour_dialog.cc
88                 ardour_ui.cc
89                 ardour_ui2.cc
90                 ardour_ui_dependents.cc
91                 ardour_ui_dialogs.cc
92                 ardour_ui_ed.cc
93                 ardour_ui_mixer.cc
94                 ardour_ui_options.cc
95                 audio_clock.cc
96                 audio_region_editor.cc
97                 audio_region_view.cc
98                 audio_streamview.cc
99                 audio_time_axis.cc
100                 automation_controller.cc
101                 automation_line.cc
102                 automation_region_view.cc
103                 automation_streamview.cc
104                 automation_time_axis.cc
105                 axis_view.cc
106                 bundle_manager.cc
107                 canvas-note-event.cc
108                 canvas-note.cc
109                 canvas-flag.cc
110                 canvas-program-change.cc
111                 canvas-sysex.cc
112                 control_point.cc
113                 control_point_dialog.cc
114                 crossfade_edit.cc
115                 crossfade_view.cc
116                 curvetest.cc
117                 diamond.cc
118                 editing.cc
119                 editor.cc
120                 editor_actions.cc
121                 editor_audio_import.cc
122                 editor_audiotrack.cc
123                 editor_canvas.cc
124                 editor_canvas_events.cc
125                 editor_cursors.cc
126                 editor_edit_groups.cc
127                 editor_export_audio.cc
128                 editor_hscroller.cc
129                 editor_keyboard.cc
130                 editor_keys.cc
131                 editor_markers.cc
132                 editor_mixer.cc
133                 editor_mouse.cc
134                 editor_nudge.cc
135                 editor_ops.cc
136                 editor_region_list.cc
137                 editor_route_list.cc
138                 editor_rulers.cc
139                 editor_scrub.cc
140                 editor_selection.cc
141                 editor_selection_list.cc
142                 editor_tempodisplay.cc
143                 editor_timefx.cc
144                 engine_dialog.cc
145                 enums.cc
146                 export_channel_selector.cc
147                 export_dialog.cc
148                 export_filename_selector.cc
149                 export_file_notebook.cc
150                 export_format_dialog.cc
151                 export_format_selector.cc
152                 export_preset_selector.cc
153                 export_timespan_selector.cc
154                 fft.cc
155                 fft_graph.cc
156                 fft_result.cc
157                 plugin_eq_gui.cc
158                 gain_meter.cc
159                 generic_pluginui.cc
160                 ghostregion.cc
161                 global_port_matrix.cc
162                 io_selector.cc
163                 keyboard.cc
164                 keyeditor.cc
165                 latency_gui.cc
166                 level_meter.cc
167                 lineset.cc
168                 location_ui.cc
169                 main.cc
170                 marker.cc
171                 midi_channel_selector.cc
172                 midi_port_dialog.cc
173                 midi_region_view.cc
174                 midi_scroomer.cc
175                 midi_streamview.cc
176                 midi_time_axis.cc
177                 mixer_strip.cc
178                 mixer_ui.cc
179                 nag.cc
180                 new_session_dialog.cc
181                 option_editor.cc
182                 opts.cc
183                 panner.cc
184                 panner2d.cc
185                 panner_ui.cc
186                 piano_roll_header.cc
187                 playlist_selector.cc
188                 plugin_selector.cc
189                 plugin_ui.cc
190                 port_group.cc
191                 port_matrix.cc
192                 port_matrix_body.cc
193                 port_matrix_column_labels.cc
194                 port_matrix_component.cc
195                 port_matrix_grid.cc
196                 port_matrix_labels.cc
197                 port_matrix_row_labels.cc
198                 processor_box.cc
199                 prompter.cc
200                 public_editor.cc
201                 region_gain_line.cc
202                 region_selection.cc
203                 region_view.cc
204                 rhythm_ferret.cc
205                 route_params_ui.cc
206                 route_processor_selection.cc
207                 route_time_axis.cc
208                 route_ui.cc
209                 selection.cc
210                 send_ui.cc
211                 session_import_dialog.cc
212                 session_metadata_dialog.cc
213                 sfdb_ui.cc
214                 simpleline.cc
215                 simplerect.cc
216                 splash.cc
217                 streamview.cc
218                 tape_region_view.cc
219                 tempo_dialog.cc
220                 tempo_lines.cc
221                 theme_manager.cc
222                 time_axis_view.cc
223                 time_axis_view_item.cc
224                 time_selection.cc
225                 ui_config.cc
226                 utils.cc
227                 version.cc
228                 waveview.cc
229         '''
230         obj.source += 'x11.cc'
231         obj.includes     = ['.']
232         obj.name         = 'gtk2_ardour'
233         obj.target       = 'ardour-3.0'
234         obj.uselib       = 'UUID FLAC GLIBMM GTHREAD GTK GNOMECANVAS OGG ALSA'
235         obj.uselib       += ' GTKMM GNOMECANVASMM'
236         obj.uselib_local = '''libpbd libmidipp libtaglib libardour libsurfaces
237                               libgtkmm2ext libgtk2_ardour_c libtaglib'''
238         obj.install_path = ''
239         obj.cxxflags     = '-DVERSIONSTRING=\\\"' + GTK2_ARDOUR_VERSION + '\\\"'
240         obj.cxxflags     += ' -DPACKAGE=\\\"gtk2_ardour\\\"'
241         obj.cxxflags     += ' -DDATA_DIR=\\\"' + os.path.normpath(bld.env['DATADIRNAME']) + '\\\"'
242         obj.cxxflags     += ' -DCONFIG_DIR=\\\"' + os.path.normpath(bld.env['CONFIGDIRNAME']) + '\\\"'
243         obj.cxxflags     += ' -DMODULE_DIR=\\\"' + os.path.normpath(bld.env['LIBDIRNAME']) + '\\\"'
244         obj.cxxflags     += ' -DLOCALEDIR=\\\"' + os.path.join(
245                         os.path.normpath(bld.env['DATADIRNAME']), 'locale') + '\\\"'
246         
247         # Wrappers
248
249         wrapper_subst_dict = {
250                 'INSTALL_PREFIX' : bld.env['PREFIX'],
251                 'LIBDIR'         : os.path.normpath(bld.env['LIBDIRNAME']),
252                 'VERSION'        : '3.0',
253                 'EXECUTABLE'     : 'build/default/gtk2_ardour/ardour-3.0'
254         }
255
256         obj = bld.new_task_gen('subst')
257         obj.source = 'ardev-common-waf.sh.in'
258         obj.target = 'ardev-common-waf.sh'
259         obj.chmod  = 0755
260         obj.dict   = wrapper_subst_dict
261         
262         # Font configuration
263         
264         font_subst_dict = {}
265         font_sizes      = {}
266         base_font       = ""
267
268         # Set up font substitution dictionary
269         for style in ['', 'BOLD', 'ITALIC']:
270                 for sizename,points in font_sizes.iteritems():
271                         if (len (style)):
272                                 key = "_".join (['FONT',style,sizename])
273                                 fontstyle = " ".join ([basefont,style.lower(),points])
274                         else:
275                                 key = "_".join (['FONT',sizename])
276                                 fontstyle = " ".join ([basefont,points])
277                         key = '%' + key + '%'
278                         font_subst_dict[key] = fontstyle
279
280         # Set up font sizes
281         if bld.env['IS_OSX']: # OS X fonts
282                 basefont = "Lucida Grande"
283                 font_sizes = {
284                         'TINY' : '7',
285                         'SMALLER' : '9',
286                         'SMALL' : '10',
287                         'NORMAL' : '11',
288                         'BIG' : '12',
289                         'BIGGER' : '14',
290                         'LARGE' : '18',
291                         'LARGER' : '28',
292                         'HUGER' : '36',
293                         'MASSIVE' : '60'
294                 }
295         else: # Linux/X11 fonts
296                 basefont = "sans"
297                 font_sizes = {
298                         'TINY' : '6',
299                         'SMALLER' : '8',
300                         'SMALL' : '9',
301                         'NORMAL' : '10',
302                         'BIG' : '14',
303                         'BIGGER' : '16',
304                         'LARGE' : '18',
305                         'LARGER' : '24',
306                         'HUGER' : '34',
307                         'MASSIVE' : '60'
308                 }
309
310         # RC files
311         
312         obj = bld.new_task_gen('subst')
313         obj.source = 'ardour3_ui_dark.rc.in'
314         obj.target = 'ardour3_ui_dark.rc'
315         obj.dict   = font_subst_dict
316         
317         obj = bld.new_task_gen('subst')
318         obj.source = 'ardour3_ui_light.rc.in'
319         obj.target = 'ardour3_ui_light.rc'
320         obj.dict   = font_subst_dict
321         
322         obj = bld.new_task_gen('subst')
323         obj.source = 'ardour3_ui_dark_sae.rc.in'
324         obj.target = 'ardour3_ui_dark_sae.rc'
325         obj.dict   = font_subst_dict
326         
327         obj = bld.new_task_gen('subst')
328         obj.source = 'ardour3_ui_light_sae.rc.in'
329         obj.target = 'ardour3_ui_light_sae.rc'
330         obj.dict   = font_subst_dict
331         
332         # Menus
333         menus_argv = []
334         if bld.env['GTKOSX']:
335                 menus_argv = [ '-E', '-P', '-DGTKOSX', '-DTOP_MENUBAR' ]
336         else:
337                 menus_argv = [ '-E', '-P' ]
338         obj = bld.new_task_gen('command-output')
339         obj.command = 'cpp'
340         obj.command_is_external = True
341         obj.no_inputs = True
342         obj.argv = menus_argv
343         obj.stdin = 'ardour.menus.in'
344         obj.stdout = 'ardour.menus'
345
346         # Keybindings
347         keybindings_dict = {}
348         if bld.env['GTKOSX']:
349                 keybindings_dict['%PRIMARY%']   = 'Meta'
350                 keybindings_dict['%SECONDARY%'] = 'Mod1'
351                 keybindings_dict['%TERTIARY%']  = 'Shift'
352                 keybindings_dict['%LEVEL4%']    = 'Ctrl'
353                 keybindings_dict['%WINDOW%']    = 'Mod1'
354         else:
355                 keybindings_dict['%PRIMARY%']   = 'Ctrl'
356                 keybindings_dict['%SECONDARY%'] = 'Alt'
357                 keybindings_dict['%TERTIARY%']  = 'Shift'
358                 keybindings_dict['%LEVEL4%']    = bld.env['WINDOWS_KEY']
359                 keybindings_dict['%WINDOW%']    = 'Alt'
360         
361         for b in [ 'SAE-de-keypad', 'SAE-de-nokeypad', 'SAE-us-keypad', 'SAE-us-nokeypad',
362                    'mnemonic-us', 'ergonomic-us' ]:
363                 obj = bld.new_task_gen('subst')
364                 obj.target = b + '.bindings'
365                 obj.source = obj.target + '.in'
366                 obj.dict   = keybindings_dict
367
368 def shutdown():
369         autowaf.shutdown()
370