s3-waf: add net.
[abartlet/samba.git/.git] / source3 / build / dynconfig.py
1 import string, Utils
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     'with-codepagedir'                    : [ '${PREFIX}/lib/samba', 'where to put codepages' ],
12     'with-privatedir'                     : [ '${PREFIX}/private', 'where to put smbpasswd' ],
13     'with-cachedir'                       : [ '${PREFIX}/var/locks', 'where to put temporary cache files' ],
14     'with-localedir'                      : [ '${PREFIX}/share/locale', 'Where to put po files' ]
15     }
16
17 # list of cflags to use for dynconfig.c
18 dyn_cflags = {
19     'CONFIGFILE'                     : '${SYSCONFDIR}/smb.conf',
20     'BINDIR'                         : '${BINDIR}',
21     'SBINDIR'                        : '${SBINDIR}',
22     'LIBDIR'                         : '${LIBDIR}',
23     'STATEDIR'                       : '${LOCALSTATEDIR}',
24     'LMHOSTSFILE'                    : '${SYSCONFDIR}/lmhosts',
25     'LOCKDIR'                        : '${LOCALSTATEDIR}/locks',
26     'PIDDIR'                         : '${LOCALSTATEDIR}/run',
27     'DATADIR'                        : '${DATADIR}',
28     'LOGFILEBASE'                    : '${LOCALSTATEDIR}',
29     'CONFIGDIR'                      : '${SYSCONFDIR}',
30     'CONFIGFILE'                     : '${LIBDIR}/smb.conf',
31     'NCALRPCDIR'                     : '${LOCALSTATEDIR}/ncalrpc',
32     'SWATDIR'                        : '${PREFIX}/swat',
33     'PRIVATE_DIR'                    : '${PRIVATEDIR}',
34     'MODULESDIR'                     : '${PREFIX}/modules',
35     'SETUPDIR'                       : '${DATADIR}/setup',
36     'WINBINDD_PRIVILEGED_SOCKET_DIR' : '${WINBINDD_PRIVILEGED_SOCKET_DIR}',
37     'WINBINDD_SOCKET_DIR'            : '${WINBINDD_SOCKET_DIR}',
38     'NTP_SIGND_SOCKET_DIR'           : '${NTP_SIGND_SOCKET_DIR}',
39     'CODEPAGEDIR'                    : '${CODEPAGEDIR}',
40     'CACHEDIR'                       : '${CACHEDIR}',
41     'LOCALEDIR'                      : '${LOCALEDIR}',
42     'SMB_PASSWD_FILE'                : '${PRIVATEDIR}/smbpasswd',
43     }
44
45 def get_varname(v):
46     '''work out a variable name from a configure option name'''
47     if v.startswith('with-'):
48         v = v[5:]
49     v = v.upper()
50     v = string.replace(v, '-', '_')
51     return v
52
53
54 def dynconfig_cflags(bld):
55     '''work out the extra CFLAGS for dynconfig.c'''
56     cflags = []
57     for f in dyn_cflags.keys():
58         # substitute twice, as we could have substitutions containing variables
59         v = Utils.subst_vars(dyn_cflags[f], bld.env)
60         v = Utils.subst_vars(v, bld.env)
61         bld.ASSERT(v != '', "Empty dynconfig value for %s" % f)
62         bld.ASSERT(v.find('${') == -1, "Unsubstituted variable in %s : %s : %s" % (f, dyn_cflags[f], v))
63         cflags.append('-D%s="%s"' % (f, v))
64     return cflags