s3:configure: add check for new CTDB_CONTROL_SCHEDULE_FOR_DELETION
[Samba.git] / source4 / dynconfig / wscript
blobf815e81a2d325c86db08b89a8bf24794ccb56809
1 #!/usr/bin/env python
3 import string, Utils, Options, sys, Build, os, intltool
4 from samba_utils import EXPAND_VARIABLES, os_path_relpath
6 # list of directory options to offer in configure
7 dir_options = {
8 'with-piddir' : [ '${PREFIX}/var/run', 'where to put pid files' ],
9 'with-privatedir' : [ '${PREFIX}/private', 'Where to put sam.ldb and other private files' ],
10 'with-winbindd-socket-dir' : [ '${PREFIX}/var/lib/winbindd', 'winbind socket directory' ],
11 'with-winbindd-privileged-socket-dir' : [ '${PREFIX}/var/lib/winbindd_privileged', 'winbind privileged socket directory'],
12 'with-ntp-signd-socket-dir' : [ '${PREFIX}/var/run/ntp_signd', 'NTP signed directory'],
13 'with-lockdir' : [ '${PREFIX}/var/locks', 'where to put lock files' ]
16 # list of cflags to use for dynconfig.c
17 dyn_cflags = {
18 'BINDIR' : '${BINDIR}',
19 'SBINDIR' : '${SBINDIR}',
20 'SCRIPTSBINDIR' : '${SBINDIR}',
21 'CONFIGDIR' : '${SYSCONFDIR}',
22 'CONFIGFILE' : '${SYSCONFDIR}/smb.conf',
23 'LMHOSTSFILE' : '${SYSCONFDIR}/lmhosts',
24 'PRIVATE_DIR' : '${PRIVATEDIR}',
25 'LOGFILEBASE' : '${LOCALSTATEDIR}',
26 'LOCKDIR' : '${LOCALSTATEDIR}/locks',
27 'PIDDIR' : '${LOCALSTATEDIR}/run',
28 'DATADIR' : '${DATADIR}',
29 'LOCALEDIR' : '${LOCALEDIR}',
30 'SETUPDIR' : '${DATADIR}/setup',
31 'WINBINDD_SOCKET_DIR' : '${WINBINDD_SOCKET_DIR}',
32 'WINBINDD_PRIVILEGED_SOCKET_DIR' : '${WINBINDD_PRIVILEGED_SOCKET_DIR}',
33 'NTP_SIGND_SOCKET_DIR' : '${NTP_SIGND_SOCKET_DIR}',
34 'NCALRPCDIR' : '${LOCALSTATEDIR}/ncalrpc',
35 'PYTHONDIR' : '${PYTHONDIR}',
36 'PYTHONARCHDIR' : '${PYTHONARCHDIR}',
37 'MODULESDIR' : '${PREFIX}/modules',
38 'INCLUDEDIR' : '${PREFIX}/include',
39 'PKGCONFIGDIR' : '${LIBDIR}/pkgconfig',
40 'SWATDIR' : '${DATADIR}/swat',
41 'CODEPAGEDIR' : '${LIBDIR}/samba',
42 'LIBDIR' : '${LIBDIR}',
43 'LIBEXECDIR' : '${MODULESDIR}',
44 'STATEDIR' : '${LOCALSTATEDIR}',
45 'CACHEDIR' : '${LOCKDIR}',
46 'SMB_PASSWD_FILE' : '${PRIVATEDIR}/smbpasswd',
47 'NMBDSOCKETDIR' : '${LOCALSTATEDIR}/nmbd',
50 # changes for when FHS is enabled
51 dyn_cflags_fhs = {
52 'BINDIR' : '${BINDIR}',
53 'SBINDIR' : '${SBINDIR}',
54 'SCRIPTSBINDIR' : '${SBINDIR}',
55 'CONFIGDIR' : '${SYSCONFDIR}/samba',
56 'CONFIGFILE' : '${SYSCONFDIR}/samba/smb.conf',
57 'LMHOSTSFILE' : '${SYSCONFDIR}/samba/lmhosts',
58 'PRIVATE_DIR' : '${LOCALSTATEDIR}/lib/samba/private',
59 'LOGFILEBASE' : '${LOCALSTATEDIR}/log/samba',
60 'LOCKDIR' : '${LOCALSTATEDIR}/lib/samba',
61 'PIDDIR' : '${LOCALSTATEDIR}/run/samba',
62 'SETUPDIR' : '${DATADIR}/samba/setup',
63 'WINBINDD_SOCKET_DIR' : '${LOCALSTATEDIR}/run/samba/winbindd',
64 'WINBINDD_PRIVILEGED_SOCKET_DIR' : '${LOCALSTATEDIR}/run/samba/winbindd_privileged',
65 'NTP_SIGND_SOCKET_DIR' : '${LOCALSTATEDIR}/run/samba/ntp_signd',
66 'NCALRPCDIR' : '${LOCALSTATEDIR}/run/samba/ncalrpc',
67 'PYTHONARCHDIR' : '${PYTHONARCHDIR}',
68 'MODULESDIR' : '${LIBDIR}/samba',
69 'LIBEXECDIR' : '${MODULESDIR}',
70 'INCLUDEDIR' : '${INCLUDEDIR}/samba-4.0',
71 'PKGCONFIGDIR' : '${LIBDIR}/pkgconfig',
72 'SWATDIR' : '${DATADIR}/swat',
73 'CODEPAGEDIR' : '${DATADIR}/samba',
74 'NMBDSOCKETDIR' : '${LOCALSTATEDIR}/run/samba/nmbd',
77 def get_varname(v):
78 '''work out a variable name from a configure option name'''
79 if v.startswith('with-'):
80 v = v[5:]
81 v = v.upper()
82 v = v.replace('-', '_')
83 return v
86 def set_options(opt):
87 # get all the basic GNU options from the gnu_dirs tool
88 opt.add_option('--enable-fhs',
89 help=("Use FHS-compliant paths (default no)"),
90 action="store_true", dest='ENABLE_FHS', default=False)
91 for option in dir_options.keys():
92 default = dir_options[option][0]
93 help = dir_options[option][1]
94 varname = get_varname(option)
95 opt.add_option('--%s' % option,
96 help=(help + ' [%s]' % default),
97 action="store", dest=varname, default=default)
99 def configure(conf):
100 # get all the basic GNU options from the gnu_dirs tool
101 for option in dir_options.keys():
102 varname = get_varname(option)
103 value = getattr(Options.options, varname, None)
104 conf.ASSERT(value is not None, "Missing configure option %s" % varname)
105 conf.ASSERT(varname not in conf.env, "Variable %s already defined" % varname)
106 conf.env[varname] = value
108 for f in dyn_cflags.keys():
109 v = EXPAND_VARIABLES(conf, dyn_cflags[f])
110 conf.ASSERT(v != '', "Empty dynconfig value for %s" % f)
111 conf.env[f] = v
113 if Options.options.ENABLE_FHS:
114 for f in dyn_cflags_fhs.keys():
115 v = EXPAND_VARIABLES(conf, dyn_cflags_fhs[f])
116 conf.ASSERT(v != '', "Empty dynconfig value for %s" % f)
117 conf.env[f] = v
119 if (not Options.options.ENABLE_FHS and
120 (conf.env.PREFIX == '/usr' or conf.env.PREFIX == '/usr/local')):
121 print("ERROR: Don't install directly under /usr or /usr/local without using the FHS option (--enable-fhs)")
122 sys.exit(1)
125 def dynconfig_cflags(bld, list=None):
126 '''work out the extra CFLAGS for dynconfig.c'''
127 cflags = []
128 # override some paths when running from the build directory
129 override = { 'MODULESDIR' : 'bin/modules',
130 'PYTHONDIR' : 'bin/python',
131 'PYTHONARCHDIR' : 'bin/python',
132 'CODEPAGEDIR' : os.path.join(bld.env.srcdir, 'codepages'),
133 'SCRIPTSBINDIR' : os.path.join(bld.env.srcdir, 'source4/scripting/bin'),
134 'SETUPDIR' : os.path.join(bld.env.srcdir, 'source4/setup') }
135 for f in dyn_cflags.keys():
136 if list and not f in list:
137 continue
138 value = bld.env[f]
139 if not Options.is_install:
140 if f in override:
141 value = os.path.join(os.getcwd(), override[f])
142 cflags.append('-D%s="%s"' % (f, value))
143 return cflags
144 Build.BuildContext.dynconfig_cflags = dynconfig_cflags
146 def build(bld):
147 cflags = bld.dynconfig_cflags()
148 bld.SAMBA_SUBSYSTEM('DYNCONFIG',
149 'dynconfig.c',
150 deps='replace talloc',
151 public_headers=os_path_relpath(os.path.join(Options.launch_dir, 'version.h'), bld.curdir),
152 header_path='samba',
153 cflags=cflags)