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