r18739: * Get the wkssvc patch right this time.
[jra/samba/.git] / source3 / configure.in
index 2c969a9c410af23ee7fba74c39dbca23bb02e8b9..a0e19c1e170cf097d5cfd221daf8bcd8f68cd827 100644 (file)
@@ -5,9 +5,6 @@ AC_PREREQ(2.53)
 AC_INIT(include/includes.h)
 AC_CONFIG_HEADER(include/config.h)
 
-AC_DISABLE_STATIC
-AC_ENABLE_SHARED
-
 SMB_VERSION_STRING=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_OFFICIAL_STRING' | cut -d '"' -f2`
 echo "SAMBA VERSION: ${SMB_VERSION_STRING}"
 
@@ -16,18 +13,25 @@ if test -n "${SAMBA_VERSION_SVN_REVISION}";then
        echo "BUILD REVISION: ${SAMBA_VERSION_SVN_REVISION}"
 fi
 
+AC_LIBREPLACE_LOCATION_CHECKS
+
+AC_DISABLE_STATIC
+AC_ENABLE_SHARED
+
 #################################################
 # Directory handling stuff to support both the
 # legacy SAMBA directories and FHS compliant
 # ones...
 AC_PREFIX_DEFAULT(/usr/local/samba)
 
+rootsbindir="\${SBINDIR}"
 lockdir="\${VARDIR}/locks"
 piddir="\${VARDIR}/locks"
-mandir="\${prefix}/man"
+test "${mandir}" || mandir="\${prefix}/man"
 logfilebase="\${VARDIR}"
 privatedir="\${prefix}/private"
-libdir="\${prefix}/lib"
+test "${libdir}" || libdir="\${prefix}/lib"
+pammodulesdir="\${LIBDIR}/security"
 configdir="\${LIBDIR}"
 swatdir="\${prefix}/swat"
 
@@ -62,6 +66,22 @@ AC_ARG_WITH(privatedir,
     ;;
   esac])
 
+#################################################
+# set root sbin directory location
+AC_ARG_WITH(rootsbindir,
+[  --with-rootsbindir=DIR  Which directory to use for root sbin ($ac_default_prefix/sbin)],
+[ case "$withval" in
+  yes|no)
+  #
+  # Just in case anybody calls it without argument
+  #
+    AC_MSG_WARN([--with-rootsbindir called without argument - will use default])
+  ;;
+  * )
+    rootsbindir="$withval"
+    ;;
+  esac])
+
 #################################################
 # set lock directory location
 AC_ARG_WITH(lockdir,
@@ -159,7 +179,23 @@ AC_ARG_WITH(libdir,
   esac])
 
 #################################################
-# set lib directory location
+# set PAM modules directory location
+AC_ARG_WITH(pammodulesdir,
+[  --with-pammodulesdir=DIR  Which directory to use for PAM modules ($ac_default_prefix/$libdir/security)],
+[ case "$withval" in
+  yes|no)
+  #
+  # Just in case anybody calls it without argument
+  #
+    AC_MSG_WARN([--with-pammodulesdir called without argument - will use default])
+  ;;
+  * )
+    pammodulesdir="$withval"
+    ;;
+  esac])
+
+#################################################
+# set man directory location
 AC_ARG_WITH(mandir,
 [  --with-mandir=DIR       Where to put man pages ($mandir)],
 [ case "$withval" in
@@ -193,6 +229,14 @@ do
 done
 ])
 
+SAMBA_CPPFLAGS="-Iinclude -I${srcdir-.}/include  -I. -I${srcdir-.}"
+SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/lib/replace"
+SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/tdb/include"
+SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/libaddns"
+SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc"
+
+SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/popt"
+
 AC_SUBST(configdir)
 AC_SUBST(lockdir)
 AC_SUBST(piddir)
@@ -201,12 +245,15 @@ AC_SUBST(privatedir)
 AC_SUBST(swatdir)
 AC_SUBST(bindir)
 AC_SUBST(sbindir)
+AC_SUBST(rootsbindir)
+AC_SUBST(pammodulesdir)
 
 dnl Unique-to-Samba variables we'll be playing with.
+AC_SUBST(SAMBA_CPPFLAGS)
 AC_SUBST(SHELL)
 AC_SUBST(LDSHFLAGS)
 AC_SUBST(SONAMEFLAG)
-AC_SUBST(SONAMEVERSIONSUFFIX)
+AC_SUBST(NSSSONAMEVERSIONSUFFIX)
 AC_SUBST(SHLD)
 AC_SUBST(HOST_OS)
 AC_SUBST(PICFLAGS)
@@ -217,13 +264,22 @@ AC_SUBST(PIE_LDFLAGS)
 AC_SUBST(SHLIBEXT)
 AC_SUBST(INSTALLLIBCMD_SH)
 AC_SUBST(INSTALLLIBCMD_A)
+AC_SUBST(UNINSTALLLIBCMD_SH)
+AC_SUBST(UNINSTALLLIBCMD_A)
 AC_SUBST(INSTALL_LIBMSRPC)
+AC_SUBST(UNINSTALL_LIBMSRPC)
 AC_SUBST(LIBMSRPC_SHARED)
 AC_SUBST(LIBMSRPC)
+AC_SUBST(INSTALL_LIBADDNS)
+AC_SUBST(UNINSTALL_LIBADDNS)
+AC_SUBST(LIBADDNS_SHARED)
+AC_SUBST(LIBADDNS)
 AC_SUBST(INSTALL_LIBSMBCLIENT)
+AC_SUBST(UNINSTALL_LIBSMBCLIENT)
 AC_SUBST(LIBSMBCLIENT_SHARED)
 AC_SUBST(LIBSMBCLIENT)
 AC_SUBST(INSTALL_LIBSMBSHAREMODES)
+AC_SUBST(UNINSTALL_LIBSMBSHAREMODES)
 AC_SUBST(LIBSMBSHAREMODES_SHARED)
 AC_SUBST(LIBSMBSHAREMODES)
 AC_SUBST(PRINT_LIBS)
@@ -232,15 +288,44 @@ AC_SUBST(ACL_LIBS)
 AC_SUBST(PASSDB_LIBS)
 AC_SUBST(IDMAP_LIBS)
 AC_SUBST(KRB5_LIBS)
+AC_SUBST(UUID_LIBS)
 AC_SUBST(LDAP_LIBS)
 AC_SUBST(SHLIB_PROGS)
+AC_SUBST(PAM_MODULES)
+AC_SUBST(INSTALL_PAM_MODULES)
+AC_SUBST(UNINSTALL_PAM_MODULES)
 AC_SUBST(SMBWRAPPER)
 AC_SUBST(SMBWRAP_OBJS)
 AC_SUBST(SMBWRAP_INC)
 AC_SUBST(EXTRA_BIN_PROGS)
+AC_SUBST(CIFSMOUNT_PROGS)
+AC_SUBST(INSTALL_CIFSMOUNT)
+AC_SUBST(UNINSTALL_CIFSMOUNT)
 AC_SUBST(EXTRA_SBIN_PROGS)
 AC_SUBST(EXTRA_ALL_TARGETS)
 AC_SUBST(CONFIG_LIBS)
+AC_SUBST(NSCD_LIBS)
+
+## check for --enable-debug first before checking CFLAGS before
+## so that we don't mix -O and -g
+AC_ARG_ENABLE(debug, 
+[  --enable-debug          Turn on compiler debugging information (default=no)],
+    [if eval "test x$enable_debug = xyes"; then
+       CFLAGS="${CFLAGS} -g"
+    fi])
+
+# compile with optimization and without debugging by default, but
+# allow people to set their own preference.
+# do this here since AC_CACHE_CHECK apparently sets the CFLAGS to "-g -O2"
+# if it has no value.  This prevent *very* large debug binaries from occurring
+# by default.
+if test "x$CFLAGS" = x; then
+  CFLAGS="-O"
+fi
+
+CFLAGS="${CFLAGS} -D_SAMBA_BUILD_"
+
+AC_LIBREPLACE_CC_CHECKS
 
 # Set defaults
 PIE_CFLAGS=""
@@ -267,30 +352,42 @@ then
        libc_cv_fpie=no
 fi
 
-AC_ARG_ENABLE(debug, 
-[  --enable-debug          Turn on compiler debugging information (default=no)],
-    [if eval "test x$enable_debug = xyes"; then
-       CFLAGS="${CFLAGS} -g"
-    fi])
-
-AC_SUBST(SOCKWRAP)
-AC_ARG_ENABLE(socket-wrapper, 
-[  --enable-socket-wrapper         Turn on socket wrapper library (default=no)],
-    [if eval "test x$enable_socket_wrapper = xyes"; then
-        AC_DEFINE(SOCKET_WRAPPER,1,[Use socket wrapper library])
-       SOCKWRAP="\$(SOCKET_WRAPPER_OBJ)"
-    fi])
+m4_include(lib/socket_wrapper/config.m4)
 
-# compile with optimization and without debugging by default, but
-# allow people to set their own preference.
-# do this here since AC_CACHE_CHECK apparently sets the CFLAGS to "-g -O2"
-# if it has no value.  This prevent *very* large debug binaries from occurring
-# by default.
-if test "x$CFLAGS" = x; then
-  CFLAGS="-O"
-fi
+#################################################
+# set prefix for 'make test'
+selftest_prefix="./"
+AC_SUBST(selftest_prefix)
+AC_ARG_WITH(selftest-prefix,
+[  --with-selftest-prefix=DIR    The prefix where make test will be runned ($selftest_prefix)],
+[ case "$withval" in
+  yes|no)
+    AC_MSG_WARN([--with-selftest-prefix called without argument - will use default])
+  ;;
+  * )
+    selftest_prefix="$withval"
+    ;;
+  esac
+])
 
-CFLAGS="${CFLAGS} -D_SAMBA_BUILD_"
+#################################################
+# set path of samba4's smbtorture
+smbtorture4_path=""
+AC_SUBST(smbtorture4_path)
+AC_ARG_WITH(smbtorture4_path,
+[  --with-smbtorture4-path=PATH    The path to a samba4 smbtorture for make test (none)],
+[ case "$withval" in
+  yes|no)
+    AC_MSG_ERROR([--with-smbtorture4-path should take a path])
+  ;;
+  * )
+    smbtorture4_path="$withval"
+    if test -z "$smbtorture4_path" -a ! -f $smbtorture4_path; then
+       AC_MSG_ERROR(['$smbtorture_path' does not  exist!]) 
+    fi
+  ;;
+ esac
+])
 
 AC_ARG_ENABLE(developer, [  --enable-developer      Turn on developer warnings and debugging (default=no)],
     [if eval "test x$enable_developer = xyes"; then
@@ -330,19 +427,26 @@ then
        LIBS="$LIBS -ldmalloc"  
 fi
 
-dnl Checks for programs.
-
-##
-## for some reason this macro resets the CFLAGS
-## so save and restore
-##
-OLD_CFLAGS=${CFLAGS}
-AC_PROG_CC
-CFLAGS=${OLD_CFLAGS}
+#################################################
+# check for a shared memory profiling support
+AC_MSG_CHECKING(whether to use profiling)
+AC_ARG_WITH(profiling-data,
+[  --with-profiling-data   Include gathering source code profile information (default=no)],
+[ case "$withval" in
+  yes)
+    AC_MSG_RESULT(yes)
+    AC_DEFINE(WITH_PROFILE,1,[Whether to use profiling])
+    samba_cv_WITH_PROFILE=yes
+    ;;
+  *)
+    AC_MSG_RESULT(no)
+    samba_cv_WITH_PROFILE=no
+    ;;
+  esac ],
+  AC_MSG_RESULT(no)
+)
 
-OLD_CFLAGS=${CFLAGS}
-AC_PROG_CPP
-CFLAGS=${OLD_CFLAGS}
+dnl Checks for programs.
 
 AC_PROG_INSTALL
 AC_PROG_AWK
@@ -386,9 +490,6 @@ if test "$ac_cv_prog_gnu_ld" = "yes"; then
         fi
 fi
 
-dnl needed before AC_TRY_COMPILE
-AC_ISC_POSIX
-
 dnl look for executable suffix
 AC_EXEEXT
 
@@ -433,6 +534,10 @@ if test x"$samba_cv_volatile" = x"yes"; then
    AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
 fi
 
+dnl Figure out the flags to support named structure initializers
+
+LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_ERROR([c99 structure initializer are not supported])])
+
 UNAME_S=`(uname -s) 2>/dev/null` || UNAME_S="unknown"
 AC_MSG_CHECKING(uname -s)
 AC_MSG_RESULT(${UNAME_S})
@@ -449,27 +554,38 @@ UNAME_P=`(uname -p) 2>/dev/null` || UNAME_P="unknown"
 AC_MSG_CHECKING(uname -p)
 AC_MSG_RESULT(${UNAME_P})
 
-AC_CANONICAL_SYSTEM
-
 dnl Add #include for broken IRIX header files
   case "$host_os" in
-       *irix6*) AC_ADD_INCLUDE(<standards.h>)
+       *irix6*)
+               #TODO add to libreplace
+               if test x"$ac_cv_prog_gcc" != x"yes" ; then
+                       dnl Fix sensible defaults for MIPSPro compilers. The
+                       dnl error numbers are valid for the 7.3 compilers,
+                       dnl hopefully also valid for the 7.4 series.
+                       dnl
+                       dnl Bugzilla 3801. Force an error on warning 1035
+                       dnl so we don't incorrectly detect stdint.h. This
+                       dnl warning is emitted for #error directives.
+                       CFLAGS="$CFLAGS -diag_error 1035"
+                       dnl 1209: Controlling expression is constant
+                       dnl 1174: Function foo declared but never referenced
+                       dnl 3201: Parameter foo was never referenced
+                       CFLAGS="$CFLAGS -woff 1209,1174,3201"
+               fi
        ;;
 esac
 
-AC_VALIDATE_CACHE_SYSTEM_TYPE
-
 DYNEXP=
 
 dnl Add modules that have to be built by default here
 dnl These have to be built static:
-default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_reg rpc_lsa_ds rpc_wks rpc_svcctl rpc_ntsvcs rpc_net rpc_netdfs rpc_srv rpc_spoolss rpc_eventlog auth_rhosts auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin"
+default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_reg rpc_lsa_ds rpc_wkssvc rpc_svcctl rpc_ntsvcs rpc_net rpc_netdfs rpc_srv rpc_spoolss rpc_eventlog rpc_unixinfo auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default"
 
 dnl These are preferably build shared, and static if dlopen() is not available
 default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy charset_CP850 charset_CP437 auth_script"
 
 if test "x$developer" = xyes; then
-   default_static_modules="$default_static_modules rpc_echo"
+   default_static_modules="$default_static_modules rpc_rpcecho"
    default_shared_modules="$default_shared_modules charset_weird"
 fi
 
@@ -481,13 +597,6 @@ fi
 case "$host_os" in
 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
     *hpux*)
-    
-      AC_PROG_CC_FLAG(Ae)
-      # mmap on HPUX is completely broken...
-      AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
-      if test $ac_cv_prog_cc_Ae = yes; then
-        CPPFLAGS="$CPPFLAGS -Ae"
-      fi
 #
 # Defines needed for HPUX support.
 # HPUX has bigcrypt but (sometimes?) doesn't use it for
@@ -510,6 +619,7 @@ case "$host_os" in
                                AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to use large file support])
                                AC_DEFINE(_ALIGNMENT_REQUIRED, 1, [Required alignment])
                                AC_DEFINE(_MAX_ALIGNMENT, 4, [Maximum alignment])
+                               AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, [Unix 98 sources -- needed for socklen_t in getsockopt on HP/UX 11])
                                ;;
       esac
       ;;
@@ -731,13 +841,19 @@ exit(1);
 
 esac
 
-AC_INLINE
-AC_HEADER_STDC
-AC_HEADER_DIRENT
-AC_HEADER_TIME
-AC_HEADER_SYS_WAIT
+AC_LIBREPLACE_BROKEN_CHECKS
+
+LIBREPLACE_DIR=`echo ${libreplacedir} |sed -e 's/^\.\///g'`
+
+LIBREPLACE_OBJS=""
+for obj in ${LIBREPLACEOBJ}; do
+       LIBREPLACE_OBJS="${LIBREPLACE_OBJS} ${LIBREPLACE_DIR}/${obj}"
+done
+AC_SUBST(LIBREPLACE_OBJS)
+
 AC_CHECK_HEADERS(aio.h arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h)
-AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h alloca.h)
+AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h memory.h alloca.h)
+AC_CHECK_HEADERS(limits.h float.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)
 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
@@ -745,8 +861,10 @@ AC_CHECK_HEADERS(sys/un.h)
 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
 AC_CHECK_HEADERS(sys/sysmacros.h security/_pam_macros.h dlfcn.h)
-AC_CHECK_HEADERS(sys/syslog.h syslog.h execinfo.h)
+AC_CHECK_HEADERS(sys/syslog.h syslog.h)
 AC_CHECK_HEADERS(langinfo.h locale.h)
+AC_CHECK_HEADERS(xfs/libxfs.h)
+AC_CHECK_HEADERS(security/pam_ext.h)
 
 AC_CHECK_HEADERS(rpcsvc/yp_prot.h,,,[[
 #if HAVE_RPC_RPC_H
@@ -792,30 +910,15 @@ case "$host_os" in
                fi
        ;;
 esac
-AC_CHECK_HEADERS(shadow.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
+AC_CHECK_HEADERS(shadow.h)
 AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h security/pam_appl.h)
 AC_CHECK_HEADERS(stropts.h poll.h)
-AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
-AC_CHECK_HEADERS(sys/acl.h sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h sys/proplist.h)
-AC_CHECK_HEADERS(sys/cdefs.h glob.h)
+AC_CHECK_HEADERS(syscall.h sys/syscall.h)
 
-AC_CHECK_HEADERS(netinet/ip.h,,,[[
-#include <sys/types.h>
-#if HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#include <netinet/in.h>
-#if HAVE_NETINET_IN_SYSTM_H
-#include <netinet/in_systm.h>
-#endif
-]])
+AC_CHECK_HEADERS(sys/acl.h sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h)
+AC_CHECK_HEADERS(sys/ea.h sys/proplist.h)
 
-AC_CHECK_HEADERS(net/if.h,,,[[
-#include <sys/types.h>
-#if HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-]])
+AC_CHECK_HEADERS(sys/cdefs.h glob.h)
 
 AC_CHECK_HEADERS(security/pam_modules.h,,,[[
 #if HAVE_SECURITY_PAM_APPL_H
@@ -828,6 +931,7 @@ AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
  
 AC_CHECK_SIZEOF(int,cross)
 AC_CHECK_SIZEOF(long,cross)
+AC_CHECK_SIZEOF(long long,cross)
 AC_CHECK_SIZEOF(short,cross)
 
 AC_C_CONST
@@ -848,6 +952,8 @@ AC_CHECK_TYPE(loff_t,off_t)
 AC_CHECK_TYPE(offset_t,loff_t)
 AC_CHECK_TYPE(ssize_t, int)
 AC_CHECK_TYPE(wchar_t, unsigned short)
+AC_CHECK_TYPE(comparison_fn_t, 
+[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])])
 
 ############################################
 # for cups support we need libcups, and a handful of header files
@@ -985,9 +1091,6 @@ AC_CACHE_CHECK([for struct timespec type],samba_cv_struct_timespec, [
 #  include <time.h>
 # endif
 #endif
-#if HAVE_AIO_H
-#include <aio.h>
-#endif
 ],[struct timespec ts;],
        samba_cv_struct_timespec=yes,samba_cv_struct_timespec=no)])
 if test x"$samba_cv_struct_timespec" = x"yes"; then
@@ -1142,7 +1245,8 @@ if test x"$ac_cv_func_execl" = x"no"; then
     EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
 fi
 
-AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
+AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strerror chown fchown chmod fchmod chroot link mknod mknod64)
+AC_CHECK_FUNCS(strtol strtoll strtoul strtoull strtouq __strtoull)
 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync memset strlcpy strlcat setpgid)
 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
@@ -1151,17 +1255,104 @@ AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate
 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64)
 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
 AC_CHECK_FUNCS(opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64)
+AC_CHECK_FUNCS(getdents getdents64)
 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
 AC_CHECK_FUNCS(syslog vsyslog timegm)
 AC_CHECK_FUNCS(setlocale nl_langinfo)
 AC_CHECK_FUNCS(nanosleep)
+AC_CHECK_FUNCS(mlock munlock mlockall munlockall)
+AC_CHECK_HEADERS(sys/mman.h)
 # setbuffer, shmget, shm_open are needed for smbtorture
-AC_CHECK_FUNCS(setbuffer shmget shm_open backtrace_symbols)
-AC_CHECK_HEADERS(libexc.h)
+AC_CHECK_FUNCS(setbuffer shmget shm_open)
+
+# Find a method of generating a stack trace
+AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
+AC_CHECK_FUNCS(backtrace_symbols)
 AC_CHECK_LIB(exc, trace_back_stack)
 
-# syscall() is needed for smbwrapper.
-AC_CHECK_FUNCS(syscall)
+# Note that all the libunwind symbols in the API are defined to internal
+# platform-specific version, so we must include libunwind.h before checking
+# any of them.
+AC_MSG_CHECKING([for libunwind])
+save_LIBS=$LIBS
+if test x"$UNAME_P" = xunknown ; then
+    # This probably won't link without the platform-specific libunwind.
+    LIBS="$LIBS -lunwind"
+else
+    # Add the platform-specific libunwind module. uname -p seems the most
+    # plausible option and works for ia64, where libunwind is most useful.
+    LIBS="$LIBS -lunwind -lunwind-$UNAME_P"
+fi
+
+AC_TRY_LINK(
+    [
+#ifdef HAVE_LIBUNWIND_H
+#include <libunwind.h>
+#endif
+    ],
+    [
+       unw_context_t ctx; unw_cursor_t cur;
+       char buf[256]; unw_word_t off; 
+       unw_getcontext(&ctx); unw_init_local(&cur, &ctx);
+       unw_get_proc_name(&cur, buf, sizeof(buf), &off);
+    ],
+    [
+       AC_MSG_RESULT(yes)
+       AC_DEFINE(HAVE_LIBUNWIND, 1, [Whether libunwind is available])
+
+       # If we have libunwind, test whether we also have libunwind-ptrace
+       # which would let us unwind arbitrary processes.
+       save_LIBS=$LIBS
+       AC_CHECK_HEADERS(libunwind-ptrace.h)
+       AC_CHECK_LIB(unwind-ptrace, _UPT_create,
+           [
+               LIBUNWIND_PTRACE="-lunwind-ptrace";
+               AC_DEFINE(HAVE_LIBUNWIND_PTRACE, 1,
+                   [Whether libunwind-ptrace.a is available.])
+           ],
+           [ LIBUNWIND_PTRACE="" ])
+
+       LIBS=$save_LIBS
+    ],
+    [
+       AC_MSG_RESULT(no)
+       LIBS=$save_LIBS
+    ])
+
+# To use libunwind-ptrace, we also need to make some ptrace system calls.
+if test x"$LIBUNWIND_PTRACE" != x"" ; then
+    AC_CHECK_HEADERS(sys/ptrace.h)
+    AC_MSG_CHECKING([for the Linux ptrace(2) interface])
+    AC_TRY_LINK(
+           [
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_SYS_PTRACE_H
+#include <sys/ptrace.h>
+#endif
+           ],
+           [
+               int main(int argc, const char ** argv)
+               {
+                       pid_t me = (pid_t)-1;
+                       ptrace(PTRACE_ATTACH, me, 0, 0);
+                       ptrace(PTRACE_DETACH, me, 0, 0);
+                       return 0;
+               }
+           ],
+           [
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_LINUX_PTRACE, 1,
+                   [Whether the Linux ptrace(2) interface is available.])
+           ],
+           [
+               AC_MSG_RESULT(no)
+               LIBUNWIND_PTRACE=""
+           ])
+fi
+
+AC_SUBST(LIBUNWIND_PTRACE)
 
 AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
 AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
@@ -1170,7 +1361,7 @@ AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
-AC_CHECK_FUNCS(getdents _getdents __getdents _lseek __lseek _read __read)
+AC_CHECK_FUNCS(getdents __getdents _lseek __lseek _read __read)
 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
@@ -1316,9 +1507,50 @@ if test x"$samba_stat_hires" = x"yes" ; then
            [whether struct stat has sub-second timestamps])
 fi
 
+AC_CACHE_CHECK([whether struct stat has sub-second timestamps without struct timespec], samba_stat_hires_notimespec,
+    [
+       AC_TRY_COMPILE(
+           [
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+           ],
+           [
+               struct timespec t;
+               struct stat s = {0};
+               t.tv_sec = s.st_mtime;
+               t.tv_nsec = s.st_mtimensec;
+               t.tv_sec = s.st_ctime;
+               t.tv_nsec = s.st_ctimensec;
+               t.tv_sec = s.st_atime;
+               t.tv_nsec = s.st_atimensec;
+           ],
+           samba_stat_hires=yes, samba_stat_hires=no)
+    ])
+
+if test x"$samba_stat_hires_notimespec" = x"yes" ; then
+    AC_DEFINE(HAVE_STAT_ST_MTIMENSEC, 1, [whether struct stat contains st_mtimensec])
+    AC_DEFINE(HAVE_STAT_ST_ATIMENSEC, 1, [whether struct stat contains st_atimensec])
+    AC_DEFINE(HAVE_STAT_ST_CTIMENSEC, 1, [whether struct stat contains st_ctimensec])
+    AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
+           [whether struct stat has sub-second timestamps without struct timespec])
+fi
+
 #####################################
-# we might need the resolv library on some systems
+# needed for SRV lookups
 AC_CHECK_LIB(resolv, dn_expand)
+AC_CHECK_LIB(resolv, _dn_expand)
+AC_CHECK_LIB(resolv, __dn_expand)
 
 #
 # Check for the functions putprpwnam, set_auth_parameters,
@@ -1344,6 +1576,8 @@ AC_LIBTESTFUNC(sec, bigcrypt)
 AC_LIBTESTFUNC(security, getprpwnam)
 AC_LIBTESTFUNC(sec, getprpwnam)
 
+AC_CHECK_FUNCS(strsignal)
+
 ############################################
 # Check if we have libattr
 case "$host_os" in
@@ -1356,6 +1590,8 @@ case "$host_os" in
   *)
        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)
@@ -1383,15 +1619,15 @@ BLDSHARED="false"
 HOST_OS="$host_os"
 LDSHFLAGS="-shared"
 SONAMEFLAG="#"
-SONAMEVERSIONSUFFIX=""
+NSSSONAMEVERSIONSUFFIX=""
 SHLD="\${CC} \${CFLAGS}"
 PICFLAGS=""
 PICSUFFIX="po"
 SHLIBEXT="so"
 
 if test "$enable_shared" = "yes"; then
-  # this bit needs to be modified for each OS that is suported by
-  # smbwrapper. You need to specify how to create a shared library and
+  # this bit needs to be modified for each OS that supports share libs
+  # You need to specify how to create a shared library and
   # how to compile C code to produce PIC object files
 
   AC_MSG_CHECKING([ability to build shared libraries])
@@ -1408,7 +1644,7 @@ if test "$enable_shared" = "yes"; then
                        DYNEXP="-Wl,--export-dynamic"
                        PICFLAGS="-fPIC"
                        SONAMEFLAG="-Wl,-soname="
-                       SONAMEVERSIONSUFFIX=".2"
+                       NSSSONAMEVERSIONSUFFIX=".2"
                        AC_DEFINE(STAT_ST_BLOCKSIZE,512)
                        ;;
                *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
@@ -1417,6 +1653,8 @@ if test "$enable_shared" = "yes"; then
                        SONAMEFLAG="-h "
                        if test "${GCC}" = "yes"; then
                                PICFLAGS="-fPIC"
+                               SONAMEFLAG="-Wl,-soname="
+                               NSSSONAMEVERSIONSUFFIX=".1"
                                if test "${ac_cv_prog_gnu_ld}" = "yes"; then
                                        DYNEXP="-Wl,-E"
                                fi
@@ -1473,9 +1711,12 @@ if test "$enable_shared" = "yes"; then
                        ;;
                *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
                        BLDSHARED="true"
-                       LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry,-berok"
+                       LDSHFLAGS="-Wl,-G,-bexpall"
                        DYNEXP="-Wl,-brtl,-bexpall,-bbigtoc"
                        PICFLAGS="-O2"
+                       # as AIX code is always position independent...
+                       # .po will just create compile warnings, use po.o:
+                       PICSUFFIX="po.o"
                        if test "${GCC}" != "yes"; then
                                ## for funky AIX compiler using strncpy()
                                CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
@@ -1605,6 +1846,9 @@ main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }]
 samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
 if test x"$samba_cv_have_longlong" = x"yes"; then
     AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
+    AC_CHECK_TYPE(intptr_t, unsigned long long)
+else
+    AC_CHECK_TYPE(intptr_t, unsigned long)
 fi
 
 #
@@ -1799,6 +2043,24 @@ if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
 fi
 
+if test x"$samba_cv_WITH_PROFILE" = x"yes"; then
+
+    # On some systems (eg. Linux) librt can pull in libpthread. We
+    # don't want this to happen because libpthreads changes signal delivery
+    # semantics in ways we are not prepared for. This breaks Linux oplocks
+    # which rely on signals.
+
+    AC_LIBTESTFUNC(rt, clock_gettime,
+           [
+               AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
+                   [Whether clock_gettime is available])
+               SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
+               SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
+               SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
+           ])
+
+fi
+
 AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
 AC_TRY_LINK([#include <stdarg.h>
 va_list ap1,ap2;], [va_copy(ap1,ap2);],
@@ -1847,15 +2109,15 @@ if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
 fi
 
-AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
+AC_CACHE_CHECK([for broken readdir name],samba_cv_HAVE_BROKEN_READDIR_NAME,[
 AC_TRY_RUN([#include <sys/types.h>
 #include <dirent.h>
 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
 di->d_name[0] == 0) exit(0); exit(1);} ],
-samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
-if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
-    AC_DEFINE(HAVE_BROKEN_READDIR,1,[Whether readdir() is broken])
+samba_cv_HAVE_BROKEN_READDIR_NAME=yes,samba_cv_HAVE_BROKEN_READDIR_NAME=no,samba_cv_HAVE_BROKEN_READDIR_NAME=cross)])
+if test x"$samba_cv_HAVE_BROKEN_READDIR_NAME" = x"yes"; then
+    AC_DEFINE(HAVE_BROKEN_READDIR_NAME,1,[Whether readdir() returns the wrong name offset])
 fi
 
 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
@@ -2202,8 +2464,18 @@ fi
 if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
     AC_DEFINE(HAVE_FAM_CHANGE_NOTIFY, 1,
            [Whether FAM is file notifications are available])
+    AC_TRY_COMPILE([#include <fam.h>],
+               [FAMCodes code = FAMChanged;],
+               AC_DEFINE(HAVE_FAM_H_FAMCODES_TYPEDEF, 1,
+                   [Whether fam.h contains a typedef for enum FAMCodes]),
+               [])
 fi
 
+#################################################
+# Check for DMAPI interfaces in libdm/libjfsdm/libxsdm
+
+SMB_CHECK_DMAPI([], AC_MSG_NOTICE(DMAPI support not present) )
+
 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
 AC_TRY_RUN([
 #include <sys/types.h>
@@ -2233,22 +2505,46 @@ if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
 fi
 
-AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
-AC_TRY_RUN([#include <sys/types.h>
+#################################################
+# Check for POSIX capability support
+
+AC_CHECK_HEADER(sys/capability.h, [samba_cv_HAVE_SYS_CAPABILITY_H=yes;
+    AC_DEFINE(HAVE_SYS_CAPABILITY_H, 1, Whether sys/capability.h is present)],
+    [], [])
+
+if test x"$samba_cv_HAVE_SYS_CAPABILITY_H" = x"yes"; then
+
+    ac_save_LIBS=$LIBS
+    AC_LIBTESTFUNC(cap, cap_get_proc)
+
+    AC_CACHE_CHECK([for POSIX capabilities],
+           samba_cv_HAVE_POSIX_CAPABILITIES,
+           [
+               AC_TRY_RUN([
+#include <sys/types.h>
 #include <sys/capability.h>
 main() {
  cap_t cap;
- if ((cap = cap_get_proc()) == NULL)
+ cap_value_t vals[1];
+ if (!(cap = cap_get_proc()))
    exit(1);
cap->cap_effective |= CAP_NETWORK_MGT;
- cap->cap_inheritable |= CAP_NETWORK_MGT;
vals[0] = CAP_CHOWN;
+ cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
  cap_set_proc(cap);
  exit(0);
-}
-],
-samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
-if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
-    AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES,1,[Whether IRIX specific capabilities are available])
+}],
+               samba_cv_HAVE_POSIX_CAPABILITIES=yes,
+               samba_cv_HAVE_POSIX_CAPABILITIES=no,
+               samba_cv_HAVE_POSIX_CAPABILITIES=cross)
+           ])
+
+if test x"$samba_cv_HAVE_POSIX_CAPABILITIES" = x"yes"; then
+    AC_DEFINE(HAVE_POSIX_CAPABILITIES, 1,
+           [Whether POSIX capabilities are available])
+else
+    LIBS=$ac_save_LIBS
+fi
+
 fi
 
 #
@@ -2352,40 +2648,6 @@ if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
 fi
 
-AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
-SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt"
-AC_TRY_COMPILE([
-#define REPLACE_GETPASS 1
-#define NO_PROTO_H 1
-#define NO_CONFIG_H 1
-#define main dont_declare_main
-#include "${srcdir-.}/lib/getsmbpass.c"
-#undef main
-],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
-CPPFLAGS="$SAVE_CPPFLAGS"
-])
-if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
-       AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
-fi
-
-AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
-AC_TRY_RUN([
-#include <stdio.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-main() { struct in_addr ip; ip.s_addr = 0x12345678;
-if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
-    strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
-exit(1);}],
-           samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
-if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
-    AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
-fi
-
 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
 AC_TRY_RUN([#include <stdlib.h>
 #include <sys/types.h>
@@ -2408,22 +2670,30 @@ if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
     AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
 fi
 
-AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
-AC_TRY_RUN([#include <unistd.h>
-main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
-samba_cv_SYSCONF_SC_NGROUPS_MAX=yes,samba_cv_SYSCONF_SC_NGROUPS_MAX=no,samba_cv_SYSCONF_SC_NGROUPS_MAX=cross)])
-if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then
-    AC_DEFINE(SYSCONF_SC_NGROUPS_MAX,1,[Whether sysconf(_SC_NGROUPS_MAX) is available])
+AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
+       AC_TRY_RUN([#include "${srcdir-.}/tests/os2_delete.c"],
+               [samba_cv_HAVE_BROKEN_READDIR=no],
+                       [samba_cv_HAVE_BROKEN_READDIR=yes],
+                       [samba_cv_HAVE_BROKEN_READDIR="assuming not"])])
+
+if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
+AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[
+       AC_TRY_RUN([
+#include "${srcdir-.}/lib/repdir.c"
+#include "${srcdir-.}/tests/os2_delete.c"],
+       samba_cv_REPLACE_READDIR=yes,samba_cv_REPLACE_READDIR=no)])
 fi
 
-AC_CACHE_CHECK([for sysconf(_SC_NPROC_ONLN)],samba_cv_SYSCONF_SC_NPROC_ONLN,[
-AC_TRY_RUN([#include <unistd.h>
-main() { exit(sysconf(_SC_NPROC_ONLN) == -1 ? 1 : 0); }],
-samba_cv_SYSCONF_SC_NPROC_ONLN=yes,samba_cv_SYSCONF_SC_NPROC_ONLN=no,samba_cv_SYSCONF_SC_NPROC_ONLN=cross)])
-if test x"$samba_cv_SYSCONF_SC_NPROC_ONLN" = x"yes"; then
-    AC_DEFINE(SYSCONF_SC_NPROC_ONLN,1,[Whether sysconf(_SC_NPROC_ONLN) is available])
+if test x"$samba_cv_REPLACE_READDIR" = x"yes"; then
+       AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
 fi
 
+SMB_CHECK_SYSCONF(_SC_NGROUPS_MAX)
+SMB_CHECK_SYSCONF(_SC_NPROC_ONLN)
+SMB_CHECK_SYSCONF(_SC_NPROCESSORS_ONLN)
+SMB_CHECK_SYSCONF(_SC_PAGESIZE)
+AC_CHECK_FUNCS(getpagesize)
+
 AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
 AC_TRY_RUN([main() { exit(getuid() != 0); }],
            samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
@@ -2437,24 +2707,29 @@ fi
 # look for a method of finding the list of network interfaces
 iface=no;
 AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
+SAVE_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
 AC_TRY_RUN([
 #define HAVE_IFACE_AIX 1
 #define AUTOCONF_TEST 1
-#include "confdefs.h"
+#undef _XOPEN_SOURCE_EXTENDED
 #include "${srcdir-.}/lib/interfaces.c"],
            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
+CPPFLAGS="$SAVE_CPPFLAGS"
 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
 fi
 
 if test $iface = no; then
 AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
+SAVE_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
 AC_TRY_RUN([
 #define HAVE_IFACE_IFCONF 1
 #define AUTOCONF_TEST 1
-#include "confdefs.h"
 #include "${srcdir-.}/lib/interfaces.c"],
            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
+CPPFLAGS="$SAVE_CPPFLAGS"
 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
 fi
@@ -2462,12 +2737,14 @@ fi
 
 if test $iface = no; then
 AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
+SAVE_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
 AC_TRY_RUN([
 #define HAVE_IFACE_IFREQ 1
 #define AUTOCONF_TEST 1
-#include "confdefs.h"
 #include "${srcdir-.}/lib/interfaces.c"],
            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
+CPPFLAGS="$SAVE_CPPFLAGS"
 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
 fi
@@ -2652,47 +2929,6 @@ if test x"$samba_cv_REALPATH_TAKES_NULL" = x"yes"; then
     AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
 fi
 
-#################################################
-# check for smbwrapper support
-AC_MSG_CHECKING(whether to use smbwrapper)
-AC_ARG_WITH(smbwrapper,
-[  --with-smbwrapper       Include SMB wrapper support (default=no) ],
-[ case "$withval" in
-  yes)
-    AC_MSG_RESULT(yes)
-    AC_DEFINE(WITH_SMBWRAPPER,1,[Whether to include smbwrapper support])
-       WRAPPROG="bin/smbsh\$(EXEEXT)"
-       WRAP="bin/smbwrapper.$SHLIBEXT"
-       WRAP_OBJS="\$(SMBW_OBJ1) \$(SMBWRAPPER_OBJ1)"
-       WRAP_INC="-I\$(srcdir)/smbwrapper"
-
-# Conditions under which smbwrapper should not be built.
-
-       if test x$PICFLAGS = x; then
-          echo No support for PIC code - disabling smbwrapper and smbsh
-          WRAPPROG=""
-          WRAP=""
-          WRAP_OBJS=""
-          WRAP_INC=""
-       elif test x$ac_cv_func_syscall = xno; then
-          AC_MSG_RESULT([No syscall() -- disabling smbwrapper and smbsh])
-          WRAPPROG=""
-          WRAP=""
-          WRAP_OBJS=""
-          WRAP_INC=""
-       fi
-       EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WRAPPROG $WRAP"
-       SMBWRAPPER="$WRAPPROG $WRAP"
-       SMBWRAP_OBJS="$WRAP_OBJS"
-       SMBWRAP_INC="$WRAP_INC"
-    ;;
-  *)
-    AC_MSG_RESULT(no)
-    ;;
-  esac ],
-  AC_MSG_RESULT(no)
-)
-
 #################################################
 # check for AFS clear-text auth support
 samba_cv_WITH_AFS=no
@@ -2766,7 +3002,7 @@ fi
 #################################################
 # check whether to compile AFS/NT ACL mapping module
 samba_cv_WITH_VFS_AFSACL=no
-AC_MSG_CHECKING(whether to use AFS fake-kaserver)
+AC_MSG_CHECKING(whether to use AFS ACL mapping module)
 AC_ARG_WITH(vfs-afsacl,
 [  --with-vfs-afsacl       Include AFS to NT ACL mapping module (default=no) ],
 [ case "$withval" in
@@ -2842,6 +3078,18 @@ if test x"$with_ldap_support" != x"no"; then
        
        with_ldap_support=no
   fi
+
+  ##################################################################
+  # HP/UX does not have ber_tag_t, disable LDAP there
+  AC_CHECK_TYPE(ber_tag_t,,,[#include <lber.h>])
+  if test x"$ac_cv_type_ber_tag_t" != x"yes"; then
+       if test x"$with_ldap_support" = x"yes"; then
+        AC_MSG_ERROR(ber_tag_t is needed for LDAP support)
+       else
+        AC_MSG_WARN(ber_tag_t is needed for LDAP support)
+       fi
+       with_ldap_support=no
+  fi
 fi
 
 if test x"$with_ldap_support" != x"no"; then
@@ -2920,42 +3168,41 @@ FOUND_KRB5=no
 KRB5_LIBS=""
 
 if test x"$with_ldap_support" != x"yes"; then
+
     if test x"$with_ads_support" = x"yes"; then
        AC_MSG_ERROR(Active Directory Support requires LDAP support)
-    elif test x"$with_ads_support" != x"no"; then
-       AC_MSG_WARN(Active Directory Support requires LDAP support)
+    elif test x"$with_ads_support" = x"auto"; then
+       AC_MSG_WARN(Disabling Active Directory support (requires LDAP support))
+       with_ads_support=no
     fi
-    with_ads_support=no
-fi
 
-AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
+else
 
-if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
-    if test x"$with_ads_support" = x"yes"; then
-        AC_MSG_ERROR(Active Directory Support requires ldap_initialize)
-    fi
-    AC_MSG_WARN(Active Directory Support requires ldap_initialize)
-    with_ads_support=no
-fi
+    # Check to see whether there is enough LDAP functionality to be able
+    # to build AD support.
 
-AC_CHECK_FUNC_EXT(ldap_domain2hostlist,$LDAP_LIBS)
+    AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
 
-if test x"$ac_cv_func_ext_ldap_domain2hostlist" != x"yes"; then
-    if test x"$with_ads_support" = x"yes"; then
-        AC_MSG_ERROR(Active Directory Support requires ldap_domain2hostlist)
+    if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
+       if test x"$with_ads_support" = x"yes"; then
+           AC_MSG_ERROR(Active Directory support requires ldap_initialize)
+       elif test x"$with_ads_support" = x"auto"; then
+           AC_MSG_WARN(Disabling Active Directory support (requires ldap_initialize))
+           with_ads_support=no
+       fi
     fi
-    AC_MSG_WARN(Active Directory Support requires ldap_domain2hostlist)
-    with_ads_support=no
-fi
 
-AC_CHECK_FUNC_EXT(ldap_add_result_entry,$LDAP_LIBS)
+    AC_CHECK_FUNC_EXT(ldap_add_result_entry,$LDAP_LIBS)
 
-if test x"$ac_cv_func_ext_ldap_add_result_entry" != x"yes"; then
-    if test x"$with_ads_support" = x"yes"; then
-        AC_MSG_ERROR(Active Directory Support requires ldap_add_result_entry)
+    if test x"$ac_cv_func_ext_ldap_add_result_entry" != x"yes"; then
+       if test x"$with_ads_support" = x"yes"; then
+           AC_MSG_ERROR(Active Directory support requires ldap_add_result_entry)
+       elif test x"$with_ads_support" = x"auto"; then
+           AC_MSG_WARN(Disabling Active Directory support (requires ldap_add_result_entry))
+           with_ads_support=no
+       fi
     fi
-    AC_MSG_WARN(Active Directory Support requires ldap_add_result_entry)
-    with_ads_support=no
+
 fi
 
 if test x"$with_ads_support" != x"no"; then
@@ -3152,6 +3399,7 @@ if test x"$with_ads_support" != x"no"; then
   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_set_pac_request, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_get_renewed_creds, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_get_kdc_cred, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_free_error_contents, $KRB5_LIBS)
 
   LIBS="$KRB5_LIBS $LIBS"
 
@@ -3201,6 +3449,18 @@ if test x"$with_ads_support" != x"no"; then
                [Whether the krb5_ap_req struct has a ticket pointer])
   fi
 
+  AC_CACHE_CHECK([for e_data pointer in krb5_error],
+                samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_error err; err.e_data = NULL;],
+      samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR=yes,
+      samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR=no)])
+
+  if test x"$samba_cv_HAVE_E_DATA_POINTER_IN_KRB5_ERROR" = x"yes"; then
+    AC_DEFINE(HAVE_E_DATA_POINTER_IN_KRB5_ERROR,1,
+               [Whether the krb5_error struct has a e_data pointer])
+  fi
+
   AC_CACHE_CHECK([for krb5_crypto type],
                 samba_cv_HAVE_KRB5_CRYPTO,[
     AC_TRY_COMPILE([#include <krb5.h>],
@@ -3400,6 +3660,18 @@ if test x"$with_ads_support" != x"no"; then
               [Whether krb5_keytab_entry has keyblock member])
   fi
 
+  AC_CACHE_CHECK([for magic in krb5_address],
+                 samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_address addr; addr.magic = 0;],
+      samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS=yes,
+      samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS=no)])
+
+  if test x"$samba_cv_HAVE_MAGIC_IN_KRB5_ADDRESS" = x"yes"; then
+    AC_DEFINE(HAVE_MAGIC_IN_KRB5_ADDRESS,1,
+              [Whether the krb5_address struct has a magic property])
+  fi
+
   if test x"$ac_cv_lib_ext_krb5_krb5_mk_req_extended" = x"yes"; then
     AC_DEFINE(HAVE_KRB5,1,[Whether to have KRB5 support])
     AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
@@ -3450,32 +3722,90 @@ if test x"$with_ads_support" != x"no"; then
               [Whether krb5_princ_realm returns krb5_realm or krb5_data])
   fi
 
+  AC_CACHE_CHECK([for krb5_addresses type],
+                samba_cv_HAVE_KRB5_ADDRESSES,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_addresses addr;],
+      samba_cv_HAVE_KRB5_ADDRESSES=yes,
+      samba_cv_HAVE_KRB5_ADDRESSES=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_ADDRESSES" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_ADDRESSES,1,
+               [Whether the type krb5_addresses type exists])
+  fi
+
 LIBS="$ac_save_LIBS"
 fi
 
-#################################################
-# check for KCM support
+AC_CHECK_LIB_EXT(nscd, NSCD_LIBS, nscd_flush_cache)
+PASSDB_LIBS="$PASSDB_LIBS $NSCD_LIBS"
+
+
+########################################################
+# Compile with DNS Updates support?
 
-with_kcm_support=no
-AC_MSG_CHECKING([for KCM support])
+with_dnsupdate_support=no
+AC_MSG_CHECKING([whether to enable DNS Updates support])
 
-AC_ARG_WITH(kcm,
-[  --with-kcm              KCM support (default no)],
+AC_ARG_WITH(dnsupdate,
+[  --with-dnsupdate        Enable DNS Updates support (default no)],
 [ case "$withval" in
-    yes)
-       if test x$FOUND_KRB5 = x"no"; then
-               AC_MSG_ERROR(libkrb5 is needed for KCM support)
-       fi
-       with_kcm_support="$withval"
-       AC_DEFINE(WITH_KCM,1,[Whether to include KCM support])
-       ;;
-    *)
-       with_kcm_support="no"
-       AC_DEFINE(WITH_KCM,0,[Whether to include KCM support])
-       ;;
+    yes|no)
+       with_dnsupdate_support=$withval
+       ;;
   esac ])
 
-AC_MSG_RESULT($with_kcm_support)
+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          
+  ##################################################################
+  # then test for uuid.h (necessary to generate unique DNS keynames
+  # (uuid.h is required for this test)
+  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)
+       fi
+       with_dnsupdate_support=no
+  fi
+fi
+
+if test x"$with_dnsupdate_support" != x"no"; then
+  ac_save_LIBS=$LIBS
+
+  ########################################################
+  # now see if we can find the uuid libs in standard paths
+  AC_CHECK_LIB_EXT(uuid, UUID_LIBS, uuid_generate)
+
+  LIBS="$LIBS $UUID_LIBS"
+  
+  if test x"$ac_cv_lib_ext_uuid_uuid_generate" = x"yes"; then
+    with_dnsupdate_support=yes
+    AC_DEFINE(WITH_DNS_UPDATES,1,[Whether to enable DNS Update support])
+    AC_MSG_CHECKING(whether UUID support is used)
+    AC_MSG_RESULT(yes)
+  else
+    if test x"$with_dnsupdate_support" = x"yes"; then
+       AC_MSG_ERROR(libuuid is needed to enable DNS Updates support)
+    else
+       AC_MSG_WARN(libuuid is needed to enable DNS Updates support)
+    fi
+    UUID_LIBS=""
+    with_dnsupdate_support=no
+  fi
+  LIBS=$ac_save_LIBS
+fi
+
 #################################################
 # check for automount support
 AC_MSG_CHECKING(whether to use automount)
@@ -3518,6 +3848,46 @@ AC_ARG_WITH(smbmount,
   AC_MSG_RESULT(no)
 )
 
+#################################################
+# check for mount- and umount.cifs support
+CIFSMOUNT_PROGS=""
+INSTALL_CIFSMOUNT=""
+UNINSTALL_CIFSMOUNT=""
+AC_MSG_CHECKING(whether to build mount.cifs and umount.cifs)
+AC_ARG_WITH(cifsmount,
+[  --with-cifsmount        Include mount.cifs and umount.cifs (Linux only) support (default=yes)],
+[ case "$withval" in
+  no)
+       AC_MSG_RESULT(no)
+       ;;
+  *)
+       case "$host_os" in
+       *linux*)
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(WITH_CIFSMOUNT,1,[Whether to build mount.cifs and umount.cifs])
+               CIFSMOUNT_PROGS="bin/mount.cifs bin/umount.cifs"
+               INSTALL_CIFSMOUNT="installcifsmount"
+               UNINSTALL_CIFSMOUNT="uninstallcifsmount"
+               ;;
+       *)
+               AC_MSG_ERROR(not on a linux system!)
+               ;;
+       esac
+    ;;
+  esac ],
+[ case "$host_os" in
+  *linux*)
+       AC_MSG_RESULT(yes)
+       AC_DEFINE(WITH_CIFSMOUNT,1,[Whether to build mount.cifs and umount.cifs])
+       CIFSMOUNT_PROGS="bin/mount.cifs bin/umount.cifs"
+       INSTALL_CIFSMOUNT="installcifsmount"
+       UNINSTALL_CIFSMOUNT="uninstallcifsmount"
+       ;;
+  *)
+       AC_MSG_RESULT(no)
+       ;;
+  esac ]
+)
 
 
 #################################################
@@ -3549,9 +3919,13 @@ AC_ARG_WITH(pam,
 
 # we can't build a pam module if we don't have pam.
 AC_CHECK_LIB(pam, pam_get_data, [AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])])
+AC_CHECK_LIB(pam, pam_vsyslog, [AC_DEFINE(HAVE_PAM_VSYSLOG,1,[Whether pam_vsyslog is available])])
 
 #################################################
 # check for pam_smbpass support
+PAM_MODULES=""
+INSTALL_PAM_MODULES=""
+UNINSTALL_PAM_MODULES=""
 AC_MSG_CHECKING(whether to use pam_smbpass)
 AC_ARG_WITH(pam_smbpass,
 [  --with-pam_smbpass      Build PAM module for authenticating against passdb backends (default=no)],
@@ -3561,7 +3935,7 @@ AC_ARG_WITH(pam_smbpass,
 
        # Conditions under which pam_smbpass should not be built.
 
-       if test x$PICFLAGS = x; then
+       if test x"$PICFLAGS" = x; then
           AC_MSG_ERROR([No support for PIC code])
        elif test x"$ac_cv_header_security_pam_appl_h" = x"no"; then
          AC_MSG_ERROR([No security/pam_appl.h found])
@@ -3569,7 +3943,9 @@ AC_ARG_WITH(pam_smbpass,
           AC_MSG_ERROR([No libpam found])
        else
          AUTH_LIBS="$AUTH_LIBS -lpam"
-          SHLIB_PROGS="$SHLIB_PROGS bin/pam_smbpass.$SHLIBEXT"
+          PAM_MODULES="pam_smbpass"
+          INSTALL_PAM_MODULES="installpammodules"
+          UNINSTALL_PAM_MODULES="uninstallpammodules"
        fi
     ;;
   *)
@@ -3604,36 +3980,6 @@ if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
 fi
 fi
 
-
-########################################################################################
-##
-## TESTS FOR SAM BACKENDS.  KEEP THESE GROUPED TOGETHER
-##
-########################################################################################
-
-#################################################
-# check for a LDAP password database configuration backwards compatibility
-AC_MSG_CHECKING(whether to use LDAP SAM 2.2 compatible configuration)
-AC_ARG_WITH(ldapsam,
-[  --with-ldapsam          Include LDAP SAM 2.2 compatible configuration (default=no)],
-[ case "$withval" in
-  yes)
-    AC_MSG_RESULT(yes)
-    AC_DEFINE(WITH_LDAP_SAMCONFIG,1,[Whether to include 2.2 compatible LDAP SAM configuration])
-    ;;
-  *)
-    AC_MSG_RESULT(no)
-    ;;
-  esac ],
-  AC_MSG_RESULT(no)
-)
-
-########################################################################################
-##
-## END OF TESTS FOR SAM BACKENDS.  
-##
-########################################################################################
-
 #################################################
 # check for a NISPLUS_HOME support 
 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
@@ -3668,24 +4014,6 @@ AC_ARG_WITH(syslog,
   AC_MSG_RESULT(no)
 )
 
-#################################################
-# check for a shared memory profiling support
-AC_MSG_CHECKING(whether to use profiling)
-AC_ARG_WITH(profiling-data,
-[  --with-profiling-data   Include gathering source code profile information (default=no)],
-[ case "$withval" in
-  yes)
-    AC_MSG_RESULT(yes)
-    AC_DEFINE(WITH_PROFILE,1,[Whether to use profiling])
-    ;;
-  *)
-    AC_MSG_RESULT(no)
-    ;;
-  esac ],
-  AC_MSG_RESULT(no)
-)
-
-
 #################################################
 # check for experimental disk-quotas support
 
@@ -3926,7 +4254,7 @@ fi
 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no"; then
 AC_CACHE_CHECK([whether the sys_quota interface works],samba_cv_SYSQUOTA_WORKS,[
 SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt -I${srcdir-.}/nsswitch"
+CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
 AC_TRY_COMPILE([
 #include "confdefs.h"
 #define NO_PROTO_H 1
@@ -3953,7 +4281,7 @@ fi
 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no" -a x"$samba_cv_found_xfs_header" = x"yes"; then
 AC_CACHE_CHECK([whether the sys_quota interface works with XFS],samba_cv_SYSQUOTA_WORKS_XFS,[
 SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt -I${srcdir-.}/nsswitch"
+CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
 AC_TRY_COMPILE([
 #include "confdefs.h"
 #define NO_PROTO_H 1
@@ -3973,7 +4301,7 @@ fi
 
 AC_CACHE_CHECK([whether the old quota support works],samba_cv_QUOTA_WORKS,[
 SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt -I${srcdir-.}/nsswitch -I${srcdir-.}/smbwrapper"
+CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
 AC_TRY_COMPILE([
 #include "confdefs.h"
 #define NO_PROTO_H 1
@@ -4036,17 +4364,22 @@ 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
 
 #################################################
 # should we build libmsrpc?
 INSTALL_LIBMSRPC=
+UNINSTALL_LIBMSRPC=
 LIBMSRPC_SHARED=
 LIBMSRPC=
 AC_MSG_CHECKING(whether to build the libmsrpc shared library)
@@ -4069,6 +4402,7 @@ AC_ARG_WITH(libmsrpc,
         LIBMSRPC=libmsrpc
      fi
      INSTALL_LIBMSRPC=installlibmsrpc
+     UNINSTALL_LIBMSRPC=uninstalllibmsrpc
      ;;
   esac ],
 [
@@ -4085,11 +4419,60 @@ AC_ARG_WITH(libmsrpc,
      LIBMSRPC=libmsrpc
   fi]
   INSTALL_LIBMSRPC=installlibmsrpc
+  UNINSTALL_LIBMSRPC=uninstalllibmsrpc
+)
+
+
+#################################################
+# should we build libaddns?
+INSTALL_LIBADDNS=
+UNINSTALL_LIBADDNS=
+LIBADDNS_SHARED=
+LIBADDNS=
+AC_MSG_CHECKING(whether to build the libaddns shared library)
+AC_ARG_WITH(libaddns,
+[  --with-libaddns         Build the libaddns shared library (default=yes if shared libs supported)],
+[ case "$withval" in
+  no) 
+     AC_MSG_RESULT(no)
+     ;;
+  *)
+     if test $BLDSHARED = true; then
+        LIBADDNS_SHARED=bin/libaddns.$SHLIBEXT
+        LIBADDNS=libaddns
+        AC_MSG_RESULT(yes)
+     else
+       enable_static=yes
+        AC_MSG_RESULT(no shared library support -- will supply static library)
+     fi
+     if test $enable_static = yes; then
+        LIBADDNS=libaddns
+     fi
+     INSTALL_LIBADDNS=installlibaddns
+     UNINSTALL_LIBADDNS=uninstalllibaddns
+     ;;
+  esac ],
+[
+# if unspecified, default is to built it if possible.
+  if test $BLDSHARED = true; then
+     LIBADDNS_SHARED=bin/libaddns.$SHLIBEXT
+     LIBADDNS=libaddns
+     AC_MSG_RESULT(yes)
+   else
+     enable_static=yes
+     AC_MSG_RESULT(no shared library support -- will supply static library)
+   fi
+   if test $enable_static = yes; then
+     LIBADDNS=libaddns
+  fi]
+  INSTALL_LIBADDNS=installlibaddns
+  UNINSTALL_LIBADDNS=uninstalllibaddns
 )
 
 #################################################
 # should we build libsmbclient?
 INSTALL_LIBSMBCLIENT=
+UNINSTALL_LIBSMBCLIENT=
 LIBSMBCLIENT_SHARED=
 LIBSMBCLIENT=
 AC_MSG_CHECKING(whether to build the libsmbclient shared library)
@@ -4112,6 +4495,7 @@ AC_ARG_WITH(libsmbclient,
         LIBSMBCLIENT=libsmbclient
      fi
      INSTALL_LIBSMBCLIENT=installclientlib
+     UNINSTALL_LIBSMBCLIENT=uninstallclientlib
      ;;
   esac ],
 [
@@ -4128,6 +4512,7 @@ AC_ARG_WITH(libsmbclient,
      LIBSMBCLIENT=libsmbclient
   fi]
   INSTALL_LIBSMBCLIENT=installclientlib
+  UNINSTALL_LIBSMBCLIENT=uninstallclientlib
 )
 
 INSTALL_LIBSMBSHAREMODES=
@@ -4153,6 +4538,7 @@ AC_ARG_WITH(libsmbsharemodes,
         LIBSMBSHAREMODES=libsmbsharemodes
      fi
      INSTALL_LIBSMBSHAREMODES=installlibsmbsharemodes
+     UNINSTALL_LIBSMBSHAREMODES=uninstalllibsmbsharemodes
      ;;
   esac ],
 [
@@ -4220,6 +4606,16 @@ if test $space = no; then
   fi
 fi
 
+# smbd/statvfs.c assumes that statvfs.f_fsid is an integer.
+# This is not the case on ancient Linux systems.
+
+AC_CACHE_CHECK([that statvfs.f_fsid is an integer],samba_cv_fsid_int, [
+    AC_TRY_COMPILE([#include <sys/statvfs.h>],[struct statvfs buf; buf.f_fsid = 0],
+       samba_cv_fsid_int=yes,samba_cv_fsid_int=no)])
+if test x"$samba_cv_fsid_int" = x"yes"; then
+    AC_DEFINE(HAVE_FSID_INT, 1, [Whether statvfs.f_fsid is an integer])
+fi
+
 if test $space = no; then
   # DEC Alpha running OSF/1
   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
@@ -4402,6 +4798,20 @@ if test "x$with_spinlocks" = "xyes"; then
     esac
 fi
 
+#################################################
+# check for cluster extensions
+
+AC_MSG_CHECKING(whether to include cluster support)
+AC_ARG_WITH(cluster-support, 
+[  --with-cluster-support  Enable cluster extensions (default=no)])
+if test "x$with_cluster_support" = "xyes"; then
+    AC_DEFINE(CLUSTER_SUPPORT,1,[Whether to enable cluster extensions])
+    AC_MSG_RESULT(yes)
+else
+    AC_MSG_RESULT(no)
+fi
+
+
 #################################################
 # check for ACL support
 
@@ -4415,28 +4825,34 @@ AC_ARG_WITH(acl-support,
        *sysv5*)
                AC_MSG_RESULT(Using UnixWare ACLs)
                AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
+               default_static_modules="$default_static_modules vfs_solarisacl"
                ;;
        *solaris*)
                AC_MSG_RESULT(Using solaris ACLs)
                AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
                ACL_LIBS="$ACL_LIBS -lsec"
+               default_static_modules="$default_static_modules vfs_solarisacl"
                ;;
        *hpux*)
                AC_MSG_RESULT(Using HPUX ACLs)
                AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
+               default_static_modules="$default_static_modules vfs_hpuxacl"
                ;;
        *irix*)
                AC_MSG_RESULT(Using IRIX ACLs)
                AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
+               default_static_modules="$default_static_modules vfs_irixacl"
                ;;
        *aix*)
                AC_MSG_RESULT(Using AIX ACLs)
                AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
+               default_static_modules="$default_static_modules vfs_aixacl"
                ;;
        *osf*)
                AC_MSG_RESULT(Using Tru64 ACLs)
                AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
                ACL_LIBS="$ACL_LIBS -lpacl"
+               default_static_modules="$default_static_modules vfs_tru64acl"
                ;;
        *freebsd[[5-9]]*)
                AC_MSG_RESULT(Using FreeBSD posix ACLs)
@@ -4507,6 +4923,10 @@ samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)
   AC_MSG_RESULT(no)
 )
 
+if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
+   default_static_modules="$default_static_modules vfs_posixacl"
+fi
+
 #################################################
 # check for AIO support
 
@@ -5005,7 +5425,9 @@ if test x"$HAVE_WINBIND" = x"yes"; then
                SHLIB_PROGS="$SHLIB_PROGS $WINBIND_NSS $WINBIND_WINS_NSS"
 
                if test x"$with_pam" = x"yes"; then
-                       SHLIB_PROGS="$SHLIB_PROGS nsswitch/pam_winbind.$SHLIBEXT"
+                       PAM_MODULES="$PAM_MODULES pam_winbind"
+                       INSTALL_PAM_MODULES="installpammodules"
+                       UNINSTALL_PAM_MODULES="uninstallpammodules"
                fi
        fi
 else
@@ -5035,6 +5457,18 @@ AC_CHECK_MEMBERS([struct secmethod_table.method_attrlist], , ,
 AC_CHECK_MEMBERS([struct secmethod_table.method_version], , ,
        [#include <usersec.h>])
 
+AC_CACHE_CHECK([for SO_PEERCRED],samba_cv_HAVE_PEERCRED,[
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/socket.h>],
+[struct ucred cred;
+ socklen_t cred_len;
+ int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);
+],
+samba_cv_HAVE_PEERCRED=yes,samba_cv_HAVE_PEERCRED=no,samba_cv_HAVE_PEERCRED=cross)])
+if test x"$samba_cv_HAVE_PEERCRED" = x"yes"; then
+    AC_DEFINE(HAVE_PEERCRED,1,[Whether we can use SO_PEERCRED to get socket credentials])
+fi
+
 
 #################################################
 # Check to see if we should use the included popt 
@@ -5061,7 +5495,7 @@ if test x"$INCLUDED_POPT" = x"yes"; then
     AC_MSG_RESULT(yes)
     BUILD_POPT='$(POPT_OBJS)'
        POPTLIBS='$(POPT_OBJS)'
-    FLAGS1="-I$srcdir/popt"
+    FLAGS1="-I\$(srcdir)/popt"
 else
     AC_MSG_RESULT(no)
        BUILD_POPT=""
@@ -5071,6 +5505,43 @@ AC_SUBST(BUILD_POPT)
 AC_SUBST(POPTLIBS)
 AC_SUBST(FLAGS1)
 
+#################################################
+# Check to see if we should use the included iniparser 
+
+AC_ARG_WITH(included-iniparser,
+[  --with-included-iniparser    use bundled iniparser library, not from system],
+[ 
+  case "$withval" in
+       yes)
+               INCLUDED_INIPARSER=yes
+               ;;
+        no)
+               INCLUDED_INIPARSER=no
+                ;;
+  esac ],
+)
+if test x"$INCLUDED_INIPARSER" != x"yes"; then
+    AC_CHECK_LIB(iniparser, iniparser_load,
+                INCLUDED_INIPARSER=no, INCLUDED_INIPARSER=yes)
+fi
+
+AC_MSG_CHECKING(whether to use included iniparser)
+if test x"$INCLUDED_INIPARSER" = x"yes"; then
+    AC_MSG_RESULT(yes)
+    BUILD_INIPARSER='$(INIPARSER_OBJ)'
+       INIPARSERLIBS=""
+    FLAGS1="$FLAGS1 -I\$(srcdir)/iniparser/src"
+else
+    AC_MSG_RESULT(no)
+       BUILD_INIPARSER=""
+    INIPARSERLIBS="-liniparser"
+fi
+AC_SUBST(BUILD_INIPARSER)
+AC_SUBST(INIPARSERLIBS)
+AC_SUBST(FLAGS1)
+
+
+
 #################################################
 # Check if the user wants Python
 
@@ -5115,7 +5586,6 @@ do
 done
 
 dnl Always built these modules static
-MODULE_pdb_guest=STATIC
 MODULE_rpc_spoolss=STATIC
 MODULE_rpc_srv=STATIC
 MODULE_idmap_tdb=STATIC
@@ -5142,14 +5612,13 @@ SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o passdb/pdb_nds.o, "bin/ldapsam.$SHLIBEXT"
                   [ PASSDB_LIBS="$PASSDB_LIBS $LDAP_LIBS" ] )
 SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, "bin/smbpasswd.$SHLIBEXT", PDB)
 SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, "bin/tdbsam.$SHLIBEXT", PDB)
-SMB_MODULE(pdb_guest, passdb/pdb_guest.o, "bin/guest.$SHLIBEXT", PDB)
 SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o)
 
 
 SMB_MODULE(rpc_lsa, \$(RPC_LSA_OBJ), "bin/librpc_lsarpc.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_reg, \$(RPC_REG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_lsa_ds, \$(RPC_LSA_DS_OBJ), "bin/librpc_lsa_ds.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_wks, \$(RPC_WKS_OBJ), "bin/librpc_wkssvc.$SHLIBEXT", RPC)
+SMB_MODULE(rpc_wkssvc, \$(RPC_WKS_OBJ), "bin/librpc_wkssvc.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_svcctl, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_ntsvcs, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_net, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
@@ -5158,7 +5627,8 @@ SMB_MODULE(rpc_srv, \$(RPC_SVC_OBJ), "bin/librpc_srvsvc.$SHLIBEXT", RPC)
 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_echo, \$(RPC_ECHO_OBJ), "bin/librpc_echo.$SHLIBEXT", RPC)
+SMB_MODULE(rpc_rpcecho, \$(RPC_ECHO_OBJ), "bin/librpc_echo.$SHLIBEXT", RPC)
+SMB_MODULE(rpc_unixinfo, \$(RPC_UNIXINFO_OBJ), "bin/librpc_unixinfo.$SHLIBEXT", RPC)
 SMB_SUBSYSTEM(RPC,smbd/server.o)
 
 SMB_MODULE(idmap_ldap, sam/idmap_ldap.o, "bin/ldap.$SHLIBEXT", IDMAP)
@@ -5173,7 +5643,6 @@ SMB_MODULE(charset_CP437, modules/CP437.o, "bin/CP437.$SHLIBEXT", CHARSET)
 SMB_MODULE(charset_macosxfs, modules/charset_macosxfs.o,"bin/macosxfs.$SHLIBEXT", CHARSET)
 SMB_SUBSYSTEM(CHARSET,lib/iconv.o)
 
-SMB_MODULE(auth_rhosts, \$(AUTH_RHOSTS_OBJ), "bin/rhosts.$SHLIBEXT", AUTH)
 SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), "bin/sam.$SHLIBEXT", AUTH)
 SMB_MODULE(auth_unix, \$(AUTH_UNIX_OBJ), "bin/unix.$SHLIBEXT", AUTH)
 SMB_MODULE(auth_winbind, \$(AUTH_WINBIND_OBJ), "bin/winbind.$SHLIBEXT", AUTH)
@@ -5183,6 +5652,7 @@ SMB_MODULE(auth_builtin, \$(AUTH_BUILTIN_OBJ), "bin/builtin.$SHLIBEXT", AUTH)
 SMB_MODULE(auth_script, \$(AUTH_SCRIPT_OBJ), "bin/script.$SHLIBEXT", AUTH)
 SMB_SUBSYSTEM(AUTH,auth/auth.o)
 
+SMB_MODULE(vfs_default, \$(VFS_DEFAULT_OBJ), "bin/default.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_recycle, \$(VFS_RECYCLE_OBJ), "bin/recycle.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_audit, \$(VFS_AUDIT_OBJ), "bin/audit.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_extd_audit, \$(VFS_EXTD_AUDIT_OBJ), "bin/extd_audit.$SHLIBEXT", VFS)
@@ -5195,7 +5665,18 @@ SMB_MODULE(vfs_cap, \$(VFS_CAP_OBJ), "bin/cap.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_expand_msdfs, \$(VFS_EXPAND_MSDFS_OBJ), "bin/expand_msdfs.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_shadow_copy, \$(VFS_SHADOW_COPY_OBJ), "bin/shadow_copy.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_afsacl, \$(VFS_AFSACL_OBJ), "bin/afsacl.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_posixacl, \$(VFS_POSIXACL_OBJ), "bin/posixacl.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_aixacl, \$(VFS_AIXACL_OBJ), "bin/aixacl.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_aixacl2, \$(VFS_AIXACL2_OBJ), "bin/aixacl2.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_solarisacl, \$(VFS_SOLARISACL_OBJ), "bin/solarisacl.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_irixacl, \$(VFS_IRIXACL_OBJ), "bin/irixacl.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_hpuxacl, \$(VFS_HPUXACL_OBJ), "bin/hpuxacl.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_tru64acl, \$(VFS_TRU64ACL_OBJ), "bin/tru64acl.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_catia, \$(VFS_CATIA_OBJ), "bin/catia.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_cacheprime, \$(VFS_CACHEPRIME_OBJ), "bin/cacheprime.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_prealloc, \$(VFS_PREALLOC_OBJ), "bin/prealloc.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_commit, \$(VFS_COMMIT_OBJ), "bin/commit.$SHLIBEXT", VFS)
+
 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
 
 AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules])
@@ -5207,6 +5688,89 @@ if test "${ac_cv_prog_CC}" = "insure"; then
        CPPFLAGS="$CPPFLAGS -D__INSURE__"
 fi
 
+#################################################
+# If run from the build farm, enable NASTY hacks
+#################################################
+AC_MSG_CHECKING(whether to enable build farm hacks)
+if test x"$RUN_FROM_BUILD_FARM" = x"yes"; then
+       AC_MSG_RESULT(yes)
+       AC_DEFINE(ENABLE_BUILD_FARM_HACKS, 1, [Defined if running in the build farm])
+else
+       AC_MSG_RESULT(no)
+fi
+
+#################################################
+# check for bad librt/libpthread interactions
+
+if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes" -o \
+    x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes" -o \
+    x"$samba_cv_HAVE_AIO64" = x"yes" -o \
+    x"$samba_cv_HAVE_AIO" = x"yes" ; then
+
+SMB_IF_RTSIGNAL_BUG(
+       [
+           # Have RT_SIGNAL bug, need to check whether the problem will
+           # affect anything we have configured.
+
+           rt_do_error=no
+           if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
+               if test x"$rt_signal_lease_ok" = x"no" ; then
+                   rt_do_error=yes
+               fi
+           fi
+
+           if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
+               if test x"$rt_signal_notify_ok" = x"no" ; then
+                   rt_do_error=yes
+               fi
+           fi
+
+           if test x"$samba_cv_HAVE_AIO64" = x"yes" -o \
+                   x"$samba_cv_HAVE_AIO" = x"yes" ; then
+               if test x"$rt_signal_aio_ok" = x"no" ; then
+                   rt_do_error=yes
+               fi
+           fi
+
+           if test x"$rt_do_error" = x"yes" ; then
+               SMB_IS_LIBPTHREAD_LINKED(
+                   [
+                       cat<<MSG
+
+*** On this platforms, linking Samba against pthreads causes problems
+*** with the oplock and change notification mechanisms. You may be
+*** using pthreads as a side-effect of using the --with-aio-support
+*** or --with-profiling-data options. Please remove these and try again.
+
+MSG
+                   ],
+                   [
+                       cat<<MSG
+
+*** On this platform, the oplock and change notification mechanisms do not
+*** appear to work. Please report this problem to samba-technical@samba.org
+*** and attach the config.log file from this directory.
+
+MSG
+                   ])
+               AC_MSG_ERROR(unable to use realtime signals on this platform)
+           fi
+       ],
+       [
+           # no RT_SIGNAL bug, we are golden
+           SMB_IS_LIBPTHREAD_LINKED(
+               [
+                   AC_MSG_WARN(using libpthreads - this may degrade performance)
+               ])
+
+       ],
+       [
+           # cross compiling, I hope you know what you are doing
+           true
+       ])
+
+fi
+
 #################################################
 # Display summary of libraries detected
 
@@ -5218,6 +5782,9 @@ fi
 if test x"$with_ldap_support" != x"no"; then
    AC_MSG_RESULT([    LDAP_LIBS = $LDAP_LIBS])
 fi
+if test x"$with_dnsupdate_support" != x"no"; then
+       AC_MSG_RESULT([   UUID_LIBS = $UUID_LIBS])
+fi
 AC_MSG_RESULT([    AUTH_LIBS = $AUTH_LIBS])
 
 #################################################
@@ -5232,8 +5799,9 @@ AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
 builddir=`pwd`
 AC_SUBST(builddir)
 
-# Stuff the FAM libraries at the end of the smbd link path (if we have them).
-SMBD_LIBS="$samba_fam_libs"
+# Stuff the smbd-only libraries at the end of the smbd link
+# path (if we have them).
+SMBD_LIBS="$samba_fam_libs $samba_dmapi_libs"
 AC_SUBST(SMBD_LIBS)
 
 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
@@ -5244,7 +5812,7 @@ dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
 
-AC_OUTPUT(include/stamp-h Makefile script/findsmb smbadduser script/gen-8bit-gap.sh)
+AC_OUTPUT(include/stamp-h Makefile script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh)
 
 #################################################
 # Print very concise instructions on building/use