s3: Remove madvise support
[ira/wip.git] / source3 / configure.in
index fc3cb261d4331e2be49f524251e6aac1c5b7ea6e..e48ff345540782ffe2dc9201757ca4b2ed4c335d 100644 (file)
@@ -31,6 +31,15 @@ for obj in ${TALLOC_OBJ}; do
 done
 AC_SUBST(LIBTALLOC_OBJ0)
 
+m4_include(../lib/tevent/libtevent.m4)
+
+LIBTEVENT_OBJ0=""
+for obj in ${TEVENT_OBJ}; do
+       LIBTEVENT_OBJ0="${LIBTEVENT_OBJ0} ${teventdir}/${obj}"
+done
+AC_SUBST(LIBTEVENT_OBJ0)
+LIBS="${LIBS} ${TEVENT_LIBS}"
+
 # TODO: These should come from m4_include(lib/tdb/libtdb.m4)
 # but currently this fails: things have to get merged from s4.
 tdbdir="../lib/tdb"
@@ -50,9 +59,11 @@ AC_SUBST(LIBTDB_OBJ0)
 SAMBA_CPPFLAGS="-Iinclude -I${srcdir-.}/include  -I. -I${srcdir-.}"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/replace"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TALLOC_CFLAGS}"
+SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TEVENT_CFLAGS}"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} ${TDB_CFLAGS}"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/libaddns"
 SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/librpc"
+SAMBA_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/.."
 
 SAMBA_CONFIGURE_CPPFLAGS="${SAMBA_CPPFLAGS} -I${srcdir-.}/../lib/popt"
 
@@ -217,10 +228,17 @@ AC_ARG_WITH(profiling-data,
 )
 
 dnl Checks for programs.
+merged_build_possible=yes
 
 AC_PROG_INSTALL
 AC_PROG_AWK
-AC_PATH_PROG(PERL, perl)
+# Check for GNU make
+m4_include(../m4/check_make.m4)
+AC_SAMBA_GNU_MAKE([true], [merged_build_possible=no])
+
+# Check for perl
+m4_include(../m4/check_perl.m4)
+AC_SAMBA_PERL([true], [merged_build_possible=no])
 
 AC_CHECK_TOOL(AR, ar)
 
@@ -396,14 +414,14 @@ AC_SUBST(DYNEXP)
 
 dnl Add modules that have to be built by default here
 dnl These have to be built static:
-default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsarpc rpc_samr rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl2 rpc_ntsvcs rpc_netlogon rpc_netdfs rpc_srvsvc rpc_spoolss rpc_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin auth_netlogond vfs_default nss_info_template"
+default_static_modules="pdb_smbpasswd pdb_tdbsam pdb_wbc_sam rpc_lsarpc rpc_samr rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl rpc_ntsvcs rpc_netlogon rpc_netdfs rpc_srvsvc rpc_spoolss2 rpc_eventlog auth_sam auth_unix auth_winbind auth_wbc auth_server auth_domain auth_builtin auth_netlogond vfs_default nss_info_template"
 
 dnl These are preferably build shared, and static if dlopen() is not available
 default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850 charset_CP437 auth_script vfs_readahead vfs_xattr_tdb vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb vfs_smb_traffic_analyzer"
 
 if test "x$developer" = xyes; then
    default_static_modules="$default_static_modules rpc_rpcecho"
-   default_shared_modules="$default_shared_modules charset_weird"
+   default_shared_modules="$default_shared_modules charset_weird perfcount_test"
 fi
 
 #
@@ -685,18 +703,6 @@ CPPFLAGS="$old_CPPFLAGS"
 # subdirectory of headers.
 AC_CHECK_HEADERS(valgrind.h valgrind/valgrind.h valgrind/memcheck.h)
 
-# check for linux on amd64 since valgrind is not quite there yet
-case "$host_os" in
-       *linux*)
-               case "$UNAME_P" in
-                       *x86_64*)
-                               AC_DEFINE(HAVE_64BIT_LINUX,1,[Whether we are running on 64bit linux])
-                               ;;
-               esac
-               ;;
-esac
-
-
 #
 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
 # This causes configure to fail to detect it. Check for shadow separately on HPUX.
@@ -1009,7 +1015,7 @@ fi
 
 AC_CHECK_FUNCS(getcwd fchown chmod fchmod mknod mknod64)
 AC_CHECK_FUNCS(strtol)
-AC_CHECK_FUNCS(fstat strchr chflags)
+AC_CHECK_FUNCS(strchr chflags)
 AC_CHECK_FUNCS(getrlimit fsync fdatasync setpgid)
 AC_CHECK_FUNCS(setsid glob strpbrk crypt16 getauthuid)
 AC_CHECK_FUNCS(sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
@@ -1023,7 +1029,7 @@ 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(nanosleep)
+AC_CHECK_FUNCS(nanosleep,,[AC_CHECK_LIB_EXT(rt, LIBS, nanosleep)])
 AC_CHECK_FUNCS(mlock munlock mlockall munlockall)
 AC_CHECK_FUNCS(memalign posix_memalign hstrerror)
 AC_CHECK_HEADERS(sys/mman.h)
@@ -1038,6 +1044,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
+AC_CHECK_FUNCS(sysctlbyname)
+
 printf "%s" "checking for GPFS GPL libs... "
 save_LIBS="$LIBS"
 LIBS="$LIBS -lgpfs_gpl"
@@ -1078,8 +1087,11 @@ AC_TRY_LINK([#include <isi_version/isi_version.h>],
 echo $samba_cv_HAVE_ONEFS
 if test x"$samba_cv_HAVE_ONEFS" = x"yes"; then
     AC_DEFINE(HAVE_ONEFS,1,[Whether building on Isilon OneFS])
-    default_shared_modules="$default_shared_modules vfs_onefs"
-    ONEFS_LIBS="-lisi_acl"
+    default_shared_modules="$default_shared_modules vfs_onefs vfs_onefs_shadow_copy perfcount_onefs"
+    default_static_modules="$default_static_modules"
+    ONEFS_LIBS="-lisi_acl -lisi_ecs -lisi_event -lisi_util"
+    # Need to also add general libs for oplocks support
+    save_LIBS="$save_LIBS -lisi_ecs -lisi_event -lisi_util -ldevstat"
 fi
 AC_SUBST(ONEFS_LIBS)
 LIBS="$save_LIBS"
 
 #################################################
 # Check whether struct stat has timestamps with sub-second resolution.
-# At least IRIX and Solaris have these.
 #
-# We check that
-#      all of st_mtim, st_atim and st_ctim exist
-#      all of the members are in fact of type struct timespec
-#
-# There is some conflicting standards weirdness about whether we should use
-# "struct timespec" or "timespec_t". Linux doesn't have timespec_t, so we
-# prefer struct timespec.
 
-AC_CACHE_CHECK([whether struct stat has sub-second timestamps], samba_cv_stat_hires,
-    [
-       AC_TRY_COMPILE(
-           [
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-           ],
-           [
-               struct timespec t;
-               struct stat s = {0};
-               t.tv_sec = s.st_mtim.tv_sec;
-               t.tv_nsec = s.st_mtim.tv_nsec;
-               t.tv_sec = s.st_ctim.tv_sec;
-               t.tv_nsec = s.st_ctim.tv_nsec;
-               t.tv_sec = s.st_atim.tv_sec;
-               t.tv_nsec = s.st_atim.tv_nsec;
-           ],
-           samba_cv_stat_hires=yes, samba_cv_stat_hires=no)
-    ])
+samba_cv_stat_hires=no
+AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec], # Linux, Solaris
+       [samba_cv_stat_hires=yes])
+AC_CHECK_MEMBERS([struct stat.st_mtimensec], # BSD, if defined _POSIX_SOURCE
+       [samba_cv_stat_hires=yes])
+AC_CHECK_MEMBERS([struct stat.st_mtimespec.tv_nsec], # BSD, if not defined _POSIX_SOURCE
+       [samba_cv_stat_hires=yes])
+AC_CHECK_MEMBERS([struct stat.st_mtime_n], # AIX
+       [samba_cv_stat_hires=yes])
+AC_CHECK_MEMBERS([struct stat.st_umtime], # Tru64
+       [samba_cv_stat_hires=yes])
 
 if test x"$samba_cv_stat_hires" = x"yes" ; then
-    AC_DEFINE(HAVE_STAT_ST_MTIM, 1, [whether struct stat contains st_mtim])
-    AC_DEFINE(HAVE_STAT_ST_ATIM, 1, [whether struct stat contains st_atim])
-    AC_DEFINE(HAVE_STAT_ST_CTIM, 1, [whether struct stat contains st_ctim])
     AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
            [whether struct stat has sub-second timestamps])
 fi
 
-AC_CACHE_CHECK([whether struct stat has sub-second timestamps without struct timespec], samba_cv_stat_hires_notimespec,
-    [
-       AC_TRY_COMPILE(
-           [
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-           ],
-           [
-               struct timespec t;
-               struct stat s = {0};
-               t.tv_sec = s.st_mtime;
-               t.tv_nsec = s.st_mtimensec;
-               t.tv_sec = s.st_ctime;
-               t.tv_nsec = s.st_ctimensec;
-               t.tv_sec = s.st_atime;
-               t.tv_nsec = s.st_atimensec;
-           ],
-           samba_cv_stat_hires=yes, samba_cv_stat_hires=no)
-    ])
-
-if test x"$samba_cv_stat_hires_notimespec" = x"yes" ; then
-    AC_DEFINE(HAVE_STAT_ST_MTIMENSEC, 1, [whether struct stat contains st_mtimensec])
-    AC_DEFINE(HAVE_STAT_ST_ATIMENSEC, 1, [whether struct stat contains st_atimensec])
-    AC_DEFINE(HAVE_STAT_ST_CTIMENSEC, 1, [whether struct stat contains st_ctimensec])
-    AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
-           [whether struct stat has sub-second timestamps without struct timespec])
-fi
-
-AC_CACHE_CHECK([whether struct stat has st_birthtimespec], samba_cv_stat_st_birthtimespec,
-    [
-       AC_TRY_COMPILE(
-           [
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-           ],
-           [
-               struct timespec t;
-               struct stat s = {0};
-               t = s.st_birthtimespec;
-           ],
-           samba_cv_stat_st_birthtimespec=yes, samba_cv_stat_birthtimespec=no)
-    ])
-
-if test x"$samba_cv_stat_st_birthtimespec" = x"yes" ; then
-    AC_DEFINE(HAVE_STAT_ST_BIRTHTIMESPEC, 1, [whether struct stat contains st_birthtimespec])
-fi
-
-AC_CACHE_CHECK([whether struct stat has st_birthtimensec], samba_cv_stat_st_birthtimensec,
-    [
-       AC_TRY_COMPILE(
-           [
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-           ],
-           [
-               struct timespec t;
-               struct stat s = {0};
-               t.tv_nsec = s.st_birthtimensec;
-           ],
-           samba_cv_stat_st_birthtimensec=yes, samba_cv_stat_birthtimensec=no)
-    ])
-
-if test x"$samba_cv_stat_st_birthtimensec" = x"yes" ; then
-    AC_DEFINE(HAVE_STAT_ST_BIRTHTIMENSEC, 1, [whether struct stat contains st_birthtimensec])
-fi
-
-AC_CACHE_CHECK([whether struct stat has st_birthtime], samba_cv_stat_st_birthtime,
-    [
-       AC_TRY_COMPILE(
-           [
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-           ],
-           [
-               struct time_t t;
-               struct stat s = {0};
-               t = s.st_birthtime;
-           ],
-           samba_cv_stat_st_birthtime=yes, samba_cv_stat_birthtime=no)
-    ])
+# recent FreeBSD, NetBSD have creation timestamps called birthtime:
+AC_CHECK_MEMBERS([struct stat.st_birthtimespec.tv_nsec])
+AC_CHECK_MEMBERS([struct stat.st_birthtime], AC_CHECK_MEMBERS([struct stat.st_birthtimensec]))
 
-if test x"$samba_cv_stat_st_birthtime" = x"yes" ; then
-    AC_DEFINE(HAVE_STAT_ST_BIRTHTIME, 1, [whether struct stat contains st_birthtime])
-fi
 
 AC_CACHE_CHECK([whether there is DOS flags support in the stat struct], samba_cv_stat_dos_flags,
     [
@@ -1899,7 +1757,7 @@ AC_CACHE_CHECK([whether building shared libraries actually works],
    # The $SHLD and $LDSHFLAGS variables may contain references to other
    # variables so they need to be eval'ed.
    $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o \
-       shlib.o ${srcdir-.}/tests/shlib.c && \
+       shlib.o ${srcdir-.}/../tests/shlib.c && \
    `eval echo $SHLD` `eval echo $LDSHFLAGS` -o "shlib.$SHLIBEXT" \
         shlib.o && ac_cv_shlib_works=yes
    rm -f "shlib.$SHLIBEXT" shlib.o
@@ -2732,20 +2590,20 @@ if test x"$samba_cv_HAVE_RPC_AUTH_ERROR_CONFLICT" = x"yes"; then
 fi
 
 AC_MSG_CHECKING([for test routines])
-AC_TRY_RUN([#include "${srcdir-.}/tests/trivial.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/trivial.c"],
            AC_MSG_RESULT(yes),
           AC_MSG_ERROR([cant find test code. Aborting config]),
           AC_MSG_WARN([cannot run when cross-compiling]))
 
 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
-AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncate.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/ftruncate.c"],
            samba_cv_HAVE_FTRUNCATE_EXTEND=yes,samba_cv_HAVE_FTRUNCATE_EXTEND=no,samba_cv_HAVE_FTRUNCATE_EXTEND=cross)])
 if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
     AC_DEFINE(HAVE_FTRUNCATE_EXTEND,1,[Truncate extend])
 fi
 
 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
-AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/getgroups.c"],
            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
 if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
@@ -2832,14 +2690,14 @@ if test x"$samba_cv_DARWIN_INITGROUPS" = x"yes" ; then
 fi
 
 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
-AC_TRY_RUN([#include "${srcdir-.}/tests/fcntl_lock.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/fcntl_lock.c"],
            samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
 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"],
+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])
@@ -3331,7 +3189,7 @@ if test x"$with_ads_support" != x"no"; then
   # check for krb5-config from recent MIT and Heimdal kerberos 5
   AC_PATH_PROG(KRB5CONFIG, krb5-config)
   AC_MSG_CHECKING(for working krb5-config)
-  if test -x "$KRB5CONFIG"; then
+  if test -x "$KRB5CONFIG" && $KRB5CONFIG --libs gssapi > /dev/null ; then
     ac_save_CFLAGS=$CFLAGS
     CFLAGS="";export CFLAGS
     ac_save_LDFLAGS=$LDFLAGS
@@ -4358,7 +4216,7 @@ if test $with_pam_for_crypt = no; then
 AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
 crypt_LIBS="$LIBS"
 LIBS="$AUTH_LIBS $LIBS"
-AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/crypttest.c"],
        samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)
 LIBS="$crypt_LIBS"])
 if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
@@ -4586,7 +4444,7 @@ AC_TRY_RUN_STRICT([
 #define HAVE_QUOTACTL_4A 1
 #define AUTOCONF_TEST 1
 #include "confdefs.h"
-#include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
+#include "${srcdir-.}/../tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
            samba_cv_HAVE_QUOTACTL_4A=yes,samba_cv_HAVE_QUOTACTL_4A=no,samba_cv_HAVE_QUOTACTL_4A=cross)])
 if test x"$samba_cv_HAVE_QUOTACTL_4A" = x"yes"; then
     samba_cv_SYSQUOTA_FOUND=yes;
@@ -4601,7 +4459,7 @@ AC_TRY_RUN_STRICT([
 #define HAVE_QUOTACTL_4B 1
 #define AUTOCONF_TEST 1
 #include "confdefs.h"
-#include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
+#include "${srcdir-.}/../tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
            samba_cv_HAVE_QUOTACTL_4B=yes,samba_cv_HAVE_QUOTACTL_4B=no,samba_cv_HAVE_QUOTACTL_4B=cross)])
 if test x"$samba_cv_HAVE_QUOTACTL_4B" = x"yes"; then
     echo "int quotactl(const char *path, int cmd, int id, char *addr) is not reworked for the new sys_quota api"
@@ -4617,7 +4475,7 @@ AC_TRY_RUN_STRICT([
 #define HAVE_QUOTACTL_3 1
 #define AUTOCONF_TEST 1
 #include "confdefs.h"
-#include "${srcdir-.}/tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
+#include "${srcdir-.}/../tests/sysquotas.c"],[$Werror_FLAGS],[$CPPFLAGS],[$LDFLAGS],
            samba_cv_HAVE_QUOTACTL_3=yes,samba_cv_HAVE_QUOTACTL_3=no,samba_cv_HAVE_QUOTACTL_3=cross)])
 if test x"$samba_cv_HAVE_QUOTACTL_3" = x"yes"; then
     echo "CRAY int quotactl (char *spec, int request, char *arg) is NOT reworked for the sys_quota api"
@@ -4864,7 +4722,6 @@ SMB_LIBRARY(lua, 0)
 SMB_LIBRARY(addns, 0, no, [undefined API])
 
 
-
 #################################################
 # these tests are taken from the GNU fileutils package
 AC_CHECKING(how to get filesystem space usage)
@@ -4935,6 +4792,23 @@ if test x"$samba_cv_frsize" = x"yes"; then
     AC_DEFINE(HAVE_FRSIZE, 1, [Whether statvfs.f_frsize exists])
 fi
 
+# Some systems use f_flag in struct statvfs while others use f_flags
+AC_CACHE_CHECK([that statvfs.statvfs_f_flag works],samba_cv_statvfs_f_flag, [
+    AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/statvfs.h>],[struct statvfs buf; buf.f_flag = 0],
+       samba_cv_statvfs_f_flag=yes,samba_cv_statvfs_f_flag=no)])
+if test x"$samba_cv_statvfs_f_flag" = x"yes"; then
+    AC_DEFINE(HAVE_STATVFS_F_FLAG, 1, [Whether statvfs.f_flag exists])
+fi
+
+AC_CACHE_CHECK([that statvfs.statvfs_f_flags works],samba_cv_statvfs_f_flags, [
+    AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/statvfs.h>],[struct statvfs buf; buf.f_flags = 0],
+       samba_cv_statvfs_f_flags=yes,samba_cv_statvfs_f_flags=no)])
+if test x"$samba_cv_statvfs_f_flags" = x"yes"; then
+    AC_DEFINE(HAVE_STATVFS_F_FLAGS, 1, [Whether statvfs.f_flags exists])
+fi
+
 if test $space = no; then
   # DEC Alpha running OSF/1
   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
@@ -5096,17 +4970,128 @@ AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
 #################################################
 # check for cluster extensions
 
-AC_MSG_CHECKING(whether to include cluster support)
+CTDB_CFLAGS=""
+AC_SUBST(CTDB_CFLAGS)
+AC_ARG_WITH(ctdb,
+[AS_HELP_STRING([--with-ctdb=DIR], [Where to find ctdb sources])],
+[ case "$withval" in
+  yes|no)
+    AC_MSG_WARN([--with-ctdb called without argument])
+    ;;
+  *)
+    CTDB_CPPFLAGS="-I$withval/include"
+    ;;
+  esac])
+
+SAVED_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $CTDB_CPPFLAGS"
+ctdb_broken="missing or broken headers"
+
+AC_CHECK_HEADERS(ctdb.h ctdb_private.h,,,[
+#include "confdefs.h"
+#define NO_CONFIG_H
+#include "replace.h"
+#include "system/wait.h"
+#include "system/network.h"
+#define private #error __USED_RESERVED_WORD_private__
+#include <talloc.h>
+#include <tdb.h>
+#include <ctdb.h>
+])
+
+AC_HAVE_DECL(CTDB_CONTROL_TRANS2_COMMIT_RETRY,[
+#include "confdefs.h"
+#define NO_CONFIG_H
+#include "replace.h"
+#include "system/wait.h"
+#include "system/network.h"
+#include <talloc.h>
+#include <tdb.h>
+#include <ctdb.h>
+#include <ctdb_private.h>
+])
+if test x"$ac_cv_have_CTDB_CONTROL_TRANS2_COMMIT_RETRY_decl" = x"yes"; then
+       ctdb_broken=no
+else
+       ctdb_broken="missing transaction 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>
+])
+
+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>
+])
+
+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"
+
+AC_MSG_CHECKING(cluster support)
 AC_ARG_WITH(cluster-support,
-[AS_HELP_STRING([--with-cluster-support], [Enable cluster extensions (default=no)])])
-if test "x$with_cluster_support" = "xyes"; then
+[AS_HELP_STRING([--with-cluster-support], [Enable cluster extensions (default=auto)])])
+
+if test x"$with_cluster_support" = x ; then
+       with_cluster_support="auto"
+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
+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
+       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)
 else
     AC_MSG_RESULT(no)
 fi
 
-
 #################################################
 # check for ACL support
 
@@ -5668,6 +5653,8 @@ fi
 ############################################
 # See if we have the Linux splice syscall.
 
+case "$host_os" in
+*linux*)
 AC_CACHE_CHECK([for Linux splice],
                 samba_cv_HAVE_LINUX_SPLICE,[
     AC_TRY_LINK([
@@ -5678,6 +5665,11 @@ AC_CACHE_CHECK([for Linux splice],
     [long ret = splice(0,0,1,0,400,0);],
     samba_cv_HAVE_LINUX_SPLICE=yes,
     samba_cv_HAVE_LINUX_SPLICE=no)])
+;;
+*)
+samba_cv_HAVE_LINUX_SPLICE=no
+;;
+esac
 
 if test x"$samba_cv_HAVE_LINUX_SPLICE" = x"yes"; then
   AC_DEFINE(HAVE_LINUX_SPLICE,1,
@@ -5696,6 +5688,34 @@ AC_MSG_CHECKING(whether to build winbind)
 # Initially, the value of $host_os decides whether winbind is supported
 
 HAVE_WINBIND=yes
+HAVE_WBCLIENT=no
+
+# Define external wbclient library to link against.  This disables winbind.
+# We define this here so --with-winbind can override it.
+AC_ARG_WITH(wbclient,
+[AS_HELP_STRING([--with-wbclient], [Use external wbclient (optional)])],
+[
+  case "$withval" in
+        no)
+               HAVE_WBCLIENT=no
+               ;;
+       yes)
+               HAVE_WBCLIENT=yes
+               HAVE_WINBIND=no
+               ;;
+        *)
+               HAVE_WBCLIENT=yes
+               HAVE_WINBIND=no
+               WBCLIENT_INCLUDES="-I$withval/include"
+               WBCLIENT_LDFLAGS="-L$withval/lib"
+               ;;
+  esac ],
+)
+
+AC_SUBST(WBCLIENT_INCLUDES)
+AC_SUBST(WBCLIENT_LDFLAGS)
+AC_SUBST(WBCLIENT_LIBS)
+
 
 # Define the winbind shared library name and any specific linker flags
 # it needs to be built with.
@@ -5777,6 +5797,7 @@ AC_ARG_WITH(winbind,
   case "$withval" in
        yes)
                HAVE_WINBIND=yes
+               HAVE_WBCLIENT=no
                ;;
         no)
                HAVE_WINBIND=no
@@ -5800,27 +5821,35 @@ if test x"$HAVE_WINBIND" = x"no"; then
        WINBIND_NSS=""
        WINBIND_WINS_NSS=""
 fi
-
-if test x"$enable_developer" = x"yes" -a x"$LINK_LIBWBCLIENT" = x"STATIC" ; then
-       BUILD_LIBWBCLIENT_SHARED=no
-else
-       BUILD_LIBWBCLIENT_SHARED=yes
-fi
-
-LIBWBCLIENT_SHARED_TARGET=bin/libwbclient.$SHLIBEXT
-LIBWBCLIENT_STATIC_TARGET=bin/libwbclient.a
-LIBWBCLIENT_SOVER=0
-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 library support
-       ## and winbindd
-        LIBWBCLIENT_SHARED=$LIBWBCLIENT_SHARED_TARGET
-        LIBWBCLIENT=libwbclient
-       INSTALL_LIBWBCLIENT=installlibwbclient
-       UNINSTALL_LIBWBCLIENT=uninstalllibwbclient
-       WINBIND_LIBS="-lwbclient"
+if test x"$HAVE_WBCLIENT" = x"yes"; then
+        AC_CHECK_LIB(wbclient, wbcInterfaceDetails,
+                    [WINBIND_LIBS="-lwbclient"], AC_MSG_ERROR([Could not find wbclient]), [$WBCLIENT_LDFLAGS])
+       WINBIND_LIBS="$WINBIND_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)"
 else
-       LIBWBCLIENT_STATIC=$LIBWBCLIENT_STATIC_TARGET
+       if test x"$enable_developer" = x"yes" -a x"$LINK_LIBWBCLIENT" = x"STATIC" ; then
+               BUILD_LIBWBCLIENT_SHARED=no
+       else
+               BUILD_LIBWBCLIENT_SHARED=yes
+       fi
+
+       LIBWBCLIENT_SHARED_TARGET=bin/libwbclient.$SHLIBEXT
+       LIBWBCLIENT_STATIC_TARGET=bin/libwbclient.a
+       LIBWBCLIENT_SOVER=0
+       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
+               # library support
+               LIBWBCLIENT_SHARED=$LIBWBCLIENT_SHARED_TARGET
+               LIBWBCLIENT=libwbclient
+               INSTALL_LIBWBCLIENT=installlibwbclient
+               UNINSTALL_LIBWBCLIENT=uninstalllibwbclient
+               WINBIND_LIBS="-lwbclient"
+       else
+               LIBWBCLIENT_STATIC=$LIBWBCLIENT_STATIC_TARGET
+       fi
 fi
 
 if test x"$HAVE_WINBIND" = x"yes"; then
@@ -5943,7 +5972,7 @@ if test x"$enable_dnssd" != x"no"; then
     AC_CHECK_FUNCS(DNSServiceRegister)
     AC_CHECK_LIB_EXT(dns_sd, DNSSD_LIBS, DNSServiceRegister)
     if test x"$ac_cv_func_DNSServiceRegister" != x"yes" -a \
-            x"$ac_cv_lib_ext_DNSServiceRegister" != x"yes"; then
+            x"$ac_cv_lib_ext_dns_sd_DNSServiceRegister" != x"yes"; then
        have_dnssd_support=no
     fi
 
@@ -6042,7 +6071,7 @@ do
 done
 
 dnl Always build these modules static
-MODULE_rpc_spoolss=STATIC
+MODULE_rpc_spoolss2=STATIC
 MODULE_rpc_srvsvc=STATIC
 MODULE_idmap_tdb=STATIC
 MODULE_idmap_passdb=STATIC
@@ -6072,6 +6101,7 @@ SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o passdb/pdb_nds.o, "bin/ldapsam.$SHLIBEXT"
                   [ PASSDB_LIBS="$PASSDB_LIBS $LDAP_LIBS" ] )
 SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, "bin/smbpasswd.$SHLIBEXT", PDB)
 SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, "bin/tdbsam.$SHLIBEXT", PDB)
+SMB_MODULE(pdb_wbc_sam, passdb/pdb_wbc_sam.o, "bin/wbc_sam.$SHLIBEXT", PDB)
 SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o)
 
 
@@ -6080,13 +6110,13 @@ SMB_MODULE(rpc_winreg, \$(RPC_REG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_initshutdown, \$(RPC_INITSHUTDOWN_OBJ), "bin/librpc_initshutdown.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_dssetup, \$(RPC_DSSETUP_OBJ), "bin/librpc_dssetup.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_wkssvc, \$(RPC_WKS_OBJ), "bin/librpc_wkssvc.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_svcctl2, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl2.$SHLIBEXT", RPC)
+SMB_MODULE(rpc_svcctl, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_ntsvcs, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_netlogon, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_netdfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_srvsvc, \$(RPC_SVC_OBJ), "bin/librpc_svcsvc.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_eventlog2, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog2.$SHLIBEXT", RPC)
+SMB_MODULE(rpc_spoolss2, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss2.$SHLIBEXT", RPC)
+SMB_MODULE(rpc_eventlog, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_rpcecho, \$(RPC_ECHO_OBJ), "bin/librpc_rpcecho.$SHLIBEXT", RPC)
 SMB_SUBSYSTEM(RPC,smbd/server.o)
@@ -6114,6 +6144,7 @@ SMB_SUBSYSTEM(CHARSET,lib/iconv.o)
 SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), "bin/sam.$SHLIBEXT", AUTH)
 SMB_MODULE(auth_unix, \$(AUTH_UNIX_OBJ), "bin/unix.$SHLIBEXT", AUTH)
 SMB_MODULE(auth_winbind, \$(AUTH_WINBIND_OBJ), "bin/winbind.$SHLIBEXT", AUTH)
+SMB_MODULE(auth_wbc, \$(AUTH_WBC_OBJ), "bin/wbc.$SHLIBEXT", AUTH)
 SMB_MODULE(auth_server, \$(AUTH_SERVER_OBJ), "bin/smbserver.$SHLIBEXT", AUTH)
 SMB_MODULE(auth_domain, \$(AUTH_DOMAIN_OBJ), "bin/domain.$SHLIBEXT", AUTH)
 SMB_MODULE(auth_builtin, \$(AUTH_BUILTIN_OBJ), "bin/builtin.$SHLIBEXT", AUTH)
@@ -6161,9 +6192,14 @@ SMB_MODULE(vfs_acl_xattr, \$(VFS_ACL_XATTR_OBJ), "bin/acl_xattr.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_acl_tdb, \$(VFS_ACL_TDB_OBJ), "bin/acl_tdb.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_smb_traffic_analyzer, \$(VFS_SMB_TRAFFIC_ANALYZER_OBJ), "bin/smb_traffic_analyzer.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_onefs, \$(VFS_ONEFS), "bin/onefs.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_onefs_shadow_copy, \$(VFS_ONEFS_SHADOW_COPY), "bin/onefs_shadow_copy.$SHLIBEXT", VFS)
 
 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
 
+SMB_MODULE(perfcount_onefs, \$(PERFCOUNT_ONEFS), "bin/pc_onefs.$SHLIBEXT", PERFCOUNT)
+SMB_MODULE(perfcount_test, \$(PERFCOUNT_TEST), "bin/pc_test.$SHLIBEXT", PERFCOUNT)
+SMB_SUBSYSTEM(PERFCOUNT,smbd/perfcount.o)
+
 SMB_MODULE(gpext_registry, libgpo/gpext/registry.o, "bin/registry.$SHLIBEXT", GPEXT)
 SMB_MODULE(gpext_scripts, libgpo/gpext/scripts.o, "bin/scripts.$SHLIBEXT", GPEXT)
 SMB_MODULE(gpext_security, libgpo/gpext/security.o, "bin/security.$SHLIBEXT", GPEXT)
@@ -6268,18 +6304,8 @@ AC_ARG_ENABLE(merged-build,
 m4_include(../lib/zlib/zlib.m4)
 
 if test x$enable_merged_build = xauto; then
-       merged_build_possible=yes
-
-       # Check for GNU make
-       m4_include(../source4/build/m4/check_make.m4)
-       AC_SAMBA_GNU_MAKE([true], [merged_build_possible=no])
-
-       # Check for perl
-       m4_include(../source4/build/m4/check_perl.m4)
-       AC_SAMBA_PERL([true], [merged_build_possible=no])
-
        # Check for python
-       m4_include(../source4/build/m4/check_python.m4)
+       m4_include(../m4/check_python.m4)
        AC_SAMBA_PYTHON_DEVEL([true], [merged_build_possible=no])
 
        AC_MSG_CHECKING([whether it would be possible to do a merged build])
@@ -6293,7 +6319,10 @@ fi
 
 if test x$enable_merged_build = xyes; then
        MERGED_BUILD=1
+       saved_USESHARED="$USESHARED"
+       USESHARED="false"
        m4_include(samba4.m4)
+       USESHARED="$saved_USESHARED"
 fi
 
 AC_SUBST(ZLIB_LIBS)
@@ -6341,7 +6370,7 @@ AC_MSG_RESULT([    AUTH_LIBS = $AUTH_LIBS])
 # final configure stuff
 
 AC_MSG_CHECKING([configure summary])
-AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
+AC_TRY_RUN([#include "${srcdir-.}/../tests/summary.c"],
            AC_MSG_RESULT(yes),
           AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
           AC_MSG_WARN([cannot run when cross-compiling]))
@@ -6367,7 +6396,17 @@ else
        fi
 fi
 
-AC_OUTPUT(Makefile
+AC_SUBST(MAKEFILE)
+if test x$samba_cv_gnu_make = xyes; then
+       MAKEFILE=Makefile
+else
+       # When we don't have GNU Make, generate a copy of Makefile.in 
+       # that doesn't have the "include " statements but just includes 
+       # the files verbatim.
+       MAKEFILE=Makefile-noincludes
+       $PERL ./script/expand-includes.pl Makefile.in > $MAKEFILE.in
+fi
+AC_OUTPUT($MAKEFILE
          script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh
          lib/netapi/examples/Makefile
          lib/netapi/tests/Makefile
@@ -6377,6 +6416,12 @@ AC_OUTPUT(Makefile
          pkgconfig/smbsharemodes.pc
          ../examples/libsmbclient/Makefile.internal
          )
+dnl If we had to expand the includes, make tsure the output file is moved back
+AC_OUTPUT_COMMANDS([
+if test x$MAKEFILE != Makefile; then
+       mv $MAKEFILE Makefile
+fi
+])
 
 #################################################
 # Print very concise instructions on building/use