5 from waflib
import Logs
, Options
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']:
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)
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()):
56 package
= v
['package']
60 value
= getattr(Options
.options
, opt
)
62 optfeatures
[opt
]['build'] = False
63 optfeatures
[opt
]['status'] = 'disabled (requested)'
65 mandatory
= value
== 'yes'
67 errmsg
= 'not found, check ' + site
70 optfeatures
[opt
]['build'] = bool(ctx
.check_cfg(package
= package
, mandatory
= mandatory
, args
= '--cflags --libs', errmsg
= errmsg
))
71 if optfeatures
[opt
]['build']:
73 optfeatures
[opt
]['status'] = 'enabled (requested)'
75 optfeatures
[opt
]['status'] = 'enabled (auto)'
77 optfeatures
[opt
]['status'] = 'disabled, package ' + package
+ ' not found, check ' + site
79 ctx
.env
['BUILD_' + opt
.upper()] = optfeatures
[opt
]['build']
82 ctx
.load('compiler_c')
86 errmsg
= "not installed, see http://www.gtk.org/",
87 args
= '--cflags --libs')
90 package
= 'gthread-2.0',
91 errmsg
= "not installed, see http://www.gtk.org/",
92 args
= '--cflags --libs')
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']:
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')
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('==================')
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')
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')
154 features
= 'c cprogram',
156 target
= 'gmidimonitor',
160 ctx
.install_files('${DATA_DIR}', 'gmidimonitor.ui')