+
+###########################################################
+#
+# Configuration of subsystems / libraries
+#
+###########################################################
+
+INSTALLLIBCMD_SH=:
+INSTALLLIBCMD_A=:
+UNINSTALLLIBCMD_SH=:
+UNINSTALLLIBCMD_A=:
+
+if test $BLDSHARED = true; then
+ INSTALLLIBCMD_SH="\$(INSTALLCMD)"
+ UNINSTALLLIBCMD_SH="rm -f"
+fi
+if test $enable_static = yes; then
+ INSTALLLIBCMD_A="\$(INSTALLCMD)"
+ UNINSTALLLIBCMD_A="rm -f"
+fi
+
+#################################################
+# --disable-shared-libs
+# can be used to disable the internal use of shared libs altogether
+# (this only has an effect when building shared libs is enabled)
+#
+USESHARED=false
+AC_SUBST(USESHARED)
+
+AC_MSG_CHECKING(whether to use shared libraries internally)
+AC_ARG_ENABLE([shared-libs],
+ AS_HELP_STRING([--enable-shared-libs],
+ [Use shared libraries internally (default=yes)]),
+ [enable_shared_libs=$enableval],
+ [enable_shared_libs=yes])
+
+if test x"$enable_shared_libs" != x"no" ; then
+ USESHARED=$BLDSHARED
+fi
+
+AC_MSG_RESULT([$USESHARED])
+
+if test x"$enable_shared_libs" = x"yes" -a x"$BLDSHARED" != x"true" ; then
+ AC_MSG_WARN([--enable-shared-libs: no support for shared libraries])
+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=libtalloc 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],
+ [AS_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 LINK_$lib=STATIC
+ done], [])],
+ [])
+
+#
+# WORKAROUND:
+# until we have organized other internal subsystems (as util, registry
+# and smbconf) into shared libraries, we CAN NOT link libnetapi
+# dynamically to samba programs.
+#
+LINK_LIBNETAPI=STATIC
+
+LINK_LIBSMBCLIENT=STATIC
+
+#
+# The library versions are hardcoded here
+# and filled into the LIBFOO_SOVER variable.
+#
+# TODO: for talloc and tdb (at least), these should
+# be extracted from their respective source directories
+#
+AC_ARG_ENABLE(external_libtalloc, [AS_HELP_STRING([--enable-external-libtalloc], [Enable external talloc [default=auto]])],
+[ enable_external_libtalloc=$enableval ], [ enable_external_libtalloc=auto ])
+
+if test "x$enable_external_libtalloc" != xno
+then
+ PKG_CHECK_MODULES(LIBTALLOC, talloc >= 2.0.1,
+ [ enable_external_libtalloc=yes ],
+ [ if test x$enable_external_libtalloc = xyes; then
+ AC_MSG_ERROR([Unable to find libtalloc])
+ else
+ enable_external_libtalloc=no
+ fi
+ ])
+fi
+
+if test "x$enable_external_libtalloc" = xno
+then
+ m4_include(../lib/talloc/libtalloc.m4)
+ LINK_LIBTALLOC=STATIC
+ SMB_LIBRARY(talloc, 2)
+ LIBTALLOC_OBJ0=""
+ for obj in ${TALLOC_OBJ}; do
+ LIBTALLOC_OBJ0="${LIBTALLOC_OBJ0} ${tallocdir}/${obj}"
+ done
+ SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TALLOC_CFLAGS}"
+ SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CONFIGURE_CPPFLAGS} ${TALLOC_CFLAGS}"
+ AC_SUBST(LIBTALLOC_OBJ0)
+
+ TALLOCTORT="bin/talloctort\$(EXEEXT)"
+ AC_SUBST(TALLOCTORT)
+fi
+
+
+AC_ARG_ENABLE(external_libtdb,
+ [AS_HELP_STRING([--enable-external-libtdb],
+ [Enable external tdb [default=auto]])],
+ [ enable_external_libtalloc=$enableval ],
+ [ enable_external_libtalloc=auto ])
+
+if test "x$enable_external_libtdb" != xno
+then
+ PKG_CHECK_MODULES(LIBTDB, tdb >= 1.1.4,
+ [ enable_external_libtdb=yes ],
+ [
+ if test x$enable_external_libtdb = xyes; then
+ AC_MSG_ERROR([Unable to find libtdb])
+ else
+ enable_external_libtdb=no
+ fi
+ ])
+fi
+
+AC_SUBST(LIBTDB_OBJ0)
+if test "x$enable_external_libtdb" = xno
+then
+ m4_include(../lib/tdb/libtdb.m4)
+ LINK_LIBTDB=STATIC
+ SMB_LIBRARY(tdb, 1)
+ LIBTDB_OBJ0=""
+ for obj in ${TDB_OBJ}; do
+ LIBTDB_OBJ0="${LIBTDB_OBJ0} ${tdbdir}/${obj}"
+ done
+ AC_SUBST(LIBTDB_OBJ0)
+ SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TDB_CFLAGS}"
+ SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CONFIGURE_CPPFLAGS} ${TDB_CFLAGS}"
+
+ TDBBACKUP="bin/tdbbackup\$(EXEEXT)"
+ AC_SUBST(TDBBACKUP)
+ TDBDUMP="bin/tdbdump\$(EXEEXT)"
+ AC_SUBST(TDBDUMP)
+ TDBTOOL="bin/tdbtool\$(EXEEXT)"
+ AC_SUBST(TDBTOOL)
+ TDBTORTURE="bin/tdbtorture\$(EXEEXT)"
+ AC_SUBST(TDBTORTURE)
+ ac_cv_have_tdb_err_nesting=yes
+else
+ AC_TRY_COMPILE([#include "tdb.h"],
+ [enum TDB_ERROR err = TDB_ERR_NESTING],
+ ac_cv_have_tdb_err_nesting=yes,
+ ac_cv_have_tdb_err_nesting=no)
+fi
+
+if test x"$ac_cv_have_tdb_err_nesting" = xyes; then
+ AC_DEFINE(HAVE_TDB_ERR_NESTING, 1, [Whether we have TDB_ERR_NESTING])
+fi
+
+SMB_LIBRARY(netapi, 0)
+SMB_LIBRARY(smbclient, 0)
+SMB_LIBRARY(smbsharemodes, 0)
+SMB_LIBRARY(addns, 0, no, [undefined API])
+
+
+