2010-03-28 01:48:49 +03:00
#!/usr/bin/env python
2011-02-09 07:56:56 +03:00
import string, Utils, Options, sys, Build, os, intltool
2011-02-07 07:03:26 +03:00
from samba_utils import EXPAND_VARIABLES, os_path_relpath
2010-03-17 14:07:42 +03:00
# list of directory options to offer in configure
dir_options = {
2011-06-14 11:01:02 +04:00
'with-piddir' : [ '${LOCALSTATEDIR}/run', 'where to put pid files' ],
2010-03-17 14:07:42 +03:00
'with-privatedir' : [ '${PREFIX}/private', 'Where to put sam.ldb and other private files' ],
2011-06-14 11:01:02 +04:00
'with-sockets-dir' : [ '${LOCALSTATEDIR}/run', 'sockets directory' ],
'with-winbindd-privileged-socket-dir' : [ '${LOCALSTATEDIR}/lib/winbindd_privileged', 'winbind privileged socket directory'],
2011-06-20 20:02:00 +04:00
'with-lockdir' : [ '${LOCALSTATEDIR}/locks', 'where to put short term disposable state files' ],
'with-cachedir' : [ '${LOCALSTATEDIR}/locks', 'where to put cache files' ],
2011-06-14 11:01:02 +04:00
'with-logfilebase' : [ '${LOCALSTATEDIR}', 'Where to put log files' ],
'with-pammodulesdir' : [ '${LIBDIR}', 'Which directory to use for PAM modules' ],
'with-statedir' : [ '${LOCALSTATEDIR}/locks', 'where to put persistent state files' ],
2010-03-17 14:07:42 +03:00
}
# list of cflags to use for dynconfig.c
dyn_cflags = {
'BINDIR' : '${BINDIR}',
'SBINDIR' : '${SBINDIR}',
2010-11-23 14:44:53 +03:00
'SCRIPTSBINDIR' : '${SBINDIR}',
2010-04-29 10:29:45 +04:00
'CONFIGDIR' : '${SYSCONFDIR}',
'CONFIGFILE' : '${SYSCONFDIR}/smb.conf',
2010-03-17 14:07:42 +03:00
'LMHOSTSFILE' : '${SYSCONFDIR}/lmhosts',
2010-04-29 10:29:45 +04:00
'PRIVATE_DIR' : '${PRIVATEDIR}',
2011-06-14 11:01:02 +04:00
'LOGFILEBASE' : '${LOGFILEBASE}',
'LOCKDIR' : '${LOCKDIR}',
'PIDDIR' : '${PIDDIR}',
2010-03-17 14:07:42 +03:00
'DATADIR' : '${DATADIR}',
2011-02-09 07:56:56 +03:00
'LOCALEDIR' : '${LOCALEDIR}',
2010-03-17 14:07:42 +03:00
'SETUPDIR' : '${DATADIR}/setup',
2011-06-14 11:01:02 +04:00
'WINBINDD_SOCKET_DIR' : '${SOCKETS_DIR}/winbindd',
2010-04-29 10:29:45 +04:00
'WINBINDD_PRIVILEGED_SOCKET_DIR' : '${WINBINDD_PRIVILEGED_SOCKET_DIR}',
2011-06-14 11:01:02 +04:00
'NTP_SIGND_SOCKET_DIR' : '${SOCKETS_DIR}/ntp_signd',
'NCALRPCDIR' : '${SOCKETS_DIR}/ncalrpc',
2010-04-20 14:23:04 +04:00
'PYTHONDIR' : '${PYTHONDIR}',
2011-01-14 09:20:01 +03:00
'PYTHONARCHDIR' : '${PYTHONARCHDIR}',
2010-04-29 10:29:45 +04:00
'MODULESDIR' : '${PREFIX}/modules',
'INCLUDEDIR' : '${PREFIX}/include',
'PKGCONFIGDIR' : '${LIBDIR}/pkgconfig',
2010-04-30 12:20:54 +04:00
'SWATDIR' : '${DATADIR}/swat',
2011-06-14 11:01:02 +04:00
'CODEPAGEDIR' : '${DATADIR}/codepages',
2010-04-25 12:08:00 +04:00
'LIBDIR' : '${LIBDIR}',
2011-06-14 11:01:02 +04:00
'LIBEXECDIR' : '${LIBEXECDIR}',
'STATEDIR' : '${STATEDIR}',
'CACHEDIR' : '${CACHEDIR}',
2010-04-25 12:08:00 +04:00
'SMB_PASSWD_FILE' : '${PRIVATEDIR}/smbpasswd',
2011-06-14 11:01:02 +04:00
'NMBDSOCKETDIR' : '${SOCKETS_DIR}/nmbd',
'PAMMODULESDIR' : '${PAMMODULESDIR}',
2010-03-29 13:43:58 +04:00
}
2010-03-17 14:07:42 +03:00
def get_varname(v):
'''work out a variable name from a configure option name'''
if v.startswith('with-'):
v = v[5:]
v = v.upper()
2010-04-08 01:45:46 +04:00
v = v.replace('-', '_')
2010-03-17 14:07:42 +03:00
return v
def set_options(opt):
# get all the basic GNU options from the gnu_dirs tool
for option in dir_options.keys():
default = dir_options[option][0]
help = dir_options[option][1]
varname = get_varname(option)
opt.add_option('--%s' % option,
help=(help + ' [%s]' % default),
action="store", dest=varname, default=default)
def configure(conf):
# get all the basic GNU options from the gnu_dirs tool
for option in dir_options.keys():
varname = get_varname(option)
value = getattr(Options.options, varname, None)
conf.ASSERT(value is not None, "Missing configure option %s" % varname)
conf.ASSERT(varname not in conf.env, "Variable %s already defined" % varname)
conf.env[varname] = value
2010-03-27 01:46:50 +03:00
for f in dyn_cflags.keys():
2010-03-29 13:43:58 +04:00
v = EXPAND_VARIABLES(conf, dyn_cflags[f])
2010-03-27 01:46:50 +03:00
conf.ASSERT(v != '', "Empty dynconfig value for %s" % f)
conf.env[f] = v
2010-10-13 05:19:37 +04:00
def dynconfig_cflags(bld, list=None):
2010-03-17 14:07:42 +03:00
'''work out the extra CFLAGS for dynconfig.c'''
cflags = []
2010-11-23 14:44:53 +03:00
# override some paths when running from the build directory
override = { 'MODULESDIR' : 'bin/modules',
2011-02-05 10:27:33 +03:00
'PYTHONDIR' : 'bin/python',
'PYTHONARCHDIR' : 'bin/python',
2011-02-07 05:13:44 +03:00
'CODEPAGEDIR' : os.path.join(bld.env.srcdir, 'codepages'),
2011-02-03 09:34:51 +03:00
'SCRIPTSBINDIR' : os.path.join(bld.env.srcdir, 'source4/scripting/bin'),
'SETUPDIR' : os.path.join(bld.env.srcdir, 'source4/setup') }
2010-03-17 14:07:42 +03:00
for f in dyn_cflags.keys():
2010-10-13 05:19:37 +04:00
if list and not f in list:
continue
2010-11-23 14:44:53 +03:00
value = bld.env[f]
if not Options.is_install:
if f in override:
value = os.path.join(os.getcwd(), override[f])
cflags.append('-D%s="%s"' % (f, value))
2010-03-17 14:07:42 +03:00
return cflags
2010-09-25 08:58:09 +04:00
Build.BuildContext.dynconfig_cflags = dynconfig_cflags
2010-03-17 14:07:42 +03:00
def build(bld):
2010-09-25 08:58:09 +04:00
cflags = bld.dynconfig_cflags()
2011-06-28 13:31:02 +04:00
version_header = 'version.h'
if not os.getenv('TOPLEVEL_BUILD'):
version_header = 'include/version.h'
2010-03-17 14:07:42 +03:00
bld.SAMBA_SUBSYSTEM('DYNCONFIG',
2011-06-21 06:48:22 +04:00
'dynconfig.c',
2010-03-17 14:07:42 +03:00
deps='replace talloc',
2011-06-28 13:31:02 +04:00
public_headers=os_path_relpath(os.path.join(Options.launch_dir, version_header), bld.curdir),
2010-03-27 05:56:05 +03:00
header_path='samba',
2010-03-17 14:07:42 +03:00
cflags=cflags)