update the website url
[gmidimonitor.git] / wscript
blobc108c649797c2438183b372d6f04599ed3040dde
1 #! /usr/bin/env python
2 # encoding: utf-8
4 import os, Logs, Options
6 top = '.'
7 out = 'build'
8 APPNAME='gmidimonitor'
9 VERSION='3.5-dev'
11 optfeatures = {
12 'jack': {'description': 'JACK MIDI support',
13 'site': 'http://jackaudio.org/'},
14 'alsa': {'description': 'ALSA MIDI support',
15 'site': 'http://www.alsa-project.org/'},
16 'lash': {'description': 'LASH support',
17 'site': 'http://www.nongnu.org/lash/',
18 'package': 'lash-1.0'},
21 def display_line(text = ""):
22 Logs.pprint('NORMAL', text)
24 def display_value(ctx, text, value, color = 'NORMAL'):
25 ctx.msg(text, value, color)
27 def display_feature(ctx, opt):
28 if optfeatures[opt]['build']:
29 color = 'GREEN'
30 else:
31 color = 'YELLOW'
33 display_value(ctx, optfeatures[opt]['description'], optfeatures[opt]['status'], color)
35 def add_cflag(ctx, flag):
36 ctx.env.append_unique('CXXFLAGS', flag)
37 ctx.env.append_unique('CFLAGS', flag)
39 def add_linkflag(ctx, flag):
40 ctx.env.append_unique('LINKFLAGS', flag)
42 def add_opt_feature(opt, feature, help):
43 help = "Whether to build " + help + ", possible values: 'yes', 'no' and 'auto'. Default is 'auto'."
44 opt.add_option('--' + feature, type='choice', choices=['auto', 'yes', 'no'], default='auto', help=help)
46 def options(opt):
47 opt.load('compiler_c')
48 for k, v in optfeatures.items():
49 add_opt_feature(opt, k, v['description'])
51 def check_opt_packages(ctx):
52 for opt, v in optfeatures.items():
53 site = v['site']
54 try:
55 package = v['package']
56 except KeyError:
57 package = opt
59 value = getattr(Options.options, opt)
60 if value == 'no':
61 optfeatures[opt]['build'] = False
62 optfeatures[opt]['status'] = 'disabled (requested)'
63 else:
64 mandatory = value == 'yes'
65 if mandatory:
66 errmsg = 'not found, check ' + site
67 else:
68 errmsg = 'not found'
69 optfeatures[opt]['build'] = bool(ctx.check_cfg(package = package, mandatory = mandatory, args = '--cflags --libs', errmsg = errmsg))
70 if optfeatures[opt]['build']:
71 if mandatory:
72 optfeatures[opt]['status'] = 'enabled (requested)'
73 else:
74 optfeatures[opt]['status'] = 'enabled (auto)'
75 else:
76 optfeatures[opt]['status'] = 'disabled, package ' + package + ' not found, check ' + site
78 ctx.env['BUILD_' + opt.upper()] = optfeatures[opt]['build']
80 def configure(ctx):
81 ctx.load('compiler_c')
83 ctx.check_cfg(
84 package = 'gtk+-2.0',
85 errmsg = "not installed, see http://www.gtk.org/",
86 args = '--cflags --libs')
88 ctx.check_cfg(
89 package = 'libglade-2.0',
90 errmsg = "not installed, see http://www.gtk.org/",
91 args = '--cflags --libs')
93 ctx.check_cfg(
94 package = 'gthread-2.0',
95 errmsg = "not installed, see http://www.gtk.org/",
96 args = '--cflags --libs')
98 ctx.check_cfg(
99 package = 'gmodule-2.0',
100 errmsg = "not installed, see http://www.gtk.org/",
101 args = '--cflags --libs')
103 check_opt_packages(ctx)
105 if not optfeatures['jack']['build'] and not optfeatures['alsa']['build']:
106 display_line()
107 display_feature(ctx, 'alsa')
108 display_feature(ctx, 'jack')
109 ctx.fatal("Neither JACK nor ALSA is available")
111 ctx.env['DATA_DIR'] = os.path.normpath(os.path.join(ctx.env['PREFIX'], 'share', APPNAME))
113 add_cflag(ctx, '-Wall')
114 #add_cflag(ctx, '-Wuninitialized')
115 #add_cflag(ctx, '-O3')
116 #add_cflag(ctx, '-g')
117 #add_linkflag(ctx, '-g')
119 display_line()
120 display_line('==================')
121 display_value(ctx, 'Prefix', ctx.env['PREFIX'])
122 display_feature(ctx, 'jack')
123 display_feature(ctx, 'alsa')
124 display_feature(ctx, 'lash')
125 display_line('==================')
126 display_line()
128 ctx.define('PACKAGE_VERSION', VERSION)
129 ctx.define('APPNAME', APPNAME)
130 ctx.define('DATA_DIR', ctx.env['DATA_DIR'])
131 ctx.write_config_header('config.h')
133 def build(ctx):
134 source = [
135 "main.c",
136 "about.c",
137 "path.c",
138 "glade.c",
139 "gm.c",
140 "log.c",
141 "memory_atomic.c",
142 "sysex.c",
144 uselib = ['GTK+-2.0', 'GTHREAD-2.0', 'LIBGLADE-2.0', 'GMODULE-2.0']
146 if ctx.env['BUILD_JACK']:
147 source.append("jack.c")
148 uselib.append('JACK')
150 if ctx.env['BUILD_ALSA']:
151 source.append("alsa.c")
152 uselib.append('ALSA')
154 if ctx.env['BUILD_LASH']:
155 uselib.append('LASH-1.0')
157 ctx.program(
158 source = source,
159 features = 'c cprogram',
160 includes = ".",
161 target = 'gmidimonitor',
162 uselib = uselib,
165 ctx.install_files('${DATA_DIR}', 'gmidimonitor.glade')