Merge branch 'v3-2-test' of ssh://jra@git.samba.org/data/git/samba into v3-2-test
[ira/wip.git] / source3 / configure.in
index cce21a29b216cb6d855a15d46c2fdc7395fa43ab..1906d7450547b16222ce7e6ccfee6c46ab21243f 100644 (file)
@@ -4,13 +4,31 @@ dnl We must use autotools 2.53 or above
 AC_PREREQ(2.53)
 AC_INIT(include/includes.h)
 AC_CONFIG_HEADER(include/config.h)
+AC_DEFINE(CONFIG_H_IS_FROM_SAMBA,1,[Marker for samba's config.h])
+
+case "$PATH" in
+    */usr/ucb*)
+       AC_MSG_WARN([\$PATH contains /usr/ucb - build errors may follow])
+       ;;
+esac 
 
 SMB_VERSION_STRING=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_OFFICIAL_STRING' | cut -d '"' -f2`
 echo "SAMBA VERSION: ${SMB_VERSION_STRING}"
 
-SAMBA_VERSION_SVN_REVISION=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_SVN_REVISION' | cut -d ' ' -f3-`
-if test -n "${SAMBA_VERSION_SVN_REVISION}";then
-       echo "BUILD REVISION: ${SAMBA_VERSION_SVN_REVISION}"
+SAMBA_VERSION_GIT_COMMIT_FULLREV=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_FULLREV' | cut -d ' ' -f3- | cut -d '"' -f2`
+if test -n "${SAMBA_VERSION_GIT_COMMIT_FULLREV}";then
+       echo "BUILD COMMIT REVISION: ${SAMBA_VERSION_GIT_COMMIT_FULLREV}"
+fi
+SAMBA_VERSION_GIT_COMMIT_DATE=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_DATE' | cut -d ' ' -f3-`
+if test -n "${SAMBA_VERSION_GIT_COMMIT_DATE}";then
+       echo "BUILD COMMIT DATE: ${SAMBA_VERSION_GIT_COMMIT_DATE}"
+fi
+SAMBA_VERSION_GIT_COMMIT_TIME=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_TIME' | cut -d ' ' -f3-`
+if test -n "${SAMBA_VERSION_GIT_COMMIT_TIME}";then
+       echo "BUILD COMMIT TIME: ${SAMBA_VERSION_GIT_COMMIT_TIME}"
+
+       # just to keep the build-farm gui happy for now...
+       echo "BUILD REVISION: ${SAMBA_VERSION_GIT_COMMIT_TIME}"
 fi
 
 AC_LIBREPLACE_LOCATION_CHECKS
@@ -34,8 +52,11 @@ test "${libdir}" || libdir="\${prefix}/lib"
 pammodulesdir="\${LIBDIR}/security"
 configdir="\${LIBDIR}"
 swatdir="\${prefix}/swat"
+codepagedir="\${LIBDIR}"
+statedir="\${LOCKDIR}"
+cachedir="\${LOCKDIR}"
 
-AC_ARG_WITH(fhs, 
+AC_ARG_WITH(fhs,
 [  --with-fhs              Use FHS-compliant paths (default=no)],
 [ case "$withval" in
   yes)
@@ -44,9 +65,13 @@ AC_ARG_WITH(fhs,
     mandir="\${prefix}/share/man"
     logfilebase="\${VARDIR}/log/samba"
     privatedir="\${CONFIGDIR}/private"
-    libdir="\${prefix}/lib/samba"
-    configdir="${sysconfdir}/samba"
+    test "${libdir}" || libdir="\${prefix}/lib/samba"
+    configdir="\${sysconfdir}/samba"
     swatdir="\${DATADIR}/samba/swat"
+    codepagedir="\${LIBDIR}"
+    statedir="\${VARDIR}/lib/samba"
+    cachedir="\${VARDIR}/lib/samba"
+    AC_DEFINE(FHS_COMPATIBLE, 1, [Whether to use fully FHS-compatible paths])
     ;;
   esac])
 
@@ -162,6 +187,20 @@ AC_ARG_WITH(logfilebase,
     ;;
   esac])
 
+
+#################################################
+# set ctdb source directory location
+AC_ARG_WITH(ctdb,
+[  --with-ctdb=DIR  Where to find ctdb sources],
+[ case "$withval" in
+  yes|no)
+    AC_MSG_WARN([--with-ctdb called without argument])
+  ;;
+  * )
+    ctdbdir="$withval"
+    ;;
+  esac])
+
 #################################################
 # set lib directory location
 AC_ARG_WITH(libdir,
@@ -232,7 +271,7 @@ done
 SAMBA_CPPFLAGS="-Iinclude -I${srcdir-.}/include  -I. -I${srcdir-.}"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/lib/replace"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/lib/talloc"
-SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/tdb/include"
+SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/lib/tdb/include"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/libaddns"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc"
 
@@ -247,10 +286,14 @@ AC_SUBST(configdir)
 AC_SUBST(lockdir)
 AC_SUBST(piddir)
 AC_SUBST(logfilebase)
+AC_SUBST(ctdbdir)
 AC_SUBST(privatedir)
 AC_SUBST(swatdir)
 AC_SUBST(bindir)
 AC_SUBST(sbindir)
+AC_SUBST(codepagedir)
+AC_SUBST(statedir)
+AC_SUBST(cachedir)
 AC_SUBST(rootsbindir)
 AC_SUBST(pammodulesdir)
 
@@ -260,6 +303,8 @@ AC_SUBST(SHELL)
 AC_SUBST(LDSHFLAGS)
 AC_SUBST(SONAMEFLAG)
 AC_SUBST(SHLD)
+AC_SUBST(MODULE_EXPORTS)
+AC_SUBST(DSO_EXPORTS)
 AC_SUBST(HOST_OS)
 AC_SUBST(PICFLAG)
 AC_SUBST(PIE_CFLAGS)
@@ -269,14 +314,19 @@ 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_LIBWBCLIENT)
+AC_SUBST(UNINSTALL_LIBWBCLIENT)
+AC_SUBST(LIBWBCLIENT_SHARED)
+AC_SUBST(LIBWBCLIENT)
+AC_SUBST(WINBIND_LIBS)
+
+AC_SUBST(LIBSAMBAUTIL_SHARED)
+
 AC_SUBST(INSTALL_LIBSMBCLIENT)
 AC_SUBST(UNINSTALL_LIBSMBCLIENT)
 AC_SUBST(LIBSMBCLIENT_SHARED)
@@ -285,6 +335,10 @@ AC_SUBST(INSTALL_LIBSMBSHAREMODES)
 AC_SUBST(UNINSTALL_LIBSMBSHAREMODES)
 AC_SUBST(LIBSMBSHAREMODES_SHARED)
 AC_SUBST(LIBSMBSHAREMODES)
+AC_SUBST(INSTALL_LIBNETAPI)
+AC_SUBST(UNINSTALL_LIBNETAPI)
+AC_SUBST(LIBNETAPI_SHARED)
+AC_SUBST(LIBNETAPI)
 AC_SUBST(PRINT_LIBS)
 AC_SUBST(AUTH_LIBS)
 AC_SUBST(ACL_LIBS)
@@ -293,17 +347,18 @@ 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(NSS_MODULES)
 AC_SUBST(EXTRA_BIN_PROGS)
+AC_SUBST(SMBMOUNT_PROGS)
 AC_SUBST(CIFSMOUNT_PROGS)
 AC_SUBST(INSTALL_CIFSMOUNT)
 AC_SUBST(UNINSTALL_CIFSMOUNT)
+AC_SUBST(CIFSSPNEGO_PROGS)
+AC_SUBST(INSTALL_CIFSSPNEGO)
+AC_SUBST(UNINSTALL_CIFSSPNEGO)
 AC_SUBST(EXTRA_SBIN_PROGS)
 AC_SUBST(EXTRA_ALL_TARGETS)
 AC_SUBST(CONFIG_LIBS)
@@ -311,7 +366,7 @@ 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, 
+AC_ARG_ENABLE(debug,
 [  --enable-debug          Turn on compiler debugging information (default=no)],
     [if eval "test x$enable_debug = xyes"; then
        CFLAGS="${CFLAGS} -g"
@@ -331,13 +386,31 @@ CFLAGS="${CFLAGS} -D_SAMBA_BUILD_=3"
 AC_LIBREPLACE_CC_CHECKS
 
 m4_include(lib/socket_wrapper/config.m4)
+m4_include(lib/nss_wrapper/config.m4)
+
+SWAT_SBIN_TARGETS='bin/swat$(EXEEXT)'
+SWAT_INSTALL_TARGETS=installswat
+
+AC_ARG_ENABLE(swat,
+[  --enable-swat           Build the SWAT tool (default=yes)],
+[
+    case "$enable_swat" in
+       no)
+           SWAT_SBIN_TARGETS=''
+           SWAT_INSTALL_TARGETS=''
+           ;;
+    esac
+])
+
+AC_SUBST(SWAT_SBIN_TARGETS)
+AC_SUBST(SWAT_INSTALL_TARGETS)
 
 #################################################
 # 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)],
+[  --with-selftest-prefix=DIR    The prefix where make test will be run ($selftest_prefix)],
 [ case "$withval" in
   yes|no)
     AC_MSG_WARN([--with-selftest-prefix called without argument - will use default])
@@ -361,7 +434,7 @@ AC_ARG_WITH(smbtorture4_path,
   * )
     smbtorture4_path="$withval"
     if test -z "$smbtorture4_path" -a ! -f $smbtorture4_path; then
-       AC_MSG_ERROR(['$smbtorture_path' does not  exist!]) 
+       AC_MSG_ERROR(['$smbtorture_path' does not  exist!])
     fi
   ;;
  esac
@@ -370,7 +443,19 @@ AC_ARG_WITH(smbtorture4_path,
 AC_ARG_ENABLE(developer, [  --enable-developer      Turn on developer warnings and debugging (default=no)],
     [if eval "test x$enable_developer = xyes"; then
         developer=yes
-       CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
+    fi])
+
+AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer  Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)],
+    [if eval "test x$enable_krb5developer = xyes"; then
+        developer=yes
+       krb5_developer=yes
+    fi])
+
+# Probe the gcc version for extra CFLAGS. We always stash these in
+# DEVELOPER_CFLAGS, so that you can turn them on and off with a simple
+# Makefile edit, avoiding the need to re-run configure.
+if test x"$ac_cv_prog_gcc" = x"yes" ; then
+       DEVELOPER_CFLAGS="-gstabs -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
        # Add -Wdeclaration-after-statement if compiler supports it
        AC_CACHE_CHECK(
           [that the C compiler understands -Wdeclaration-after-statement],
@@ -384,23 +469,41 @@ AC_ARG_ENABLE(developer, [  --enable-developer      Turn on developer warnings a
            samba_cv_HAVE_Wdeclaration_after_statement=no,
            samba_cv_HAVE_Wdeclaration_after_statement=cross)
        ])
-       if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
-           CFLAGS="${CFLAGS} -Wdeclaration-after-statement"
+
+       if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
+           DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Wdeclaration-after-statement"
+       fi
+
+       #-Werror-implicit-function-declaration
+       AC_CACHE_CHECK(
+          [that the C compiler understands -Werror-implicit-function-declaration],
+          samba_cv_HAVE_Werror_implicit_function_declaration, [
+         AC_TRY_RUN_STRICT([
+           int main(void)
+           {
+               return 0;
+           }],[-Werror-implicit-function-declaration],[$CPPFLAGS],[$LDFLAGS],
+           samba_cv_HAVE_Werror_implicit_function_declaration=yes,
+           samba_cv_HAVE_Werror_implicit_function_declaration=no,
+           samba_cv_HAVE_Werror_implicit_function_declaration=cross)
+       ])
+       if test x"$samba_cv_HAVE_Werror_implicit_function_declaration" = x"yes"; then
+           DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -Werror-implicit-function-declaration"
        fi
-    fi])
 
-AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer  Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)],
-    [if eval "test x$enable_krb5developer = xyes"; then
-        developer=yes
-       CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
-    fi])
+       # krb5developer is like developer, except we don't get
+       # -Wstrict-prototypes.
+       if test x"$krb5_developer" != x"$yes" ; then
+           DEVELOPER_CFLAGS="$DEVELOPER_CFLAGS -Wstrict-prototypes"
+       fi
+fi
 
 AC_ARG_ENABLE(dmalloc, [  --enable-dmalloc        Enable heap debugging [default=no]])
 
 if test "x$enable_dmalloc" = xyes
 then
        AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
-       AC_DEFINE(DMALLOC_FUNC_CHECK, 1, 
+       AC_DEFINE(DMALLOC_FUNC_CHECK, 1,
                   [Define to check invariants around some common functions])
        LIBS="$LIBS -ldmalloc"  
 fi
@@ -436,7 +539,7 @@ dnl Check if we use GNU ld
 LD=ld
 AC_PROG_LD_GNU
 
-dnl Certain versions of GNU ld the default is not to have the 
+dnl Certain versions of GNU ld the default is not to have the
 dnl --allow-shlib-undefined flag defined.  This causes a stackload of
 dnl warnings when building modules.
 if test "$ac_cv_prog_gnu_ld" = "yes"; then
@@ -450,6 +553,9 @@ if test "$ac_cv_prog_gnu_ld" = "yes"; then
        if test "$ac_cv_gnu_ld_date" -lt 20030217; then
                ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
        fi
+       if test "$ac_cv_gnu_ld_date" -gt 20030101; then
+               ac_cv_gnu_ld_version_script=yes
+       fi
         else
            AC_MSG_CHECKING(GNU ld release version)
            changequote(,)dnl
@@ -465,6 +571,9 @@ if test "$ac_cv_prog_gnu_ld" = "yes"; then
            if test "$ac_cv_gnu_ld_vernr_major" -lt 2 || test "$ac_cv_gnu_ld_vernr_minor" -lt 14; then
              ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
            fi
+           if test "$ac_cv_gnu_ld_vernr_major" -gt 2 || test "$ac_cv_gnu_l= d_vernr_major"=2 && test "$ac_cv_gnu_ld_vernr_minor" -ge 12; then
+             ac_cv_gnu_ld_version_script=yes
+           fi
         fi
 fi
 
@@ -490,7 +599,7 @@ AC_CACHE_CHECK([that the C compiler understands -Werror],samba_cv_HAVE_Werror, [
   samba_cv_HAVE_Werror=yes,samba_cv_HAVE_Werror=no,samba_cv_HAVE_Werror=cross)])
 if test x"$samba_cv_HAVE_Werror" = x"yes"; then
    Werror_FLAGS="-Werror"
-else 
+else
 dnl Check if the C compiler understands -w2
 AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
  AC_TRY_RUN_STRICT([
@@ -564,6 +673,10 @@ UNAME_P=`(uname -p) 2>/dev/null` || UNAME_P="unknown"
 AC_MSG_CHECKING(uname -p)
 AC_MSG_RESULT(${UNAME_P})
 
+UNAME_I=`(uname -i) 2>/dev/null` || UNAME_I="unknown"
+AC_MSG_CHECKING(uname -i)
+AC_MSG_RESULT(${UNAME_I})
+
 dnl Add #include for broken IRIX header files
   case "$host_os" in
        *irix6*)
@@ -590,10 +703,10 @@ AC_SUBST(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_winreg rpc_initshutdown rpc_lsa_ds rpc_wkssvc rpc_svcctl rpc_ntsvcs rpc_net rpc_netdfs rpc_srvsvc rpc_spoolss rpc_eventlog rpc_unixinfo auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default"
+default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_winreg rpc_initshutdown rpc_lsa_ds rpc_wkssvc rpc_svcctl2 rpc_ntsvcs rpc_net rpc_netdfs rpc_srvsvc2 rpc_spoolss rpc_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template"
 
 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"
+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 vfs_readahead vfs_syncops"
 
 if test "x$developer" = xyes; then
    default_static_modules="$default_static_modules rpc_rpcecho"
@@ -606,7 +719,6 @@ fi
 # case statement; its first reference must be unconditional.
 #
 case "$host_os" in
-# Try to work out if this is the native HPUX compiler that uses the -Ae flag.
     *hpux*)
 #
 # Defines needed for HPUX support.
@@ -614,24 +726,9 @@ case "$host_os" in
 # password hashing - hence the USE_BOTH_CRYPT_CALLS define.
 #
       case `uname -r` in
-                       *9*|*10*)
-                               CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
-                               AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
-                               AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
-                               AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
-                               AC_DEFINE(_ALIGNMENT_REQUIRED,1,[Required alignment])
-                               AC_DEFINE(_MAX_ALIGNMENT,4,[Maximum alignment])
-                               ;;
-                       *11*)
-                               CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
-                               AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
-                               AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
-                               AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
-                               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])
-                               ;;
+               *9*|*10*|*11)
+                       AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
+               ;;
       esac
       ;;
 
@@ -650,7 +747,7 @@ case "$host_os" in
          AC_MSG_RESULT([enabling large file support])
       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
          AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
-      ;;    
+      ;;
 #
 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
 # to the existance of large files..
@@ -813,7 +910,7 @@ main() {
     *darwin*)
        AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
 
-       # Add a system specific charset module.
+# Add a system specific charset module.
        default_shared_modules="$default_shared_modules charset_macosxfs"
 
        ;;
@@ -851,16 +948,19 @@ for obj in ${LIBREPLACEOBJ}; do
 done
 AC_SUBST(LIBREPLACE_OBJS)
 
+# add -ldl to the global LIBS
+LIBS="${LIBS} ${LIBDL}"
+
 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 memory.h alloca.h)
-AC_CHECK_HEADERS(limits.h float.h)
+AC_CHECK_HEADERS(limits.h float.h pthread.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)
-AC_CHECK_HEADERS(sys/un.h)
+AC_CHECK_HEADERS(sys/un.h ifaddrs.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 dlfcn.h)
+AC_CHECK_HEADERS(sys/sysmacros.h)
 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
 AC_CHECK_HEADERS(langinfo.h locale.h)
 AC_CHECK_HEADERS(xfs/libxfs.h)
@@ -913,14 +1013,14 @@ AC_CHECK_HEADERS(shadow.h)
 AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h)
 AC_CHECK_HEADERS(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)
+AC_CHECK_HEADERS(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(sys/cdefs.h glob.h)
 
 # For experimental utmp support (lastlog on some BSD-like systems)
 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)
@@ -944,7 +1044,7 @@ 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_CHECK_TYPE(comparison_fn_t,
 [AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])])
 
 ############################################
@@ -978,12 +1078,7 @@ if test x$enable_iprint != xno; then
 fi
 
 ############################################
-# we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the plugin loading code
-AC_SEARCH_LIBS(dlopen, [dl])
-# dlopen/dlclose/dlsym/dlerror will be checked again later and defines will be set then
-
-############################################
-# check if the compiler can do immediate structures
+# check if the compiler will optimize out function calls
 AC_CACHE_CHECK([if the compiler will optimize out function calls],samba_cv_optimize_out_funcation_calls, [
     AC_TRY_LINK([
 #include <stdio.h>],
@@ -1010,7 +1105,7 @@ AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
 #include <sys/socket.h>
 #include <sys/un.h>],
 [
-  struct sockaddr_un sunaddr; 
+  struct sockaddr_un sunaddr;
   sunaddr.sun_family = AF_UNIX;
 ],
        samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
@@ -1019,19 +1114,6 @@ if test x"$samba_cv_unixsocket" = x"yes"; then
 fi
 
 
-AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
-    AC_TRY_COMPILE([
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
-#include <sys/socket.h>],[socklen_t i = 0],
-       samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
-if test x"$samba_cv_socklen_t" = x"yes"; then
-   AC_DEFINE(HAVE_SOCKLEN_T_TYPE,1,[Whether we have the variable type socklen_t])
-fi
-
 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
     AC_TRY_COMPILE([
 #include <sys/types.h>
@@ -1166,7 +1248,7 @@ AC_SUBST(TERMLDFLAGS)
 # code will generate warnings on one of them unless we have a few
 # special cases.
 AC_CHECK_LIB(readline, rl_completion_matches,
-            [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1, 
+            [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1,
                        [Do we have rl_completion_matches?])],
             [],
             [$TERMLIBS])
@@ -1204,7 +1286,7 @@ if test x"$ac_cv_func_connect" = x"no"; then
     esac
     dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
     dnl has been cached.
-    if test x"$ac_cv_lib_socket_connect" = x"yes" || 
+    if test x"$ac_cv_lib_socket_connect" = x"yes" ||
        test x"$ac_cv_lib_inet_connect" = x"yes"; then
         # ac_cv_func_connect=yes
         # don't!  it would cause AC_CHECK_FUNC to succeed next time configure is run
@@ -1223,9 +1305,10 @@ 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 strerror chown fchown chmod fchmod chroot link mknod mknod64)
+AC_CHECK_FUNCS(waitpid getcwd strdup strndup strnlen strerror chown fchown lchown 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(fstat strchr utime utimes chflags)
+AC_CHECK_FUNCS(getrlimit fsync fdatasync 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)
 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
@@ -1240,6 +1323,7 @@ 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_FUNCS(memalign posix_memalign hstrerror)
 AC_CHECK_HEADERS(sys/mman.h)
 # setbuffer, shmget, shm_open are needed for smbtorture
 AC_CHECK_FUNCS(setbuffer shmget shm_open)
@@ -1268,15 +1352,33 @@ LIBS="$save_LIBS"
 # 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"
+
+UNWIND_ARCH="unknown"
+if test x"$UNAME_I" != x"unknown"; then
+       UNWIND_ARCH="$UNAME_I"
+elif test x"$UNAME_M" != x"unknown"; then
+       UNWIND_ARCH="$UNAME_M"
+elif test x"$UNAME_P" != x"unknown"; then
+       UNWIND_ARCH="$UNAME_P"
 fi
 
+case "$UNWIND_ARCH" in
+       unknown)
+               # This probably won't link without
+               # the platform-specific libunwind.
+               LIBS="$LIBS -lunwind"
+               ;;
+       i386|i586|i686)
+               # Add the platform-specific libunwind module.
+               LIBS="$LIBS -lunwind -lunwind-x86"
+               ;;
+       *)
+               # Add the platform-specific libunwind module.
+               # based on uname -i, uname -m or uname -p
+               LIBS="$LIBS -lunwind -lunwind-$UNWIND_ARCH"
+               ;;
+esac
+
 AC_TRY_LINK(
     [
 #ifdef HAVE_LIBUNWIND_H
@@ -1285,7 +1387,7 @@ AC_TRY_LINK(
     ],
     [
        unw_context_t ctx; unw_cursor_t cur;
-       char buf[256]; unw_word_t off; 
+       char buf[256]; unw_word_t off;
        unw_getcontext(&ctx); unw_init_local(&cur, &ctx);
        unw_get_proc_name(&cur, buf, sizeof(buf), &off);
     ],
@@ -1372,7 +1474,7 @@ AC_TRY_COMPILE([
 AC_DEFINE(HAVE_PRCTL, 1, [Whether prctl is available]),[])
 
 #
-# 
+#
 #
 case "$host_os" in
     *linux*)
@@ -1453,7 +1555,7 @@ fi
 # Check whether struct stat has timestamps with sub-second resolution.
 # At least IRIX and Solaris have these.
 #
-# We check that 
+# We check that
 #      all of st_mtim, st_atim and st_ctim exist
 #      all of the members are in fact of type struct timespec
 #
@@ -1592,6 +1694,14 @@ case "$host_os" in
   ;;
 esac
 
+########################################################
+# Check if attropen() is present if this is Solaris
+case "$host_os" in
+  *solaris*)
+       AC_CHECK_FUNCS(attropen)
+  ;;
+esac
+
 ########################################################
 # Do xattr functions take additional options like on Darwin?
 if test x"$ac_cv_func_getxattr" = x"yes" ; then
@@ -1663,25 +1773,27 @@ BLDSHARED="false"
 # these are the defaults, good for lots of systems
 HOST_OS="$host_os"
 LDSHFLAGS="-shared"
+MODULE_EXPORTS=""
 SONAMEFLAG="#"
 SHLD="\${CC} \${CFLAGS}"
 PICFLAG="${PIE_CFLAGS}"
 SHLIBEXT="so"
+DSO_EXPORTS=""
 
 # 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
+  # how to compile C code to produce PIC object files
 
-AC_MSG_CHECKING([ability to build shared libraries])
+  AC_MSG_CHECKING([ability to build shared libraries])
 
-# and these are for particular systems
-case "$host_os" in
+  # and these are for particular systems
+  case "$host_os" in
                *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
                        BLDSHARED="true"
                        if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
-                               LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined" 
+                               LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined"
                        else
-                               LDSHFLAGS="-shared -Wl,-Bsymbolic" 
+                               LDSHFLAGS="-shared -Wl,-Bsymbolic"
                        fi
                        DYNEXP="-Wl,--export-dynamic"
                        PICFLAG="-fPIC"
@@ -1700,7 +1812,7 @@ case "$host_os" in
                                fi
                        else
                                PICFLAG="-KPIC"
-                               ## ${CFLAGS} added for building 64-bit shared 
+                               ## ${CFLAGS} added for building 64-bit shared
                                ## libs using Sun's Compiler
                                LDSHFLAGS="-G \${CFLAGS}"
                        fi
@@ -1715,7 +1827,7 @@ case "$host_os" in
                        AC_DEFINE(STAT_ST_BLOCKSIZE,512)
                        AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
                        ;;
-               *netbsd* | *freebsd* | *dragonfly* )  
+               *netbsd* | *freebsd* | *dragonfly* )
                        BLDSHARED="true"
                        LDSHFLAGS="-shared"
                        DYNEXP="-Wl,--export-dynamic"
@@ -1743,7 +1855,7 @@ case "$host_os" in
                        SHLD="\${LD}"
                        if test "${GCC}" = "yes"; then
                                PICFLAG="-fPIC"
-                       else 
+                       else
                                PICFLAG="-KPIC"
                        fi
                        AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
@@ -1766,17 +1878,19 @@ case "$host_os" in
                        ;;
                *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
                        # Use special PIC flags for the native HP-UX compiler.
-                       if test $ac_cv_prog_cc_Ae = yes; then
                                BLDSHARED="true"
                                SHLD="cc"
                                LDSHFLAGS="-b -Wl,-B,symbolic,-b,-z"
                                SONAMEFLAG="-Wl,+h "
                                PICFLAG="+z"
-                       elif test "${GCC}" = "yes"; then
+                       if test "${GCC}" = "yes"; then
                                PICFLAG="-fPIC"
+                       else
+                               PICFLAG="+z +ESnolit"
                        fi
                        if test "$host_cpu" = "ia64"; then
                                SHLIBEXT="so"
+                             PICFLAG="+z"
                                DYNEXP="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32"
                        else
                                SHLIBEXT="sl"
@@ -1841,18 +1955,29 @@ case "$host_os" in
                        BLDSHARED="true"
                        LDSHFLAGS="-bundle -flat_namespace -undefined suppress"
                        SHLIBEXT="dylib"
+                        MODULE_EXPORTS="-exported_symbols_list \$(srcdir)/exports/modules-darwin.syms"
+                        SHLIBEXT="dylib"
+                        # Since gcc doesn't fail on unrecognised options, the
+                        # PIE test incorrectly succeeds. Darwin gcc does not
+                        # actually support the PIE stuff.
+                        PIE_LDFLAGS=
+                        PIE_CFLAGS=
                        AC_DEFINE(STAT_ST_BLOCKSIZE,512)
                        ;;
 
                *)
                        AC_DEFINE(STAT_ST_BLOCKSIZE,512)
                        ;;
-esac
+  esac
 
 if test "$enable_shared" != "yes"; then
        BLDSHARED=false
 fi
 
+if test "$enable_shared" = yes -a "${ac_cv_gnu_ld_version_script}" = yes; then
+       DSO_EXPORTS=\$\(DSO_EXPORTS_CMD\)
+fi
+
 AC_MSG_RESULT($BLDSHARED)
 
 AC_MSG_CHECKING([LDFLAGS])
@@ -1880,7 +2005,7 @@ AC_MSG_RESULT([$PICFLAG])
 AC_MSG_CHECKING([NSSSONAMEVERSIONSUFFIX])
 AC_MSG_RESULT([$NSSSONAMEVERSIONSUFFIX])
 
-AC_CACHE_CHECK([whether building shared libraries actually works], 
+AC_CACHE_CHECK([whether building shared libraries actually works],
                [ac_cv_shlib_works],[
    # try building a trivial shared library
    ac_cv_shlib_works=no
@@ -1910,6 +2035,8 @@ fi
 AC_MSG_CHECKING([used PICFLAG])
 AC_MSG_RESULT([$PICFLAG])
 
+AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
+
 ################
 
 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
@@ -1934,7 +2061,15 @@ if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
    AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
 fi
 
-  
+
+AC_CACHE_CHECK([for 64 bit time_t],samba_cv_SIZEOF_TIME_T,[
+AC_TRY_RUN([#include <time.h>
+main() { exit((sizeof(time_t) == 8) ? 0 : 1); }],
+samba_cv_SIZEOF_TIME_T=yes,samba_cv_SIZEOF_TIME_T=no,samba_cv_SIZEOF_TIME_T=cross)])
+if test x"$samba_cv_SIZEOF_TIME_T" = x"yes"; then
+    AC_DEFINE(SIZEOF_TIME_T,8,[The size of the 'time_t' type])
+fi
+
 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
 AC_TRY_RUN([#include <stdio.h>
 #include <sys/stat.h>
@@ -2106,13 +2241,13 @@ if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
 fi
 
 AC_CACHE_CHECK([if gettimeofday takes tz argument],samba_cv_HAVE_GETTIMEOFDAY_TZ,[
-AC_TRY_RUN([
+AC_TRY_LINK([
 #include <sys/time.h>
-#include <unistd.h>
-main() { struct timeval tv; exit(gettimeofday(&tv, NULL));}],
-           samba_cv_HAVE_GETTIMEOFDAY_TZ=yes,samba_cv_HAVE_GETTIMEOFDAY_TZ=no,samba_cv_HAVE_GETTIMEOFDAY_TZ=cross)])
+#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() is available])
+    AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday takes a tz argument])
 fi
 
 if test x"$samba_cv_WITH_PROFILE" = x"yes"; then
@@ -2124,12 +2259,12 @@ if test x"$samba_cv_WITH_PROFILE" = x"yes"; then
 
     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)
-           ])
+                           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
 
@@ -2155,7 +2290,7 @@ AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
 AC_TRY_RUN([
 #include <sys/types.h>
 #include <stdarg.h>
-void foo(const char *format, ...) { 
+void foo(const char *format, ...) {
        va_list ap;
        int len;
        char buf[5];
@@ -2218,7 +2353,7 @@ AC_TRY_COMPILE([#include <sys/types.h>
 samba_cv_HAVE_UT_UT_NAME=yes,samba_cv_HAVE_UT_UT_NAME=no,samba_cv_HAVE_UT_UT_NAME=cross)])
 if test x"$samba_cv_HAVE_UT_UT_NAME" = x"yes"; then
     AC_DEFINE(HAVE_UT_UT_NAME,1,[Whether the utmp struct has a property ut_name])
-fi 
+fi
 
 AC_CACHE_CHECK([for ut_user in utmp],samba_cv_HAVE_UT_UT_USER,[
 AC_TRY_COMPILE([#include <sys/types.h>
@@ -2227,7 +2362,7 @@ AC_TRY_COMPILE([#include <sys/types.h>
 samba_cv_HAVE_UT_UT_USER=yes,samba_cv_HAVE_UT_UT_USER=no,samba_cv_HAVE_UT_UT_USER=cross)])
 if test x"$samba_cv_HAVE_UT_UT_USER" = x"yes"; then
     AC_DEFINE(HAVE_UT_UT_USER,1,[Whether the utmp struct has a property ut_user])
-fi 
+fi
 
 AC_CACHE_CHECK([for ut_id in utmp],samba_cv_HAVE_UT_UT_ID,[
 AC_TRY_COMPILE([#include <sys/types.h>
@@ -2236,7 +2371,7 @@ AC_TRY_COMPILE([#include <sys/types.h>
 samba_cv_HAVE_UT_UT_ID=yes,samba_cv_HAVE_UT_UT_ID=no,samba_cv_HAVE_UT_UT_ID=cross)])
 if test x"$samba_cv_HAVE_UT_UT_ID" = x"yes"; then
     AC_DEFINE(HAVE_UT_UT_ID,1,[Whether the utmp struct has a property ut_id])
-fi 
+fi
 
 AC_CACHE_CHECK([for ut_host in utmp],samba_cv_HAVE_UT_UT_HOST,[
 AC_TRY_COMPILE([#include <sys/types.h>
@@ -2245,7 +2380,7 @@ AC_TRY_COMPILE([#include <sys/types.h>
 samba_cv_HAVE_UT_UT_HOST=yes,samba_cv_HAVE_UT_UT_HOST=no,samba_cv_HAVE_UT_UT_HOST=cross)])
 if test x"$samba_cv_HAVE_UT_UT_HOST" = x"yes"; then
     AC_DEFINE(HAVE_UT_UT_HOST,1,[Whether the utmp struct has a property ut_host])
-fi 
+fi
 
 AC_CACHE_CHECK([for ut_time in utmp],samba_cv_HAVE_UT_UT_TIME,[
 AC_TRY_COMPILE([#include <sys/types.h>
@@ -2254,7 +2389,7 @@ AC_TRY_COMPILE([#include <sys/types.h>
 samba_cv_HAVE_UT_UT_TIME=yes,samba_cv_HAVE_UT_UT_TIME=no,samba_cv_HAVE_UT_UT_TIME=cross)])
 if test x"$samba_cv_HAVE_UT_UT_TIME" = x"yes"; then
     AC_DEFINE(HAVE_UT_UT_TIME,1,[Whether the utmp struct has a property ut_time])
-fi 
+fi
 
 AC_CACHE_CHECK([for ut_tv in utmp],samba_cv_HAVE_UT_UT_TV,[
 AC_TRY_COMPILE([#include <sys/types.h>
@@ -2263,7 +2398,7 @@ AC_TRY_COMPILE([#include <sys/types.h>
 samba_cv_HAVE_UT_UT_TV=yes,samba_cv_HAVE_UT_UT_TV=no,samba_cv_HAVE_UT_UT_TV=cross)])
 if test x"$samba_cv_HAVE_UT_UT_TV" = x"yes"; then
     AC_DEFINE(HAVE_UT_UT_TV,1,[Whether the utmp struct has a property ut_tv])
-fi 
+fi
 
 AC_CACHE_CHECK([for ut_type in utmp],samba_cv_HAVE_UT_UT_TYPE,[
 AC_TRY_COMPILE([#include <sys/types.h>
@@ -2272,7 +2407,7 @@ AC_TRY_COMPILE([#include <sys/types.h>
 samba_cv_HAVE_UT_UT_TYPE=yes,samba_cv_HAVE_UT_UT_TYPE=no,samba_cv_HAVE_UT_UT_TYPE=cross)])
 if test x"$samba_cv_HAVE_UT_UT_TYPE" = x"yes"; then
     AC_DEFINE(HAVE_UT_UT_TYPE,1,[Whether the utmp struct has a property ut_type])
-fi 
+fi
 
 AC_CACHE_CHECK([for ut_pid in utmp],samba_cv_HAVE_UT_UT_PID,[
 AC_TRY_COMPILE([#include <sys/types.h>
@@ -2281,7 +2416,7 @@ AC_TRY_COMPILE([#include <sys/types.h>
 samba_cv_HAVE_UT_UT_PID=yes,samba_cv_HAVE_UT_UT_PID=no,samba_cv_HAVE_UT_UT_PID=cross)])
 if test x"$samba_cv_HAVE_UT_UT_PID" = x"yes"; then
     AC_DEFINE(HAVE_UT_UT_PID,1,[Whether the utmp struct has a property ut_pid])
-fi 
+fi
 
 AC_CACHE_CHECK([for ut_exit in utmp],samba_cv_HAVE_UT_UT_EXIT,[
 AC_TRY_COMPILE([#include <sys/types.h>
@@ -2290,7 +2425,17 @@ AC_TRY_COMPILE([#include <sys/types.h>
 samba_cv_HAVE_UT_UT_EXIT=yes,samba_cv_HAVE_UT_UT_EXIT=no,samba_cv_HAVE_UT_UT_EXIT=cross)])
 if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
     AC_DEFINE(HAVE_UT_UT_EXIT,1,[Whether the utmp struct has a property ut_exit])
-fi 
+fi
+
+dnl Look for the IPv6 varient by preference. Many systems have both.
+AC_CACHE_CHECK([for ut_addr_v6 in utmp],samba_cv_HAVE_UT_UT_ADDR_V6,[
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <utmp.h>],
+[struct utmp ut;  ut.ut_addr_v6[0] = 0;],
+samba_cv_HAVE_UT_UT_ADDR_V6=yes,samba_cv_HAVE_UT_UT_ADDR_V6=no,samba_cv_HAVE_UT_UT_ADDR_V6=cross)])
+if test x"$samba_cv_HAVE_UT_UT_ADDR_V6" = x"yes"; then
+    AC_DEFINE(HAVE_UT_UT_ADDR_V6,1,[Whether the utmp struct has a property ut_addr_v6])
+fi
 
 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
 AC_TRY_COMPILE([#include <sys/types.h>
@@ -2299,7 +2444,7 @@ AC_TRY_COMPILE([#include <sys/types.h>
 samba_cv_HAVE_UT_UT_ADDR=yes,samba_cv_HAVE_UT_UT_ADDR=no,samba_cv_HAVE_UT_UT_ADDR=cross)])
 if test x"$samba_cv_HAVE_UT_UT_ADDR" = x"yes"; then
     AC_DEFINE(HAVE_UT_UT_ADDR,1,[Whether the utmp struct has a property ut_addr])
-fi 
+fi
 
 if test x$ac_cv_func_pututline = xyes ; then
   AC_CACHE_CHECK([whether pututline returns pointer],samba_cv_PUTUTLINE_RETURNS_UTMP,[
@@ -2319,14 +2464,13 @@ AC_TRY_COMPILE([#include <sys/types.h>
 samba_cv_HAVE_UX_UT_SYSLEN=yes,samba_cv_HAVE_UX_UT_SYSLEN=no,samba_cv_HAVE_UX_UT_SYSLEN=cross)])
 if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
     AC_DEFINE(HAVE_UX_UT_SYSLEN,1,[Whether the utmpx struct has a property ut_syslen])
-fi 
+fi
 
 fi
 # end utmp details
 
 
-ICONV_LOCATION=standard
-LOOK_DIRS="/usr /usr/local /sw /opt"
+ICONV_LOOK_DIRS="/usr /usr/local /sw /opt"
 AC_ARG_WITH(libiconv,
 [  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
 [
@@ -2335,62 +2479,69 @@ AC_ARG_WITH(libiconv,
   else
      if test "$withval" != "yes" ; then
        ICONV_PATH_SPEC=yes
-        LOOK_DIRS="$withval"
+        ICONV_LOOK_DIRS="$withval"
      fi
   fi
 ])
 
-for i in $LOOK_DIRS ; do
-    save_LIBS=$LIBS
-    save_LDFLAGS=$LDFLAGS
-    save_CPPFLAGS=$CPPFLAGS
+for i in $ICONV_LOOK_DIRS ; do
+
+    save_LIBS="$LIBS"
+    save_LDFLAGS="$LDFLAGS"
+    save_CPPFLAGS="$CPPFLAGS"
+
+    iconv_current_LIBS=""
+    iconv_current_LDFLAGS=""
+    iconv_current_CPPFLAGS=""
+
     ICONV_FOUND="no"
     unset libext
-    CPPFLAGS="$CPPFLAGS -I$i/include"
-dnl This is here to handle -withval stuff for --with-libiconv
-dnl Perhaps we should always add a -L
-
-dnl Check lib and lib32 library variants to cater for IRIX ABI-specific
-dnl installation paths. This gets a little tricky since we might have iconv
-dnl in both libiconv and in libc. In this case the jm_ICONV test will always
-dnl succeed when the header is found. To counter this, make sure the 
-dnl library directory is there and check the ABI directory first (which
-dnl should be harmless on other systems.
-dnl For IA64 HPUX systems, the libs are located in lib/hpux32 instead of lib.
+
+    #  This is here to handle -withval stuff for --with-libiconv
+    #  Perhaps we should always add a -L
+    CPPFLAGS="$save_CPPFLAGS -I$i/include"
+
+    # Check lib and lib32 library variants to cater for IRIX ABI-specific
+    # installation paths. This gets a little tricky since we might have iconv
+    # in both libiconv and in libc. In this case the jm_ICONV test will always
+    # succeed when the header is found. To counter this, make sure the
+    # library directory is there and check the ABI directory first (which
+    # should be harmless on other systems.
+    # For IA64 HPUX systems, the libs are located in lib/hpux32 instead of lib.
     for l in "lib32" "lib" "lib/hpux32"; do
         if test -d "$i/$l" ; then
                 LDFLAGS="$save_LDFLAGS -L$i/$l"
-        LIBS=
-        export LDFLAGS LIBS CPPFLAGS
-dnl Try to find iconv(3)
+               LIBS=
+               export LDFLAGS LIBS CPPFLAGS
+               # Try to find iconv(3)
                 jm_ICONV($i/$l)
                 if test x"$ICONV_FOUND" = "xyes" ; then
-            libext="$l"
-            break;
-        fi
+                   libext="$l"
+                   break
+               fi
         fi
     done
 
     if test x"$ICONV_FOUND" = "xyes" ; then
-       LDFLAGS=$save_LDFLAGS
-        LIB_ADD_DIR(LDFLAGS, "$i/$libext")
-        CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
-       LIBS="$save_LIBS"
-        ICONV_LOCATION=$i
-        export LDFLAGS LIBS CPPFLAGS
-dnl Now, check for a working iconv ... we want to do it here because
-dnl there might be a working iconv further down the list of LOOK_DIRS
-
-        ############
-        # check for iconv in libc
-        ic_save_LIBS="$LIBS"
-        if test x"$ICONV_PATH_SPEC" = "xyes" ; then
-           LIBS="$LIBS -L$ICONV_LOCATION/$libext"
-        fi
+       iconv_current_LDFLAGS="-L$i/$libext"
+       iconv_current_CPPFLAGS="-I$i/include"
+
         if test x"$jm_cv_lib_iconv" != x; then
-           LIBS="$LIBS -l$jm_cv_lib_iconv"
+           iconv_current_LIBS="$LIBS -l$jm_cv_lib_iconv"
+       else
+           # We found iconv in libc.
+           iconv_current_LIBS=""
         fi
-dnl        AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
+
+    fi
+
+    if test x"$ICONV_FOUND" = "xyes" ; then
+
+        LDFLAGS="$save_LDFLAGS $iconv_current_LDFLAGS"
+        CPPFLAGS="$save_CPPFLAGS $iconv_current_CPPFLAGS"
+       LIBS="$save_LIBS $iconv_current_LIBS"
+        export LDFLAGS LIBS CPPFLAGS
+
        default_dos_charset=no
        default_display_charset=no
        default_unix_charset=no
@@ -2398,68 +2549,95 @@ dnl        AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
        # check for default dos charset name
        for j in CP850 IBM850 ; do
            rjs_CHARSET($j)
-           if test x"$ICONV_CHARSET" = x"$j"; then
-               default_dos_charset="\"$j\""
+           default_dos_charset="$ICONV_CHARSET"
+           if test x"$default_dos_charset" = x"$j"; then
                break
            fi
        done
+
        # check for default display charset name
        for j in ASCII 646 ; do
            rjs_CHARSET($j)
-           if test x"$ICONV_CHARSET" = x"$j"; then
-               default_display_charset="\"$j\""
+           default_display_charset="$ICONV_CHARSET"
+           if test x"$default_display_charset" = x"$j"; then
                break
            fi
        done
+
        # check for default unix charset name
        for j in UTF-8 UTF8 ; do
            rjs_CHARSET($j)
-           if test x"$ICONV_CHARSET" = x"$j"; then
-               default_unix_charset="\"$j\""
+           default_unix_charset="$ICONV_CHARSET"
+           if test x"$default_unix_charset" = x"$j"; then
                break
            fi
        done
-       
+
        if test "$default_dos_charset" != "no" -a \
                "$default_dos_charset" != "cross" -a \
-               "$default_display_charset" != "no" -a \ 
+               "$default_display_charset" != "no" -a \
                "$default_display_charset" != "cross" -a \
                "$default_unix_charset" != "no" -a \
                "$default_unix_charset" != "cross"
        then
                samba_cv_HAVE_NATIVE_ICONV=yes
-       else if test "$default_dos_charset" = "cross" -o \
+       else
+           if test "$default_dos_charset" = "cross" -o \
                     "$default_display_charset" = "cross" -o \
                     "$default_unix_charset" = "cross"
-       then
-               samba_cv_HAVE_NATIVE_ICONV=cross
-       else
-               samba_cv_HAVE_NATIVE_ICONV=no
+           then
+                   samba_cv_HAVE_NATIVE_ICONV=cross
+           else
+                   samba_cv_HAVE_NATIVE_ICONV=no
+           fi
        fi
+
+       # At this point, we have a libiconv candidate. We know that
+       # we have the right headers and libraries, but we don't know
+       # whether it does the conversions we want. We can't test this
+       # because we are cross-compiling. This is not necessarily a big
+       # deal, since we can't guarantee that the results we get now will
+       # match the results we get at runtime anyway.
+       if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"cross" ; then
+           default_dos_charset="CP850"
+           default_display_charset="ASCII"
+           default_unix_charset="UTF-8"
+           samba_cv_HAVE_NATIVE_ICONV=yes
+           AC_MSG_WARN(assuming the libiconv in $iconv_current_LDFLAGS can convert)
+           AC_MSG_WARN([$default_dos_charset, $default_display_charset and $default_unix_charset to UCS-16LE])
        fi
-dnl ])
-
-        LIBS="$ic_save_LIBS"
-        if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
-          CPPFLAGS=$save_CPPFLAGS
-          LDFLAGS=$save_LDFLAGS
-          LIBS=$save_LIBS
-           if test x"$jm_cv_lib_iconv" != x; then
-              LIBS="$LIBS -l$jm_cv_lib_iconv"
-           fi
-          dnl Add the flags we need to CPPFLAGS and LDFLAGS
-          CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
-          LIB_ADD_DIR(LDFLAGS, "$i/$libext")
-          export CPPFLAGS
-           AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
-          AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
-          AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name])
-          AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name])
+
+        if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes" ; then
+
+           CPPFLAGS=$save_CPPFLAGS
+           LDFLAGS=$save_LDFLAGS
+           LIBS=$save_LIBS
+
+           if test x"$iconv_current_LIBS" != x; then
+               LIBS="$LIBS $iconv_current_LIBS"
+           fi
+
+           # Add the flags we need to CPPFLAGS and LDFLAGS
+           CPPFLAGS="$CPPFLAGS $iconv_current_CPPFLAGS"
+           LDFLAGS="$LDFLAGS $iconv_current_LDFLAGS"
+
+           # Turn the #defines into string literals
+           default_dos_charset="\"$default_dos_charset\""
+           default_display_charset="\"$default_display_charset\""
+           default_unix_charset="\"$default_unix_charset\""
+
+           AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
+           AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
+           AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,$default_display_charset,[Default display charset name])
+           AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,$default_unix_charset,[Default unix charset name])
+
            break
         fi
-dnl We didn't find a working iconv, so keep going
+
+    # We didn't find a working iconv, so keep going
     fi
-dnl We only need to clean these up here for the next pass through the loop
+
+    #  We only need to clean these up here for the next pass through the loop
     CPPFLAGS=$save_CPPFLAGS
     LDFLAGS=$save_LDFLAGS
     LIBS=$save_LIBS
@@ -2469,7 +2647,7 @@ unset libext
 
 
 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
-    AC_MSG_WARN([Sufficient support for iconv function was not found. 
+    AC_MSG_WARN([Sufficient support for iconv function was not found.
     Install libiconv from http://freshmeat.net/projects/libiconv/ for better charset compatibility!])
    AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,"ASCII",[Default dos charset name])
    AC_DEFINE_UNQUOTED(DEFAULT_DISPLAY_CHARSET,"ASCII",[Default display charset name])
@@ -2511,6 +2689,19 @@ if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
 fi
 
+AC_CACHE_CHECK([for inotify support],samba_cv_HAVE_INOTIFY,[
+AC_CHECK_HEADERS(linux/inotify.h asm/unistd.h)
+AC_CHECK_FUNC(inotify_init)
+AC_HAVE_DECL(__NR_inotify_init, [#include <asm/unistd.h>])
+],
+samba_cv_HAVE_INOTIFY=yes,
+samba_cv_HAVE_INOTIFY=no,
+samba_cv_HAVE_INOTIFY=cross)
+
+if test x"$ac_cv_func_inotify_init" = x"yes" -a x"$ac_cv_header_linux_inotify_h" = x"yes"; then
+    AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has inotify support])
+fi
+
 #################################################
 # Check if FAM notifications are available. For FAM info, see
 #      http://oss.sgi.com/projects/fam/
@@ -2524,21 +2715,20 @@ if test x$enable_fam != xno; then
         # On IRIX, libfam requires libC, but other FAM implementations
        # might not need it.
         AC_CHECK_LIB(fam, FAMOpen2,
-            [samba_cv_HAVE_LIBFAM=yes; samba_fam_libs="-lfam"],
+            [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam"],
             [samba_cv_HAVE_LIBFAM=no])
 
         if test x"$samba_cv_HAVE_LIBFAM" = x"no" ; then
             samba_fam_xtra=-lC
             AC_CHECK_LIB_EXT(fam, samba_fam_xtra, FAMOpen2,
-                [samba_cv_HAVE_LIBFAM=yes; samba_fam_libs="-lfam -lC"],
+                [samba_cv_HAVE_LIBFAM=yes; SMB_FAM_LIBS="-lfam -lC"],
                 [samba_cv_HAVE_LIBFAM=no])
             unset samba_fam_xtra
         fi
     fi
 
     if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
-        AC_DEFINE(HAVE_FAM_CHANGE_NOTIFY, 1,
-                [Whether FAM file notifications are available])
+        default_shared_modules="$default_shared_modules vfs_notify_fam"
         AC_TRY_COMPILE([#include <fam.h>],
                     [FAMCodes code = FAMChanged;],
                     AC_DEFINE(HAVE_FAM_H_FAMCODES_TYPEDEF, 1,
@@ -2551,6 +2741,8 @@ if test x$enable_fam != xno; then
     fi
 fi
 
+AC_SUBST(SMB_FAM_LIBS)
+
 #################################################
 # Check for DMAPI interfaces in libdm/libjfsdm/libxsdm
 
@@ -2733,10 +2925,10 @@ AC_TRY_RUN([#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-main() { 
+main() {
   struct stat st;
-  char tpl[20]="/tmp/test.XXXXXX"; 
-  int fd = mkstemp(tpl); 
+  char tpl[20]="/tmp/test.XXXXXX";
+  int fd = mkstemp(tpl);
   if (fd == -1) exit(1);
   unlink(tpl);
   if (fstat(fd, &st) != 0) exit(1);
@@ -2774,21 +2966,42 @@ SMB_CHECK_SYSCONF(_SC_NPROCESSORS_ONLN)
 SMB_CHECK_SYSCONF(_SC_PAGESIZE)
 AC_CHECK_FUNCS(getpagesize)
 
+dnl test for getifaddrs and freeifaddrs
+AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[
+AC_TRY_COMPILE([
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <ifaddrs.h>
+#include <netdb.h>],
+[
+struct ifaddrs *ifp = NULL;
+int ret = getifaddrs (&ifp);
+freeifaddrs(ifp);
+],
+samba_cv_HAVE_GETIFADDRS=yes,samba_cv_HAVE_GETIFADDRS=no)])
+if test x"$samba_cv_HAVE_GETIFADDRS" = x"yes"; then
+    AC_DEFINE(HAVE_GETIFADDRS,1,[Whether the system has getifaddrs])
+    AC_DEFINE(HAVE_FREEIFADDRS,1,[Whether the system has freeifaddrs])
+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,[
+AC_CACHE_CHECK([for iface getifaddrs],samba_cv_HAVE_IFACE_GETIFADDRS,[
 SAVE_CPPFLAGS="$CPPFLAGS"
 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
 AC_TRY_RUN([
-#define HAVE_IFACE_AIX 1
+#define NO_CONFIG_H 1
+#define HAVE_IFACE_GETIFADDRS 1
 #define AUTOCONF_TEST 1
-#undef _XOPEN_SOURCE_EXTENDED
+#include "${srcdir-.}/lib/replace/replace.c"
 #include "${srcdir-.}/lib/interfaces.c"],
-           samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
+           samba_cv_HAVE_IFACE_GETIFADDRS=yes,samba_cv_HAVE_IFACE_GETIFADDRS=no,samba_cv_HAVE_IFACE_GETIFADDRS=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])
+if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then
+    iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available])
 fi
 
 if test $iface = no; then
@@ -2796,8 +3009,10 @@ AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
 SAVE_CPPFLAGS="$CPPFLAGS"
 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
 AC_TRY_RUN([
+#define NO_CONFIG_H 1
 #define HAVE_IFACE_IFCONF 1
 #define AUTOCONF_TEST 1
+#include "${srcdir-.}/lib/replace/replace.c"
 #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"
@@ -2811,8 +3026,10 @@ AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
 SAVE_CPPFLAGS="$CPPFLAGS"
 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
 AC_TRY_RUN([
+#define NO_CONFIG_H 1
 #define HAVE_IFACE_IFREQ 1
 #define AUTOCONF_TEST 1
+#include "${srcdir-.}/lib/replace/replace.c"
 #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"
@@ -2821,6 +3038,46 @@ if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
 fi
 fi
 
+if test $iface = no; then
+AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
+SAVE_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
+AC_TRY_RUN([
+#define NO_CONFIG_H 1
+#define HAVE_IFACE_AIX 1
+#define AUTOCONF_TEST 1
+#undef _XOPEN_SOURCE_EXTENDED
+#include "${srcdir-.}/lib/replace/replace.c"
+#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
+fi
+
+dnl test for ipv6
+AC_CACHE_CHECK([for ipv6 support],samba_cv_HAVE_IPV6,[
+AC_TRY_COMPILE([
+#include <stdlib.h> /* for NULL */
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netdb.h>],
+[
+struct sockaddr_storage sa_store;
+struct addrinfo *ai = NULL;
+struct in6_addr in6addr;
+int s = socket(AF_INET6, SOCK_STREAM, 0);
+int ret = getaddrinfo(NULL, NULL, NULL, &ai);
+if (ret != 0) {
+       const char *es = gai_strerror(ret);
+}
+freeaddrinfo(ai);
+],
+samba_cv_HAVE_IPV6=yes,samba_cv_HAVE_IPV6=no)])
+if test x"$samba_cv_HAVE_IPV6" = x"yes"; then
+    AC_DEFINE(HAVE_IPV6,1,[Whether the system has IPv6 support])
+fi
 
 ################################################
 # look for a method of setting the effective uid
@@ -2878,6 +3135,21 @@ if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
 fi
 fi
 
+AC_CACHE_CHECK([for the Darwin initgroups system call],
+       samba_cv_DARWIN_INITGROUPS,
+       AC_TRY_LINK([
+#include <sys/syscall.h>
+#include <unistd.h>
+       ],
+       [ syscall(SYS_initgroups, 16, NULL, NULL, 0); ],
+       samba_cv_DARWIN_INITGROUPS=yes,
+       samba_cv_DARWIN_INITGROUPS=no)
+)
+
+if test x"$samba_cv_DARWIN_INITGROUPS" = x"yes" ; then
+    AC_DEFINE(HAVE_DARWIN_INITGROUPS, 1,
+       [Whether to use the Darwin-specific initgroups system call])
+fi
 
 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
 AC_TRY_RUN([#include "${srcdir-.}/tests/shared_mmap.c"],
@@ -2904,7 +3176,7 @@ else
 dnl
 dnl Don't check for 64 bit fcntl locking if we know that the
 dnl glibc2.1 broken check has succeeded.
-dnl 
+dnl
 
   AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
   AC_TRY_RUN([
@@ -2943,7 +3215,7 @@ AC_TRY_COMPILE([#include <sys/types.h>
 samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
 if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
     AC_DEFINE(HAVE_STAT_ST_BLOCKS,1,[Whether the stat struct has a st_block property])
-fi 
+fi
 
 AC_CACHE_CHECK([for st_blksize in struct stat],samba_cv_HAVE_STAT_ST_BLKSIZE,[
 AC_TRY_COMPILE([#include <sys/types.h>
@@ -2955,23 +3227,22 @@ if test x"$samba_cv_HAVE_STAT_ST_BLKSIZE" = x"yes"; then
     AC_DEFINE(HAVE_STAT_ST_BLKSIZE,1,[Whether the stat struct has a st_blksize property])
 fi
 
-case "$host_os" in
-*linux*)
-AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
-AC_TRY_COMPILE([
-#ifdef HAVE_SYS_VFS_H
-#include <sys/vfs.h>
-#endif
-#ifdef HAVE_SYS_CAPABILITY_H
-#include <sys/capability.h>
-#endif
-],[int i;],
-   samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
-if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
-   AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files])
+AC_CACHE_CHECK([for st_flags in struct stat],
+       samba_cv_HAVE_STAT_ST_FLAGS,
+       [
+           AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>],
+           [struct stat st;  st.st_flags = 0;],
+           samba_cv_HAVE_STAT_ST_FLAGS=yes,
+           samba_cv_HAVE_STAT_ST_FLAGS=no,
+           samba_cv_HAVE_STAT_ST_FLAGS=cross)
+       ])
+
+if test x"$samba_cv_HAVE_STAT_ST_FLAGS" = x"yes"; then
+    AC_DEFINE(HAVE_STAT_ST_FLAGS, 1,
+               [Whether the stat struct has a st_flags member])
 fi
-;;
-esac
 
 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
 AC_TRY_COMPILE([
@@ -3050,7 +3321,7 @@ if test x"$samba_cv_WITH_AFS" != x"no" ||
     else
       AC_MSG_RESULT(no)
     fi
-   
+
     # check for afs.h
     have_afs_headers=no
     AC_CHECK_HEADERS(afs.h afs/afs.h)
@@ -3142,7 +3413,7 @@ if test x"$with_ldap_support" != x"no"; then
   # first test for ldap.h and lber.h
   # (ldap.h is required for this test)
   AC_CHECK_HEADERS(ldap.h lber.h)
-  
+
   if test x"$ac_cv_header_ldap_h" != x"yes"; then
        if test x"$with_ldap_support" = x"yes"; then
         AC_MSG_ERROR(ldap.h is needed for LDAP support)
@@ -3154,16 +3425,26 @@ if test x"$with_ldap_support" != x"no"; then
   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
+  # HP/UX does not have ber_tag_t in lber.h - it must be configured as
+  # unsigned int in include/includes.h
+  case $host_os in
+       *hpux*)
         AC_MSG_WARN(ber_tag_t is needed for LDAP support)
-       fi
-       with_ldap_support=no
-  fi
+        AC_MSG_WARN(ber_tag_t must be configured in includes.h for hpux)
+       with_ldap_support=yes
+       ;;
+       *)
+       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
+       ;;
+  esac
 fi
 
 if test x"$with_ldap_support" != x"no"; then
@@ -3174,6 +3455,22 @@ if test x"$with_ldap_support" != x"no"; then
   # this test must be before the libldap test
   AC_CHECK_LIB_EXT(lber, LDAP_LIBS, ber_scanf)
 
+  ########################################################
+  # If ber_sockbuf_add_io() is available we can add
+  # SASL wrapping hooks
+  AC_CHECK_FUNC_EXT(ber_sockbuf_add_io,$LDAP_LIBS)
+
+  AC_CACHE_CHECK([for LDAP_OPT_SOCKBUF],samba_cv_HAVE_LDAP_OPT_SOCKBUF,[
+                AC_TRY_COMPILE([#include <ldap.h>],
+                               [int val = LDAP_OPT_SOCKBUF;],
+                       samba_cv_HAVE_LDAP_OPT_SOCKBUF=yes,
+                       samba_cv_HAVE_LDAP_OPT_SOCKBUF=no)])
+
+  if test x"$ac_cv_func_ext_ber_sockbuf_add_io" = x"yes" -a \
+         x"$samba_cv_HAVE_LDAP_OPT_SOCKBUF" = x"yes"; then
+       AC_DEFINE(HAVE_LDAP_SASL_WRAPPING, 1, [Support for SASL wrapping])
+  fi
+
   ########################################################
   # now see if we can find the ldap libs in standard paths
   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
@@ -3187,18 +3484,17 @@ if test x"$with_ldap_support" != x"no"; then
   AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, smb_ldap_cv_ldap_set_rebind_proc, [
     AC_TRY_COMPILE([
        #include <lber.h>
-       #include <ldap.h>], 
-       [ldap_set_rebind_proc(0, 0, 0);], 
-       [smb_ldap_cv_ldap_set_rebind_proc=3], 
+       #include <ldap.h>],
+       [ldap_set_rebind_proc(0, 0, 0);],
+       [smb_ldap_cv_ldap_set_rebind_proc=3],
        [smb_ldap_cv_ldap_set_rebind_proc=2]
-    ) 
+    )
   ])
-  
+
   AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
 
-  AC_CHECK_FUNC_EXT(ldap_dn2ad_canonical,$LDAP_LIBS)   
   AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
-  
+
   if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes"; then
     AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
     CPPFLAGS="$CPPFLAGS -DLDAP_DEPRECATED"
@@ -3206,12 +3502,6 @@ if test x"$with_ldap_support" != x"no"; then
     default_shared_modules="$default_shared_modules";
     SMBLDAP="lib/smbldap.o"
     SMBLDAPUTIL="lib/smbldap_util.o"
-    if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
-      AC_MSG_WARN(Disabling ldb_ldap support (requires ldap_initialize))
-    else
-      AC_DEFINE(HAVE_LDB_LDAP,1,[Whether ldb_ldap is available])
-      LDBLDAP="lib/ldb/ldb_ldap/ldb_ldap.o"
-    fi
     with_ldap_support=yes
     AC_MSG_CHECKING(whether LDAP support is used)
     AC_MSG_RESULT(yes)
@@ -3221,7 +3511,7 @@ if test x"$with_ldap_support" != x"no"; then
     else
        AC_MSG_WARN(libldap is needed for LDAP support)
     fi
-    
+
     LDAP_LIBS=""
     with_ldap_support=no
   fi
@@ -3262,6 +3552,21 @@ else
     # Check to see whether there is enough LDAP functionality to be able
     # to build AD support.
 
+# HPUX only has ldap_init; ok, we take care of this in smbldap.c
+case "$host_os" in
+       *hpux*)
+    AC_CHECK_FUNC_EXT(ldap_init,$LDAP_LIBS)
+
+    if test x"$ac_cv_func_ext_ldap_init" != x"yes"; then
+       if test x"$with_ads_support" = x"yes"; then
+           AC_MSG_ERROR(Active Directory support on HPUX requires ldap_init)
+       elif test x"$with_ads_support" = x"auto"; then
+           AC_MSG_WARN(Disabling Active Directory support (requires ldap_init on HPUX))
+           with_ads_support=no
+       fi
+    fi
+    ;;
+       *)
     AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
 
     if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
@@ -3272,6 +3577,9 @@ else
            with_ads_support=no
        fi
     fi
+    ;;
+esac
+
 
     AC_CHECK_FUNC_EXT(ldap_add_result_entry,$LDAP_LIBS)
 
@@ -3290,7 +3598,7 @@ if test x"$with_ads_support" != x"no"; then
 
   # Do no harm to the values of CFLAGS and LIBS while testing for
   # Kerberos support.
+
   if test x$FOUND_KRB5 = x"no"; then
     #################################################
     # check for location of Kerberos 5 install
@@ -3331,7 +3639,7 @@ if test x"$with_ads_support" != x"no"; then
     LDFLAGS="";export LDFLAGS
     KRB5_LIBS="`$KRB5CONFIG --libs gssapi`"
     KRB5_LDFLAGS="`$KRB5CONFIG --libs gssapi | sed s/-lgss.*//`"
-    KRB5_CFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`" 
+    KRB5_CFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
     KRB5_CPPFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
     CFLAGS=$ac_save_CFLAGS;export CFLAGS
     LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
@@ -3340,7 +3648,7 @@ if test x"$with_ads_support" != x"no"; then
   else
     AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
   fi
+
   if test x$FOUND_KRB5 = x"no"; then
     #################################################
     # see if this box has the SuSE location for the heimdal krb implementation
@@ -3350,10 +3658,12 @@ if test x"$with_ads_support" != x"no"; then
           KRB5_CFLAGS="-I/usr/include/heimdal"
           KRB5_CPPFLAGS="-I/usr/include/heimdal"
           KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
+         FOUND_KRB5=yes
           AC_MSG_RESULT(yes)
       else
           KRB5_CFLAGS="-I/usr/include/heimdal"
           KRB5_CPPFLAGS="-I/usr/include/heimdal"
+         FOUND_KRB5=yes
           AC_MSG_RESULT(yes)
       fi
     else
@@ -3369,6 +3679,21 @@ if test x"$with_ads_support" != x"no"; then
       KRB5_LDFLAGS="-L/usr/kerberos/lib"
       KRB5_CFLAGS="-I/usr/kerberos/include"
       KRB5_CPPFLAGS="-I/usr/kerberos/include"
+      FOUND_KRB5=yes
+      AC_MSG_RESULT(yes)
+    else
+      AC_MSG_RESULT(no)
+    fi
+  fi
+
+  if test x$FOUND_KRB5 = x"no"; then
+    #################################################
+    # see if this box has the OpenBSD location for heimdal krb5
+    AC_MSG_CHECKING(for /usr/include/kerberosV)
+    if test -d /usr/include/kerberosV; then
+      KRB5_CPPFLAGS="-I/usr/include/kerberosV"
+      KRB5_LIBS="-lcrypto"
+      FOUND_KRB5=yes
       AC_MSG_RESULT(yes)
     else
       AC_MSG_RESULT(no)
@@ -3404,11 +3729,16 @@ if test x"$with_ads_support" != x"no"; then
     # Turn off AD support and restore CFLAGS and LIBS variables
 
     with_ads_support="no"
-    
+
     CFLAGS=$ac_save_CFLAGS
     CPPFLAGS=$ac_save_CPPFLAGS
     LDFLAGS=$ac_save_LDFLAGS
   fi
+  AC_CHECK_HEADERS(krb5/locate_plugin.h)
+  if test x"$ac_cv_header_krb5_locate_plugin_h" = x"yes"; then
+       WINBIND_KRB5_LOCATOR="bin/winbind_krb5_locator.$SHLIBEXT"
+       EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WINBIND_KRB5_LOCATOR"
+  fi
 fi
 
 # Now we have determined whether we really want ADS support
@@ -3453,14 +3783,14 @@ if test x"$with_ads_support" != x"no"; then
   AC_CHECK_FUNC_EXT(krb5_set_default_tgs_ktypes, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_principal2salt, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_use_enctype, $KRB5_LIBS)
-  AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS) 
+  AC_CHECK_FUNC_EXT(krb5_string_to_key, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_get_pw_salt, $KRB5_LIBS)
-  AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS) 
+  AC_CHECK_FUNC_EXT(krb5_string_to_key_salt, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_auth_con_setkey, $KRB5_LIBS)
-  AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS) 
+  AC_CHECK_FUNC_EXT(krb5_auth_con_setuseruserkey, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_locate_kdc, $KRB5_LIBS)
-  AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS) 
-  AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS) 
+  AC_CHECK_FUNC_EXT(krb5_get_permitted_enctypes, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_get_default_in_tkt_etypes, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_free_data_contents, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_free_unparsed_name, $KRB5_LIBS)
@@ -3474,6 +3804,7 @@ if test x"$with_ads_support" != x"no"; then
   AC_CHECK_FUNC_EXT(krb5_crypto_destroy, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_decode_ap_req, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(free_AP_REQ, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_verify_checksum, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_c_verify_checksum, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_principal_compare_any_realm, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_parse_name_norealm, $KRB5_LIBS)
@@ -3483,6 +3814,10 @@ if test x"$with_ads_support" != x"no"; then
   AC_CHECK_FUNC_EXT(krb5_get_kdc_cred, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_free_error_contents, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(initialize_krb5_error_table, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_alloc, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_free, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_get_error, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_enctype_to_string, $KRB5_LIBS)
 
   LIBS="$KRB5_LIBS $LIBS"
 
@@ -3510,13 +3845,33 @@ if test x"$with_ads_support" != x"no"; then
            [Whether the krb5_ticket structure contains the kvno and enctype])
   fi
 
+  AC_CACHE_CHECK(whether krb5_get_init_creds_opt_free takes a context argument,
+         smb_krb5_creds_opt_free_context,
+         [
+               AC_TRY_COMPILE([
+                   #include <krb5.h>],
+                   [
+                       krb5_context ctx;
+                       krb5_get_init_creds_opt *opt = NULL;
+                       krb5_get_init_creds_opt_free(ctx, opt);
+                   ],
+                   [smb_krb5_creds_opt_free_context=yes],
+                   [smb_krb5_creds_opt_free_context=no]
+               )
+         ])
+
+  if test x"$smb_krb5_creds_opt_free_context" = x"yes" ; then
+       AC_DEFINE(KRB5_CREDS_OPT_FREE_REQUIRES_CONTEXT, 1,
+           [Whether krb5_get_init_creds_opt_free takes a context argument])
+  fi
+
   AC_CACHE_CHECK(whether krb5_verify_checksum takes 7 arguments, smb_krb5_verify_checksum, [
     AC_TRY_COMPILE([
-       #include <krb5.h>], 
-       [krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);], 
-       [smb_krb5_verify_checksum=7], 
-       [smb_krb5_verify_checksum=6], 
-    ) 
+       #include <krb5.h>],
+       [krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);],
+       [smb_krb5_verify_checksum=7],
+       [smb_krb5_verify_checksum=6],
+    )
   ])
   AC_DEFINE_UNQUOTED(KRB5_VERIFY_CHECKSUM_ARGS, $smb_krb5_verify_checksum, [Number of arguments to krb5_verify_checksum])
 
@@ -3616,7 +3971,7 @@ if test x"$with_ads_support" != x"no"; then
               [Whether the krb5_address struct has a addr_type property])
   fi
 
-  AC_CACHE_CHECK([for enc_part2 in krb5_ticket], 
+  AC_CACHE_CHECK([for enc_part2 in krb5_ticket],
                 samba_cv_HAVE_KRB5_TKT_ENC_PART2,
                  [AC_TRY_COMPILE([#include <krb5.h>],
     [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
@@ -3718,7 +4073,7 @@ if test x"$with_ads_support" != x"no"; then
     AC_DEFINE(HAVE_KRB5_KU_OTHER_CKSUM,1,
               [Whether KRB5_KU_OTHER_CKSUM is available])
   fi
-  
+
   AC_CACHE_CHECK([for KRB5_KEYUSAGE_APP_DATA_CKSUM],
                  samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,[
     AC_TRY_COMPILE([#include <krb5.h>],
@@ -3826,10 +4181,87 @@ if test x"$with_ads_support" != x"no"; then
                [Whether the type krb5_addresses type exists])
   fi
 
+  AC_CACHE_CHECK([whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal],
+               samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE, [
+    AC_TRY_COMPILE([#include <krb5.h>],
+    [
+    krb5_mk_error(0,0,0);],
+    samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE=yes,
+    samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE=no)])
+
+  if test x"$samba_cv_HAVE_SHORT_KRB5_MK_ERROR_INTERFACE" = x"yes"; then
+    AC_DEFINE(HAVE_SHORT_KRB5_MK_ERROR_INTERFACE,1,
+              [whether krb5_mk_error takes 3 arguments MIT or 9 Heimdal])
+  fi
+
+  if test x"$ac_cv_func_ext_krb5_enctype_to_string" = x"yes"; then
+    AC_CACHE_CHECK([for krb5_error_code krb5_enctype_to_string(krb5_context context, krb5_enctype enctype, char **str)],
+        smb_krb5_enctype_to_string_takes_krb5_context_arg,[
+       AC_TRY_RUN_STRICT([
+               #include <krb5.h>
+               int main(void) {
+                       krb5_context context = NULL;
+                       char *str = NULL;
+                       krb5_enctype_to_string(context, 1, &str);
+                       if (str) free (str); 
+                       return 0;
+               }
+               ],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
+               smb_krb5_enctype_to_string_takes_krb5_context_arg=yes,
+               smb_krb5_enctype_to_string_takes_krb5_context_arg=no)])
+
+    if test x"$smb_krb5_enctype_to_string_takes_krb5_context_arg" = x"yes"; then
+      AC_DEFINE(HAVE_KRB5_ENCTYPE_TO_STRING_WITH_KRB5_CONTEXT_ARG,1,
+                [whether krb5_enctype_to_string takes krb5_context argument])
+    fi
+
+    AC_CACHE_CHECK([for krb5_error_code krb5_enctype_to_string(krb5_enctype enctype, char *str, size_t len)],
+        smb_krb5_enctype_to_string_takes_size_t_arg,[
+       AC_TRY_RUN_STRICT([
+               #include <krb5.h>
+               int main(void) {
+                       char buf[256];
+                       krb5_enctype_to_string(1, buf, 256);
+                       return 0;
+               }
+               ],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
+               smb_krb5_enctype_to_string_takes_size_t_arg=yes,
+               smb_krb5_enctype_to_string_takes_size_t_arg=no)])
+
+    if test x"$smb_krb5_enctype_to_string_takes_size_t_arg" = x"yes"; then
+      AC_DEFINE(HAVE_KRB5_ENCTYPE_TO_STRING_WITH_SIZE_T_ARG,1,
+                [whether krb5_enctype_to_string takes size_t argument])
+    fi
+  fi
+
+  AC_CACHE_CHECK([for krb5_principal_get_realm],
+                samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM,[
+    AC_TRY_LINK([#include <krb5.h>],
+      [krb5_context ctx = NULL; krb5_principal princ = NULL; const char *str = krb5_principal_get_realm(ctx, princ);],
+      samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM=yes,
+      samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_PRINCIPAL_GET_REALM,1,
+               [Whether the function krb5_principal_get_realm is defined])
+  fi
+
+  AC_CACHE_CHECK([for krb5_princ_realm],
+                samba_cv_HAVE_KRB5_PRINC_REALM,[
+    AC_TRY_LINK([#include <krb5.h>],
+      [krb5_context ctx = NULL; krb5_principal princ = NULL; const char *str = krb5_princ_realm(ctx, princ)->data;],
+      samba_cv_HAVE_KRB5_PRINC_REALM=yes,
+      samba_cv_HAVE_KRB5_PRINC_REALM=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_PRINC_REALM" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_PRINC_REALM,1,
+               [Whether the macro krb5_princ_realm is defined])
+  fi
+
   #
   #
   # Now the decisions whether we can support krb5
-  # 
+  #
   # NOTE: all tests should be done before this block!
   #
   #
@@ -3902,7 +4334,7 @@ if test x"$with_ads_support" != x"no"; then
     AC_REMOVE_DEFINE(HAVE_GSSAPI_GSSAPI_GENERIC_H)
     AC_REMOVE_DEFINE(HAVE_GSSAPI_GSSAPI_H)
     KRB5_LIBS=""
-    with_ads_support=no 
+    with_ads_support=no
   fi
   AC_MSG_CHECKING(whether Active Directory and krb5 support is used)
   AC_MSG_RESULT([$use_ads])
@@ -3942,7 +4374,7 @@ if test x"$with_dnsupdate_support" != x"no"; then
   # 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)
@@ -3954,29 +4386,33 @@ if test x"$with_dnsupdate_support" != x"no"; then
 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
+  # Now see if we can find the uuid libs in standard paths
+  # On some systems, the uuid API is in libc, so we have to
+  # be careful not to insert a spurious -luuid.
+
+  UUID_LIBS=""
+  AC_LIBTESTFUNC(uuid, uuid_generate,
+         [
+           case " $LIBS " in
+               *\ -luuid\ *)
+               UUID_LIBS="-luuid"
+               SMB_REMOVE_LIB(uuid)
+               ;;
+           esac
+
+           with_dnsupdate_support=yes
+           AC_DEFINE(WITH_DNS_UPDATES,1,[Whether to enable DNS Update support])
+       ],
+       [
+           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
+           with_dnsupdate_support=no
+       ])
 fi
 
 #################################################
@@ -4007,7 +4443,7 @@ AC_ARG_WITH(smbmount,
        *linux*)
                AC_MSG_RESULT(yes)
                AC_DEFINE(WITH_SMBMOUNT,1,[Whether to build smbmount])
-               EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbmount bin/smbmnt bin/smbumount"
+               SMBMOUNT_PROGS="bin/smbmount bin/smbmnt bin/smbumount"
                ;;
        *)
                AC_MSG_ERROR(not on a linux system!)
@@ -4062,9 +4498,52 @@ AC_ARG_WITH(cifsmount,
   esac ]
 )
 
+#################################################
+# check for cifs.spnego support
+AC_CHECK_HEADERS([keyutils.h], [HAVE_KEYUTILS_H=1], [HAVE_KEYUTILS_H=0])
+CIFSSPNEGO_PROGS=""
+INSTALL_CIFSSPNEGO=""
+UNINSTALL_CIFSSPNEGO=""
+AC_MSG_CHECKING(whether to build cifs.spnego)
+AC_ARG_WITH(cifsspnego,
+[  --with-cifsspnego       Include cifs.spnego (Linux only) support (default=no)],
+[ case "$withval" in
+  no)
+       AC_MSG_RESULT(no)
+       ;;
+  *)
+       case "$host_os" in
+       *linux*)
+               if test x"$use_ads" != x"yes"; then
+                       AC_MSG_ERROR(ADS support should be enabled for building cifs.spnego)
+               elif test x"$HAVE_KEYUTILS_H" != "x1"; then
+                       AC_MSG_ERROR(keyutils package is required for cifs.spnego)
+               else
+                       AC_MSG_RESULT(yes)
+                       AC_DEFINE(WITH_CIFSSPNEGO,1,[whether to build cifs.spnego])
+                       CIFSSPNEGO_PROGS="bin/cifs.spnego"
+                       INSTALL_CIFSSPNEGO="installcifsspnego"
+                       UNINSTALL_CIFSSPNEGO="uninstallcifsspnego"
+               fi
+               ;;
+       *)
+               AC_MSG_ERROR(not on a linux system!)
+               ;;
+       esac
+    ;;
+  esac ],
+[
+  AC_MSG_RESULT(no)
+  ]
+)
+
 
 #################################################
-# check for a PAM clear-text auth, accounts, password and session support
+# Check for a PAM clear-text auth, accounts, password
+# and session support. Most PAM implementations keep their
+# headers in /usr/include/security. Darwin keeps its in
+# /usr/include/pam.
+
 with_pam_for_crypt=no
 try_pam=no
 AC_MSG_CHECKING(whether to try PAM support)
@@ -4084,10 +4563,13 @@ if test x"${try_pam}" != x"no";then
        use_pam=yes
        create_pam_modules=yes
 
-       AC_CHECK_HEADERS(security/pam_appl.h)
-       if test x"$ac_cv_header_security_pam_appl_h" != x"yes"; then
+       # Most systems have PAM headers in /usr/include/security, but Darwin
+       # has them in /usr/include/pam.
+       AC_CHECK_HEADERS(security/pam_appl.h pam/pam_appl.h)
+       if test x"$ac_cv_header_security_pam_appl_h" != x"yes" -a \
+               x"$ac_cv_header_pam_pam_appl_h" != x"yes"; then
                if test x"${try_pam}" = x"yes";then
-                       AC_MSG_ERROR([--with-pam=yes but security/pam_appl.h not found])
+                       AC_MSG_ERROR([--with-pam=yes but pam_appl.h not found])
                fi
                use_pam=no
                create_pam_modules=no
@@ -4102,29 +4584,34 @@ if test x"${try_pam}" != x"no";then
                create_pam_modules=no
        fi
 
-       AC_CHECK_HEADERS(security/pam_modules.h,,,[[
+       AC_CHECK_HEADERS(security/pam_modules.h pam/pam_modules.h,,,[[
                #if HAVE_SECURITY_PAM_APPL_H
                #include <security/pam_appl.h>
                #endif
+               #if HAVE_PAM_PAM_APPL_H
+               #include <pam/pam_appl.h>
+               #endif
        ]])
-       if test x"$ac_cv_header_security_pam_modules_h" = x"no"; then
+       if test x"$ac_cv_header_security_pam_modules_h" = x"no" -a \
+               x"$ac_cv_header_pam_pam_modules_h" = x"no" ; then
                if test x"${try_pam}" = x"yes";then
-                       AC_MSG_ERROR([--with-pam=yes but security/pam_modules.h not found])
-               fi
+                       AC_MSG_ERROR([--with-pam=yes but pam_modules.h not found])
+       fi
                create_pam_modules=no
-       fi
+    fi
 
        if test x"$use_pam" = x"yes"; then
-               AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
+    AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
                AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])
                AUTH_LIBS="$AUTH_LIBS $PAM_LIBS"
-               with_pam_for_crypt=yes
+    with_pam_for_crypt=yes
 
                if test x"$create_pam_modules" = x"yes"; then
                        AC_DEFINE(WITH_PAM_MODULES,1,[Whether to include PAM MODULES support])
                        # this checks are optional,
                        # we don't care about the results here
                        AC_CHECK_HEADERS(security/pam_ext.h security/_pam_macros.h)
+                       AC_CHECK_HEADERS(pam/pam_ext.h pam/_pam_macros.h)
                        AC_CHECK_FUNC_EXT(pam_vsyslog,$PAM_LIBS)
                else
                        AC_MSG_WARN([PAM support detected but PAM MODULES support is missing])          
@@ -4194,7 +4681,7 @@ fi
 fi
 
 #################################################
-# check for a NISPLUS_HOME support 
+# check for a NISPLUS_HOME support
 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
 AC_ARG_WITH(nisplus-home,
 [  --with-nisplus-home     Include NISPLUS_HOME support (default=no)],
@@ -4348,6 +4835,9 @@ AC_CHECK_HEADER(asm/types.h,[
 # For quotas on Veritas VxFS filesystems
 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
 
+# For quotas on Linux XFS filesystems
+AC_CHECK_HEADERS(linux/dqblk_xfs.h)
+
 # For sys/quota.h and linux/quota.h
 AC_CHECK_HEADERS(sys/quota.h)
 
@@ -4370,7 +4860,7 @@ if test "$samba_cv_HAVE_SYS_QUOTA_XFS"x = "yes"x; then
 fi
 fi
 
-# if we have struct dqblk .dqb_fsoftlimit instead of .dqb_isoftlimit on IRIX 
+# if we have struct dqblk .dqb_fsoftlimit instead of .dqb_isoftlimit on IRIX
 AC_CACHE_CHECK([if struct dqblk has .dqb_fsoftlimit],samba_cv_HAVE_DQB_FSOFTLIMIT, [
 AC_TRY_COMPILE([
 #include "confdefs.h"
@@ -4451,13 +4941,13 @@ AC_CHECK_FUNCS(devnm)
 
 if test x"$samba_cv_WITH_SYS_QUOTAS" = x"yes"; then
     if test x"$samba_cv_SYSQUOTA_FOUND" != x"yes"; then
-       # if --with-sys-quotas=yes then build it 
+       # if --with-sys-quotas=yes then build it
        # you have can use the get/set quota command smb.conf
        # options then
        samba_cv_SYSQUOTA_FOUND=auto
     fi
     if test x"$samba_cv_TRY_SYS_QUOTAS" != x"yes"; then
-       # if --with-sys-quotas=yes then build it 
+       # if --with-sys-quotas=yes then build it
        # you have can use the get/set quota command smb.conf
        # options then
        samba_cv_TRY_SYS_QUOTAS=auto
@@ -4480,7 +4970,7 @@ CPPFLAGS="$SAVE_CPPFLAGS"
 ])
 if test x"$samba_cv_SYSQUOTA_WORKS" = x"yes"; then
 AC_MSG_CHECKING(whether to use the new lib/sysquotas.c interface)
-    if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then 
+    if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then
        AC_DEFINE(WITH_QUOTAS,1,[Whether to use disk quota support])
        AC_DEFINE(HAVE_SYS_QUOTAS,1,[Whether the new lib/sysquotas.c interface can be used])
        samba_cv_WE_USE_SYS_QUOTAS=yes
@@ -4590,52 +5080,50 @@ if test $enable_static = yes; then
 fi
 
 #################################################
-# should we build libmsrpc?
-INSTALL_LIBMSRPC=
-UNINSTALL_LIBMSRPC=
-LIBMSRPC_SHARED=
-LIBMSRPC=
-AC_MSG_CHECKING(whether to build the libmsrpc shared library)
-AC_ARG_WITH(libmsrpc,
-[  --with-libmsrpc         Build the libmsrpc shared library (default=yes if shared libs supported)],
+# should we build libnetapi?
+INSTALL_LIBNETAPI=
+UNINSTALL_LIBNETAPI=
+LIBNETAPI_SHARED=
+LIBNETAPI=
+AC_MSG_CHECKING(whether to build the libnetapi shared library)
+AC_ARG_WITH(libnetapi,
+[  --with-libnetapi         Build the libnetapi shared library (default=no undefined API)],
 [ case "$withval" in
-  no) 
+  *)
      AC_MSG_RESULT(no)
      ;;
-  *)
+  yes)
      if test $BLDSHARED = true; then
-        LIBMSRPC_SHARED=bin/libmsrpc.$SHLIBEXT
-        LIBMSRPC=libmsrpc
+        LIBNETAPI_SHARED=bin/libnetapi.$SHLIBEXT
+        LIBNETAPI=libnetapi
         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
-        LIBMSRPC=libmsrpc
+        LIBNETAPI=libnetapi
      fi
-     INSTALL_LIBMSRPC=installlibmsrpc
-     UNINSTALL_LIBMSRPC=uninstalllibmsrpc
+     INSTALL_LIBNETAPI=installlibnetapi
+     UNINSTALL_LIBNETAPI=uninstalllibnetapi
      ;;
   esac ],
 [
 # if unspecified, default is to built it if possible.
   if test $BLDSHARED = true; then
-     LIBMSRPC_SHARED=bin/libmsrpc.$SHLIBEXT
-     LIBMSRPC=libmsrpc
+     LIBNETAPI_SHARED=bin/libnetapi.$SHLIBEXT
+     LIBNETAPI=libnetapi
      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
-     LIBMSRPC=libmsrpc
+     LIBNETAPI=libnetapi
   fi]
-  INSTALL_LIBMSRPC=installlibmsrpc
-  UNINSTALL_LIBMSRPC=uninstalllibmsrpc
+  INSTALL_LIBNETAPI=installlibnetapi
 )
 
-
 #################################################
 # should we build libaddns?
 INSTALL_LIBADDNS=
@@ -4644,12 +5132,12 @@ 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)],
+[  --with-libaddns         Build the libaddns shared library (default=no undefined API)],
 [ case "$withval" in
-  no) 
+  *)
      AC_MSG_RESULT(no)
      ;;
-  *)
+  yes)
      if test $BLDSHARED = true; then
         LIBADDNS_SHARED=bin/libaddns.$SHLIBEXT
         LIBADDNS=libaddns
@@ -4665,25 +5153,12 @@ AC_ARG_WITH(libaddns,
      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
+[AC_MSG_RESULT(no)]
 )
 
 #################################################
 # should we build libsmbclient?
+
 INSTALL_LIBSMBCLIENT=
 UNINSTALL_LIBSMBCLIENT=
 LIBSMBCLIENT_SHARED=
@@ -4692,7 +5167,7 @@ AC_MSG_CHECKING(whether to build the libsmbclient shared library)
 AC_ARG_WITH(libsmbclient,
 [  --with-libsmbclient     Build the libsmbclient shared library (default=yes if shared libs supported)],
 [ case "$withval" in
-  no) 
+  no)
      AC_MSG_RESULT(no)
      ;;
   *)
@@ -4770,6 +5245,7 @@ AC_ARG_WITH(libsmbsharemodes,
   INSTALL_LIBSMBSHAREMODES=installlibsmbsharemodes
 )
 
+
 #################################################
 # these tests are taken from the GNU fileutils package
 AC_CHECKING(how to get filesystem space usage)
@@ -4991,7 +5467,7 @@ AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
 # check for cluster extensions
 
 AC_MSG_CHECKING(whether to include cluster support)
-AC_ARG_WITH(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])
@@ -5006,54 +5482,71 @@ fi
 
 AC_MSG_CHECKING(whether to support ACLs)
 AC_ARG_WITH(acl-support,
-[  --with-acl-support      Include ACL support (default=no)],
+[  --with-acl-support      Include ACL support (default=auto)],
 [ case "$withval" in
-  yes)
+       yes|no)
+               with_acl_support="$withval"
+               ;;
+  esac ])
+
+if test x"$with_acl_support" = x ; then
+       with_acl_support="auto"
+fi
 
+AC_MSG_RESULT($with_acl_support)
+
+if test x"$with_acl_support" = x"no"; then
+       AC_MSG_RESULT(Disabling ACL support)
+       AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
+else
+       AC_MSG_NOTICE(checking whether ACL support is available:)
        case "$host_os" in
        *sysv5*)
-               AC_MSG_RESULT(Using UnixWare ACLs)
+               AC_MSG_NOTICE(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_MSG_NOTICE(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_MSG_NOTICE(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_MSG_NOTICE(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_MSG_NOTICE(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_MSG_NOTICE(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)
-               AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether FreeBSD POSIX ACLs are available])
-               AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
+       *darwin*)
+               AC_MSG_NOTICE(ACLs on Darwin currently not supported)
+               AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
                ;;
-       *linux*)
-               AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
-                       AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
-               AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
+       *)
+               AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
+               case "$host_os" in
+               *linux*)
+                       AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
+                       ;;
+               esac
+               AC_CACHE_CHECK([for POSIX ACL support],samba_cv_HAVE_POSIX_ACLS,[
                        acl_LIBS=$LIBS
-                       LIBS="$LIBS -lacl"
+                       LIBS="$LIBS $ACL_LIBS"
                        AC_TRY_LINK([
                                #include <sys/types.h>
                                #include <sys/acl.h>
@@ -5068,11 +5561,11 @@ AC_ARG_WITH(acl-support,
                        LIBS=$acl_LIBS
                ])
                if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
-                       AC_MSG_RESULT(Using posix ACLs)
+                       AC_MSG_NOTICE(Using posix ACLs)
                        AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
                        AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
                                acl_LIBS=$LIBS
-                               LIBS="$LIBS -lacl"
+                               LIBS="$LIBS $ACL_LIBS"
                                AC_TRY_LINK([
                                        #include <sys/types.h>
                                        #include <sys/acl.h>
@@ -5088,63 +5581,16 @@ AC_ARG_WITH(acl-support,
                        if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
                                AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
                        fi
+                       default_static_modules="$default_static_modules vfs_posixacl"
+               else
+                       AC_MSG_NOTICE(ACL support is not avaliable)
+                       AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
                fi
-            ;;
-         *)
-               AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
-               AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
-                       acl_LIBS=$LIBS
-                       LIBS="$LIBS -lacl"
-                       AC_TRY_LINK([
-                               #include <sys/types.h>
-                               #include <sys/acl.h>
-                       ],[
-                               acl_t acl;
-                               int entry_id;
-                               acl_entry_t *entry_p;
-                               return acl_get_entry( acl, entry_id, entry_p);
-                       ],
-                       [samba_cv_HAVE_POSIX_ACLS=yes],
-                       [samba_cv_HAVE_POSIX_ACLS=no])
-                       LIBS=$acl_LIBS
-               ])
-               if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
-                       AC_MSG_RESULT(Using posix ACLs)
-                       AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
-                       AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
-                               acl_LIBS=$LIBS
-                               LIBS="$LIBS -lacl"
-                               AC_TRY_LINK([
-                                       #include <sys/types.h>
-                                       #include <sys/acl.h>
-                               ],[
-                                       acl_permset_t permset_d;
-                                       acl_perm_t perm;
-                                       return acl_get_perm_np( permset_d, perm);
-                               ],
-                               [samba_cv_HAVE_ACL_GET_PERM_NP=yes],
-                               [samba_cv_HAVE_ACL_GET_PERM_NP=no])
-                               LIBS=$acl_LIBS
-                       ])
-                       if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
-                               AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
-                       fi
-               fi
-            ;;
+               ;;
         esac
-        ;;
-  *)
-    AC_MSG_RESULT(no)
-    AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
-    ;;
-  esac ],
-  AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
-  AC_MSG_RESULT(no)
-)
+fi # with_acl_support
+
 
-if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
-   default_static_modules="$default_static_modules vfs_posixacl"
-fi
 
 #################################################
 # check for AIO support
@@ -5542,6 +5988,47 @@ samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
   AC_MSG_RESULT(yes)
 )
 
+############################################
+# See if we have the Linux readahead syscall.
+
+AC_CACHE_CHECK([for Linux readahead],
+                samba_cv_HAVE_LINUX_READAHEAD,[
+    AC_TRY_LINK([
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+#include <fcntl.h>],
+    [ssize_t err = readahead(0,0,0x80000);],
+    samba_cv_HAVE_LINUX_READAHEAD=yes,
+    samba_cv_HAVE_LINUX_READAHEAD=no)])
+
+if test x"$samba_cv_HAVE_LINUX_READAHEAD" = x"yes"; then
+  AC_DEFINE(HAVE_LINUX_READAHEAD,1,
+             [Whether Linux readahead is available])
+fi
+
+AC_HAVE_DECL(readahead, [#include <fcntl.h>])
+
+############################################
+# See if we have the posix_fadvise syscall.
+
+AC_CACHE_CHECK([for posix_fadvise],
+                samba_cv_HAVE_POSIX_FADVISE,[
+    AC_TRY_LINK([
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+#include <fcntl.h>],
+    [ssize_t err = posix_fadvise(0,0,0x80000,POSIX_FADV_WILLNEED);],
+    samba_cv_HAVE_POSIX_FADVISE=yes,
+    samba_cv_HAVE_POSIX_FADVISE=no)])
+
+if test x"$samba_cv_HAVE_POSIX_FADVISE" = x"yes"; then
+  AC_DEFINE(HAVE_POSIX_FADVISE,1,
+             [Whether posix_fadvise is available])
+fi
+
+
 
 #################################################
 # Check whether winbind is supported on this platform.  If so we need to
@@ -5560,6 +6047,7 @@ 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*)
@@ -5623,18 +6111,11 @@ case "$host_os" in
                ;;
 esac
 
-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)
-
 # Check the setting of --with-winbind
 
 AC_ARG_WITH(winbind,
 [  --with-winbind          Build winbind (default, if supported by OS)],
-[ 
+[
   case "$withval" in
        yes)
                HAVE_WINBIND=yes
@@ -5662,33 +6143,54 @@ if test x"$HAVE_WINBIND" = x"no"; then
        WINBIND_WINS_NSS=""
 fi
 
+if test $BLDSHARED = true -a x"$HAVE_WINBIND" = x"yes"; then
+       NSS_MODULES="${WINBIND_NSS} ${WINBIND_WINS_NSS}"
+       ## Only worry about libwbclient if we have shared library support
+       ## and winbindd
+        LIBWBCLIENT_SHARED=bin/libwbclient.$SHLIBEXT
+        LIBWBCLIENT=libwbclient
+       INSTALL_LIBWBCLIENT=installlibwbclient
+       UNINSTALL_LIBWBCLIENT=uninstalllibwbclient
+       WINBIND_LIBS="-lwbclient"
+       LDFLAGS="$LDFLAGS -L./bin"
+fi
+
 if test x"$HAVE_WINBIND" = x"yes"; then
         AC_MSG_RESULT(yes)
        AC_DEFINE(WITH_WINBIND,1,[Whether to build winbind])
 
        EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
        EXTRA_SBIN_PROGS="$EXTRA_SBIN_PROGS bin/winbindd\$(EXEEXT)"
-        if test $BLDSHARED = true; then
-               SHLIB_PROGS="$SHLIB_PROGS $WINBIND_NSS $WINBIND_WINS_NSS"
-
-               if test x"$create_pam_modules" = x"yes"; then
-                       PAM_MODULES="$PAM_MODULES pam_winbind"
-                       INSTALL_PAM_MODULES="installpammodules"
-                       UNINSTALL_PAM_MODULES="uninstallpammodules"
-               fi
+        if test $BLDSHARED = true -a x"$create_pam_modules" = x"yes"; then
+               PAM_MODULES="$PAM_MODULES pam_winbind"
+               INSTALL_PAM_MODULES="installpammodules"
+               UNINSTALL_PAM_MODULES="uninstallpammodules"
        fi
 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])])
+
+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(WINBIND_KRB5_LOCATOR)
+
 # Solaris 10 does have new member in nss_XbyY_key
 AC_CHECK_MEMBER(union nss_XbyY_key.ipnode.af_family,
                AC_DEFINE(HAVE_NSS_XBYY_KEY_IPNODE, 1, [Defined if union nss_XbyY_key has ipnode field]),,
                [#include <nss_dbdefs.h>])
 
 # Solaris has some extra fields in struct passwd that need to be
-# initialised otherwise nscd crashes.  
+# initialised otherwise nscd crashes.
+
 AC_CHECK_MEMBER(struct passwd.pw_comment,
                AC_DEFINE(HAVE_PASSWD_PW_COMMENT, 1, [Defined if struct passwd has pw_comment field]),,
                [#include <pwd.h>])
@@ -5718,11 +6220,11 @@ fi
 
 
 #################################################
-# Check to see if we should use the included popt 
+# Check to see if we should use the included popt
 
 AC_ARG_WITH(included-popt,
 [  --with-included-popt    use bundled popt library, not from system],
-[ 
+[
   case "$withval" in
        yes)
                INCLUDED_POPT=yes
@@ -5745,7 +6247,7 @@ if test x"$INCLUDED_POPT" = x"yes"; then
     FLAGS1="-I\$(srcdir)/popt"
 else
     AC_MSG_RESULT(no)
-    BUILD_POPT=""
+       BUILD_POPT=""
     POPTLIBS="-lpopt"
 fi
 AC_SUBST(BUILD_POPT)
@@ -5753,11 +6255,46 @@ AC_SUBST(POPTLIBS)
 AC_SUBST(FLAGS1)
 
 #################################################
-# Check to see if we should use the included iniparser 
+# Check if user wants DNS service discovery support
+
+AC_ARG_ENABLE(dnssd,
+[  --enable-dnssd          Enable DNS service discovery support (default=auto)])
+
+AC_SUBST(DNSSD_LIBS)
+if test x"$enable_dnssd" != x"no"; then
+    have_dnssd_support=yes
+
+    AC_CHECK_HEADERS(dns_sd.h)
+    if test x"$ac_cv_header_dns_sd_h" != x"yes"; then
+       have_dnssd_support=no
+    fi
+
+    # On Darwin the DNSSD API is in libc, but on other platforms it's
+    # probably in -ldns_sd
+    AC_CHECK_FUNCS(DNSServiceRegister)
+    AC_CHECK_LIB_EXT(dns_sd, DNSSD_LIBS, DNSServiceRegister)
+    if test x"$ac_cv_func_DNSServiceRegister" != x"yes" -a \
+            x"$ac_cv_lib_ext_DNSServiceRegister" != x"yes"; then
+       have_dnssd_support=no
+    fi
+
+    if test x"$have_dnssd_support" = x"yes"; then
+       AC_DEFINE(WITH_DNSSD_SUPPORT, 1,
+               [Whether to enable DNS service discovery support])
+    else
+       if test x"$enable_dnssd" = x"yes"; then
+           AC_MSG_ERROR(DNS service discovery support not available)
+       fi
+    fi
+
+fi
+
+#################################################
+# 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
@@ -5789,33 +6326,36 @@ AC_SUBST(FLAGS1)
 
 
 
-#################################################
-# Check if the user wants Python
+# Checks for the vfs_fileid module
+# Start
+AC_CHECK_FUNC(getmntent)
 
-# At the moment, you can use this to set which Python binary to link
-# against.  (Libraries built for Python2.2 can't be used by 2.1,
-# though they can coexist in different directories.)  In the future
-# this might make the Python stuff be built by default.
+AC_CHECK_HEADERS(sys/statfs.h)
 
-# Defaulting python breaks the clean target if python isn't installed
+AC_MSG_CHECKING([vfs_fileid: checking for statfs() and struct statfs.f_fsid)])
+AC_CACHE_VAL(vfsfileid_cv_statfs,[
+            AC_TRY_RUN([
+               #include <sys/types.h>
+               #include <sys/statfs.h>
+               int main(void)
+               {
+                       struct statfs fsd;
+                       fsid_t fsid = fsd.f_fsid;
+                       return statfs (".", &fsd);
+               }],
+               vfsfileid_cv_statfs=yes,
+               vfsfileid_cv_statfs=no,
+               vfsfileid_cv_statfs=cross)
+])
+AC_MSG_RESULT($vfsfileid_cv_statfs)
 
-PYTHON=
+if test x"$ac_cv_func_getmntent" = x"yes" -a \
+       x"$vfsfileid_cv_statfs" = x"yes"; then
+       default_shared_modules="$default_shared_modules vfs_fileid"
+fi
+# End
+# Checks for the vfs_fileid module
 
-AC_ARG_WITH(python,
-[  --with-python=PYTHONNAME  build Python libraries],
-[ case "${withval-python}" in
-  yes)
-       PYTHON=python
-       EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS python_ext"
-       ;;
-  no)
-       PYTHON=
-       ;;
-  *)
-       PYTHON=${withval-python}
-       ;;
-  esac ])
-AC_SUBST(PYTHON)
 
 for i in `echo $default_static_modules | sed -e 's/,/ /g'`
 do
@@ -5834,11 +6374,15 @@ done
 
 dnl Always built these modules static
 MODULE_rpc_spoolss=STATIC
-MODULE_rpc_srvsvc=STATIC
+MODULE_rpc_srvsvc2=STATIC
 MODULE_idmap_tdb=STATIC
+MODULE_idmap_passdb=STATIC
+MODULE_idmap_nss=STATIC
+
+MODULE_nss_info_template=STATIC
 
 AC_ARG_WITH(static-modules,
-[  --with-static-modules=MODULES  Comma-seperated list of names of modules to statically link in],
+[  --with-static-modules=MODULES  Comma-separated list of names of modules to statically link in],
 [ if test $withval; then
        for i in `echo $withval | sed -e 's/,/ /g'`
        do
@@ -5847,7 +6391,7 @@ AC_ARG_WITH(static-modules,
 fi ])
 
 AC_ARG_WITH(shared-modules,
-[  --with-shared-modules=MODULES  Comma-seperated list of names of modules to build shared],
+[  --with-shared-modules=MODULES  Comma-separated list of names of modules to build shared],
 [ if test $withval; then
        for i in `echo $withval | sed -e 's/,/ /g'`
        do
@@ -5855,7 +6399,7 @@ AC_ARG_WITH(shared-modules,
        done
 fi ])
 
-SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o passdb/pdb_nds.o, "bin/ldapsam.$SHLIBEXT", PDB, 
+SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o passdb/pdb_nds.o, "bin/ldapsam.$SHLIBEXT", PDB,
                   [ 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)
@@ -5867,23 +6411,27 @@ SMB_MODULE(rpc_winreg, \$(RPC_REG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_initshutdown, \$(RPC_INITSHUTDOWN_OBJ), "bin/librpc_initshutdown.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_lsa_ds, \$(RPC_LSA_DS_OBJ), "bin/librpc_lsa_ds.$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_svcctl2, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl2.$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)
 SMB_MODULE(rpc_netdfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_srvsvc, \$(RPC_SVC_OBJ), "bin/librpc_srvsvc.$SHLIBEXT", RPC)
+SMB_MODULE(rpc_srvsvc2, \$(RPC_SVC_OBJ), "bin/librpc_svcsvc2.$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_eventlog2, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog2.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$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_MODULE(rpc_rpcecho, \$(RPC_ECHO_OBJ), "bin/librpc_rpcecho.$SHLIBEXT", RPC)
 SMB_SUBSYSTEM(RPC,smbd/server.o)
 
-SMB_MODULE(idmap_ldap, sam/idmap_ldap.o, "bin/ldap.$SHLIBEXT", IDMAP)
-SMB_MODULE(idmap_tdb, sam/idmap_tdb.o, "bin/tdb.$SHLIBEXT", IDMAP)
-SMB_MODULE(idmap_rid, sam/idmap_rid.o, "bin/rid.$SHLIBEXT", IDMAP)
-SMB_MODULE(idmap_ad, sam/idmap_ad.o, "bin/ad.$SHLIBEXT", IDMAP)
-SMB_SUBSYSTEM(IDMAP,sam/idmap.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)
+SMB_MODULE(idmap_passdb, winbindd/idmap_passdb.o, "bin/passdb.$SHLIBEXT", IDMAP)
+SMB_MODULE(idmap_nss, winbindd/idmap_nss.o, "bin/nss.$SHLIBEXT", IDMAP)
+SMB_MODULE(idmap_rid, winbindd/idmap_rid.o, "bin/rid.$SHLIBEXT", IDMAP)
+SMB_MODULE(idmap_ad, winbindd/idmap_ad.o, "bin/ad.$SHLIBEXT", IDMAP)
+SMB_SUBSYSTEM(IDMAP, winbindd/idmap.o)
+
+SMB_MODULE(nss_info_template, winbindd/nss_info_template.o, "bin/template.$SHLIBEXT", NSS_INFO)
+SMB_SUBSYSTEM(NSS_INFO, winbindd/nss_info.o)
 
 SMB_MODULE(charset_weird, modules/weird.o, "bin/weird.$SHLIBEXT", CHARSET)
 SMB_MODULE(charset_CP850, modules/CP850.o, "bin/CP850.$SHLIBEXT", CHARSET)
@@ -5925,6 +6473,10 @@ SMB_MODULE(vfs_cacheprime, \$(VFS_CACHEPRIME_OBJ), "bin/cacheprime.$SHLIBEXT", V
 SMB_MODULE(vfs_prealloc, \$(VFS_PREALLOC_OBJ), "bin/prealloc.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_commit, \$(VFS_COMMIT_OBJ), "bin/commit.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_gpfs, \$(VFS_GPFS_OBJ), "bin/gpfs.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_readahead, \$(VFS_READAHEAD_OBJ), "bin/readahead.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_fileid, \$(VFS_FILEID_OBJ), "bin/fileid.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_syncops, \$(VFS_SYNCOPS_OBJ), "bin/syncops.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_zfsacl, \$(VFS_ZFSACL_OBJ), "bin/zfsacl.$SHLIBEXT", VFS)
 
 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
 
@@ -6035,13 +6587,16 @@ CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
 AC_MSG_RESULT([Using libraries:])
 AC_MSG_RESULT([    LIBS = $LIBS])
 if test x"$with_ads_support" != x"no"; then
-   AC_MSG_RESULT([    KRB5_LIBS = $KRB5_LIBS])
+    AC_MSG_RESULT([    KRB5_LIBS = $KRB5_LIBS])
 fi
 if test x"$with_ldap_support" != x"no"; then
-   AC_MSG_RESULT([    LDAP_LIBS = $LDAP_LIBS])
+    AC_MSG_RESULT([    LDAP_LIBS = $LDAP_LIBS])
 fi
 if test x"$with_dnsupdate_support" != x"no"; then
-       AC_MSG_RESULT([   UUID_LIBS = $UUID_LIBS])
+    AC_MSG_RESULT([    UUID_LIBS = $UUID_LIBS])
+fi
+if test x"$have_dnssd_support" != x"no"; then
+    AC_MSG_RESULT([    DNSSD_LIBS = $DNSSD_LIBS])
 fi
 AC_MSG_RESULT([    AUTH_LIBS = $AUTH_LIBS])
 
@@ -6054,15 +6609,25 @@ AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
           AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
           AC_MSG_WARN([cannot run when cross-compiling]))
 
+dnl Merge in developer cflags from now on
+AC_SUBST(DEVELOPER_CFLAGS)
+if test x"$krb5_developer" = x"yes" -o x"$developer" = x"yes"; then
+    CFLAGS="${CFLAGS} \$(DEVELOPER_CFLAGS)"
+fi
+
 builddir=`pwd`
 AC_SUBST(builddir)
 
 # 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"
+SMBD_LIBS="$samba_dmapi_libs"
 AC_SUBST(SMBD_LIBS)
 
-AC_OUTPUT(include/stamp-h Makefile script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh)
+AC_OUTPUT(Makefile library-versions
+         script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh
+         lib/netapi/examples/Makefile
+         pkgconfig/smbclient.pc pkgconfig/netapi.pc pkgconfig/smbsharemodes.pc
+         )
 
 #################################################
 # Print very concise instructions on building/use