summaryrefslogtreecommitdiffstats
path: root/dynconfig
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2011-06-24 16:26:23 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-06-24 16:26:23 +1000
commit6da26870e0ae5acd6ff49a30ec2f6886b44d095e (patch)
tree850c71039563c16a5d563c47e7ba2ab645baf198 /dynconfig
parent6925a799d04c6fa59dd2ddef1f5510f9bb7d17d1 (diff)
parent2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 (diff)
downloadsamba-4.0.0alpha16.tar.gz
samba-4.0.0alpha16.tar.xz
samba-4.0.0alpha16.zip
Merge 2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 as Samba-4.0alpha16samba-4.0.0alpha16
Diffstat (limited to 'dynconfig')
-rw-r--r--dynconfig/dynconfig.c117
-rw-r--r--dynconfig/dynconfig.h62
-rwxr-xr-xdynconfig/wscript115
3 files changed, 294 insertions, 0 deletions
diff --git a/dynconfig/dynconfig.c b/dynconfig/dynconfig.c
new file mode 100644
index 00000000000..4bcdab35961
--- /dev/null
+++ b/dynconfig/dynconfig.c
@@ -0,0 +1,117 @@
+/*
+ Unix SMB/CIFS implementation.
+ Copyright (C) 2001 by Martin Pool <mbp@samba.org>
+ Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
+ Copyright (C) Stefan Metzmacher 2003
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "nsswitch/winbind_struct_protocol.h"
+
+/**
+ * @file dynconfig.c
+ *
+ * @brief Global configurations, initialized to configured defaults.
+ *
+ * This file should be the only file that depends on path
+ * configuration (--prefix, etc), so that if ./configure is re-run,
+ * all programs will be appropriately updated. Everything else in
+ * Samba should import extern variables from here, rather than relying
+ * on preprocessor macros.
+ *
+ * Eventually some of these may become even more variable, so that
+ * they can for example consistently be set across the whole of Samba
+ * by command-line parameters, config file entries, or environment
+ * variables.
+ *
+ * @todo Perhaps eventually these should be merged into the parameter
+ * table? There's kind of a chicken-and-egg situation there...
+ **/
+
+#include "dynconfig.h"
+#ifdef strdup
+#undef strdup
+#endif
+
+#define DEFINE_DYN_CONFIG_PARAM(name) \
+const char *dyn_##name = name; \
+\
+bool is_default_dyn_##name(void) \
+{\
+ if (strcmp(name, dyn_##name) == 0) { \
+ return true; \
+ } \
+ return false; \
+}\
+\
+const char *get_dyn_##name(void) \
+{\
+ return dyn_##name;\
+}\
+\
+const char *set_dyn_##name(const char *newpath) \
+{\
+ if (newpath == NULL) { \
+ return NULL; \
+ } \
+ if (strcmp(name, newpath) == 0) { \
+ return dyn_##name; \
+ } \
+ newpath = strdup(newpath);\
+ if (newpath == NULL) { \
+ return NULL; \
+ } \
+ if (is_default_dyn_##name()) { \
+ /* do not free a static string */ \
+ } else if (dyn_##name) {\
+ free(discard_const(dyn_##name)); \
+ }\
+ dyn_##name = newpath; \
+ return dyn_##name;\
+}
+
+/* these are in common with s3 */
+DEFINE_DYN_CONFIG_PARAM(SBINDIR)
+DEFINE_DYN_CONFIG_PARAM(BINDIR)
+DEFINE_DYN_CONFIG_PARAM(SWATDIR)
+DEFINE_DYN_CONFIG_PARAM(CONFIGFILE) /**< Location of smb.conf file. **/
+DEFINE_DYN_CONFIG_PARAM(LOGFILEBASE) /** Log file directory. **/
+DEFINE_DYN_CONFIG_PARAM(LMHOSTSFILE) /** Statically configured LanMan hosts. **/
+DEFINE_DYN_CONFIG_PARAM(CODEPAGEDIR)
+DEFINE_DYN_CONFIG_PARAM(LIBDIR)
+DEFINE_DYN_CONFIG_PARAM(MODULESDIR)
+DEFINE_DYN_CONFIG_PARAM(SHLIBEXT)
+DEFINE_DYN_CONFIG_PARAM(LOCKDIR)
+DEFINE_DYN_CONFIG_PARAM(STATEDIR) /** Persistent state files. Default LOCKDIR */
+DEFINE_DYN_CONFIG_PARAM(CACHEDIR) /** Temporary cache files. Default LOCKDIR */
+DEFINE_DYN_CONFIG_PARAM(PIDDIR)
+DEFINE_DYN_CONFIG_PARAM(NCALRPCDIR)
+DEFINE_DYN_CONFIG_PARAM(SMB_PASSWD_FILE)
+DEFINE_DYN_CONFIG_PARAM(PRIVATE_DIR)
+DEFINE_DYN_CONFIG_PARAM(LOCALEDIR)
+DEFINE_DYN_CONFIG_PARAM(NMBDSOCKETDIR)
+DEFINE_DYN_CONFIG_PARAM(DATADIR)
+DEFINE_DYN_CONFIG_PARAM(SETUPDIR)
+DEFINE_DYN_CONFIG_PARAM(WINBINDD_SOCKET_DIR) /* from winbind_struct_protocol.h in s3 autoconf */
+
+/* these are not in s3 */
+#if (_SAMBA_BUILD_ >= 4)
+DEFINE_DYN_CONFIG_PARAM(WINBINDD_PRIVILEGED_SOCKET_DIR)
+DEFINE_DYN_CONFIG_PARAM(NTP_SIGND_SOCKET_DIR)
+DEFINE_DYN_CONFIG_PARAM(PYTHONDIR)
+DEFINE_DYN_CONFIG_PARAM(PYTHONARCHDIR)
+DEFINE_DYN_CONFIG_PARAM(SCRIPTSBINDIR)
+#endif
diff --git a/dynconfig/dynconfig.h b/dynconfig/dynconfig.h
new file mode 100644
index 00000000000..e53cd8ff5fa
--- /dev/null
+++ b/dynconfig/dynconfig.h
@@ -0,0 +1,62 @@
+/*
+ Unix SMB/CIFS implementation.
+ Copyright (C) 2001 by Martin Pool <mbp@samba.org>
+ Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003.
+
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file dynconfig.h
+ *
+ * @brief Exported global configurations.
+ **/
+
+#define DEFINE_DYN_CONFIG_PROTO(name) \
+extern const char *dyn_##name; \
+const char *get_dyn_##name(void); \
+const char *set_dyn_##name(const char *newpath); \
+bool is_default_dyn_##name(void);
+
+/* these are in common with s3 */
+DEFINE_DYN_CONFIG_PROTO(SBINDIR)
+DEFINE_DYN_CONFIG_PROTO(BINDIR)
+DEFINE_DYN_CONFIG_PROTO(SWATDIR)
+DEFINE_DYN_CONFIG_PROTO(CONFIGFILE) /**< Location of smb.conf file. **/
+DEFINE_DYN_CONFIG_PROTO(LOGFILEBASE) /** Log file directory. **/
+DEFINE_DYN_CONFIG_PROTO(LMHOSTSFILE) /** Statically configured LanMan hosts. **/
+DEFINE_DYN_CONFIG_PROTO(CODEPAGEDIR)
+DEFINE_DYN_CONFIG_PROTO(LIBDIR)
+DEFINE_DYN_CONFIG_PROTO(MODULESDIR)
+DEFINE_DYN_CONFIG_PROTO(SHLIBEXT)
+DEFINE_DYN_CONFIG_PROTO(LOCKDIR)
+DEFINE_DYN_CONFIG_PROTO(STATEDIR) /** Persistent state files. Default LOCKDIR */
+DEFINE_DYN_CONFIG_PROTO(CACHEDIR) /** Temporary cache files. Default LOCKDIR */
+DEFINE_DYN_CONFIG_PROTO(PIDDIR)
+DEFINE_DYN_CONFIG_PROTO(NCALRPCDIR)
+DEFINE_DYN_CONFIG_PROTO(SMB_PASSWD_FILE)
+DEFINE_DYN_CONFIG_PROTO(PRIVATE_DIR)
+DEFINE_DYN_CONFIG_PROTO(LOCALEDIR)
+DEFINE_DYN_CONFIG_PROTO(NMBDSOCKETDIR)
+
+/* these are not in s3 */
+DEFINE_DYN_CONFIG_PROTO(DATADIR)
+DEFINE_DYN_CONFIG_PROTO(SETUPDIR)
+DEFINE_DYN_CONFIG_PROTO(WINBINDD_SOCKET_DIR)
+DEFINE_DYN_CONFIG_PROTO(WINBINDD_PRIVILEGED_SOCKET_DIR)
+DEFINE_DYN_CONFIG_PROTO(NTP_SIGND_SOCKET_DIR)
+DEFINE_DYN_CONFIG_PROTO(PYTHONDIR)
+DEFINE_DYN_CONFIG_PROTO(PYTHONARCHDIR)
+DEFINE_DYN_CONFIG_PROTO(SCRIPTSBINDIR)
diff --git a/dynconfig/wscript b/dynconfig/wscript
new file mode 100755
index 00000000000..35af13db7ec
--- /dev/null
+++ b/dynconfig/wscript
@@ -0,0 +1,115 @@
+#!/usr/bin/env python
+
+import string, Utils, Options, sys, Build, os, intltool
+from samba_utils import EXPAND_VARIABLES, os_path_relpath
+
+# list of directory options to offer in configure
+dir_options = {
+ 'with-piddir' : [ '${LOCALSTATEDIR}/run', 'where to put pid files' ],
+ 'with-privatedir' : [ '${PREFIX}/private', 'Where to put sam.ldb and other private files' ],
+ 'with-sockets-dir' : [ '${LOCALSTATEDIR}/run', 'sockets directory' ],
+ 'with-winbindd-privileged-socket-dir' : [ '${LOCALSTATEDIR}/lib/winbindd_privileged', 'winbind privileged socket directory'],
+ 'with-lockdir' : [ '${LOCALSTATEDIR}/lock', 'where to put short term disposable state files' ],
+ 'with-cachedir' : [ '${LOCALSTATEDIR}/cache', 'where to put cache files' ],
+ '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' ],
+ }
+
+# list of cflags to use for dynconfig.c
+dyn_cflags = {
+ 'BINDIR' : '${BINDIR}',
+ 'SBINDIR' : '${SBINDIR}',
+ 'SCRIPTSBINDIR' : '${SBINDIR}',
+ 'CONFIGDIR' : '${SYSCONFDIR}',
+ 'CONFIGFILE' : '${SYSCONFDIR}/smb.conf',
+ 'LMHOSTSFILE' : '${SYSCONFDIR}/lmhosts',
+ 'PRIVATE_DIR' : '${PRIVATEDIR}',
+ 'LOGFILEBASE' : '${LOGFILEBASE}',
+ 'LOCKDIR' : '${LOCKDIR}',
+ 'PIDDIR' : '${PIDDIR}',
+ 'DATADIR' : '${DATADIR}',
+ 'LOCALEDIR' : '${LOCALEDIR}',
+ 'SETUPDIR' : '${DATADIR}/setup',
+ 'WINBINDD_SOCKET_DIR' : '${SOCKETS_DIR}/winbindd',
+ 'WINBINDD_PRIVILEGED_SOCKET_DIR' : '${WINBINDD_PRIVILEGED_SOCKET_DIR}',
+ 'NTP_SIGND_SOCKET_DIR' : '${SOCKETS_DIR}/ntp_signd',
+ 'NCALRPCDIR' : '${SOCKETS_DIR}/ncalrpc',
+ 'PYTHONDIR' : '${PYTHONDIR}',
+ 'PYTHONARCHDIR' : '${PYTHONARCHDIR}',
+ 'MODULESDIR' : '${PREFIX}/modules',
+ 'INCLUDEDIR' : '${PREFIX}/include',
+ 'PKGCONFIGDIR' : '${LIBDIR}/pkgconfig',
+ 'SWATDIR' : '${DATADIR}/swat',
+ 'CODEPAGEDIR' : '${DATADIR}/codepages',
+ 'LIBDIR' : '${LIBDIR}',
+ 'LIBEXECDIR' : '${LIBEXECDIR}',
+ 'STATEDIR' : '${STATEDIR}',
+ 'CACHEDIR' : '${CACHEDIR}',
+ 'SMB_PASSWD_FILE' : '${PRIVATEDIR}/smbpasswd',
+ 'NMBDSOCKETDIR' : '${SOCKETS_DIR}/nmbd',
+ 'PAMMODULESDIR' : '${PAMMODULESDIR}',
+ }
+
+def get_varname(v):
+ '''work out a variable name from a configure option name'''
+ if v.startswith('with-'):
+ v = v[5:]
+ v = v.upper()
+ v = v.replace('-', '_')
+ 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
+
+ for f in dyn_cflags.keys():
+ v = EXPAND_VARIABLES(conf, dyn_cflags[f])
+ conf.ASSERT(v != '', "Empty dynconfig value for %s" % f)
+ conf.env[f] = v
+
+def dynconfig_cflags(bld, list=None):
+ '''work out the extra CFLAGS for dynconfig.c'''
+ cflags = []
+ # override some paths when running from the build directory
+ override = { 'MODULESDIR' : 'bin/modules',
+ 'PYTHONDIR' : 'bin/python',
+ 'PYTHONARCHDIR' : 'bin/python',
+ 'CODEPAGEDIR' : os.path.join(bld.env.srcdir, 'codepages'),
+ 'SCRIPTSBINDIR' : os.path.join(bld.env.srcdir, 'source4/scripting/bin'),
+ 'SETUPDIR' : os.path.join(bld.env.srcdir, 'source4/setup') }
+ for f in dyn_cflags.keys():
+ if list and not f in list:
+ continue
+ 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))
+ return cflags
+Build.BuildContext.dynconfig_cflags = dynconfig_cflags
+
+def build(bld):
+ cflags = bld.dynconfig_cflags()
+ bld.SAMBA_SUBSYSTEM('DYNCONFIG',
+ 'dynconfig.c',
+ deps='replace talloc',
+ public_headers=os_path_relpath(os.path.join(Options.launch_dir, 'version.h'), bld.curdir),
+ header_path='samba',
+ cflags=cflags)