s3-waf: fix LOCALEDIR usage.
[samba.git] / source3 / build / wscript
1 #!/usr/bin/env python
2
3 import string, Utils, Options
4 from dynconfig import *
5
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)
16
17
18 cflags_vars = [ 'CONFIGFILE' ]
19
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         conf.ASSERT(value is not None, "Missing configure option %s" % varname)
27         conf.ASSERT(varname not in conf.env, "Variable %s already defined" % varname)
28         conf.env[varname] = value
29
30     for f in dyn_cflags.keys():
31         # substitute twice, as we could have substitutions containing variables
32         v = Utils.subst_vars(dyn_cflags[f], conf.env)
33         v = Utils.subst_vars(v, conf.env)
34         conf.ASSERT(v != '', "Empty dynconfig value for %s" % f)
35         conf.ASSERT(v.find('${') == -1, "Unsubstituted variable in %s : %s : %s" % (f, dyn_cflags[f], v))
36         conf.env[f] = v
37         if f in cflags_vars:
38             conf.DEFINE(f, v, quote=True)
39
40 def build(bld):
41     cflags = dynconfig_cflags(bld)
42     bld.SAMBA_SUBSYSTEM('DYNCONFIG',
43                         '../dynconfig.c',
44                         deps='replace talloc tdb popt',
45                         cflags=cflags)
46     bld.SAMBA_SUBSYSTEM('LOCALE_DIR',
47                         '../localedir.c',
48                         cflags='-DLOCALEDIR=\"%s\"' % bld.env.LOCALEDIR)
49
50
51 def dynconfig_cflags(bld):
52     '''work out the extra CFLAGS for dynconfig.c'''
53     cflags = []
54     for f in dyn_cflags.keys():
55         # substitute twice, as we could have substitutions containing variables
56         v = Utils.subst_vars(dyn_cflags[f], bld.env)
57         v = Utils.subst_vars(v, bld.env)
58         bld.ASSERT(v != '', "Empty dynconfig value for %s" % f)
59         bld.ASSERT(v.find('${') == -1, "Unsubstituted variable in %s : %s : %s" % (f, dyn_cflags[f], v))
60         cflags.append('-D%s="%s"' % (f, v))
61     return cflags