build: Remove configure tests for *64 functions and types
[garming/samba-autobuild/.git] / source3 / configure.in
index b98b49ef88d54f239ed20ef6c0b929063b02c74b..3c7ed6f1258d0f8eac145d3738dee059cbf60a6e 100644 (file)
@@ -269,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
@@ -478,6 +475,7 @@ if test "x$developer" = xyes; then
    default_shared_modules="$default_shared_modules perfcount_test"
 fi
 
+
 #
 # Config CPPFLAG settings for strange OS's that must be set
 # before other tests. Do NOT invoke AC_CHECK_HEADERS within this
@@ -510,51 +508,19 @@ case "$host_os" in
 #
     *aix4*)
          AC_MSG_RESULT([enabling large file support])
-      CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
+         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..
-# Note that -D_LARGEFILE64_SOURCE is different from the Sun
-# recommendations on large file support, however it makes the
-# compile work using gcc 2.7 and 2.8, whereas using the Sun
-# recommendation makes the compile fail on gcc2.7. JRA.
 #
 # Solaris uses SYSV printing.  Make sure to set that here.  --jerry
 #
        *solaris*)
                AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
-               case `uname -r` in
-                       5.0|5.0.*|5.1|5.1.*|5.2|5.2.*|5.3|5.3.*|5.5|5.5.*)
-                               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
-                               ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
-                               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"
-                                               AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
-                                               ;;
-                                       *)
-                                               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_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
-                       ;;
-               esac
+               LDFLAGS="$LDFLAGS -lthread"
+               CPPFLAGS="$CPPFLAGS -D_REENTRANT"
                ;;
 #
 # IRIX uses SYSV printing.  Make sure to set that here
@@ -585,97 +551,13 @@ case "$host_os" in
                AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
     esac
     ;;
+# GNU systems
 #
-# Tests needed for SINIX large file support.
-#
-    *sysv4*)
-      if test $host = mips-sni-sysv4 ; then
-        AC_MSG_CHECKING([for LFS support])
-        old_CPPFLAGS="$CPPFLAGS"
-        CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
-        AC_TRY_RUN([
-#include <unistd.h>
-main () {
-#if _LFS64_LARGEFILE == 1
-exit(0);
-#else
-exit(1);
-#endif
-}], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
-        CPPFLAGS="$old_CPPFLAGS"
-        if test x$SINIX_LFS_SUPPORT = xyes ; then
-          CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
-                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
-          CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
-          LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
-          LIBS="`getconf LFS64_LIBS` $LIBS"
-        fi
-      AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
-      fi
-    ;;
-
-# Systems with LFS support.
-#
-    gnu* | k*bsd*-gnu | kopensolaris*-gnu)
-       CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
-       AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
-       AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
+    *linux* | *hurd* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
+       CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
        AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
        ;;
 
-# Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
-#
-    *linux*)
-        AC_MSG_CHECKING([for LFS support])
-        old_CPPFLAGS="$CPPFLAGS"
-        CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
-       AC_TRY_RUN([
-#include <unistd.h>
-#include <sys/utsname.h>
-#include <string.h>
-#include <stdlib.h>
-main() {
-#if _LFS64_LARGEFILE == 1
-       struct utsname uts;
-       char *release;
-       int major, minor;
-
-       /* Ensure this is glibc 2.2 or higher */
-#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
-       int libc_major = __GLIBC__;
-       int libc_minor = __GLIBC_MINOR__;
-
-       if (libc_major < 2)
-              exit(1);
-       if (libc_minor < 2)
-              exit(1);
-#endif
-
-       /* Ensure this is kernel 2.4 or higher */
-
-       uname(&uts);
-       release = strdup(uts.release);
-       major = atoi(strsep(&release, "."));
-       minor = atoi(strsep(&release, "."));
-
-       if (major > 2 || (major == 2 && minor > 3))
-               exit(0);
-       exit(1);
-#else
-       exit(1);
-#endif
-}
-], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
-       CPPFLAGS="$old_CPPFLAGS"
-       if test x$LINUX_LFS_SUPPORT = xyes ; then
-               CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
-               AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
-               AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
-               AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
-       fi
-       AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
-       ;;
-
 #
 # MacOS X is the *only* system that uses compose character in utf8. This
 # is so horribly broken....
@@ -687,30 +569,7 @@ main() {
        default_shared_modules="$default_shared_modules"
 
        ;;
-    *hurd*)
-        AC_MSG_CHECKING([for LFS support])
-        old_CPPFLAGS="$CPPFLAGS"
-        CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
-        AC_TRY_RUN([
-#include <unistd.h>
-main () {
-#if _LFS64_LARGEFILE == 1
-exit(0);
-#else
-exit(1);
-#endif
-}], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
-        CPPFLAGS="$old_CPPFLAGS"
-        if test x$GLIBC_LFS_SUPPORT = xyes ; then
-          CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
-                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
-          AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
-        fi
-      AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
-    ;;
     *qnx*)
-        CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
-        AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
         ;;
 
 esac
@@ -752,12 +611,20 @@ AC_CHECK_HEADERS(langinfo.h locale.h)
 AC_CHECK_HEADERS(xfs/libxfs.h)
 AC_CHECK_HEADERS(netgroup.h)
 AC_CHECK_HEADERS(linux/falloc.h)
+AC_CHECK_HEADERS(sys/uuid.h)
+AC_CHECK_HEADERS(CommonCrypto/CommonDigest.h)
 
 AC_CHECK_HEADERS(rpcsvc/yp_prot.h,,,[[
 #if HAVE_RPC_RPC_H
 #include <rpc/rpc.h>
 #endif
 ]])
+CRYPTO_MD5_OBJ=
+if test "x$ac_cv_header_CommonCrypto_CommonDigest_h" != "xyes"
+then
+       CRYPTO_MD5_OBJ="../lib/crypto/md5.o"
+fi
+AC_SUBST(CRYPTO_MD5_OBJ)
 
 ## These fail to compile on IRIX so just check for their presence
 AC_CHECK_HEADERS(sys/mode.h,,,)
@@ -769,9 +636,9 @@ AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEA
 CPPFLAGS="$old_CPPFLAGS"
 
 # To link lib/util/charset/charset_macosxfs.c, we need to tell the linker
-# about CoreFoundation
+# about CoreFoundation, at least on os X 10.6 and 10.7
 case "$host_os" in
-    *darwin11*)
+    *darwin11*|*darwin10*)
                LDFLAGS="$LDFLAGS -framework CoreFoundation"
        ;;
 esac
@@ -1078,7 +945,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)
@@ -1090,14 +957,12 @@ AC_CHECK_FUNCS(setsid glob strpbrk crypt16 getauthuid)
 AC_CHECK_FUNCS(sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
 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(fseeko fseek64 fseeko64 ftell64 ftello64 setluid getpwanam)
-AC_CHECK_FUNCS(opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64)
-AC_CHECK_FUNCS(fdopendir fdopendir64)
+AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf)
+AC_CHECK_FUNCS(atexit grantpt posix_fallocate)
+AC_CHECK_FUNCS(fallocate)
+AC_CHECK_FUNCS(fseeko setluid getpwanam)
+AC_CHECK_FUNCS(fdopendir)
 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)
@@ -1270,11 +1135,9 @@ AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
 AC_CHECK_FUNCS(getdents __getdents _lseek __lseek _read __read)
 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
-AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
-AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
-AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
-AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
-AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
+AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek)
+AC_CHECK_FUNCS(pread _pread __pread)
+AC_CHECK_FUNCS(pwrite _pwrite __pwrite)
 AC_CHECK_FUNCS(prctl)
 
 AC_TRY_COMPILE([
@@ -1319,52 +1182,6 @@ main() {
        ;;
 esac
 
-#
-# stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
-#
-
-if test x$ac_cv_func_stat64 = xno ; then
-  AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
-  AC_TRY_LINK([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <sys/stat.h>
-], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
-  AC_MSG_RESULT([$ac_cv_func_stat64])
-  if test x$ac_cv_func_stat64 = xyes ; then
-    AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
-  fi
-fi
-
-if test x$ac_cv_func_lstat64 = xno ; then
-  AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
-  AC_TRY_LINK([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <sys/stat.h>
-], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
-  AC_MSG_RESULT([$ac_cv_func_lstat64])
-  if test x$ac_cv_func_lstat64 = xyes ; then
-    AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
-  fi
-fi
-
-if test x$ac_cv_func_fstat64 = xno ; then
-  AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
-  AC_TRY_LINK([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <sys/stat.h>
-], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
-  AC_MSG_RESULT([$ac_cv_func_fstat64])
-  if test x$ac_cv_func_fstat64 = xyes ; then
-    AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
-  fi
-fi
-
 #################################################
 # Check whether struct stat has timestamps with sub-second resolution.
 #
@@ -2135,7 +1952,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
 
@@ -2177,15 +1994,15 @@ 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)
 fi
 
@@ -2263,19 +2080,6 @@ if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
     AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
 fi
 
-AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
-AC_TRY_RUN([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include <sys/stat.h>
-main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
-samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
-if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
-    AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
-fi
-
 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
 AC_TRY_RUN([
 #if defined(HAVE_UNISTD_H)
@@ -2289,19 +2093,6 @@ if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
     AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
 fi
 
-AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
-AC_TRY_RUN([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include <sys/stat.h>
-main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
-samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
-if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
-    AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
-fi
-
 AC_CACHE_CHECK([for 64 bit dev_t],samba_cv_SIZEOF_DEV_T,[
 AC_TRY_RUN([
 #if defined(HAVE_UNISTD_H)
@@ -2315,45 +2106,6 @@ if test x"$samba_cv_SIZEOF_DEV_T" = x"yes"; then
     AC_DEFINE(SIZEOF_DEV_T,8,[The size of the 'dev_t' type])
 fi
 
-AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
-AC_TRY_RUN([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include <sys/stat.h>
-main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
-samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
-if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
-    AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
-fi
-
-AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIR64,[
-AC_TRY_COMPILE([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <sys/types.h>
-#include <dirent.h>],
-[DIR64 de;],
-samba_cv_HAVE_STRUCT_DIR64=yes,samba_cv_HAVE_STRUCT_DIR64=no)])
-if test x"$samba_cv_HAVE_STRUCT_DIR64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
-    AC_DEFINE(HAVE_STRUCT_DIR64,1,[Whether the 'DIR64' abstract data type is available])
-fi
-
-AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
-AC_TRY_COMPILE([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <sys/types.h>
-#include <dirent.h>],
-[struct dirent64 de;],
-samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
-if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
-    AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
-fi
-
 AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
 AC_TRY_RUN([
 #if defined(HAVE_UNISTD_H)
@@ -2588,23 +2340,6 @@ if test x"$samba_cv_HAVE_LINUX_FALLOCATE" = x"yes" && test x"$ac_cv_func_falloca
     AC_DEFINE(HAVE_LINUX_FALLOCATE,1,[Whether the Linux 'fallocate' function is available])
 fi
 
-AC_CACHE_CHECK([for linux fallocate64],samba_cv_HAVE_LINUX_FALLOCATE64,[
-AC_TRY_COMPILE([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <sys/types.h>
-#define _GNU_SOURCE
-#include <fcntl.h>
-#if defined(HAVE_LINUX_FALLOC_H)
-#include <linux/falloc.h>
-#endif],
-[int ret = fallocate64(0, FALLOC_FL_KEEP_SIZE, 0, 10);],
-samba_cv_HAVE_LINUX_FALLOCATE64=yes,samba_cv_HAVE_LINUX_FALLOCATE64=no)])
-if test x"$samba_cv_HAVE_LINUX_FALLOCATE64" = x"yes" && test x"$ac_cv_func_fallocate64" = x"yes"; then
-    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)
@@ -3165,48 +2900,6 @@ if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
     AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
 fi
 
-AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
-AC_TRY_RUN([#include "${srcdir-.}/../tests/fcntl_lock64.c"],
-           samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
-if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
-    AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
-
-else
-
-dnl
-dnl Don't check for 64 bit fcntl locking if we know that the
-dnl glibc2.1 broken check has succeeded.
-dnl
-
-  AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
-  AC_TRY_RUN([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_SYS_FCNTL_H
-#include <sys/fcntl.h>
-#endif
-main() { struct flock64 fl64;
-#if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
-exit(0);
-#else
-exit(1);
-#endif
-}],
-       samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
-
-  if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
-      AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
-  fi
-fi
-
 # glibc up to 2.3.6 had dangerously broken posix_fallocate(). DON'T USE IT.
 AC_CACHE_CHECK([for broken posix_fallocate],samba_cv_HAVE_BROKEN_POSIX_FALLOCATE,[
 AC_TRY_COMPILE([
@@ -3844,7 +3537,12 @@ if test x"$with_ads_support" != x"no"; then
   if test x"$have_gssapi" != x"yes"; then
      AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],have_gssapi=yes)
      AC_CHECK_LIB_EXT(gss, KRB5_LIBS,gss_display_status,[],[],have_gssapi=yes)
-     AC_CHECK_FUNC_EXT(gss_wrap_iov, $KRB5_LIBS)
+  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)
@@ -3858,7 +3556,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)
@@ -3868,18 +3565,14 @@ 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_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_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)
@@ -3896,9 +3589,11 @@ if test x"$with_ads_support" != x"no"; then
   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)
 
   # This is for FreeBSD (and possibly others). gss_mech_krb5 is a
   # #define to GSS_KRB5_MECHANISM, which is defined in -lgssapi_krb5
@@ -3914,30 +3609,6 @@ if test x"$with_ads_support" != x"no"; then
 
   LIBS="$KRB5_LIBS $LIBS"
 
-  AC_CACHE_CHECK(whether krb5_ticket contains kvno and enctype,
-       smb_krb5_cv_ticket_has_keyinfo,
-       [
-           AC_TRY_COMPILE(
-           [
-               #include <krb5.h>
-           ],
-           [
-               krb5_ticket ticket;
-               krb5_kvno kvno;
-               krb5_enctype enctype;
-
-               enctype = ticket.enc_part.enctype;
-               kvno = ticket.enc_part.kvno;
-           ],
-           [ smb_krb5_cv_ticket_has_keyinfo=yes ],
-           [ smb_krb5_cv_ticket_has_keyinfo=no ])
-       ])
-
-  if test x"$smb_krb5_cv_ticket_has_keyinfo" = x"yes" ; then
-       AC_DEFINE(KRB5_TICKET_HAS_KEYINFO, 1,
-           [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_cv_creds_opt_free_context,
          [
@@ -3958,16 +3629,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>],
@@ -4064,41 +3725,6 @@ 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],
-                samba_cv_HAVE_KRB5_TKT_ENC_PART2,
-                 [AC_TRY_COMPILE([#include <krb5.h>],
-    [krb5_ticket tkt; tkt.enc_part2->authorization_data[0]->contents = NULL;],
-    samba_cv_HAVE_KRB5_TKT_ENC_PART2=yes,samba_cv_HAVE_KRB5_TKT_ENC_PART2=no)])
-
-  if test x"$samba_cv_HAVE_KRB5_TKT_ENC_PART2" = x"yes"; then
-    AC_DEFINE(HAVE_KRB5_TKT_ENC_PART2,1,
-              [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>],
@@ -4320,19 +3946,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,[
@@ -4412,13 +4025,13 @@ if test x"$with_ads_support" != x"no"; then
     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)
+  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_func_ext_krb5_c_enctype_compare" != x"yes"; then
-    AC_MSG_WARN(krb5_c_enctype_compare not found in -lkrb5)
+  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
 
@@ -4452,6 +4065,24 @@ if test x"$with_ads_support" != x"no"; then
     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
@@ -4479,31 +4110,18 @@ if test x"$with_ads_support" != x"no"; then
     use_ads=no
   fi
 
-  if test x"$smb_krb5_cv_ticket_has_keyinfo" != x"yes" ; then
-
-      # We only need the following functions if we can't get the enctype
-      # and kvno out of the ticket directly (ie. on Heimdal).
-
-      if test x"$ac_cv_func_ext_free_AP_REQ" != x"yes"
-      then
-       AC_MSG_WARN(no KRB5_AP_REQ_FREE_FUNCTION detected)
-       use_ads=no
-      fi
-
-      if test x"$ac_cv_func_ext_krb5_decode_ap_req" != x"yes"
-      then
-       AC_MSG_WARN(no KRB5_AP_REQ_DECODING_FUNCTION detected)
-       use_ads=no
-      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"$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)
@@ -4547,7 +4165,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
@@ -5256,30 +4874,6 @@ fi
 AC_CHECKING(how to get filesystem space usage)
 space=no
 
-# Test for statvfs64.
-if test $space = no; then
-  # SVR4
-  AC_CACHE_CHECK([statvfs64 function (SVR4)], fu_cv_sys_stat_statvfs64,
-  [AC_TRY_RUN([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <sys/types.h>
-#include <sys/statvfs.h>
-  main ()
-  {
-    struct statvfs64 fsd;
-    exit (statvfs64 (".", &fsd));
-  }],
-  fu_cv_sys_stat_statvfs64=yes,
-  fu_cv_sys_stat_statvfs64=no,
-  fu_cv_sys_stat_statvfs64=cross)])
-  if test $fu_cv_sys_stat_statvfs64 = yes; then
-    space=yes
-    AC_DEFINE(STAT_STATVFS64,1,[Whether statvfs64() is available])
-  fi
-fi
-
 # Perform only the link test since it seems there are no variants of the
 # statvfs function.  This check is more than just AC_CHECK_FUNCS(statvfs)
 # because that got a false positive on SCO OSR5.  Adding the declaration
@@ -5476,25 +5070,23 @@ fi
 #
 # As a gating factor for large file support, in order to
 # use <4GB files we must have the following minimal support
-# available.
-# long long, and a 64 bit off_t or off64_t.
-# If we don't have all of these then disable large
-# file support.
+# available: a 64 bit off_t
+# If we don't have all of these then fail the build
 #
 AC_MSG_CHECKING([if large file support can be enabled])
 AC_TRY_COMPILE([
-#if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
+#if (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8))
 #include <sys/types.h>
 #else
 __COMPILE_ERROR_
 #endif
 ],
 [int i],
-samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
-if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
-       AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
+samba_cv_HAVE_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_LARGEFILE_SUPPORT=no)
+if test x"$samba_cv_HAVE_LARGEFILE_SUPPORT" != x"yes"; then
+       AC_MSG_ERROR(["large file support support not available: sizeof(off_t) != 8"])
 fi
-AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
+AC_MSG_RESULT([$samba_cv_HAVE_LARGEFILE_SUPPORT])
 
 
 #################################################
@@ -5628,6 +5220,34 @@ if test "x$have_cluster_support" = "xyes" ; then
        fi
 fi
 
+AC_ARG_ENABLE([ctdb-readonly-records],
+       AS_HELP_STRING([--enable-ctdb-readonly-records],
+               [Turn on CTDB readonly records support (default=yes)]),
+       [want_ctdb_readonly=$enableval],
+       [want_ctdb_readonly=yes])
+
+if test "x$have_cluster_support" = "xyes" -a "x$want_ctdb_readonly" = "xyes" ; then
+       AC_HAVE_DECL(CTDB_WANT_READONLY,[
+       #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>
+       ])
+
+       if test "x$ac_cv_have_CTDB_WANT_READONLY_decl" != "xyes" ; then
+               if test "x$enable_old_ctdb" = "xyes" ; then
+                       AC_MSG_WARN([ignoring missing READONLY support (--enable-old-ctdb)])
+               else
+                       ctdb_broken="support for CTDB readonly records missing"
+                       have_cluster_support=no
+               fi
+       fi
+fi
+
 if test "x$have_cluster_support" = "xyes" ; then
        # In ctdb 1.0.57, ctdb_control_tcp was temporarily renamed
        # to ctdb_tcp_client.
@@ -5868,24 +5488,9 @@ AC_ARG_WITH(aio-support,
 [ struct aiocb a; return aio_read(&a);],
 samba_cv_HAVE_AIO=yes,samba_cv_HAVE_AIO=no)
                LIBS=$aio_LIBS])
-               AC_CACHE_CHECK([for 64-bit asynchronous io support],samba_cv_HAVE_AIO64,[
-               aio_LIBS=$LIBS
-               LIBS=$AIO_LIBS
-               AC_TRY_LINK([#include <sys/types.h>
-#include <aio.h>],
-[ struct aiocb64 a; return aio_read64(&a);],
-samba_cv_HAVE_AIO64=yes,samba_cv_HAVE_AIO64=no)
-               LIBS=$aio_LIBS])
-               if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
-                       AC_DEFINE(HAVE_AIOCB64,1,[Whether 64 bit aio is available])
-                       AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
-                       LIBS=$AIO_LIBS
-               elif test x"$samba_cv_HAVE_AIO" = x"yes"; then
+               if test x"$samba_cv_HAVE_AIO" = x"yes"; then
                        AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
                        LIBS=$AIO_LIBS
-               fi
-
-               if test x"$samba_cv_HAVE_AIO" = x"yes"; then
                        AC_MSG_CHECKING(for aio_read)
                        AC_LINK_IFELSE([#include <aio.h>
 int main() { struct aiocb a; return aio_read(&a); }],
@@ -5929,49 +5534,6 @@ int main() { struct aiocb a; return aio_suspend(&a, 1, NULL); }],
 [AC_MSG_RESULT(no)])
                fi
 
-               if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
-                       AC_MSG_CHECKING(for aio_read64)
-                       AC_LINK_IFELSE([#include <aio.h>
-int main() { struct aiocb a; return aio_read64(&a); }],
-[AC_DEFINE(HAVE_AIO_READ64, 1, [Have aio_read64]) AC_MSG_RESULT(yes)],
-[AC_MSG_RESULT(no)])
-
-                       AC_MSG_CHECKING(for aio_write64)
-                       AC_LINK_IFELSE([#include <aio.h>
-int main() { struct aiocb a; return aio_write64(&a); }],
-[AC_DEFINE(HAVE_AIO_WRITE64, 1, [Have aio_write64]) AC_MSG_RESULT(yes)],
-[AC_MSG_RESULT(no)])
-
-                       AC_MSG_CHECKING(for aio_fsync64)
-                       AC_LINK_IFELSE([#include <aio.h>
-int main() { struct aiocb a; return aio_fsync64(1, &a); }],
-[AC_DEFINE(HAVE_AIO_FSYNC64, 1, [Have aio_fsync64]) AC_MSG_RESULT(yes)],
-[AC_MSG_RESULT(no)])
-
-                       AC_MSG_CHECKING(for aio_return64)
-                       AC_LINK_IFELSE([#include <aio.h>
-int main() { struct aiocb a; return aio_return64(&a); }],
-[AC_DEFINE(HAVE_AIO_RETURN64, 1, [Have aio_return64]) AC_MSG_RESULT(yes)],
-[AC_MSG_RESULT(no)])
-
-                       AC_MSG_CHECKING(for aio_error64)
-                       AC_LINK_IFELSE([#include <aio.h>
-int main() { struct aiocb a; return aio_error64(&a); }],
-[AC_DEFINE(HAVE_AIO_ERROR64, 1, [Have aio_error64]) AC_MSG_RESULT(yes)],
-[AC_MSG_RESULT(no)])
-
-                       AC_MSG_CHECKING(for aio_cancel64)
-                       AC_LINK_IFELSE([#include <aio.h>
-int main() { struct aiocb a; return aio_cancel64(1, &a); }],
-[AC_DEFINE(HAVE_AIO_CANCEL64, 1, [Have aio_cancel64]) AC_MSG_RESULT(yes)],
-[AC_MSG_RESULT(no)])
-
-                       AC_MSG_CHECKING(for aio_suspend64)
-                       AC_LINK_IFELSE([#include <aio.h>
-int main() { struct aiocb a; return aio_suspend64(&a, 1, NULL); }],
-[AC_DEFINE(HAVE_AIO_SUSPEND64, 1, [Have aio_suspend64]) AC_MSG_RESULT(yes)],
-[AC_MSG_RESULT(no)])
-               fi
             ;;
         esac
         ;;
@@ -6005,16 +5567,6 @@ AC_ARG_WITH(sendfile-support,
 
        case "$host_os" in
        *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
-               AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
-               AC_TRY_LINK([#include <sys/sendfile.h>],
-[\
-int tofd, fromfd;
-off64_t offset;
-size_t total;
-ssize_t nwritten = sendfile64(tofd, fromfd, &offset, total);
-],
-samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
-
                AC_CACHE_CHECK([for linux sendfile support],samba_cv_HAVE_SENDFILE,[
                AC_TRY_LINK([#include <sys/sendfile.h>],
 [\
@@ -6040,11 +5592,7 @@ ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
 ],
 samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)])
 
-       if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
-               AC_DEFINE(HAVE_SENDFILE64,1,[Whether 64-bit sendfile() is available])
-               AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
-               AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
-       elif test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
+        if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
                AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
                AC_DEFINE(LINUX_SENDFILE_API,1,[Whether linux sendfile() API is available])
                AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
@@ -6088,31 +5636,6 @@ samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
        ;;
 
        *hpux*)
-               AC_CACHE_CHECK([for hpux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
-               AC_TRY_LINK([\
-#include <sys/socket.h>
-#include <sys/uio.h>],
-[\
-       int fromfd, tofd;
-       size_t total=0;
-       struct iovec hdtrl[2];
-       ssize_t nwritten;
-       off64_t offset;
-
-       hdtrl[0].iov_base = 0;
-       hdtrl[0].iov_len = 0;
-
-       nwritten = sendfile64(tofd, fromfd, offset, total, &hdtrl[0], 0);
-],
-samba_cv_HAVE_SENDFILE64=yes,samba_cv_HAVE_SENDFILE64=no)])
-       if test x"$samba_cv_HAVE_SENDFILE64" = x"yes"; then
-               AC_DEFINE(HAVE_SENDFILE64,1,[Whether sendfile64() is available])
-               AC_DEFINE(HPUX_SENDFILE_API,1,[Whether the hpux sendfile() API is available])
-               AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
-       else
-               AC_MSG_RESULT(no);
-       fi
-
                AC_CACHE_CHECK([for hpux sendfile support],samba_cv_HAVE_SENDFILE,[
                AC_TRY_LINK([\
 #include <sys/socket.h>
@@ -6141,39 +5664,6 @@ samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
 
        *solaris*)
                AC_CHECK_LIB(sendfile,sendfilev)
-               AC_CACHE_CHECK([for solaris sendfilev64 support],samba_cv_HAVE_SENDFILEV64,[
-               AC_TRY_LINK([\
-#include <sys/sendfile.h>],
-[\
-        int sfvcnt;
-        size_t xferred;
-        struct sendfilevec vec[2];
-       ssize_t nwritten;
-       int tofd;
-
-       sfvcnt = 2;
-
-       vec[0].sfv_fd = SFV_FD_SELF;
-       vec[0].sfv_flag = 0;
-       vec[0].sfv_off = 0;
-       vec[0].sfv_len = 0;
-
-       vec[1].sfv_fd = 0;
-       vec[1].sfv_flag = 0;
-       vec[1].sfv_off = 0;
-       vec[1].sfv_len = 0;
-       nwritten = sendfilev64(tofd, vec, sfvcnt, &xferred);
-],
-samba_cv_HAVE_SENDFILEV64=yes,samba_cv_HAVE_SENDFILEV64=no)])
-
-       if test x"$samba_cv_HAVE_SENDFILEV64" = x"yes"; then
-               AC_DEFINE(HAVE_SENDFILEV64,1,[Whether sendfilev64() is available])
-               AC_DEFINE(SOLARIS_SENDFILE_API,1,[Whether the soloris sendfile() API is available])
-               AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() support should be included])
-       else
-               AC_MSG_RESULT(no);
-       fi
-
                AC_CACHE_CHECK([for solaris sendfilev support],samba_cv_HAVE_SENDFILEV,[
                AC_TRY_LINK([\
 #include <sys/sendfile.h>],
@@ -6474,7 +5964,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
@@ -6507,8 +5997,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"
@@ -6563,31 +6053,6 @@ AC_CHECK_MEMBERS([struct secmethod_table.method_attrlist], , ,
 AC_CHECK_MEMBERS([struct secmethod_table.method_version], , ,
        [#include <usersec.h>])
 
-AC_CACHE_CHECK([for SO_PEERCRED],samba_cv_HAVE_PEERCRED,[
-AC_TRY_COMPILE([#include <sys/types.h>
-#include <sys/socket.h>],
-[struct ucred cred;
- socklen_t cred_len;
- int ret = getsockopt(0, SOL_SOCKET, SO_PEERCRED, &cred, &cred_len);
-],
-samba_cv_HAVE_PEERCRED=yes,samba_cv_HAVE_PEERCRED=no,samba_cv_HAVE_PEERCRED=cross)])
-if test x"$samba_cv_HAVE_PEERCRED" = x"yes"; then
-    AC_DEFINE(HAVE_PEERCRED,1,[Whether we can use SO_PEERCRED to get socket credentials])
-fi
-
-AC_CACHE_CHECK([for getpeereid],samba_cv_HAVE_GETPEEREID,[
-AC_TRY_LINK([#include <sys/types.h>
-#include <unistd.h>],
-[uid_t uid; gid_t gid; int ret;
- ret = getpeereid(0, &uid, &gid);
-],
-samba_cv_HAVE_GETPEEREID=yes,samba_cv_HAVE_GETPEEREID=no)])
-if test x"$samba_cv_HAVE_GETPEEREID" = xyes; then
-   AC_DEFINE(HAVE_GETPEEREID,1,
-            [Whether we have getpeereid to get socket credentials])
-fi
-
-
 #################################################
 # Check to see if we should use the included popt
 
@@ -6772,13 +6237,14 @@ if test x"$enable_pthreadpool" = x"yes" -a x"$samba_cv_HAVE_PTHREAD" = x"yes"; t
     CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
     AC_DEFINE(WITH_PTHREADPOOL, 1, [Whether to include pthreadpool helpers])
     AC_SUBST(PTHREADPOOL_OBJ, "lib/pthreadpool/pthreadpool.o")
-    PTHREADPOOLTEST="bin/pthreadpooltest\$(EXEEXT)"
+    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
 
+
 #################################################
 # Check to see if we should use the included iniparser
 
@@ -6814,6 +6280,12 @@ AC_SUBST(BUILD_INIPARSER)
 AC_SUBST(INIPARSERLIBS)
 AC_SUBST(FLAGS1)
 
+AC_ARG_ENABLE(fault-handler,[AS_HELP_STRING([--disable-fault-handler], [Disable the default handler])])
+
+if test x"$enable_fault_handler" = x"no"; then
+       AC_DEFINE(HAVE_DISABLE_FAULT_HANDLER, 1, [Disable the default signal handler])
+fi
+
 ###################################################
 # Check for different/missing (set|get|end)netgrent prototypes
 CFLAGS_SAVE=$CFLAGS
@@ -6850,13 +6322,44 @@ fi
 
 CFLAGS=$CFLAGS_SAVE
 
+# Checks for *BSD bsd_statvfs() function
+# Start
+AC_CHECK_HEADERS(sys/param.h sys/mount.h)
+
+AC_MSG_CHECKING([bsd_statvfs: checking for statfs() and struct statfs.bsize])
+AC_CACHE_VAL(bsdstatvfs_cv_statfs,[
+            AC_TRY_RUN([
+               #ifdef HAVE_SYS_PARAM_H
+               #include <sys/param.h>
+               #endif
+               #ifdef HAVE_SYS_MOUNT_H
+               #include <sys/mount.h>
+               #endif
+               int main (void)
+               {
+                       struct statfs fsd;
+                       fsd.f_bsize = 0;
+                       exit (statfs (".", &fsd));
+               }],
+               bsdstatvfs_cv_statfs=yes,
+               bsdstatvfs_cv_statfs=no,
+               bsdstatvfs_cv_statfs=no)])
+AC_MSG_RESULT($bsdstatvfs_cv_statfs)
+
+if test $bsdstatvfs_cv_statfs = yes; then
+  AC_DEFINE(BSD_STATVFS_BSIZE,1,[Whether statfs exists and struct statfs has bsize property])
+fi
+
+# End
+# Checks for *BSD sys_statvfs() function
+
 # Checks for the vfs_fileid module
 # Start
 AC_CHECK_FUNC(getmntent)
 
 AC_CHECK_HEADERS(sys/statfs.h)
 
-AC_MSG_CHECKING([vfs_fileid: checking for statfs() and struct statfs.f_fsid)])
+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>
@@ -6929,7 +6432,7 @@ 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 passdb/pdb_ipa.o passdb/pdb_ldap_util.o passdb/pdb_ldap_schema.o,
+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)
@@ -7139,6 +6642,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
@@ -7188,7 +6694,7 @@ AC_TRY_RUN([#include "${srcdir-.}/../tests/summary.c"],
 dnl Merge in developer cflags from now on
 AC_SUBST(DEVELOPER_CFLAGS)
 if test x"$krb5_developer" = x"yes" -o x"$developer" = x"yes" -o x"$picky_developer" = x"yes"; then
-    CFLAGS="${CFLAGS} \$(DEVELOPER_CFLAGS)"
+    CFLAGS="${CFLAGS} \$(DEVELOPER_CFLAGS) ${CFLAGS_APPEND}"
 fi
 
 # Stuff the smbd-only libraries at the end of the smbd link