build: commit all the waf build files in the tree
[idra/samba.git] / source4 / dynconfig / wscript
1 import string, Utils, Options
2
3 # list of directory options to offer in configure
4 dir_options = {
5     'with-piddir'                         : [ '${PREFIX}/var/run', 'where to put pid files' ],
6     'with-modulesdir'                     : [ '${PREFIX}/modules', 'Where to put dynamically loadable modules' ],
7     'with-privatedir'                     : [ '${PREFIX}/private', 'Where to put sam.ldb and other private files' ],
8     'with-winbindd-socket-dir'            : [ '${PREFIX}/var/lib/winbindd', 'winbind socket directory' ],
9     'with-winbindd-privileged-socket-dir' : [ '${PREFIX}/var/lib/winbindd_privileged', 'winbind privileged socket directory'],
10     'with-ntp-signd-socket-dir'           : [ '${PREFIX}/var/run/ntp_signd', 'NTP signed directory'],
11     'with-lockdir'                        : [ '${PREFIX}/var/locks', 'where to put lock files' ]
12     }
13
14 # list of cflags to use for dynconfig.c
15 dyn_cflags = {
16     'CONFIGFILE'                     : '${SYSCONFDIR}/smb.conf',
17     'BINDIR'                         : '${BINDIR}',
18     'SBINDIR'                        : '${SBINDIR}',
19     'LMHOSTSFILE'                    : '${SYSCONFDIR}/lmhosts',
20     'LOCKDIR'                        : '${LOCALSTATEDIR}/locks',
21     'PIDDIR'                         : '${LOCALSTATEDIR}/run',
22     'DATADIR'                        : '${DATADIR}',
23     'LOGFILEBASE'                    : '${LOCALSTATEDIR}',
24     'CONFIGDIR'                      : '${SYSCONFDIR}',
25     'NCALRPCDIR'                     : '${LOCALSTATEDIR}/ncalrpc',
26     'SWATDIR'                        : '${DATADIR}/swat',
27     'PRIVATE_DIR'                    : '${PRIVATEDIR}',
28     'MODULESDIR'                     : '${PREFIX}/modules',
29     'SETUPDIR'                       : '${DATADIR}/setup',
30     'WINBINDD_PRIVILEGED_SOCKET_DIR' : '${WINBINDD_PRIVILEGED_SOCKET_DIR}',
31     'WINBINDD_SOCKET_DIR'            : '${WINBINDD_SOCKET_DIR}',
32     'NTP_SIGND_SOCKET_DIR'           : '${NTP_SIGND_SOCKET_DIR}',
33     }
34
35 def get_varname(v):
36     '''work out a variable name from a configure option name'''
37     if v.startswith('with-'):
38         v = v[5:]
39     v = v.upper()
40     v = string.replace(v, '-', '_')
41     return v
42
43
44 def set_options(opt):
45     # get all the basic GNU options from the gnu_dirs tool
46     opt.tool_options('gnu_dirs')
47     for option in dir_options.keys():
48         default = dir_options[option][0]
49         help    = dir_options[option][1]
50         varname = get_varname(option)
51         opt.add_option('--%s' % option,
52                        help=(help + ' [%s]' % default),
53                        action="store", dest=varname, default=default)
54
55 def configure(conf):
56     # get all the basic GNU options from the gnu_dirs tool
57     conf.check_tool('gnu_dirs')
58     for option in dir_options.keys():
59         varname = get_varname(option)
60         value = getattr(Options.options, varname, None)
61         conf.ASSERT(value is not None, "Missing configure option %s" % varname)
62         conf.ASSERT(varname not in conf.env, "Variable %s already defined" % varname)
63         conf.env[varname] = value
64
65 def dynconfig_cflags(bld):
66     '''work out the extra CFLAGS for dynconfig.c'''
67     cflags = []
68     for f in dyn_cflags.keys():
69         # substitute twice, as we could have substitutions containing variables
70         v = Utils.subst_vars(dyn_cflags[f], bld.env)
71         v = Utils.subst_vars(v, bld.env)
72         bld.ASSERT(v != '', "Empty dynconfig value for %s" % f)
73         bld.ASSERT(v.find('${') == -1, "Unsubstituted variable in %s : %s : %s" % (f, dyn_cflags[f], v))
74         cflags.append('-D%s="%s"' % (f, v))
75     return cflags
76
77 def build(bld):
78     cflags = dynconfig_cflags(bld)
79     bld.SAMBA_SUBSYSTEM('DYNCONFIG',
80                         'dynconfig.c',
81                         deps='replace talloc',
82                         cflags=cflags)