s3-waf: make the --with-Xdir options work more like in the classic build.
[Samba.git] / source3 / build / wscript
blobc6eb55fc29d07a209e70bd850714acaa1a8a7e91
1 #!/usr/bin/env python
3 import string, Utils, Options
4 from dynconfig import *
6 def set_options(opt):
7 # get all the basic GNU options from the gnu_dirs tool
8 opt.tool_options('gnu_dirs')
9 for option in dir_options.keys():
10 default = dir_options[option][0]
11 help = dir_options[option][1]
12 varname = get_varname(option)
13 opt.add_option('--%s' % option,
14 help=(help + ' [%s]' % default),
15 action="store", dest=varname, default=default)
18 cflags_vars = [ 'CONFIGFILE' ]
20 def configure(conf):
21 # get all the basic GNU options from the gnu_dirs tool
22 conf.check_tool('gnu_dirs')
23 for option in dir_options.keys():
24 varname = get_varname(option)
25 value = getattr(Options.options, varname, None)
26 value = Utils.subst_vars(value, conf.env)
27 conf.ASSERT(value is not None, "Missing configure option %s" % varname)
28 conf.ASSERT(varname not in conf.env, "Variable %s already defined" % varname)
29 conf.env[varname] = value
31 for f in dyn_cflags.keys():
32 # substitute twice, as we could have substitutions containing variables
33 v = Utils.subst_vars(dyn_cflags[f], conf.env)
34 v = Utils.subst_vars(v, conf.env)
35 conf.ASSERT(v != '', "Empty dynconfig value for %s" % f)
36 conf.ASSERT(v.find('${') == -1, "Unsubstituted variable in %s : %s : %s" % (f, dyn_cflags[f], v))
37 if f not in conf.env:
38 conf.env[f] = v
39 if f in cflags_vars:
40 conf.DEFINE(f, v, quote=True)
42 def build(bld):
43 cflags = dynconfig_cflags(bld)
44 bld.SAMBA_SUBSYSTEM('DYNCONFIG',
45 '../dynconfig.c',
46 deps='replace talloc tdb popt',
47 cflags=cflags)
48 bld.SAMBA_SUBSYSTEM('LOCALE_DIR',
49 '../localedir.c',
50 cflags='-DLOCALEDIR=\"%s\"' % bld.env.LOCALEDIR)
53 def dynconfig_cflags(bld):
54 '''work out the extra CFLAGS for dynconfig.c'''
55 cflags = []
56 for f in dyn_cflags.keys():
57 # substitute twice, as we could have substitutions containing variables
58 v = Utils.subst_vars(dyn_cflags[f], bld.env)
59 v = Utils.subst_vars(v, bld.env)
60 bld.ASSERT(v != '', "Empty dynconfig value for %s" % f)
61 bld.ASSERT(v.find('${') == -1, "Unsubstituted variable in %s : %s : %s" % (f, dyn_cflags[f], v))
62 cflags.append('-D%s="%s"' % (f, v))
63 return cflags