Waf: install stuff
[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_fx_dialog.cc
225                 time_selection.cc
226                 ui_config.cc
227                 utils.cc
228                 version.cc
229                 waveview.cc
230         '''
231         obj.source += 'x11.cc'
232         obj.includes     = ['.']
233         obj.name         = 'gtk2_ardour'
234         obj.target       = 'ardour-3.0'
235         obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3')
236         obj.uselib       = 'UUID FLAC GLIBMM GTHREAD GTK GNOMECANVAS OGG ALSA'
237         obj.uselib       += ' GTKMM GNOMECANVASMM'
238         obj.uselib_local = '''libpbd libmidipp libtaglib libardour libsurfaces
239                               libgtkmm2ext libgtk2_ardour_c libtaglib'''
240         obj.cxxflags     = '-DVERSIONSTRING=\\\"' + GTK2_ARDOUR_VERSION + '\\\"'
241         obj.cxxflags     += ' -DPACKAGE=\\\"gtk2_ardour\\\"'
242         obj.cxxflags     += ' -DDATA_DIR=\\\"' + os.path.normpath(bld.env['DATADIRNAME']) + '\\\"'
243         obj.cxxflags     += ' -DCONFIG_DIR=\\\"' + os.path.normpath(bld.env['CONFIGDIRNAME']) + '\\\"'
244         obj.cxxflags     += ' -DMODULE_DIR=\\\"' + os.path.normpath(bld.env['LIBDIRNAME']) + '\\\"'
245         obj.cxxflags     += ' -DLOCALEDIR=\\\"' + os.path.join(
246                         os.path.normpath(bld.env['DATADIRNAME']), 'locale') + '\\\"'
247         
248         # Wrappers
249
250         wrapper_subst_dict = {
251                 'INSTALL_PREFIX' : bld.env['PREFIX'],
252                 'LIBDIR'         : os.path.normpath(bld.env['LIBDIRNAME']),
253                 'LIBS'           : 'build/default/libs',
254                 'VERSION'        : '3.0',
255                 'EXECUTABLE'     : 'build/default/gtk2_ardour/ardour-3.0'
256         }
257
258         obj              = bld.new_task_gen('subst')
259         obj.source       = 'ardev_common.sh.in'
260         obj.target       = 'ardev_common_waf.sh'
261         obj.chmod        = 0755
262         obj.dict         = wrapper_subst_dict
263         
264         obj              = bld.new_task_gen('subst')
265         obj.source       = 'ardour.sh.in'
266         obj.target       = 'ardour3'
267         obj.chmod        = 0755
268         obj.dict         = wrapper_subst_dict
269         obj.install_path = bld.env['BINDIR']
270         
271         # Font configuration
272         
273         font_subst_dict = {}
274         font_sizes      = {}
275         base_font       = ""
276
277         # Set up font substitution dictionary
278         for style in ['', 'BOLD', 'ITALIC']:
279                 for sizename,points in font_sizes.iteritems():
280                         if (len (style)):
281                                 key = "_".join (['FONT',style,sizename])
282                                 fontstyle = " ".join ([basefont,style.lower(),points])
283                         else:
284                                 key = "_".join (['FONT',sizename])
285                                 fontstyle = " ".join ([basefont,points])
286                         key = '%' + key + '%'
287                         font_subst_dict[key] = fontstyle
288
289         # Set up font sizes
290         if bld.env['IS_OSX']: # OS X fonts
291                 basefont = "Lucida Grande"
292                 font_sizes = {
293                         'TINY' : '7',
294                         'SMALLER' : '9',
295                         'SMALL' : '10',
296                         'NORMAL' : '11',
297                         'BIG' : '12',
298                         'BIGGER' : '14',
299                         'LARGE' : '18',
300                         'LARGER' : '28',
301                         'HUGER' : '36',
302                         'MASSIVE' : '60'
303                 }
304         else: # Linux/X11 fonts
305                 basefont = "sans"
306                 font_sizes = {
307                         'TINY' : '6',
308                         'SMALLER' : '8',
309                         'SMALL' : '9',
310                         'NORMAL' : '10',
311                         'BIG' : '14',
312                         'BIGGER' : '16',
313                         'LARGE' : '18',
314                         'LARGER' : '24',
315                         'HUGER' : '34',
316                         'MASSIVE' : '60'
317                 }
318
319         # RC files
320         
321         obj              = bld.new_task_gen('subst')
322         obj.source       = 'ardour3_ui_dark.rc.in'
323         obj.target       = 'ardour3_ui_dark.rc'
324         obj.dict         = font_subst_dict
325         obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
326         
327         obj              = bld.new_task_gen('subst')
328         obj.source       = 'ardour3_ui_light.rc.in'
329         obj.target       = 'ardour3_ui_light.rc'
330         obj.dict         = font_subst_dict
331         obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
332         
333         obj              = bld.new_task_gen('subst')
334         obj.source       = 'ardour3_ui_dark_sae.rc.in'
335         obj.target       = 'ardour3_ui_dark_sae.rc'
336         obj.dict         = font_subst_dict
337         obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
338         
339         obj              = bld.new_task_gen('subst')
340         obj.source       = 'ardour3_ui_light_sae.rc.in'
341         obj.target       = 'ardour3_ui_light_sae.rc'
342         obj.dict         = font_subst_dict
343         obj.install_path = os.path.join(bld.env['CONFIGDIR'], 'ardour3')
344         
345         # Menus
346         menus_argv = []
347         if bld.env['GTKOSX']:
348                 menus_argv = [ '-E', '-P', '-DGTKOSX', '-DTOP_MENUBAR' ]
349         else:
350                 menus_argv = [ '-E', '-P' ]
351         obj = bld.new_task_gen('command-output')
352         obj.command = 'cpp'
353         obj.command_is_external = True
354         obj.no_inputs = True
355         obj.argv = menus_argv
356         obj.stdin = 'ardour.menus.in'
357         obj.stdout = 'ardour.menus'
358
359         # Keybindings
360         keybindings_dict = {}
361         if bld.env['GTKOSX']:
362                 keybindings_dict['%PRIMARY%']   = 'Meta'
363                 keybindings_dict['%SECONDARY%'] = 'Mod1'
364                 keybindings_dict['%TERTIARY%']  = 'Shift'
365                 keybindings_dict['%LEVEL4%']    = 'Ctrl'
366                 keybindings_dict['%WINDOW%']    = 'Mod1'
367         else:
368                 keybindings_dict['%PRIMARY%']   = 'Ctrl'
369                 keybindings_dict['%SECONDARY%'] = 'Alt'
370                 keybindings_dict['%TERTIARY%']  = 'Shift'
371                 keybindings_dict['%LEVEL4%']    = bld.env['WINDOWS_KEY']
372                 keybindings_dict['%WINDOW%']    = 'Alt'
373         
374         for b in [ 'SAE-de-keypad', 'SAE-de-nokeypad', 'SAE-us-keypad', 'SAE-us-nokeypad',
375                    'mnemonic-us', 'ergonomic-us' ]:
376                 obj = bld.new_task_gen('subst')
377                 obj.target = b + '.bindings'
378                 obj.source = obj.target + '.in'
379                 obj.dict   = keybindings_dict
380         
381         # Icons/Images
382         bld.install_files('${DATADIR}/ardour3/icons', 'icons/*.png')
383         bld.install_files('${DATADIR}/ardour3/pixmaps', 'pixmaps/*.xpm')
384         bld.install_files('${DATADIR}/ardour3', 'splash.png')
385
386 def shutdown():
387         autowaf.shutdown()
388