3 This is NOT a waf tool but generic functions to be called from a waf 4 tool, in particular by wcb.py. 6 There's probably a wafier way to do this. 8 The interpretation of options are very specific so don't change them 9 unless you really know all the use cases. The rules are: 11 If package is optional: 13 - omitting all --with-NAME* options will omit use the package 15 - explicitly using --with-NAME=false (or "no" or "off") will omit 18 If package is mandatory: 20 - omitting all --with-NAME* options will use pkg-config to find 23 - explicitly using --with-NAME=false (or "no" or "off") will 28 - explicitly using --with-NAME=true (or "yes" or "on") will use 29 pkg-config to find the package. 31 - using --with-NAME* with a path will attempt to locate the 32 package without using pkg-config 34 Note, actually, pgk-config fails often to do its job. Best to always 35 use explicit --with-NAME=[<bool>|<dir>]. 41 opt = opt.add_option_group(
'%s Options' % name)
42 opt.add_option(
'--with-%s'%lower, type=
'string', default=
None,
43 help=
"give %s installation location" % name)
44 opt.add_option(
'--with-%s-include'%lower, type=
'string',
45 help=
"give %s include installation location"%name)
46 opt.add_option(
'--with-%s-lib'%lower, type=
'string',
47 help=
"give %s lib installation location"%name)
50 def _configure(ctx, name, incs=(), libs=(), bins=(), pcname=
None, mandatory=
True):
56 instdir = getattr(ctx.options,
'with_'+lower,
None)
57 incdir = getattr(ctx.options,
'with_%s_include'%lower,
None)
58 libdir = getattr(ctx.options,
'with_%s_lib'%lower,
None)
59 bindir = getattr(ctx.options,
'with_%s_bin'%lower,
None)
64 assert (instdir.lower()
not in [
'no',
'off',
'false'])
66 if not any([instdir, incdir, libdir]):
67 print (
"skipping non mandatory %s, use --with-%s=[yes|<dir>] to force" % (name, lower))
69 if instdir
and instdir.lower()
in [
'no',
'off',
'false']:
73 if not any([instdir,incdir,libdir,bindir])
or (instdir
and instdir.lower()
in [
'yes',
'on',
'true']):
74 ctx.start_msg(
'Checking for %s in PKG_CONFIG_PATH' % name)
78 ctx.check_cfg(package=pcname, uselib_store=UPPER,
79 args=args, mandatory=mandatory)
80 if 'HAVE_'+UPPER
in ctx.env:
88 if not incdir
and instdir:
89 incdir = osp.join(instdir,
'include')
91 setattr(ctx.env,
'INCLUDES_'+UPPER, [incdir])
94 if not libdir
and instdir:
95 libdir = osp.join(instdir,
'lib')
97 setattr(ctx.env,
'LIBPATH_'+UPPER, [libdir])
100 if not bindir
and instdir:
101 bindir = osp.join(instdir,
'bin')
103 setattr(ctx.env,
'PATH_'+UPPER, [bindir])
109 ctx.start_msg(
"Location for %s headers" % name)
111 ctx.check_cxx(header_name=tryh,
112 use=UPPER, uselib_store=UPPER, mandatory=mandatory)
113 ctx.end_msg(
str(getattr(ctx.env,
'INCLUDES_' + UPPER,
None)))
116 ctx.start_msg(
"Location for %s libs" % name)
118 ctx.check_cxx(lib=tryl,
119 use=UPPER, uselib_store=UPPER, mandatory=mandatory)
120 ctx.end_msg(
str(getattr(ctx.env,
'LIBPATH_' + UPPER,
None)))
122 ctx.start_msg(
"Libs for %s" % name)
123 ctx.end_msg(
str(getattr(ctx.env,
'LIB_' + UPPER)))
126 ctx.start_msg(
"Bins for %s" % name)
129 ctx.find_program(tryb, var=tryb.upper(), mandatory=mandatory)
130 found_bins += ctx.env[tryb.upper()]
131 ctx.end_msg(
str(found_bins))
def _configure(ctx, name, incs=(), libs=(), bins=(), pcname=None, mandatory=True)
std::string str(const std::pair< Type, Type > &tt)