4 import os
, Logs
, Options
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']:
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)
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():
55 package
= v
['package']
59 value
= getattr(Options
.options
, opt
)
61 optfeatures
[opt
]['build'] = False
62 optfeatures
[opt
]['status'] = 'disabled (requested)'
64 mandatory
= value
== 'yes'
66 errmsg
= 'not found, check ' + site
69 optfeatures
[opt
]['build'] = bool(ctx
.check_cfg(package
= package
, mandatory
= mandatory
, args
= '--cflags --libs', errmsg
= errmsg
))
70 if optfeatures
[opt
]['build']:
72 optfeatures
[opt
]['status'] = 'enabled (requested)'
74 optfeatures
[opt
]['status'] = 'enabled (auto)'
76 optfeatures
[opt
]['status'] = 'disabled, package ' + package
+ ' not found, check ' + site
78 ctx
.env
['BUILD_' + opt
.upper()] = optfeatures
[opt
]['build']
81 ctx
.load('compiler_c')
85 errmsg
= "not installed, see http://www.gtk.org/",
86 args
= '--cflags --libs')
89 package
= 'gthread-2.0',
90 errmsg
= "not installed, see http://www.gtk.org/",
91 args
= '--cflags --libs')
94 package
= 'gmodule-2.0',
95 errmsg
= "not installed, see http://www.gtk.org/",
96 args
= '--cflags --libs')
98 check_opt_packages(ctx
)
100 if not optfeatures
['jack']['build'] and not optfeatures
['alsa']['build']:
102 display_feature(ctx
, 'alsa')
103 display_feature(ctx
, 'jack')
104 ctx
.fatal("Neither JACK nor ALSA is available")
106 ctx
.env
['DATA_DIR'] = os
.path
.normpath(os
.path
.join(ctx
.env
['PREFIX'], 'share', APPNAME
))
108 add_cflag(ctx
, '-Wall')
109 #add_cflag(ctx, '-Wuninitialized')
110 #add_cflag(ctx, '-O3')
111 #add_cflag(ctx, '-g')
112 #add_linkflag(ctx, '-g')
115 display_line('==================')
116 display_value(ctx
, 'Prefix', ctx
.env
['PREFIX'])
117 display_feature(ctx
, 'jack')
118 display_feature(ctx
, 'alsa')
119 display_feature(ctx
, 'lash')
120 display_line('==================')
123 ctx
.define('PACKAGE_VERSION', VERSION
)
124 ctx
.define('APPNAME', APPNAME
)
125 ctx
.define('DATA_DIR', ctx
.env
['DATA_DIR'])
126 ctx
.write_config_header('config.h')
138 uselib
= ['GTK+-2.0', 'GTHREAD-2.0', 'GMODULE-2.0']
140 if ctx
.env
['BUILD_JACK']:
141 source
.append("jack.c")
142 uselib
.append('JACK')
144 if ctx
.env
['BUILD_ALSA']:
145 source
.append("alsa.c")
146 uselib
.append('ALSA')
148 if ctx
.env
['BUILD_LASH']:
149 uselib
.append('LASH-1.0')
153 features
= 'c cprogram',
155 target
= 'gmidimonitor',
159 ctx
.install_files('${DATA_DIR}', 'gmidimonitor.ui')