summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-02-08 14:41:30 +0100
committerMichael Adam <obnox@samba.org>2008-02-13 09:25:31 +0100
commitea22f7549341da1cadce269b9036753ad5567ca8 (patch)
tree8903119167647e62e58ec479d2c06bd6eadc3783 /source3
parent2a9cbe3c138153df0a5564c978ca9bfd42baa8a2 (diff)
downloadsamba-ea22f7549341da1cadce269b9036753ad5567ca8.tar.gz
samba-ea22f7549341da1cadce269b9036753ad5567ca8.tar.bz2
samba-ea22f7549341da1cadce269b9036753ad5567ca8.zip
Add support for linking talloc library statically or dynamically into samba.
This also establishes a general configure mechanism to control static vs dynamic linking of internal subsystems built as libraries: This first simple approach is as follows. * It applies only to "subsystems" that we build as libraries and for that linking samba against the libraries (as opposed to linking in the plain object files) has been configured in Makefile.in. * If we do build the shared library, then we link dynamically by default. * We only link statically if we don't build shared or if the library appears in the new --with-static-libs configure option (comma-separated list). Example (currently only one): --with-static-libs=talloc makes use of libtalloc.a instead of linking the dynamic variant with -ltalloc. A possilble way to setup linking against libraries in Makefile.in is this: For a subsystem, "mylib" say, we build bin/libmylib.a and bin/libmylib.so. The subsystem usually has a MYLIB_OBJ definition in Makefile.in. Define LIBMYLIB_STATIC=bin/libmylib.a and and LIBMYLIB_LIBS=-lmylib in configure.in as controlled by presence of "mylib" in the list given to --with-static-libs and change uses of $(MYLIB_OBJ) to @LIBMYLIB_STATIC@ in Makefile.in and add @LIBMYLIB_LIBS@ to the link targets as needed. In the example of talloc, which is needed everywhere, I have simply added @LIBTALLOC_LIBS@ to the definition of "LIBS" in Makefile.in. For other subsystems, one will have to be more careful. Michael (This used to be commit 71b990d9d687b517dec3d4eff67b6a3fe417a12a)
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in8
-rw-r--r--source3/configure.in42
2 files changed, 46 insertions, 4 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 69a08a0c2a..01aba442da 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -18,7 +18,7 @@ datarootdir=@datarootdir@
selftest_prefix=@selftest_prefix@
smbtorture4_path=@smbtorture4_path@
-LIBS=@LIBS@
+LIBS=@LIBS@ @LIBTALLOC_LIBS@
CC=@CC@
SHLD=@SHLD@
LIB_PATH_VAR=@LIB_PATH_VAR@
@@ -300,7 +300,7 @@ TALLOC_OBJ = @TALLOC_OBJS@
LIBTALLOC_OBJ0 = $(TALLOC_OBJ)
LIBTALLOC_OBJ = $(LIBTALLOC_OBJ0)
-LIBSAMBAUTIL_OBJ = $(TALLOC_OBJ) \
+LIBSAMBAUTIL_OBJ = @LIBTALLOC_STATIC@ \
$(LIBREPLACE_OBJ) \
$(SOCKET_WRAPPER_OBJ) \
$(NSS_WRAPPER_OBJ)
@@ -353,7 +353,7 @@ KRBCLIENT_OBJ = libads/kerberos.o libads/ads_status.o
LIBADDNS_OBJ0 = libaddns/dnsrecord.o libaddns/dnsutils.o libaddns/dnssock.o \
libaddns/dnsgss.o libaddns/dnsmarshall.o
-LIBADDNS_OBJ = $(LIBADDNS_OBJ0) $(TALLOC_OBJ)
+LIBADDNS_OBJ = $(LIBADDNS_OBJ0) @LIBTALLOC_STATIC@
LIBWBCLIENT_OBJ0 = nsswitch/libwbclient/wbclient.o \
nsswitch/libwbclient/wbc_util.o \
@@ -361,7 +361,7 @@ LIBWBCLIENT_OBJ0 = nsswitch/libwbclient/wbclient.o \
nsswitch/libwbclient/wbc_idmap.o \
nsswitch/libwbclient/wbc_sid.o \
nsswitch/libwbclient/wbc_pam.o
-LIBWBCLIENT_OBJ = $(LIBWBCLIENT_OBJ0) $(WBCOMMON_OBJ) $(TALLOC_OBJ) $(LIBREPLACE_OBJ)
+LIBWBCLIENT_OBJ = $(LIBWBCLIENT_OBJ0) $(WBCOMMON_OBJ) @LIBTALLOC_STATIC@ $(LIBREPLACE_OBJ)
LIBGPO_OBJ0 = libgpo/gpo_ldap.o libgpo/gpo_ini.o libgpo/gpo_util.o \
libgpo/gpo_fetch.o libgpo/gpo_filesync.o libgpo/gpo_sec.o
diff --git a/source3/configure.in b/source3/configure.in
index 8d8fcab03d..eab8645b37 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -336,6 +336,8 @@ AC_SUBST(INSTALL_LIBTALLOC)
AC_SUBST(UNINSTALL_LIBTALLOC)
AC_SUBST(LIBTALLOC_SHARED)
AC_SUBST(LIBTALLOC)
+AC_SUBST(LIBTALLOC_STATIC)
+AC_SUBST(LIBTALLOC_LIBS)
AC_SUBST(INSTALL_LIBWBCLIENT)
AC_SUBST(UNINSTALL_LIBWBCLIENT)
@@ -5127,11 +5129,45 @@ if test $enable_static = yes; then
fi
#################################################
+# --with-static-libs=LIBS:
+# link (internal) libs dynamically or statically?
+#
+# If a subsystem is built as a library then this controls whether they are
+# linked into Samba targets statically or dynamically:
+#
+# * If we build the shared library at all, we link dynamically by default.
+#
+# * We only link statically if we don't build shared or if the library
+# appears in the --with-static-libs configure option.
+#
+# Example:
+# --with-static-libs=talloc makes use of libtalloc.a instead
+# of linking the dynamic variant with -ltalloc.
+#
+# NOTE: This option only affects libraries that we do not only build
+# but that samba also links against as libraries (as opposed to linking
+# the plain object files. - This has to be configured in Makefile.in.
+# So in particular it does not harm to give invalid or unknown names here.
+#
+
+AC_ARG_WITH([static-libs],
+ [AC_HELP_STRING([--with-static-libs=LIBS],
+ [Comma-separated list of names of (internal) libraries to link statically (instead of dynamically)])],
+ [AS_IF([test $withval],
+ [for lib in `echo $withval | sed -e 's/,/ /g'` ; do
+ [lib=`echo $lib | tr '[a-z]' '[A-Z]'`]
+ eval LIB_$lib=STATIC
+ done], [])],
+ [])
+
+#################################################
# should we build libtalloc?
INSTALL_LIBTALLOC=
UNINSTALL_LIBTALLOC=
LIBTALLOC_SHARED=
LIBTALLOC=
+LIBTALLOC_STATIC=
+LIBTALLOC_LIBS=
AC_MSG_CHECKING(whether to build the libtalloc shared library)
AC_ARG_WITH(libtalloc,
@@ -5157,12 +5193,18 @@ if test x"$samba_cv_with_libtalloc" = "xyes" -a $BLDSHARED = true; then
LIBTALLOC_SHARED=bin/libtalloc.$SHLIBEXT
LIBTALLOC=libtalloc
AC_MSG_RESULT(yes)
+ if test x"$LIB_TALLOC" = "xSTATIC" ; then
+ LIBTALLOC_STATIC=bin/libtalloc.a
+ else
+ LIBTALLOC_LIBS=-ltalloc
+ fi
else
enable_static=yes
AC_MSG_RESULT(no shared library support -- will supply static library)
fi
if test $enable_static = yes; then
LIBTALLOC=libtalloc
+ LIBTALLOC_STATIC=bin/libtalloc.a
fi
INSTALL_LIBTALLOC=installlibtalloc
UNINSTALL_LIBTALLOC=uninstalllibtalloc