README: Fix adjust homepage URL
[gmidimonitor.git] / wscript
blob96737d5ef5373ecbe0aa6eb050568a8878db827c
1 #! /usr/bin/env python
2 # encoding: utf-8
4 import os
5 from waflib import Logs, Options
7 top = '.'
8 out = 'build'
9 APPNAME='gmidimonitor'
10 VERSION='3.6'
12 optfeatures = {
13 'jack': {'description': 'JACK MIDI support',
14 'site': 'http://jackaudio.org/'},
15 'alsa': {'description': 'ALSA MIDI support',
16 'site': 'http://www.alsa-project.org/'},
17 'lash': {'description': 'LASH support',
18 'site': 'http://www.nongnu.org/lash/',
19 'package': 'lash-1.0'},
22 def display_line(text = ""):
23 Logs.pprint('NORMAL', text)
25 def display_value(ctx, text, value, color = 'NORMAL'):
26 ctx.msg(text, value, color)
28 def display_feature(ctx, opt):
29 if optfeatures[opt]['build']:
30 color = 'GREEN'
31 else:
32 color = 'YELLOW'
34 display_value(ctx, optfeatures[opt]['description'], optfeatures[opt]['status'], color)
36 def add_cflag(ctx, flag):
37 ctx.env.append_unique('CXXFLAGS', flag)
38 ctx.env.append_unique('CFLAGS', flag)
40 def add_linkflag(ctx, flag):
41 ctx.env.append_unique('LINKFLAGS', flag)
43 def add_opt_feature(opt, feature, help):
44 help = "Whether to build " + help + ", possible values: 'yes', 'no' and 'auto'. Default is 'auto'."
45 opt.add_option('--' + feature, type='choice', choices=['auto', 'yes', 'no'], default='auto', help=help)
47 def options(opt):
48 opt.load('compiler_c')
49 for k, v in list(optfeatures.items()):
50 add_opt_feature(opt, k, v['description'])
52 def check_opt_packages(ctx):
53 for opt, v in list(optfeatures.items()):
54 site = v['site']
55 try:
56 package = v['package']
57 except KeyError:
58 package = opt
60 value = getattr(Options.options, opt)
61 if value == 'no':
62 optfeatures[opt]['build'] = False
63 optfeatures[opt]['status'] = 'disabled (requested)'
64 else:
65 mandatory = value == 'yes'
66 if mandatory:
67 errmsg = 'not found, check ' + site
68 else:
69 errmsg = 'not found'
70 optfeatures[opt]['build'] = bool(ctx.check_cfg(package = package, mandatory = mandatory, args = '--cflags --libs', errmsg = errmsg))
71 if optfeatures[opt]['build']:
72 if mandatory:
73 optfeatures[opt]['status'] = 'enabled (requested)'
74 else:
75 optfeatures[opt]['status'] = 'enabled (auto)'
76 else:
77 optfeatures[opt]['status'] = 'disabled, package ' + package + ' not found, check ' + site
79 ctx.env['BUILD_' + opt.upper()] = optfeatures[opt]['build']
81 def configure(ctx):
82 ctx.load('compiler_c')
84 ctx.check_cfg(
85 package = 'gtk+-2.0',
86 errmsg = "not installed, see http://www.gtk.org/",
87 args = '--cflags --libs')
89 ctx.check_cfg(
90 package = 'gthread-2.0',
91 errmsg = "not installed, see http://www.gtk.org/",
92 args = '--cflags --libs')
94 ctx.check_cfg(
95 package = 'gmodule-2.0',
96 errmsg = "not installed, see http://www.gtk.org/",
97 args = '--cflags --libs')
99 check_opt_packages(ctx)
101 if not optfeatures['jack']['build'] and not optfeatures['alsa']['build']:
102 display_line()
103 display_feature(ctx, 'alsa')
104 display_feature(ctx, 'jack')
105 ctx.fatal("Neither JACK nor ALSA is available")
107 ctx.env['DATA_DIR'] = os.path.normpath(os.path.join(ctx.env['PREFIX'], 'share', APPNAME))
109 add_cflag(ctx, '-Wall')
110 #add_cflag(ctx, '-Wuninitialized')
111 #add_cflag(ctx, '-O3')
112 #add_cflag(ctx, '-g')
113 #add_linkflag(ctx, '-g')
115 display_line()
116 display_line('==================')
117 display_value(ctx, 'Prefix', ctx.env['PREFIX'])
118 display_feature(ctx, 'jack')
119 display_feature(ctx, 'alsa')
120 display_feature(ctx, 'lash')
121 display_line('==================')
122 display_line()
124 ctx.define('PACKAGE_VERSION', VERSION)
125 ctx.define('APPNAME', APPNAME)
126 ctx.define('DATA_DIR', ctx.env['DATA_DIR'])
127 ctx.write_config_header('config.h')
129 def build(ctx):
130 source = [
131 "main.c",
132 "about.c",
133 "path.c",
134 "gm.c",
135 "log.c",
136 "memory_atomic.c",
137 "sysex.c",
139 uselib = ['GTK+-2.0', 'GTHREAD-2.0', 'GMODULE-2.0']
141 if ctx.env['BUILD_JACK']:
142 source.append("jack.c")
143 uselib.append('JACK')
145 if ctx.env['BUILD_ALSA']:
146 source.append("alsa.c")
147 uselib.append('ALSA')
149 if ctx.env['BUILD_LASH']:
150 uselib.append('LASH-1.0')
152 ctx.program(
153 source = source,
154 features = 'c cprogram',
155 includes = ".",
156 target = 'gmidimonitor',
157 uselib = uselib,
160 ctx.install_files('${DATA_DIR}', 'gmidimonitor.ui')