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