s4-waf: started adding auto-install of include files
[gd/samba-autobuild/.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-privatedir'                     : [ '${PREFIX}/private', 'Where to put sam.ldb and other private files' ],
7     'with-winbindd-socket-dir'            : [ '${PREFIX}/var/lib/winbindd', 'winbind socket directory' ],
8     'with-winbindd-privileged-socket-dir' : [ '${PREFIX}/var/lib/winbindd_privileged', 'winbind privileged socket directory'],
9     'with-ntp-signd-socket-dir'           : [ '${PREFIX}/var/run/ntp_signd', 'NTP signed directory'],
10     'with-lockdir'                        : [ '${PREFIX}/var/locks', 'where to put lock files' ]
11     }
12
13 # list of cflags to use for dynconfig.c
14 dyn_cflags = {
15     'CONFIGFILE'                     : '${SYSCONFDIR}/smb.conf',
16     'BINDIR'                         : '${BINDIR}',
17     'SBINDIR'                        : '${SBINDIR}',
18     'LMHOSTSFILE'                    : '${SYSCONFDIR}/lmhosts',
19     'LOCKDIR'                        : '${LOCALSTATEDIR}/locks',
20     'PIDDIR'                         : '${LOCALSTATEDIR}/run',
21     'DATADIR'                        : '${DATADIR}',
22     'LOGFILEBASE'                    : '${LOCALSTATEDIR}',
23     'CONFIGDIR'                      : '${SYSCONFDIR}',
24     'NCALRPCDIR'                     : '${LOCALSTATEDIR}/ncalrpc',
25     'SWATDIR'                        : '${DATADIR}/swat',
26     'PRIVATE_DIR'                    : '${PRIVATEDIR}',
27     'MODULESDIR'                     : '${PREFIX}/modules',
28     'SETUPDIR'                       : '${DATADIR}/setup',
29     'INCLUDEDIR'                     : '${PREFIX}/include',
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     for f in dyn_cflags.keys():
66         # substitute twice, as we could have substitutions containing variables
67         v = Utils.subst_vars(dyn_cflags[f], conf.env)
68         v = Utils.subst_vars(v, conf.env)
69         conf.ASSERT(v != '', "Empty dynconfig value for %s" % f)
70         conf.ASSERT(v.find('${') == -1, "Unsubstituted variable in %s : %s : %s" % (f, dyn_cflags[f], v))
71         conf.env[f] = v
72
73 def dynconfig_cflags(bld):
74     '''work out the extra CFLAGS for dynconfig.c'''
75     cflags = []
76     for f in dyn_cflags.keys():
77         cflags.append('-D%s="%s"' % (f, bld.env[f]))
78     return cflags
79
80 def build(bld):
81     cflags = dynconfig_cflags(bld)
82     bld.SAMBA_SUBSYSTEM('DYNCONFIG',
83                         'dynconfig.c',
84                         deps='replace talloc',
85                         cflags=cflags)