tdb: raise version to 1.2.1
[ira/wip.git] / source3 / configure.in
index 36c89efe2b4e9b24b1e16eaa35c6d8d533760818..14b57b688a19e9fa2483086055a67a25b510e72d 100644 (file)
@@ -120,6 +120,7 @@ fi
 
 m4_include(../lib/socket_wrapper/config.m4)
 m4_include(../lib/nss_wrapper/config.m4)
+m4_include(../lib/util/time.m4)
 
 m4_include(m4/swat.m4)
 
@@ -377,6 +378,10 @@ esac
 
 DYNEXP=
 AC_SUBST(DYNEXP)
+LDSHFLAGS_Z_DEFS=
+AC_SUBST(LDSHFLAGS_Z_DEFS)
+LDSHFLAGS_Z_NODEFS=
+AC_SUBST(LDSHFLAGS_Z_NODEFS)
 
 dnl Add modules that have to be built by default here
 dnl These have to be built static:
@@ -434,6 +439,7 @@ default_shared_modules="$default_shared_modules vfs_acl_tdb"
 default_shared_modules="$default_shared_modules vfs_smb_traffic_analyzer"
 default_shared_modules="$default_shared_modules vfs_preopen"
 default_shared_modules="$default_shared_modules vfs_catia"
+default_shared_modules="$default_shared_modules vfs_scannedonly"
 
 if test "x$developer" = xyes; then
    default_static_modules="$default_static_modules rpc_rpcecho pdb_ads"
@@ -692,6 +698,10 @@ LIBREPLACE_DIR=`echo ${libreplacedir} | sed -e "s;${srcdir};;" -e "s;^/;;"`
 LIBREPLACE_OBJS="${LIBREPLACEOBJ}"
 AC_SUBST(LIBREPLACE_OBJS)
 
+LIBREPLACE_LIBS="${LIBREPLACE_NETWORK_LIBS}"
+AC_SUBST(LIBREPLACE_LIBS)
+
+
 # add -ldl to the global LIBS
 LIBS="${LIBS} ${LIBDL} ${LIBREPLACE_NETWORK_LIBS}"
 AUTH_LIBS="${AUTH_LIBS} ${CRYPT_LIBS}"
@@ -699,7 +709,7 @@ AUTH_LIBS="${AUTH_LIBS} ${CRYPT_LIBS}"
 
 AC_CHECK_HEADERS(aio.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h)
 AC_CHECK_HEADERS(unistd.h grp.h sys/id.h memory.h alloca.h)
-AC_CHECK_HEADERS(limits.h float.h pthread.h libintl.h)
+AC_CHECK_HEADERS(limits.h float.h libintl.h)
 AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/ypclnt.h)
 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/prctl.h sys/sysctl.h)
 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h)
@@ -1049,7 +1059,7 @@ AC_CHECK_FUNCS(setsid glob strpbrk crypt16 getauthuid)
 AC_CHECK_FUNCS(sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf)
 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf stat64 fstat64)
-AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt lseek64 ftruncate64)
+AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt lseek64 ftruncate64 posix_fallocate posix_fallocate64)
 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam)
 AC_CHECK_FUNCS(opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64)
 AC_CHECK_FUNCS(getpwent_r)
@@ -1058,6 +1068,7 @@ AC_CHECK_FUNCS(setenv strcasecmp fcvt fcvtl)
 AC_CHECK_FUNCS(syslog vsyslog timegm)
 AC_CHECK_FUNCS(setlocale nl_langinfo)
 AC_CHECK_FUNCS(nanosleep,,[AC_CHECK_LIB_EXT(rt, LIBS, nanosleep)])
+AC_CHECK_FUNCS(lutimes futimes utimensat futimens)
 AC_CHECK_FUNCS(mlock munlock mlockall munlockall)
 AC_CHECK_FUNCS(memalign posix_memalign hstrerror)
 AC_CHECK_HEADERS(sys/mman.h)
@@ -1077,33 +1088,13 @@ AC_CHECK_LIB(exc, trace_back_stack)
 # check for sysctlbyname for BSD systems
 AC_CHECK_FUNCS(sysctlbyname)
 
-printf "%s" "checking for GPFS GPL libs... "
-save_LIBS="$LIBS"
-LIBS="$LIBS -lgpfs_gpl"
-AC_TRY_LINK([#include <gpfs_gpl.h>],
-          [gpfs_set_share(0,GPFS_SHARE_READ,GPFS_DENY_NONE)],
-          samba_cv_HAVE_GPFS=yes,
-          samba_cv_HAVE_GPFS=no)
-echo $samba_cv_HAVE_GPFS
-if test x"$samba_cv_HAVE_GPFS" = x"yes"; then
-    AC_DEFINE(HAVE_GPFS,1,[Whether GPFS GPL libs are available])
+#############################
+# check if building with gpfs
+AC_CHECK_HEADERS(gpfs_gpl.h)
+if test x"$ac_cv_header_gpfs_gpl_h" = x"yes"; then
+    AC_DEFINE(HAVE_GPFS,1,[Whether GPFS GPL headers are available])
     default_shared_modules="$default_shared_modules vfs_gpfs"
 fi
-LIBS="$save_LIBS"
-
-printf "%s" "checking for GPFS libs (with 3.2.1 PTF8 available as GPL)... "
-save_LIBS="$LIBS"
-LIBS="$LIBS -lgpfs"
-AC_TRY_LINK([#include <gpfs.h>],
-          [gpfs_set_share(0,GPFS_SHARE_READ,GPFS_DENY_NONE)],
-          samba_cv_HAVE_GPFS=yes,
-          samba_cv_HAVE_GPFS=no)
-echo $samba_cv_HAVE_GPFS
-if test x"$samba_cv_HAVE_GPFS" = x"yes"; then
-    AC_DEFINE(HAVE_GPFS,1,[Whether GPFS GPL libs are available])
-    default_shared_modules="$default_shared_modules vfs_gpfs"
-fi
-LIBS="$save_LIBS"
 
 #############################################
 # check if building on Isilon OneFS
@@ -1255,7 +1246,7 @@ AC_DEFINE(HAVE_PRCTL, 1, [Whether prctl is available]),[])
 case "$host_os" in
     *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
        # glibc <= 2.3.2 has a broken getgrouplist
-       AC_TRY_RUN([
+       AC_CACHE_CHECK([for good getgrouplist],samba_cv_linux_getgrouplist_ok,[AC_TRY_RUN([
 #include <unistd.h>
 #include <sys/utsname.h>
 main() {
@@ -1271,8 +1262,10 @@ main() {
 #endif
        exit(0);
 }
-], [linux_getgrouplist_ok=yes], [linux_getgrouplist_ok=no])
-       if test x"$linux_getgrouplist_ok" = x"yes"; then
+], [samba_cv_linux_getgrouplist_ok=yes],
+   [samba_cv_linux_getgrouplist_ok=no],
+   [samba_cv_linux_getgrouplist_ok=cross])])
+       if test x"$samba_cv_linux_getgrouplist_ok" = x"yes"; then
           AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
        fi
        ;;
@@ -1405,7 +1398,7 @@ AC_LIBTESTFUNC(sec, getprpwnam)
 AC_CHECK_FUNCS(strsignal)
 
 ############################################
-# Check if we have libattr
+# Check for EA implementations
 case "$host_os" in
   *osf*)
        AC_SEARCH_LIBS(getproplist, [proplist])
@@ -1413,24 +1406,27 @@ case "$host_os" in
        AC_CHECK_FUNCS(delproplist fdelproplist add_proplist_entry get_proplist_entry)
        AC_CHECK_FUNCS(sizeof_proplist_entry)
   ;;
-  *)
-       AC_SEARCH_LIBS(getxattr, [attr])
-       AC_CHECK_FUNCS(getxattr lgetxattr fgetxattr listxattr llistxattr)
-       AC_CHECK_FUNCS(getea fgetea lgetea listea flistea llistea)
-       AC_CHECK_FUNCS(removeea fremoveea lremoveea setea fsetea lsetea)
-       AC_CHECK_FUNCS(flistxattr removexattr lremovexattr fremovexattr)
-       AC_CHECK_FUNCS(setxattr lsetxattr fsetxattr)
-       AC_CHECK_FUNCS(attr_get attr_list attr_set attr_remove)
-       AC_CHECK_FUNCS(attr_getf attr_listf attr_setf attr_removef)
+  *freebsd4* | *dragonfly* )
+       AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
   ;;
-esac
-
-########################################################
-# Check if attropen() is present if this is Solaris
-case "$host_os" in
   *solaris*)
        AC_CHECK_FUNCS(attropen)
   ;;
+  *)
+       AC_SEARCH_LIBS(getxattr, [attr])
+       AC_CHECK_FUNCS(getxattr,[
+               AC_CHECK_FUNCS(lgetxattr fgetxattr listxattr llistxattr flistxattr removexattr lremovexattr fremovexattr setxattr lsetxattr fsetxattr)
+               ])
+       AC_CHECK_FUNCS(getea,[
+               AC_CHECK_FUNCS(fgetea lgetea listea flistea llistea removeea fremoveea lremoveea setea fsetea lsetea)
+               ])
+       AC_CHECK_FUNCS(attr_get,[
+               AC_CHECK_FUNCS(attr_list attr_set attr_remove attr_getf attr_listf attr_setf attr_removef)
+               ])
+       AC_CHECK_FUNCS(extattr_delete_file,[
+               AC_CHECK_FUNCS(extattr_delete_fd extattr_delete_link extattr_get_fd extattr_get_file extattr_get_link extattr_list_fd extattr_list_file extattr_list_link extattr_set_fd extattr_set_file extattr_set_link)
+               ])
+  ;;
 esac
 
 ########################################################
@@ -1457,19 +1453,6 @@ if test x"$ac_cv_func_getxattr" = x"yes" ; then
        fi
 fi
 
-# Check if we have extattr
-case "$host_os" in
-  *freebsd4* | *dragonfly* )
-    AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
-    ;;
-  *)
-    AC_CHECK_FUNCS(extattr_delete_fd extattr_delete_file extattr_delete_link)
-    AC_CHECK_FUNCS(extattr_get_fd extattr_get_file extattr_get_link)
-    AC_CHECK_FUNCS(extattr_list_fd extattr_list_file extattr_list_link)
-    AC_CHECK_FUNCS(extattr_set_fd extattr_set_file extattr_set_link)
-    ;;
-esac
-
 AC_DISABLE_STATIC
 AC_ENABLE_SHARED
 
@@ -1552,15 +1535,15 @@ DSO_EXPORTS=""
 
   # and these are for particular systems
   case "$host_os" in
-               *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
-                       case "$host_os" in *linux*)
-                               AC_DEFINE(LINUX,1,[Whether the host os is linux]) ;;
+               *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu | *qnx*)
+                       case "$host_os" in
+                               *linux*) AC_DEFINE(LINUX,1,[Whether the host os is linux]) ;;
+                               *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx]) ;;
                        esac
                        BLDSHARED="true"
+                       LDSHFLAGS="-shared -Wl,-Bsymbolic"
                        if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
-                               LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined"
-                       else
-                               LDSHFLAGS="-shared -Wl,-Bsymbolic"
+                               LDSHFLAGS_Z_NODEFS="-Wl,--allow-shlib-undefined"
                        fi
                        DYNEXP="-Wl,--export-dynamic"
                        PICFLAG="-fPIC"
@@ -1668,9 +1651,6 @@ DSO_EXPORTS=""
                        AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
                        AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
                        ;;
-               *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx])
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,512)
-                       ;;
                *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
                        BLDSHARED="true"
                        LDSHFLAGS="-shared"
@@ -1755,23 +1735,40 @@ fi
 
 AC_MSG_RESULT($BLDSHARED)
 
-if test x"${ac_cv_prog_gnu_ld}" = x"yes"; then
+for flags in "-Wl,--as-needed" "-Wl,-z,ignore" "-z ignore" ; do
        saved_ldflags="$LDFLAGS"
-       AC_MSG_CHECKING([if --as-needed works])
-       LDFLAGS="--as-needed $saved_ldflags"
-       AC_TRY_LINK([],[],
-               [AC_MSG_RESULT([yes])
-               LD_AS_NEEDED_FLAG=--as-needed],
-               AC_MSG_RESULT([no]))
-       AC_MSG_CHECKING([if -Wl,--as-needed works])
-       LDFLAGS="-Wl,--as-needed $saved_ldflags"
+       AC_MSG_CHECKING([if $flags works])
+       LDFLAGS="$flags $saved_ldflags"
        AC_TRY_LINK([],[],
                [AC_MSG_RESULT([yes])
-               LD_AS_NEEDED_FLAG=-Wl,--as-needed],
+               LD_AS_NEEDED_FLAG=$flags
+               ld_as_needed_flag_found=yes],
                AC_MSG_RESULT([no]))
        LDFLAGS="$LD_AS_NEEDED_FLAG $saved_ldflags"
-fi
+       test x"$ld_as_needed_flag_found" = xyes && break
+done
+
+# for historical reasons almost all linkers don't complain about unresolved
+# symbols in shared libs. Except for the internal samba modules we want to get
+# errors when we produce a shared lib with unresolved symbols. On some
+# platforms unresolved symbols might be intended, so we might have to add
+# platform specific exceptions here.
+
+for flags in "-Wl,-z,defs" "-error_unresolved" "-Wl,-error_unresolved" ; do
+       saved_ldflags="$LDFLAGS"
+       AC_MSG_CHECKING([if $flags works])
+       LDFLAGS="$flags $saved_ldflags"
+       AC_TRY_LINK([],[],
+       [AC_MSG_RESULT([yes])
+       LDSHFLAGS_Z_DEFS=$flags
+       ldshflags_z_defs_found=yes],
+       AC_MSG_RESULT([no]))
+       LDFLAGS=$saved_ldflags
+       test x"$ldshflags_z_defs_found" = xyes && break
+done
 
+AC_MSG_CHECKING([LDSHFLAGS_Z_DEFS])
+AC_MSG_RESULT([$LDSHFLAGS_Z_DEFS])
 AC_MSG_CHECKING([LDFLAGS])
 AC_MSG_RESULT([$LDFLAGS])
 AC_MSG_CHECKING([DYNEXP])
@@ -1832,6 +1829,194 @@ AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
 
 AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
 
+
+###########################################################
+#
+# 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.2.1,
+               [ 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])
+
+
+
 ################
 
 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
@@ -2025,15 +2210,6 @@ if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
     AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
 fi
 
-AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
-AC_TRY_LINK([
-#include <sys/time.h>
-#include <unistd.h>], [struct timeval tv; return gettimeofday(&tv, NULL);],
-           samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,
-          samba_cv_HAVE_GETTIMEOFDAY_TZ=no)])
-if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
-    AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday takes a tz argument])
-fi
 
 if test x"$samba_cv_WITH_PROFILE" = x"yes"; then
 
@@ -2081,7 +2257,7 @@ dnl  We need to check for many of them
 dnl  But we don't need to do each and every one, because our code uses
 dnl  mostly just the utmp (not utmpx) fields.
 
-AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx)
+AC_CHECK_FUNCS(pututline pututxline updwtmp updwtmpx getutmpx getutxent)
 
 AC_CACHE_CHECK([for ut_name in utmp],samba_cv_HAVE_UT_UT_NAME,[
 AC_TRY_COMPILE([#include <sys/types.h>
@@ -2786,6 +2962,22 @@ exit(1);
   fi
 fi
 
+# glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
+AC_CACHE_CHECK([for broken posix_fallocate],samba_cv_HAVE_BROKEN_POSIX_FALLOCATE,[
+AC_TRY_COMPILE([
+  #define _XOPEN_SOURCE 600
+  #include <stdlib.h>
+  #if defined(__GLIBC__) && ((__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 4))
+    probably broken posix_fallocate
+  #endif
+], [
+], 
+samba_cv_HAVE_BROKEN_POSIX_FALLOCATE=no,samba_cv_HAVE_BROKEN_POSIX_FALLOCATE=yes)])
+if test x"$samba_cv_HAVE_BROKEN_POSIX_FALLOCATE" = xyes; then
+       AC_DEFINE(HAVE_BROKEN_POSIX_FALLOCATE,, Whether we have a broken posix_fallocate)
+fi
+
+
 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
 AC_TRY_COMPILE([#include <sys/types.h>
 #include <sys/stat.h>
@@ -2984,7 +3176,7 @@ with_ldap_support=auto
 AC_MSG_CHECKING([for LDAP support])
 
 AC_ARG_WITH(ldap,
-[AS_HELP_STRING([--with-ldap], [LDAP support (default yes)])],
+[AS_HELP_STRING([--with-ldap], [LDAP support (default=yes)])],
 [ case "$withval" in
     yes|no)
        with_ldap_support=$withval
@@ -3134,7 +3326,7 @@ with_ads_support=auto
 AC_MSG_CHECKING([for Active Directory and krb5 support])
 
 AC_ARG_WITH(ads,
-[AS_HELP_STRING([--with-ads], [Active Directory support (default auto)])],
+[AS_HELP_STRING([--with-ads], [Active Directory support (default=auto)])],
 [ case "$withval" in
     yes|no)
        with_ads_support="$withval"
@@ -3345,13 +3537,34 @@ if test x"$with_ads_support" != x"no"; then
     CPPFLAGS=$ac_save_CPPFLAGS
     LDFLAGS=$ac_save_LDFLAGS
   fi
-  AC_CHECK_HEADERS(krb5/locate_plugin.h)
+  AC_CHECK_HEADERS([krb5/locate_plugin.h], [], [],
+[[#ifdef HAVE_KRB5_H
+ #include <krb5.h>
+ #endif
+]])
+
   if test x"$ac_cv_header_krb5_locate_plugin_h" = x"yes"; then
        WINBIND_KRB5_LOCATOR="bin/winbind_krb5_locator.$SHLIBEXT"
        if test x"$BLDSHARED" = x"true" ; then
                EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WINBIND_KRB5_LOCATOR"
        fi
   fi
+
+  # check for new heimdal KRB5_DEPRECATED handling
+
+  AC_CACHE_CHECK([for KRB5_DEPRECATED define taking an identifier],
+                samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER,[
+    AC_TRY_COMPILE(
+      [#define KRB5_DEPRECATED 1
+      #include <krb5.h>],
+      [],
+      samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER=yes,
+      samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_DEPRECATED_WITH_IDENTIFIER, 1,
+              [Whether to use deprecated krb5 interfaces])
+  fi
 fi
 
 # Now we have determined whether we really want ADS support
@@ -3433,6 +3646,15 @@ if test x"$with_ads_support" != x"no"; then
   AC_CHECK_FUNC_EXT(krb5_enctype_to_string, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_fwd_tgt_creds, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_auth_con_set_req_cksumtype, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_get_creds_opt_alloc, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_get_creds_opt_set_impersonate, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_get_creds, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_get_credentials_for_user, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_get_host_realm, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_free_host_realm, $KRB5_LIBS)
+
+  # MIT krb5 1.8 does not expose this call (yet)
+  AC_CHECK_DECLS(krb5_get_credentials_for_user, [], [], [#include <krb5.h>])
 
   # MIT krb5 1.7beta3 (in Ubuntu Karmic) does not have this declaration
   # but does have the symbol
@@ -3773,6 +3995,18 @@ if test x"$with_ads_support" != x"no"; then
                [Whether the WRFILE:-keytab is supported])
   fi
 
+  AC_CACHE_CHECK([for krb5_realm type],
+                samba_cv_HAVE_KRB5_REALM_TYPE,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_realm realm;],
+      samba_cv_HAVE_KRB5_REALM_TYPE=yes,
+      samba_cv_HAVE_KRB5_REALM_TYPE=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_REALM_TYPE" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_REALM_TYPE,1,
+               [Whether the type krb5_realm exists])
+  fi
+
   AC_CACHE_CHECK([for krb5_princ_realm returns krb5_realm or krb5_data],
                samba_cv_KRB5_PRINC_REALM_RETURNS_REALM,[
     AC_TRY_COMPILE([#include <krb5.h>],
@@ -3973,11 +4207,11 @@ PASSDB_LIBS="$PASSDB_LIBS $NSCD_LIBS"
 ########################################################
 # Compile with DNS Updates support?
 
-with_dnsupdate_support=no
+with_dnsupdate_support=auto
 AC_MSG_CHECKING([whether to enable DNS Updates support])
 
 AC_ARG_WITH(dnsupdate,
-[AS_HELP_STRING([--with-dnsupdate], [Enable DNS Updates support (default no)])],
+[AS_HELP_STRING([--with-dnsupdate], [Enable DNS Updates support (default=auto)])],
 [ case "$withval" in
     yes|no)
        with_dnsupdate_support=$withval
@@ -3989,24 +4223,29 @@ AC_MSG_RESULT($with_dnsupdate_support)
 if test x"$with_dnsupdate_support" != x"no"; then
 
   ################################################################
-  # first test for Active Directory support being enabled
-  #if test x"$with_ads_support" = x"no"; then
-  #            AC_MSG_ERROR(Active Directory support is required to enable DNS Update support)
-  #            with_dnsupdate_support=no
-  #fi          
+  # first test for AD / GSSAPI support being enabled
+       if test x"$have_gssapi" != xyes ; then
+               if test x"$with_dnsupdate_support" = x"yes" ; then
+                       AC_MSG_ERROR(DNS Updates support only possible with AD and GSSAPI support)
+               else
+                       AC_MSG_NOTICE(DNS Updates support only possible with AD and GSSAPI support)
+                       with_dnsupdate_support=no
+               fi
+       fi
   ##################################################################
   # then test for uuid.h (necessary to generate unique DNS keynames
   # (uuid.h is required for this test)
-  AC_CHECK_HEADERS(uuid/uuid.h)
+       AC_CHECK_HEADERS(uuid/uuid.h)
 
-  if test x"$ac_cv_header_uuid_uuid_h" != x"yes"; then
-       if test x"$with_dnsupdate_support" = x"yes"; then
-        AC_MSG_ERROR(uuid.h is needed to enable DNS Updates support)
-       else
-        AC_MSG_WARN(uuid.h is needed to enable DNS Updates support)
+       
+       if test x"$ac_cv_header_uuid_uuid_h" != x"yes"; then
+               if test x"$with_dnsupdate_support" = x"yes"; then
+                       AC_MSG_ERROR(uuid.h is needed to enable DNS Updates support)
+               else
+                       AC_MSG_NOTICE(uuid.h is needed to enable DNS Updates support)
+               fi
+               with_dnsupdate_support=no
        fi
-       with_dnsupdate_support=no
-  fi
 fi
 
 if test x"$with_dnsupdate_support" != x"no"; then
@@ -4038,6 +4277,10 @@ if test x"$with_dnsupdate_support" != x"no"; then
            with_dnsupdate_support=no
        ])
 fi
+  # finally print out the result:
+AC_MSG_CHECKING(whether DNS Updates support is used)
+AC_MSG_RESULT([$with_dnsupdate_support])
+
 
 #################################################
 # check for automount support
@@ -4266,6 +4509,39 @@ if test x"${try_pam}" != x"no";then
        AC_MSG_RESULT([$create_pam_modules])
 fi # try_pam != no
 
+#################################################
+# check for PAM_RADIO_TYPE
+AC_TRY_COMPILE([
+#if (!defined(LINUX))
+
+#define PAM_EXTERN extern
+#if defined(HAVE_SECURITY_PAM_APPL_H)
+#include <security/pam_appl.h>
+#elif defined(HAVE_PAM_PAM_APPL_H)
+#include <pam/pam_appl.h>
+#endif
+
+#endif
+
+#if defined(HAVE_SECURITY_PAM_MODULES_H)
+#include <security/pam_modules.h>
+#elif defined(HAVE_PAM_PAM_MODULES_H)
+#include <pam/pam_modules.h>
+#endif
+
+#if defined(HAVE_SECURITY__PAM_MACROS_H)
+#include <security/_pam_macros.h>
+#elif defined(HAVE_PAM__PAM_MACROS_H)
+#include <pam/_pam_macros.h>
+#endif
+
+#ifdef HAVE_SECURITY_PAM_EXT_H
+#include <security/pam_ext.h>
+#endif
+],
+[int i; i = PAM_RADIO_TYPE; ],
+AC_DEFINE(HAVE_PAM_RADIO_TYPE, 1, [Define to 1 if PAM_RADIO_TYPE is available]),[])
+
 #################################################
 # check for pam_smbpass support
 PAM_MODULES=""
@@ -4731,173 +5007,6 @@ else
         AC_MSG_RESULT(no$utmp_no_reason)
 fi
 
-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}"
-       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}"
-
-       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)
-fi
-
-SMB_LIBRARY(netapi, 0)
-SMB_LIBRARY(smbclient, 0)
-SMB_LIBRARY(smbsharemodes, 0)
-SMB_LIBRARY(addns, 0, no, [undefined API])
-
 
 #################################################
 # these tests are taken from the GNU fileutils package
@@ -5161,7 +5270,7 @@ AC_ARG_WITH(ctdb,
   esac])
 
 SAVED_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $CTDB_CPPFLAGS"
+CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS} $CTDB_CPPFLAGS"
 ctdb_broken="missing or broken headers"
 
 AC_CHECK_HEADERS(ctdb.h ctdb_private.h,,,[
@@ -5193,6 +5302,23 @@ else
        ctdb_broken="missing transaction support"
 fi
 
+AC_HAVE_DECL(CTDB_CONTROL_TRANS2_ACTIVE,[
+#include "confdefs.h"
+#define NO_CONFIG_H
+#include "replace.h"
+#include "system/wait.h"
+#include "system/network.h"
+#include <talloc.h>
+#include <tdb.h>
+#include <ctdb.h>
+#include <ctdb_private.h>
+])
+if test x"$ac_cv_have_CTDB_CONTROL_TRANS2_ACTIVE_decl" = x"yes"; then
+       ctdb_broken=no
+else
+       ctdb_broken="transaction support too old"
+fi
+
 # in ctdb 1.0.57 ctdb_control_tcp was temparary renamed to ctdb_tcp_client
 AC_CHECK_TYPE(struct ctdb_tcp_client,[
        AC_DEFINE([ctdb_control_tcp],[ctdb_tcp_client],[ctdb ipv4 support])
@@ -5911,7 +6037,6 @@ WINBIND_NSS="../nsswitch/libnss_winbind.$SHLIBEXT"
 WINBIND_WINS_NSS="../nsswitch/libnss_wins.$SHLIBEXT"
 WINBIND_NSS_LDSHFLAGS=$LDSHFLAGS
 NSSSONAMEVERSIONSUFFIX=""
-WINBIND_NSS_PTHREAD=""
 
 case "$host_os" in
        *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
@@ -5956,8 +6081,6 @@ case "$host_os" in
                NSSSONAMEVERSIONSUFFIX=".1"
                WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_solaris.o \
                    ../nsswitch/winbind_nss_linux.o"
-               WINBIND_NSS_EXTRA_LIBS="${LIBREPLACE_NETWORK_LIBS}"
-               PAM_WINBIND_EXTRA_LIBS="${LIBREPLACE_NETWORK_LIBS}"
                ;;
        *hpux11*)
                WINBIND_NSS_EXTRA_OBJS="../nsswitch/winbind_nss_solaris.o"
@@ -6055,19 +6178,11 @@ else
         AC_MSG_RESULT(no$winbind_no_reason)
 fi
 
-AC_CHECK_LIB(pthread, pthread_mutex_lock, [WINBIND_NSS_PTHREAD="-lpthread"
-                       AC_DEFINE(HAVE_PTHREAD, 1, [whether pthread exists])
-                       samba_cv_HAVE_PTHREAD=yes],
-                       samba_cv_HAVE_PTHREAD=no)
-
-AC_SUBST(WINBIND_NSS_PTHREAD)
 AC_SUBST(WINBIND_NSS)
 AC_SUBST(WINBIND_WINS_NSS)
 AC_SUBST(WINBIND_NSS_LDSHFLAGS)
 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
-AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
 AC_SUBST(NSSSONAMEVERSIONSUFFIX)
-AC_SUBST(PAM_WINBIND_EXTRA_LIBS)
 
 AC_SUBST(WINBIND_KRB5_LOCATOR)
 
@@ -6197,12 +6312,12 @@ if test x"$enable_avahi" != x"no"; then
     fi
 
     save_LIBS="$LIBS"
-    AC_CHECK_LIB(avahi-client, avahi_client_new)
-    AC_CHECK_LIB(avahi-common, avahi_strerror)
+    AC_CHECK_LIB(avahi-client, avahi_client_new,[have_avahi_client_new=yes])
+    AC_CHECK_LIB(avahi-common, avahi_strerror,[have_avahi_strerror=yes])
     LIBS="$save_LIBS"
 
-    if test x"$ac_cv_lib_ext_avahi_client_avahi_client_new" != x"yes" -o \
-       x"$ac_cv_lib_ext_avahi_common_avahi_strerror" != x"yes" ; then
+    if test x"$have_avahi_client_new" != x"yes" -o \
+       x"$have_avahi_strerror" != x"yes" ; then
        have_avahi_support=no
     fi
 
@@ -6218,16 +6333,76 @@ if test x"$enable_avahi" != x"no"; then
     fi
 fi
 
+
+#################################################
+# Set pthread stuff
+
+PTHREAD_CFLAGS=error
+PTHREAD_LDFLAGS=error
+
+# If it's error, then the user didn't 
+# define it.
+if test "x$PTHREAD_LDFLAGS" = xerror; then
+  AC_CHECK_LIB(pthread, pthread_attr_init, [
+            PTHREAD_CFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
+            PTHREAD_LDFLAGS="-lpthread" ])
+fi
+
+if test "x$PTHREAD_LDFLAGS" = xerror; then
+  AC_CHECK_LIB(pthreads, pthread_attr_init, [
+            PTHREAD_CFLAGS="-D_THREAD_SAFE"
+            PTHREAD_LDFLAGS="-lpthreads" ])
+fi
+
+if test "x$PTHREAD_LDFLAGS" = xerror; then
+   AC_CHECK_LIB(c_r, pthread_attr_init, [
+               PTHREAD_CFLAGS="-D_THREAD_SAFE -pthread"
+               PTHREAD_LDFLAGS="-pthread" ])
+fi
+
+if test "x$PTHREAD_LDFLAGS" = xerror; then
+   AC_CHECK_FUNC(pthread_attr_init, [
+                PTHREAD_CFLAGS="-D_REENTRANT"
+                PTHREAD_LDFLAGS="-lpthread" ])
+fi
+
+# especially for HP-UX, where the AC_CHECK_FUNC macro fails to test for
+# pthread_attr_init. On pthread_mutex_lock it works there...
+if test "x$PTHREAD_LDFLAGS" = xerror; then
+   AC_CHECK_LIB(pthread, pthread_mutex_lock, [
+               PTHREAD_CFLAGS="-D_REENTRANT"
+               PTHREAD_LDFLAGS="-lpthread" ])
+fi
+
+AC_SUBST(PTHREAD_CFLAGS)
+AC_SUBST(PTHREAD_LDFLAGS)
+
+samba_cv_HAVE_PTHREAD=no
+if test x"$PTHREAD_CFLAGS" != xerror -a x"$PTHREAD_LDFLAGS" != xerror; then
+       samba_cv_HAVE_PTHREAD=yes
+       # now check for pthread.h with pthread-correct CFLAGS and LDFLAGS:
+       ac_save_CFLAGS=$CFLAGS
+       CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+       ac_save_LDFLAGS=$LDFLAGS
+       LDFLAGS="$LDFLAGS $PTHREAD_LDFLAGS"
+       AC_CHECK_HEADERS(pthread.h)
+       CFLAGS=$ac_save_CFLAGS
+       LDFLAGS=$ac_save_LDFLAGS
+fi
+
 #################################################
 # Check if user wants pthreadpool support
 
 AC_ARG_ENABLE(pthreadpool,
-[AS_HELP_STRING([--enable-pthreadpool], [Enable pthreads pool helper support (default=auto)])])
+[AS_HELP_STRING([--enable-pthreadpool], [Enable pthreads pool helper support (default=no)])])
+
+if test x"$enable_pthreadpool" = xyes -a x"$samba_cv_HAVE_PTHREAD" != x"yes"; then
+       AC_MSG_ERROR([pthreadpool support cannot be enabled when pthread support was found])
+fi
 
-if test x"$enable_pthreadpool" != x"no" -a x"$samba_cv_HAVE_PTHREAD" = x"yes"; then
-    AC_TRY_LINK([#include "pthread.h"],
-    [pthread_create(NULL, NULL, NULL, NULL)],
-                   ,LIBS="$LIBS -lpthread")
+if test x"$enable_pthreadpool" = x"yes" -a x"$samba_cv_HAVE_PTHREAD" = x"yes"; then
+    LIBS="$LIBS $PTHREAD_LDFLAGS"
+    CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
     AC_DEFINE(WITH_PTHREADPOOL, 1, [Whether to include pthreadpool helpers])
     AC_SUBST(PTHREADPOOL_OBJ, "lib/pthreadpool.o")
 fi
@@ -6371,7 +6546,7 @@ SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC
 SMB_MODULE(rpc_eventlog, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_rpcecho, \$(RPC_ECHO_OBJ), "bin/librpc_rpcecho.$SHLIBEXT", RPC)
-SMB_SUBSYSTEM(RPC,smbd/server.o)
+SMB_SUBSYSTEM(RPC,smbd/process.o)
 
 SMB_MODULE(idmap_ldap, winbindd/idmap_ldap.o, "bin/ldap.$SHLIBEXT", IDMAP)
 SMB_MODULE(idmap_tdb, winbindd/idmap_tdb.o, "bin/tdb.$SHLIBEXT", IDMAP)
@@ -6447,6 +6622,7 @@ SMB_MODULE(vfs_smb_traffic_analyzer, \$(VFS_SMB_TRAFFIC_ANALYZER_OBJ), "bin/smb_
 SMB_MODULE(vfs_onefs, \$(VFS_ONEFS), "bin/onefs.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_onefs_shadow_copy, \$(VFS_ONEFS_SHADOW_COPY), "bin/onefs_shadow_copy.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_dirsort, \$(VFS_DIRSORT_OBJ), "bin/dirsort.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_scannedonly, \$(VFS_SCANNEDONLY_OBJ), "bin/scannedonly.$SHLIBEXT", VFS)
 
 SMB_SUBSYSTEM(VFS,smbd/vfs.o)