s3-selftest: Verify GK and GF flag behaviour
[ira/wip.git] / source3 / configure.in
index 363fbac352d8568cca031005d7122ecb7a4f5ae1..7b90c8f075dcbe608a737dcebdb6e67872017cbb 100644 (file)
@@ -6,7 +6,7 @@ AC_PREREQ(2.54)
 AC_INIT([Samba],[3],[samba-technical@samba.org])
 
 AC_CONFIG_SRCDIR([include/includes.h])
-AC_CONFIG_HEADER(include/config.h)
+AC_CONFIG_HEADER(include/autoconf/config.h)
 AC_DEFINE(CONFIG_H_IS_FROM_SAMBA,1,[Marker for samba's config.h])
 
 case "$PATH" in
@@ -26,6 +26,7 @@ AC_LIBREPLACE_CC_CHECKS
 AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
 
 m4_include(../lib/tevent/libtevent.m4)
+m4_include(../lib/ccan/libccan.m4)
 
 LIBTEVENT_OBJ0=""
 for obj in ${TEVENT_OBJ}; do
@@ -34,12 +35,13 @@ done
 AC_SUBST(LIBTEVENT_OBJ0)
 LIBS="${LIBS} ${TEVENT_LIBS}"
 
-SAMBA_CPPFLAGS="-Iinclude -I${srcdir-.}/include  -I. -I${srcdir-.}"
+SAMBA_CPPFLAGS="-Iinclude/autoconf -Iinclude -I${srcdir-.}/include  -I. -I${srcdir-.}"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/replace"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TEVENT_CFLAGS}"
-SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/addns"
+SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${CCAN_CFLAGS}"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/.."
+SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/tdb_compat"
 
 SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/popt"
 
@@ -70,10 +72,13 @@ AC_SUBST(UNINSTALLLIBCMD_A)
 AC_SUBST(INSTALL_LIBWBCLIENT)
 AC_SUBST(UNINSTALL_LIBWBCLIENT)
 AC_SUBST(LIBWBCLIENT_SHARED_TARGET)
+AC_SUBST(LIBWBCLIENT_SHARED_TARGET_SOVER)
+AC_SUBST(LIBWBCLIENT_SHARED_TARGET_FULLVER)
 AC_SUBST(LIBWBCLIENT_SHARED)
 AC_SUBST(LIBWBCLIENT_STATIC_TARGET)
 AC_SUBST(LIBWBCLIENT_STATIC)
 AC_SUBST(LIBWBCLIENT_SOVER)
+AC_SUBST(LIBWBCLIENT_FULLVER)
 AC_SUBST(LIBWBCLIENT)
 AC_SUBST(LIBWBCLIENT_LIBS)
 
@@ -121,6 +126,7 @@ fi
 
 m4_include(../lib/socket_wrapper/config.m4)
 m4_include(../lib/nss_wrapper/config.m4)
+m4_include(../lib/uid_wrapper/config.m4)
 
 m4_include(m4/swat.m4)
 
@@ -197,7 +203,14 @@ AC_ARG_WITH(profiling-data,
 )
 
 dnl Checks for programs.
-smbtorture4_possible=yes
+AC_ARG_ENABLE(smbtorture4,
+       [AS_HELP_STRING([--enable-smbtorture4], [Enable building smbtorture4 (default=auto)])])
+
+if test x$enable_smbtorture4 != xno; then
+       smbtorture4_possible=yes
+else
+       smbtorture4_possible=no
+fi
 
 AC_PROG_INSTALL
 AC_PROG_AWK
@@ -256,9 +269,6 @@ if test "$ac_cv_prog_gnu_ld" = "yes"; then
         fi
 fi
 
-dnl look for executable suffix
-AC_EXEEXT
-
 dnl Check if C compiler understands -c and -o at the same time
 AC_PROG_CC_C_O
 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
@@ -443,8 +453,6 @@ default_shared_modules="$default_shared_modules vfs_cap"
 default_shared_modules="$default_shared_modules vfs_expand_msdfs"
 default_shared_modules="$default_shared_modules vfs_shadow_copy"
 default_shared_modules="$default_shared_modules vfs_shadow_copy2"
-default_shared_modules="$default_shared_modules charset_CP850"
-default_shared_modules="$default_shared_modules charset_CP437"
 default_shared_modules="$default_shared_modules auth_script"
 default_shared_modules="$default_shared_modules vfs_readahead"
 default_shared_modules="$default_shared_modules vfs_xattr_tdb"
@@ -464,7 +472,7 @@ default_shared_modules="$default_shared_modules idmap_autorid"
 if test "x$developer" = xyes; then
    default_static_modules="$default_static_modules rpc_rpcecho pdb_ads"
    default_static_modules="$default_static_modules auth_netlogond"
-   default_shared_modules="$default_shared_modules charset_weird perfcount_test"
+   default_shared_modules="$default_shared_modules perfcount_test"
 fi
 
 #
@@ -519,6 +527,8 @@ case "$host_os" in
                                AC_MSG_RESULT([no large file support])
                                ;;
                        5.*)
+                       LDFLAGS="$LDFLAGS -lthread"
+                       CPPFLAGS="$CPPFLAGS -D_REENTRANT"
                        AC_MSG_RESULT([enabling large file support])
                        if test "$ac_cv_prog_gcc" = yes; then
                                ${CC-cc} -v >conftest.c 2>&1
@@ -526,20 +536,17 @@ case "$host_os" in
                                rm -fr conftest.c
                                case "$ac_cv_gcc_compiler_version_number" in
                                        *"gcc version 2.6"*|*"gcc version 2.7"*)
-                                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE -D_REENTRANT"
-                                               LDFLAGS="$LDFLAGS -lthread"
+                                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
                                                AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
                                                ;;
                                        *)
-                                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
-                                               LDFLAGS="$LDFLAGS -lthread"
+                                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
                                                AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
                                                AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
                                                ;;
                                esac
                        else
-                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
-                               LDFLAGS="$LDFLAGS -lthread"
+                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
                                AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
                                AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
                        fi
@@ -674,7 +681,7 @@ main() {
        AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
 
 # Add a system specific charset module.
-       default_shared_modules="$default_shared_modules charset_macosxfs"
+       default_shared_modules="$default_shared_modules"
 
        ;;
     *hurd*)
@@ -758,6 +765,14 @@ CPPFLAGS="-Iinclude $CPPFLAGS"
 AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEADERS([CFStringEncodingConverter.h])])
 CPPFLAGS="$old_CPPFLAGS"
 
+# To link lib/util/charset/charset_macosxfs.c, we need to tell the linker
+# about CoreFoundation
+case "$host_os" in
+    *darwin11*)
+               LDFLAGS="$LDFLAGS -framework CoreFoundation"
+       ;;
+esac
+
 # In valgrind 1.0.x, it's just valgrind.h.  In 1.9.x+ there's a
 # subdirectory of headers.
 AC_CHECK_HEADERS(valgrind.h valgrind/valgrind.h valgrind/memcheck.h)
@@ -951,29 +966,6 @@ if test x"$samba_cv_struct_sigevent" = x"yes"; then
        [#include <signal.h>])
 fi
 
-AC_CACHE_CHECK([for struct timespec type],samba_cv_struct_timespec, [
-    AC_TRY_COMPILE([
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-],[struct timespec ts;],
-       samba_cv_struct_timespec=yes,samba_cv_struct_timespec=no)])
-if test x"$samba_cv_struct_timespec" = x"yes"; then
-   AC_DEFINE(HAVE_STRUCT_TIMESPEC,1,[Whether we have struct timespec])
-fi
-
 # and glibc has setresuid under linux but the function does
 # nothing until kernel 2.1.44! very dumb.
 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
@@ -1083,7 +1075,7 @@ AC_CHECK_FUNCS(yp_get_default_domain)
 # Check if we have execl, if not we need to compile smbrun.
 AC_CHECK_FUNCS(execl)
 if test x"$ac_cv_func_execl" = x"no"; then
-    EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
+    EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun"
 fi
 
 AC_CHECK_FUNCS(getcwd fchown chmod fchmod mknod mknod64)
@@ -1093,18 +1085,19 @@ AC_CHECK_FUNCS(getrlimit fsync setpgid)
 AC_CHECK_FUNCS(fdatasync,,[AC_CHECK_LIB_EXT(rt, LIBS, fdatasync)])
 AC_CHECK_FUNCS(setsid glob strpbrk crypt16 getauthuid)
 AC_CHECK_FUNCS(sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
-AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf)
+AC_CHECK_FUNCS(initgroups select rdchk getgrnam getgrent pathconf)
+AC_CHECK_FUNCS(getgrset)
 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf stat64 fstat64)
 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt lseek64 ftruncate64 posix_fallocate posix_fallocate64)
 AC_CHECK_FUNCS(fallocate fallocate64)
-AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam)
+AC_CHECK_FUNCS(fseeko fseek64 fseeko64 ftell64 ftello64 setluid getpwanam)
 AC_CHECK_FUNCS(opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64)
 AC_CHECK_FUNCS(fdopendir fdopendir64)
 AC_CHECK_FUNCS(getpwent_r)
 AC_CHECK_FUNCS(getdents64)
 AC_CHECK_FUNCS(setenv strcasecmp fcvt fcvtl)
 AC_CHECK_FUNCS(syslog vsyslog timegm)
-AC_CHECK_FUNCS(setlocale nl_langinfo)
+AC_CHECK_FUNCS(setlocale)
 AC_CHECK_FUNCS(nanosleep,,[AC_CHECK_LIB_EXT(rt, LIBS, nanosleep)])
 AC_CHECK_FUNCS(lutimes futimes utimensat futimens)
 AC_CHECK_FUNCS(mlock munlock mlockall munlockall)
@@ -1113,7 +1106,7 @@ AC_CHECK_HEADERS(sys/mman.h)
 # setbuffer, shmget, shm_open are needed for smbtorture
 AC_CHECK_FUNCS(shmget shm_open)
 AC_CHECK_FUNCS(gettext dgettext)
-AC_CHECK_FUNCS(bindtextdomain textdomain)
+AC_CHECK_FUNCS(bindtextdomain textdomain bind_textdomain_codeset)
 AC_CHECK_FUNCS(strupr)
 
 # Find a method of generating a stack trace
@@ -1123,8 +1116,9 @@ AC_SEARCH_LIBS(backtrace_symbols, [execinfo])
 AC_CHECK_FUNCS(backtrace_symbols)
 AC_CHECK_LIB(exc, trace_back_stack)
 
-# check for sysctlbyname for BSD systems
+# check for sysctlbyname and sysctl for BSD systems
 AC_CHECK_FUNCS(sysctlbyname)
+AC_CHECK_FUNCS(sysctl)
 
 #################################################
 # Check to see if core dump directory is defined in linux
@@ -1141,6 +1135,7 @@ AC_CHECK_HEADERS(gpfs_gpl.h)
 if test x"$ac_cv_header_gpfs_gpl_h" = x"yes"; then
     AC_DEFINE(HAVE_GPFS,1,[Whether GPFS GPL headers are available])
     default_shared_modules="$default_shared_modules vfs_gpfs"
+    default_shared_modules="$default_shared_modules vfs_gpfs_hsm_notify"
 fi
 
 #############################################
@@ -1434,6 +1429,14 @@ AC_CHECK_LIB(resolv, dn_expand)
 AC_CHECK_LIB(resolv, _dn_expand)
 AC_CHECK_LIB(resolv, __dn_expand)
 
+AC_TRY_COMPILE([#include <resolv.h>],
+              [struct __res_state s; res_ninit(&s);],
+              ac_cv_have_res_ninit=yes,ac_cv_have_res_ninit=no)
+
+if test x"$ac_cv_have_res_ninit" = x"yes"; then
+       AC_DEFINE(HAVE_RES_NINIT, 1, [Whether we have res_ninit])
+fi
+
 #
 # Check for the functions putprpwnam, set_auth_parameters,
 # getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
@@ -2095,8 +2098,11 @@ LINK_LIBSMBCLIENT=STATIC
 #  TODO: for talloc and tdb (at least), these should
 #  be extracted from their respective source directories
 #
-AC_ARG_ENABLE(external_libtalloc, [AS_HELP_STRING([--enable-external-libtalloc], [Enable external talloc [default=auto]])],
-[ enable_external_libtalloc=$enableval ], [ enable_external_libtalloc=auto ])
+AC_ARG_ENABLE(external_libtalloc,
+       [AS_HELP_STRING([--enable-external-libtalloc],
+               [Enable external talloc [default=auto]])],
+       [ enable_external_libtalloc=$enableval ],
+       [ enable_external_libtalloc=auto ])
 
 if test "x$enable_external_libtalloc" != xno
 then
@@ -2113,8 +2119,11 @@ fi
 if test "x$enable_external_libtalloc" = xno
 then
        m4_include(../lib/talloc/libtalloc.m4)
-       LINK_LIBTALLOC=STATIC
-       SMB_LIBRARY(talloc, 2)
+       if test x"$USESHARED" == x"no" ; then
+               LINK_LIBTALLOC=STATIC
+       fi
+       LIBTALLOCVERSION=`grep ^VERSION ${tallocdir}/wscript | sed -e "s/'//g" -e 's/.* //'`
+       SMB_LIBRARY(talloc, 2, ${LIBTALLOCVERSION})
        LIBTALLOC_OBJ0=""
        for obj in ${TALLOC_OBJ}; do
                LIBTALLOC_OBJ0="${LIBTALLOC_OBJ0} ${tallocdir}/${obj}"
@@ -2123,7 +2132,7 @@ then
        SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CONFIGURE_CPPFLAGS} ${TALLOC_CFLAGS}"
        AC_SUBST(LIBTALLOC_OBJ0)
 
-       TALLOCTORT="bin/talloctort\$(EXEEXT)"
+       TALLOCTORT="bin/talloctort"
        AC_SUBST(TALLOCTORT)
 fi
 
@@ -2131,8 +2140,8 @@ fi
 AC_ARG_ENABLE(external_libtdb,
        [AS_HELP_STRING([--enable-external-libtdb],
                [Enable external tdb [default=auto]])],
-               [ enable_external_libtalloc=$enableval ],
-               [ enable_external_libtalloc=auto ])
+               [ enable_external_libtdb=$enableval ],
+               [ enable_external_libtdb=auto ])
 
 if test "x$enable_external_libtdb" != xno
 then
@@ -2151,8 +2160,11 @@ AC_SUBST(LIBTDB_OBJ0)
 if test "x$enable_external_libtdb" = xno
 then
        m4_include(../lib/tdb/libtdb.m4)
-       LINK_LIBTDB=STATIC
-       SMB_LIBRARY(tdb, 1)
+       if test x"$USESHARED" == x"no" ; then
+               LINK_LIBTDB=STATIC
+       fi
+       LIBTDBVERSION=`grep ^VERSION ${tdbdir}/wscript | sed -e "s/'//g" -e 's/.* //'`
+       SMB_LIBRARY(tdb, 1, ${LIBTDBVERSION})
        LIBTDB_OBJ0=""
        LIBTDB_LIBS="$LIBTDB_LIBS $TDB_DEPS"
        for obj in ${TDB_OBJ}; do
@@ -2162,32 +2174,22 @@ then
        SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TDB_CFLAGS}"
        SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CONFIGURE_CPPFLAGS} ${TDB_CFLAGS}"
 
-       TDBBACKUP="bin/tdbbackup\$(EXEEXT)"
+       TDBBACKUP="bin/tdbbackup"
        AC_SUBST(TDBBACKUP)
-       TDBDUMP="bin/tdbdump\$(EXEEXT)"
+       TDBDUMP="bin/tdbdump"
        AC_SUBST(TDBDUMP)
-       TDBRESTORE="bin/tdbrestore\$(EXEEXT)"
+       TDBRESTORE="bin/tdbrestore"
        AC_SUBST(TDBRESTORE)
-       TDBTOOL="bin/tdbtool\$(EXEEXT)"
+       TDBTOOL="bin/tdbtool"
        AC_SUBST(TDBTOOL)
-       TDBTORTURE="bin/tdbtorture\$(EXEEXT)"
+       TDBTORTURE="bin/tdbtorture"
        AC_SUBST(TDBTORTURE)
-       ac_cv_have_tdb_err_nesting=yes
-else
-       AC_TRY_COMPILE([#include "tdb.h"],
-                      [enum TDB_ERROR err = TDB_ERR_NESTING],
-                      ac_cv_have_tdb_err_nesting=yes,
-                      ac_cv_have_tdb_err_nesting=no)
-fi
-
-if test x"$ac_cv_have_tdb_err_nesting" = xyes; then
-   AC_DEFINE(HAVE_TDB_ERR_NESTING, 1, [Whether we have TDB_ERR_NESTING])
 fi
 
 SMB_LIBRARY(netapi, 0)
 SMB_LIBRARY(smbclient, 0)
 SMB_LIBRARY(smbsharemodes, 0)
-SMB_LIBRARY(addns, 0, no, [undefined API])
+SMB_LIBRARY(addns, 0, [], no, [undefined API])
 
 
 
@@ -2600,6 +2602,17 @@ if test x"$samba_cv_HAVE_LINUX_FALLOCATE64" = x"yes" && test x"$ac_cv_func_fallo
     AC_DEFINE(HAVE_LINUX_FALLOCATE64,1,[Whether the Linux 'fallocate64' function is available])
 fi
 
+AC_CACHE_CHECK([for getcwd takes NULL],samba_cv_GETCWD_TAKES_NULL,[
+AC_TRY_RUN([
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+main() { char *s = getcwd(NULL,0); if (s) exit(0); exit(1); }],
+samba_cv_GETCWD_TAKES_NULL=yes,samba_cv_GETCWD_TAKES_NULL=no,samba_cv_GETCWD_TAKES_NULL=cross)])
+if test x"$samba_cv_GETCWD_TAKES_NULL" = x"yes"; then
+    AC_DEFINE(GETCWD_TAKES_NULL,1,[Whether the getcwd function takes NULL as an argument])
+fi
+
 ICONV_LOOK_DIRS="/usr /usr/local /sw /opt"
 AC_ARG_WITH(libiconv,
 [AS_HELP_STRING([--with-libiconv=BASEDIR], [Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto)])],
@@ -2677,7 +2690,6 @@ for i in $ICONV_LOOK_DIRS ; do
         export LDFLAGS LIBS CPPFLAGS
 
        default_dos_charset=no
-       default_display_charset=no
        default_unix_charset=no
 
        # check for default dos charset name
@@ -2689,15 +2701,6 @@ for i in $ICONV_LOOK_DIRS ; do
            fi
        done
 
-       # check for default display charset name
-       for j in ASCII 646 ; do
-           rjs_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)
@@ -2709,15 +2712,12 @@ for i in $ICONV_LOOK_DIRS ; do
 
        if test "$default_dos_charset" != "no" -a \
                "$default_dos_charset" != "cross" -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 \
-                    "$default_display_charset" = "cross" -o \
                     "$default_unix_charset" = "cross"
            then
                    samba_cv_HAVE_NATIVE_ICONV=cross
@@ -2734,11 +2734,10 @@ for i in $ICONV_LOOK_DIRS ; do
        # 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])
+           AC_MSG_WARN([$default_dos_charset and $default_unix_charset to UCS-16LE])
        fi
 
         if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes" ; then
@@ -2757,12 +2756,10 @@ for i in $ICONV_LOOK_DIRS ; do
 
            # 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
@@ -2784,7 +2781,6 @@ if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; th
     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])
    AC_DEFINE_UNQUOTED(DEFAULT_UNIX_CHARSET,"UTF8",[Default unix charset name])
 fi
 
@@ -2832,8 +2828,10 @@ 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])
+if test x"$ac_cv_func_inotify_init" = x"yes"; then
+    if test  x"$ac_cv_header_sys_inotify_h" = x"yes" -o x"$ac_cv_header_linux_inotify_h" = x"yes"; then
+        AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel or sys has inotify support])
+    fi
 fi
 
 #################################################
@@ -3431,8 +3429,6 @@ AC_MSG_RESULT($with_ldap_support)
 
 SMBLDAP=""
 AC_SUBST(SMBLDAP)
-SMBLDAPUTIL=""
-AC_SUBST(SMBLDAPUTIL)
 
 if test x"$with_ldap_support" != x"no"; then
 
@@ -3543,7 +3539,6 @@ if test x"$with_ldap_support" != x"no"; then
     default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
     default_shared_modules="$default_shared_modules";
     SMBLDAP="lib/smbldap.o"
-    SMBLDAPUTIL="lib/smbldap_util.o"
     with_ldap_support=yes
     AC_MSG_CHECKING(whether LDAP support is used)
     AC_MSG_RESULT(yes)
@@ -3594,16 +3589,16 @@ 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
+# HPUX and Solaris only has ldap_init; ok, we take care of this in smbldap.c
 case "$host_os" in
-       *hpux*)
+       *hpux* | *solaris*)
     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)
+           AC_MSG_ERROR(Active Directory support on HPUX or Solaris requires ldap_init)
        elif test x"$with_ads_support" = x"auto"; then
-           AC_MSG_WARN(Disabling Active Directory support (requires ldap_init on HPUX))
+           AC_MSG_WARN(Disabling Active Directory support (requires ldap_init on HPUX or Solaris))
            with_ads_support=no
        fi
     fi
@@ -3653,7 +3648,6 @@ if test x"$with_ads_support" != x"no"; then
         ;;
       yes)
         AC_MSG_RESULT(/usr)
-        FOUND_KRB5=yes
         ;;
       *)
         AC_MSG_RESULT($withval)
@@ -3742,6 +3736,21 @@ if test x"$with_ads_support" != x"no"; then
     fi
   fi
 
+  if test x$FOUND_KRB5 = x"no"; then
+    #################################################
+    # see if this box has Solaris MIT kerberos implementation
+    AC_MSG_CHECKING(for Solaris MIT kerberos)
+    if test -x "$KRB5CONFIG" && $KRB5CONFIG --version | grep -s Solaris | grep -s MIT > /dev/null ; then
+       FOUND_KRB5=yes
+       KRB5_LIBS="-lgss -lkrb5"
+       KRB5_CFLAGS="`$KRB5CONFIG --cflags`"
+       KRB5_CPPFLAGS="`$KRB5CONFIG --cflags`"
+       AC_MSG_RESULT(yes)
+    else
+      AC_MSG_RESULT(no)
+    fi
+  fi
+
   ac_save_CFLAGS=$CFLAGS
   ac_save_CPPFLAGS=$CPPFLAGS
   ac_save_LDFLAGS=$LDFLAGS
@@ -3806,7 +3815,7 @@ if test x"$with_ads_support" != x"no"; then
 
   # now check for gssapi headers.  This is also done here to allow for
   # different kerberos include paths
-  AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_ext.h com_err.h)
+  AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_ext.h gssapi/gssapi_krb5.h com_err.h)
 
   ##################################################################
   # we might need the k5crypto and com_err libraries on some systems
@@ -3831,7 +3840,13 @@ if test x"$with_ads_support" != x"no"; then
   # now see if we can find the gssapi libs in standard paths
   if test x"$have_gssapi" != x"yes"; then
      AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],have_gssapi=yes)
-     AC_CHECK_FUNC_EXT(gss_wrap_iov, $KRB5_LIBS)
+     AC_CHECK_LIB_EXT(gss, KRB5_LIBS,gss_display_status,[],[],have_gssapi=yes)
+  fi
+  ################################################################
+  # test for AD / GSSAPI support being enabled
+  if test x"$have_gssapi" != xyes ; then
+       AC_MSG_WARN([Samba cannot be supported without GSSAPI])
+       use_ads=no
   fi
 
   AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
@@ -3845,7 +3860,6 @@ if test x"$with_ads_support" != x"no"; then
   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_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_free_data_contents, $KRB5_LIBS)
@@ -3855,20 +3869,16 @@ if test x"$with_ads_support" != x"no"; then
   AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_krbhst_init, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
-  AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
-  AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_crypto_init, $KRB5_LIBS)
   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)
   AC_CHECK_FUNC_EXT(krb5_princ_size, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_set_pac_request, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_get_renewed_creds, $KRB5_LIBS)
-  AC_CHECK_FUNC_EXT(krb5_get_kdc_cred, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_free_error_contents, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(initialize_krb5_error_table, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_alloc, $KRB5_LIBS)
@@ -3883,6 +3893,19 @@ if test x"$with_ads_support" != x"no"; then
   AC_CHECK_FUNC_EXT(krb5_get_credentials_for_user, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_get_host_realm, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_free_host_realm, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(gss_krb5_import_cred, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(gss_get_name_attribute, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(gsskrb5_extract_authz_data_from_sec_context, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(gss_mech_krb5, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(gss_oid_equal, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(gss_inquire_sec_context_by_oid, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(gss_wrap_iov, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(gss_krb5_export_lucid_sec_context, $KRB5_LIBS)
+
+  # This is for FreeBSD (and possibly others). gss_mech_krb5 is a
+  # #define to GSS_KRB5_MECHANISM, which is defined in -lgssapi_krb5
+  AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS, GSS_KRB5_MECHANISM,
+                  [KRB5_LIBS="$KRB5_LIBS -lgssapi_krb5"])
 
   # MIT krb5 1.8 does not expose this call (yet)
   AC_CHECK_DECLS(krb5_get_credentials_for_user, [], [], [#include <krb5.h>])
@@ -3937,16 +3960,6 @@ if test x"$with_ads_support" != x"no"; then
            [Whether krb5_get_init_creds_opt_free takes a context argument])
   fi
 
-  AC_CACHE_CHECK(whether krb5_verify_checksum takes 7 arguments, smb_krb5_cv_verify_checksum, [
-    AC_TRY_COMPILE([
-       #include <krb5.h>],
-       [krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);],
-       [smb_krb5_cv_verify_checksum=7],
-       [smb_krb5_cv_verify_checksum=6],
-    )
-  ])
-  AC_DEFINE_UNQUOTED(KRB5_VERIFY_CHECKSUM_ARGS, $smb_krb5_cv_verify_checksum, [Number of arguments to krb5_verify_checksum])
-
   AC_CACHE_CHECK([for checksum in krb5_checksum],
                 samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM,[
     AC_TRY_COMPILE([#include <krb5.h>],
@@ -4054,30 +4067,6 @@ if test x"$with_ads_support" != x"no"; then
               [Whether the krb5_ticket struct has a enc_part2 property])
   fi
 
-  AC_CACHE_CHECK([for keyblock in krb5_creds],
-                 samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS,[
-    AC_TRY_COMPILE([#include <krb5.h>],
-      [krb5_creds creds; krb5_keyblock kb; creds.keyblock = kb;],
-      samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=yes,
-      samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=no)])
-
-  if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS" = x"yes"; then
-    AC_DEFINE(HAVE_KRB5_KEYBLOCK_IN_CREDS,1,
-              [Whether the krb5_creds struct has a keyblock property])
-  fi
-
-  AC_CACHE_CHECK([for session in krb5_creds],
-                 samba_cv_HAVE_KRB5_SESSION_IN_CREDS,[
-    AC_TRY_COMPILE([#include <krb5.h>],
-      [krb5_creds creds; krb5_keyblock kb; creds.session = kb;],
-      samba_cv_HAVE_KRB5_SESSION_IN_CREDS=yes,
-      samba_cv_HAVE_KRB5_SESSION_IN_CREDS=no)])
-
-  if test x"$samba_cv_HAVE_KRB5_SESSION_IN_CREDS" = x"yes"; then
-    AC_DEFINE(HAVE_KRB5_SESSION_IN_CREDS,1,
-              [Whether the krb5_creds struct has a session property])
-  fi
-
   AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
                  samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
     AC_TRY_COMPILE([#include <krb5.h>],
@@ -4123,6 +4112,27 @@ if test x"$with_ads_support" != x"no"; then
     found_arcfour_hmac=yes
   fi
 
+  AC_CACHE_CHECK([for ENCTYPE_AES128_CTS_HMAC_SHA1_96],
+                 samba_cv_HAVE_ENCTYPE_AES128_CTS_HMAC_SHA1_96,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_enctype enctype; enctype = ENCTYPE_AES128_CTS_HMAC_SHA1_96;],
+      samba_cv_HAVE_ENCTYPE_AES128_CTS_HMAC_SHA1_96=yes,
+      samba_cv_HAVE_ENCTYPE_AES128_CTS_HMAC_SHA1_96=no)])
+  if test x"$samba_cv_HAVE_ENCTYPE_AES128_CTS_HMAC_SHA1_96" = x"yes"; then
+    AC_DEFINE(HAVE_ENCTYPE_AES128_CTS_HMAC_SHA1_96,1,
+              [Whether the ENCTYPE_AES128_CTS_HMAC_SHA1_96 key type definition is available])
+  fi
+  AC_CACHE_CHECK([for ENCTYPE_AES256_CTS_HMAC_SHA1_96],
+                 samba_cv_HAVE_ENCTYPE_AES256_CTS_HMAC_SHA1_96,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_enctype enctype; enctype = ENCTYPE_AES256_CTS_HMAC_SHA1_96;],
+      samba_cv_HAVE_ENCTYPE_AES256_CTS_HMAC_SHA1_96=yes,
+      samba_cv_HAVE_ENCTYPE_AES256_CTS_HMAC_SHA1_96=no)])
+  if test x"$samba_cv_HAVE_ENCTYPE_AES256_CTS_HMAC_SHA1_96" = x"yes"; then
+    AC_DEFINE(HAVE_ENCTYPE_AES256_CTS_HMAC_SHA1_96,1,
+              [Whether the ENCTYPE_AES256_CTS_HMAC_SHA1_96 key type definition is available])
+  fi
+
   AC_CACHE_CHECK([for AP_OPTS_USE_SUBKEY],
                  samba_cv_HAVE_AP_OPTS_USE_SUBKEY,[
     AC_TRY_COMPILE([#include <krb5.h>],
@@ -4278,19 +4288,6 @@ 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_cv_enctype_to_string_takes_krb5_context_arg,[
@@ -4356,6 +4353,8 @@ if test x"$with_ads_support" != x"no"; then
                [Whether the macro krb5_princ_realm is defined])
   fi
 
+  AC_HAVE_DECL(KRB5_PDU_NONE,[#include <krb5.h>])
+
   #
   #
   # Now the decisions whether we can support krb5
@@ -4368,11 +4367,64 @@ if test x"$with_ads_support" != x"no"; then
     use_ads=no
   fi
 
+  if test x"$ac_cv_func_ext_krb5_set_real_time" != x"yes"; then
+    AC_MSG_WARN(krb5_set_real_time encryption type not found in -lkrb5)
+    use_ads=no
+  fi
+
   if test x"$ac_cv_lib_ext_krb5_krb5_mk_req_extended" != x"yes"; then
     AC_MSG_WARN(krb5_mk_req_extended not found in -lkrb5)
     use_ads=no
   fi
 
+  if test x"$ac_cv_func_ext_krb5_get_host_realm" != x"yes"
+  then
+    AC_MSG_WARN(krb5_get_host_realm not found in -lkrb5)
+    use_ads=no
+  fi
+
+  if test x"$ac_cv_func_ext_krb5_free_host_realm" != x"yes"
+  then
+    AC_MSG_WARN(krb5_free_host_realm not found in -lkrb5)
+    use_ads=no
+  fi
+
+  if test x"$ac_cv_func_ext_krb5_fwd_tgt_creds" != x"yes"
+  then
+    AC_MSG_WARN(krb5_fwd_tgt_creds not found in -lkrb5)
+    use_ads=no
+  fi
+
+  if test x"$ac_cv_func_ext_krb5_get_init_creds_opt_alloc" != x"yes"
+  then
+    AC_MSG_WARN(krb5_get_init_creds_opt_alloc found in -lkrb5)
+    use_ads=no
+  fi
+
+  if test x"$smb_krb5_cv_creds_opt_free_context" != x"yes"
+  then
+    AC_MSG_WARN(krb5_get_init_creds_opt_free not found or was too old in -lkrb5)
+    use_ads=no
+  fi
+
+  if test x"$ac_cv_func_ext_krb5_get_renewed_creds" != x"yes"
+  then
+    AC_MSG_WARN(krb5_get_renewed_creds not found in -lkrb5)
+    use_ads=no
+  fi
+
+  if test x"$ac_cv_func_ext_krb5_principal_compare_any_realm" != x"yes"
+  then
+    AC_MSG_WARN(krb5_principal_compare_any_realm not found in -lkrb5)
+    use_ads=no
+  fi
+
+  if test x"$ac_cv_func_ext_krb5_string_to_key" != x"yes"
+  then
+    AC_MSG_WARN(krb5_string_to_key not found in -lkrb5)
+    use_ads=no
+  fi
+
   if test x"$ac_cv_func_ext_krb5_principal2salt" != x"yes" -a \
           x"$ac_cv_func_ext_krb5_get_pw_salt" != x"yes"
   then
@@ -4394,10 +4446,9 @@ if test x"$with_ads_support" != x"no"; then
     use_ads=no
   fi
 
-  if test x"$ac_cv_func_ext_krb5_c_verify_checksum" != x"yes" -a \
-          x"$ac_cv_func_ext_krb5_verify_checksum" != x"yes"
+  if test x"$ac_cv_func_ext_krb5_c_verify_checksum" != x"yes"
   then
-    AC_MSG_WARN(no KRB5_VERIFY_CHECKSUM_FUNCTION detected)
+    AC_MSG_WARN(krb5_c_verify_checksum not found in -lkrb5)
     use_ads=no
   fi
 
@@ -4420,12 +4471,23 @@ if test x"$with_ads_support" != x"no"; then
 
   fi
 
+  if test x"$ac_cv_func_ext_gss_get_name_attribute" != x"yes" ; then
+    if test x"$ac_cv_func_ext_gsskrb5_extract_authz_data_from_sec_context" != x"yes" -o \
+            x"$ac_cv_func_ext_gss_inquire_sec_context_by_oid" != x"yes"
+    then
+      AC_MSG_WARN(need either gss_get_name_attribute or gsskrb5_extract_authz_data_from_sec_context and gss_inquire_sec_context_by_oid in -lgssapi for PAC support)
+      use_ads=no
+    fi
+  fi
+
+  if test x"$ac_cv_func_ext_gss_krb5_export_lucid_sec_context" != x"yes" ; then
+    AC_MSG_WARN(need gss_krb5_export_lucid_sec_context for SPNEGO and gss_wrap support)
+    use_ads=no
+  fi
+
   if test x"$use_ads" = x"yes"; then
     AC_DEFINE(WITH_ADS,1,[Whether to include Active Directory support])
     AC_DEFINE(HAVE_KRB5,1,[Whether to have KRB5 support])
-    if test x"$have_gssapi" = x"yes"; then
-      AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available])
-    fi
   else
     if test x"$with_ads_support" = x"yes"; then
        AC_MSG_ERROR(krb5 libs don't have all features required for Active Directory support)
@@ -4445,10 +4507,6 @@ if test x"$with_ads_support" != x"no"; then
 LIBS="$ac_save_LIBS"
 fi
 
-if test x"$use_ads" != xyes; then
-       smbtorture4_possible=no
-fi
-
 AC_CHECK_LIB_EXT(nscd, NSCD_LIBS, nscd_flush_cache)
 PASSDB_LIBS="$PASSDB_LIBS $NSCD_LIBS"
 
@@ -4473,7 +4531,7 @@ if test x"$with_dnsupdate_support" != x"no"; then
 
   ################################################################
   # first test for AD / GSSAPI support being enabled
-       if test x"$have_gssapi" != xyes ; then
+       if test x"$have_gssapi" != xyes -o x"$use_ads" != xyes ; then
                if test x"$with_dnsupdate_support" = x"yes" ; then
                        AC_MSG_ERROR(DNS Updates support only possible with AD and GSSAPI support)
                else
@@ -5422,11 +5480,20 @@ if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
 fi
 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
 
+
 #################################################
 # check for cluster extensions
 
-CTDB_CFLAGS=""
-AC_SUBST(CTDB_CFLAGS)
+AC_MSG_CHECKING(cluster support)
+AC_ARG_WITH(cluster-support,
+[AS_HELP_STRING([--with-cluster-support], [Enable cluster extensions (default=auto)])])
+
+if test x"$with_cluster_support" = x ; then
+       with_cluster_support="auto"
+fi
+
+AC_MSG_RESULT($with_cluster_support)
+
 AC_ARG_WITH(ctdb,
 [AS_HELP_STRING([--with-ctdb=DIR], [Where to find ctdb sources])],
 [ case "$withval" in
@@ -5438,9 +5505,21 @@ AC_ARG_WITH(ctdb,
     ;;
   esac])
 
+AC_ARG_ENABLE(old-ctdb,
+       [AS_HELP_STRING([--enable-old-ctdb],
+               [Enable build against (too) old ctdb version (default=no)])],,
+               [enable_old_ctdb=no])
+
+
+if test "$with_cluster_support" != "no" ; then
+
+AC_MSG_NOTICE(checking whether cluster support is available)
+
+have_cluster_support="yes"
+ctdb_broken="no"
+
 SAVED_CPPFLAGS="$CPPFLAGS"
 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS} $CTDB_CPPFLAGS"
-ctdb_broken="missing or broken headers"
 
 AC_CHECK_HEADERS(ctdb.h ctdb_private.h,,,[
 #include "confdefs.h"
@@ -5454,99 +5533,164 @@ AC_CHECK_HEADERS(ctdb.h ctdb_private.h,,,[
 #include <ctdb.h>
 ])
 
-AC_HAVE_DECL(CTDB_CONTROL_TRANS3_COMMIT,[
-#include "confdefs.h"
-#define NO_CONFIG_H
-#include "replace.h"
-#include "system/wait.h"
-#include "system/network.h"
-#include <talloc.h>
-#include <tdb.h>
-#include <ctdb.h>
-#include <ctdb_private.h>
-])
-if test x"$ac_cv_have_CTDB_CONTROL_TRANS3_COMMIT_decl" = x"yes"; then
-       ctdb_broken=no
-else
-       ctdb_broken="ctdb transaction support missing or too old"
+if test "x$have_cluster_support" = "xyes" -a \
+       "x$ac_cv_header_ctdb_h" != "xyes"
+then
+       have_cluster_support=no
+       ctdb_broken="ctdb.h is required for cluster support"
 fi
 
-# in ctdb 1.0.57 ctdb_control_tcp was temparary renamed to ctdb_tcp_client
-AC_CHECK_TYPE(struct ctdb_tcp_client,[
-       AC_DEFINE([ctdb_control_tcp],[ctdb_tcp_client],[ctdb ipv4 support])
-],,[
-#include "confdefs.h"
-#define NO_CONFIG_H
-#include "replace.h"
-#include "system/wait.h"
-#include "system/network.h"
-#include <talloc.h>
-#include <tdb.h>
-#include <ctdb.h>
-#include <ctdb_private.h>
-])
+if test "x$have_cluster_support" = "xyes" -a \
+       "x$ac_cv_header_ctdb_h" != "xyes"
+then
+       have_cluster_support=no
+       ctdb_broken="ctdb_private.h is required for cluster support"
+fi
+
+
+if test "x$have_cluster_support" = "xyes" ; then
+       AC_HAVE_DECL(CTDB_CONTROL_TRANS3_COMMIT,[
+       #include "confdefs.h"
+       #define NO_CONFIG_H
+       #include "replace.h"
+       #include "system/wait.h"
+       #include "system/network.h"
+       #include <talloc.h>
+       #include <tdb.h>
+       #include <ctdb.h>
+       #include <ctdb_private.h>
+       ])
+       if test x"$ac_cv_have_CTDB_CONTROL_TRANS3_COMMIT_decl" != x"yes"; then
+               ctdb_broken="ctdb transaction support missing or too old"
+               have_cluster_support=no
+       fi
+fi
 
-AC_CHECK_TYPE(struct ctdb_control_tcp,[
-       AC_DEFINE([HAVE_STRUCT_CTDB_CONTROL_TCP],[1],[ctdb ipv4 support])
-],[
-       ctdb_broken="missing struct ctdb_control_tcp"
-],[
-#include "confdefs.h"
-#define NO_CONFIG_H
-#include "replace.h"
-#include "system/wait.h"
-#include "system/network.h"
-#include <talloc.h>
-#include <tdb.h>
-#include <ctdb.h>
-#include <ctdb_private.h>
-])
+if test "x$have_cluster_support" = "xyes" ; then
+       AC_HAVE_DECL(CTDB_CONTROL_SCHEDULE_FOR_DELETION,[
+       #include "confdefs.h"
+       #define NO_CONFIG_H
+       #include "replace.h"
+       #include "system/wait.h"
+       #include "system/network.h"
+       #include <talloc.h>
+       #include <tdb.h>
+       #include <ctdb.h>
+       #include <ctdb_private.h>
+       ])
+       if test x"$ac_cv_have_CTDB_CONTROL_SCHEDULE_FOR_DELETION_decl" != x"yes"
+       then
+               if test "x$enable_old_ctdb" = "xyes" ; then
+                       AC_MSG_WARN([ignoring missing SCHEDULE_FOR_DELETION (--enable-old-ctdb)])
+               else
+                       ctdb_broken="support for SCHEDULE_FOR_DELETION control missing"
+                       have_cluster_support=no
+               fi
+       fi
+fi
 
-AC_CHECK_TYPE(struct ctdb_control_tcp_addr,[
-       AC_DEFINE([HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR],[1],[ctdb ipv6 support])
-],,[
-#include "confdefs.h"
-#define NO_CONFIG_H
-#include "replace.h"
-#include "system/wait.h"
-#include "system/network.h"
-#include <talloc.h>
-#include <tdb.h>
-#include <ctdb.h>
-#include <ctdb_private.h>
-])
-CPPFLAGS="$SAVED_CPPFLAGS"
+if test "x$have_cluster_support" = "xyes" ; then
+       AC_HAVE_DECL(CTDB_CONTROL_CHECK_SRVIDS,[
+       #include "confdefs.h"
+       #define NO_CONFIG_H
+       #include "replace.h"
+       #include "system/wait.h"
+       #include "system/network.h"
+       #include <talloc.h>
+       #include <tdb.h>
+       #include <ctdb.h>
+       #include <ctdb_private.h>
+       ])
+       if test x"$ac_cv_have_CTDB_CONTROL_CHECK_SRVIDS_decl" != x"yes"
+       then
+               if test "x$enable_old_ctdb" = "xyes" ; then
+                       AC_MSG_WARN([ignoring missing CHECK_SRVIDS (--enable-old-ctdb)])
+               else
+                       ctdb_broken="support for CHECK_SRVIDS control missing"
+                       have_cluster_support=no
+               fi
+       fi
+fi
 
-AC_MSG_CHECKING(cluster support)
-AC_ARG_WITH(cluster-support,
-[AS_HELP_STRING([--with-cluster-support], [Enable cluster extensions (default=auto)])])
+if test "x$have_cluster_support" = "xyes" ; then
+       # In ctdb 1.0.57, ctdb_control_tcp was temporarily renamed
+       # to ctdb_tcp_client.
+       AC_CHECK_TYPE(struct ctdb_tcp_client,[
+               AC_DEFINE([ctdb_control_tcp],[ctdb_tcp_client],[ctdb ipv4 support])
+       ],,[
+       #include "confdefs.h"
+       #define NO_CONFIG_H
+       #include "replace.h"
+       #include "system/wait.h"
+       #include "system/network.h"
+       #include <talloc.h>
+       #include <tdb.h>
+       #include <ctdb.h>
+       #include <ctdb_private.h>
+       ])
+fi
 
-if test x"$with_cluster_support" = x ; then
-       with_cluster_support="auto"
+if test "x$have_cluster_support" = "xyes" ; then
+       AC_CHECK_TYPE(struct ctdb_control_tcp,[
+               AC_DEFINE([HAVE_STRUCT_CTDB_CONTROL_TCP],[1],[ctdb ipv4 support])
+       ],[
+               ctdb_broken="missing struct ctdb_control_tcp"
+               have_cluster_support=no
+       ],[
+       #include "confdefs.h"
+       #define NO_CONFIG_H
+       #include "replace.h"
+       #include "system/wait.h"
+       #include "system/network.h"
+       #include <talloc.h>
+       #include <tdb.h>
+       #include <ctdb.h>
+       #include <ctdb_private.h>
+       ])
 fi
 
-if test x"$ac_cv_header_ctdb_private_h" != x"yes"; then
-       if test "x$with_cluster_support" = "xyes"; then
-               AC_MSG_ERROR("ctdb_private.h is required for cluster support")
-       fi
-       with_cluster_support=no
+# test for optional ipv6 support in ctdb:
+if test "x$have_cluster_support" = "xyes" ; then
+       AC_CHECK_TYPE(struct ctdb_control_tcp_addr,[
+               AC_DEFINE([HAVE_STRUCT_CTDB_CONTROL_TCP_ADDR],[1],[ctdb ipv6 support])
+       ],,[
+       #include "confdefs.h"
+       #define NO_CONFIG_H
+       #include "replace.h"
+       #include "system/wait.h"
+       #include "system/network.h"
+       #include <talloc.h>
+       #include <tdb.h>
+       #include <ctdb.h>
+       #include <ctdb_private.h>
+       ])
 fi
 
-if test x"$ctdb_broken" != x"no"; then
-       if test "x$with_cluster_support" = "xyes"; then
-               AC_MSG_ERROR(["cluster support: $ctdb_broken"])
-       fi
+CPPFLAGS="$SAVED_CPPFLAGS"
+
+fi # (if test "$with_cluster_support" != "no")
+
+if test x"$have_cluster_support" = "xno" ; then
+       case "$with_cluster_support" in
+       yes)
+               AC_MSG_ERROR(["cluster support not available: $ctdb_broken"])
+               ;;
+       auto)
+               AC_MSG_WARN(["cluster support not available: $ctdb_broken"])
+               ;;
+       esac
        with_cluster_support=no
 fi
 
 if test "x$with_cluster_support" != "xno"; then
     AC_DEFINE(CLUSTER_SUPPORT,1,[Whether to enable cluster extensions])
     SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${CTDB_CPPFLAGS}"
-    AC_MSG_RESULT(yes)
+    AC_MSG_NOTICE(Building with cluster support)
 else
-    AC_MSG_RESULT(no)
+    AC_MSG_NOTICE(Building without cluster support)
 fi
 
+
 #################################################
 # check for rtnetlink
 
@@ -6268,6 +6412,8 @@ case "$host_os" in
                WINBIND_NSS="../nsswitch/WINBIND"
                WINBIND_WINS_NSS=""
                ;;
+       *darwin*)
+               ;;
        *)
                HAVE_WINBIND=no
                winbind_no_reason=", unsupported on $host_os"
@@ -6312,7 +6458,7 @@ if test x"$HAVE_WBCLIENT" = x"yes"; then
        LIBWBCLIENT_LIBS="$LIBWBCLIENT_LIBS $WBCLIENT_LDFLAGS"
        AC_MSG_RESULT(yes)
        AC_DEFINE(WITH_WINBIND,1,[Whether to link to wbclient])
-       EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
+       EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo"
 else
        if test x"$enable_developer" = x"yes" -a x"$LINK_LIBWBCLIENT" = x"STATIC" ; then
                BUILD_LIBWBCLIENT_SHARED=no
@@ -6322,7 +6468,10 @@ else
 
        LIBWBCLIENT_SHARED_TARGET=bin/libwbclient.$SHLIBEXT
        LIBWBCLIENT_STATIC_TARGET=bin/libwbclient.a
-       LIBWBCLIENT_SOVER=1
+       LIBWBCLIENT_SOVER=0
+       LIBWBCLIENT_FULLVER=0
+       LIBWBCLIENT_SHARED_TARGET_SOVER=$LIBWBCLIENT_SHARED_TARGET.$LIBWBCLIENT_SOVER
+       LIBWBCLIENT_SHARED_TARGET_FULLVER=$LIBWBCLIENT_SHARED_TARGET.$LIBWBCLIENT_FULLVER
        if test $BLDSHARED = true -a x"$HAVE_WINBIND" = x"yes" -a x"$BUILD_LIBWBCLIENT_SHARED" = x"yes"; then
                NSS_MODULES="${WINBIND_NSS} ${WINBIND_WINS_NSS}"
                ## Only worry about libwbclient if we have shared
@@ -6342,8 +6491,8 @@ 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)"
+       EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo"
+       EXTRA_SBIN_PROGS="$EXTRA_SBIN_PROGS bin/winbindd"
         if test $BLDSHARED = true -a x"$create_pam_modules" = x"yes"; then
                PAM_MODULES="$PAM_MODULES pam_winbind"
                INSTALL_PAM_MODULES="installpammodules"
@@ -6606,7 +6755,12 @@ if test x"$enable_pthreadpool" = x"yes" -a x"$samba_cv_HAVE_PTHREAD" = x"yes"; t
     LIBS="$LIBS $PTHREAD_LDFLAGS"
     CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
     AC_DEFINE(WITH_PTHREADPOOL, 1, [Whether to include pthreadpool helpers])
-    AC_SUBST(PTHREADPOOL_OBJ, "lib/pthreadpool.o")
+    AC_SUBST(PTHREADPOOL_OBJ, "lib/pthreadpool/pthreadpool.o")
+    PTHREADPOOLTEST="bin/pthreadpooltest"
+    AC_SUBST(PTHREADPOOLTEST)
+    if test x"$samba_cv_HAVE_AIO" = x"yes"; then
+        default_shared_modules="$default_shared_modules vfs_aio_pthread"
+    fi
 fi
 
 #################################################
@@ -6647,7 +6801,7 @@ AC_SUBST(FLAGS1)
 ###################################################
 # Check for different/missing (set|get|end)netgrent prototypes
 CFLAGS_SAVE=$CFLAGS
-if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
+if test x"$samba_cv_HAVE_Werror_implicit_function_declaration" = x"yes"; then
        CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
 fi
 AC_CACHE_CHECK([for setnetgrent prototype],samba_cv_setnetgrent_prototype, [
@@ -6759,7 +6913,8 @@ if test x"$MODULE_DEFAULT_vfs_notify_fam" = xSTATIC -o \
        AC_SUBST(SMBD_FAM_LIBS)
 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 passdb/pdb_ipa.o passdb/pdb_ldap_util.o,
+                  "bin/ldapsam.$SHLIBEXT", PDB,
                   [ PASSDB_LIBS="$PASSDB_LIBS $LDAP_LIBS" ] )
 SMB_MODULE(pdb_ads, passdb/pdb_ads.o \$(TLDAP_OBJ), "bin/ads.$SHLIBEXT", PDB)
 SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, "bin/smbpasswd.$SHLIBEXT", PDB)
@@ -6782,10 +6937,6 @@ 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)
-SMB_MODULE(charset_CP437, modules/CP437.o, "bin/CP437.$SHLIBEXT", CHARSET)
-SMB_MODULE(charset_macosxfs, modules/charset_macosxfs.o,"bin/macosxfs.$SHLIBEXT", CHARSET)
 SMB_SUBSYSTEM(CHARSET,lib/iconv.o)
 
 SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), "bin/sam.$SHLIBEXT", AUTH)
@@ -6828,10 +6979,12 @@ 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_gpfs_hsm_notify, \$(VFS_GPFS_PREFETCH_OBJ), "bin/gpfs_hsm_notify.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_readahead, \$(VFS_READAHEAD_OBJ), "bin/readahead.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_tsmsm, \$(VFS_TSMSM_OBJ), "bin/tsmsm.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_fileid, \$(VFS_FILEID_OBJ), "bin/fileid.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_aio_fork, \$(VFS_AIO_FORK_OBJ), "bin/aio_fork.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_aio_pthread, \$(VFS_AIO_PTHREAD_OBJ), "bin/aio_pthread.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_preopen, \$(VFS_PREOPEN_OBJ), "bin/preopen.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_syncops, \$(VFS_SYNCOPS_OBJ), "bin/syncops.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_zfsacl, \$(VFS_ZFSACL_OBJ), "bin/zfsacl.$SHLIBEXT", VFS)
@@ -6953,13 +7106,6 @@ fi
 m4_include(../lib/zlib/zlib.m4)
 
 if test x$smbtorture4_possible = xyes; then
-       saved_USESHARED="$USESHARED"
-       USESHARED="false"
-       smbtorture4_path="bin/smbtorture4"
-       smbtorture4_option="-t bin/smbtorture4"
-       AC_SUBST(smbtorture4_path)
-       AC_SUBST(smbtorture4_option)
-       USESHARED="$saved_USESHARED"
        SMBTORTURE4="bin/smbtorture4"
        AC_SUBST(SMBTORTURE4)
 fi
@@ -6977,6 +7123,9 @@ AC_ZLIB([ZLIB_OBJS=""], [
        CFLAGS="-I../lib/zlib $CFLAGS"
 ])
 
+AC_DEFINE(STATIC_gensec_MODULES, [gensec_spnego_init,gensec_ntlmssp_init,NULL],[gensec modules])
+AC_DEFINE(STATIC_gensec_MODULES_PROTO, [_MODULE_PROTO(gensec_spnego_init)_MODULE_PROTO(gensec_ntlmssp_init)],[gensec protos])
+
 AC_ARG_ENABLE(dmalloc, [AS_HELP_STRING([--enable-dmalloc], [Enable heap debugging [default=no]])])
 
 if test "x$enable_dmalloc" = xyes