Add thread pool
[ira/wip.git] / source3 / configure.in
index 3ae2c8c9d37350bd8dcd33e6289a38bbe74ddba8..fc925ee736a469a2095ed0a6a58cb55ae1f8d12f 100644 (file)
@@ -20,10 +20,29 @@ AC_SUBST(builddir)
 
 m4_include(m4/samba_version.m4)
 m4_include(m4/check_path.m4)
+m4_include(pkg.m4)
 
 AC_LIBREPLACE_CC_CHECKS
 
-m4_include(../lib/talloc/libtalloc.m4)
+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
+       PKG_CHECK_MODULES(TALLOC, talloc >= 1.3.0, 
+               [ enable_external_libtalloc=yes ],
+               [ if test x$enable_external_libtalloc = xyes; then
+                       AC_MSG_ERROR([Unable to find libtalloc])
+             else 
+                       enable_external_libtalloc=no
+                 fi
+               ])
+fi
+
+if test "x$enable_external_libtalloc" = xno
+then
+       m4_include(../lib/talloc/libtalloc.m4)
+fi
 
 LIBTALLOC_OBJ0=""
 for obj in ${TALLOC_OBJ}; do
@@ -97,9 +116,10 @@ AC_SUBST(LIBWBCLIENT_SHARED_TARGET)
 AC_SUBST(LIBWBCLIENT_SHARED)
 AC_SUBST(LIBWBCLIENT_STATIC_TARGET)
 AC_SUBST(LIBWBCLIENT_STATIC)
+AC_SUBST(LIBWBCLIENT_TARGET)
 AC_SUBST(LIBWBCLIENT_SOVER)
 AC_SUBST(LIBWBCLIENT)
-AC_SUBST(WINBIND_LIBS)
+AC_SUBST(LIBWBCLIENT_LIBS)
 
 AC_SUBST(LIBSAMBAUTIL_SHARED)
 
@@ -133,13 +153,11 @@ AC_SUBST(NSCD_LIBS)
 # do this here since AC_CACHE_CHECK apparently sets the CFLAGS to "-g -O2"
 # if it has no value.  This prevent *very* large debug binaries from occurring
 # by default.
-if test "x$CFLAGS" = x; then
-  CFLAGS="-O"
-fi
 if test "x$debug" = "xyes" ; then
        CFLAGS="${CFLAGS} -g"
-else
-       CFLAGS="${CFLAGS} -O"
+fi
+if test "x$CFLAGS" = x; then
+  CFLAGS="-O"
 fi
 
 m4_include(../lib/socket_wrapper/config.m4)
@@ -266,7 +284,7 @@ if test "$ac_cv_prog_gnu_ld" = "yes"; then
         else
            AC_MSG_CHECKING(GNU ld release version)
            changequote(,)dnl
-           ac_cv_gnu_ld_vernr=`echo $ac_cv_gnu_ld_version | sed -n 's,^.*\([1-9][0-9]*\.[0-9][0-9]*\).*$,\1,p'`
+           ac_cv_gnu_ld_vernr=`echo $ac_cv_gnu_ld_version | sed -n 's,^[^0-9]*\([1-9][0-9]*\.[0-9][0-9]*\).*$,\1,p'`
            ac_cv_gnu_ld_vernr_major=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 1`
            ac_cv_gnu_ld_vernr_minor=`echo $ac_cv_gnu_ld_vernr | cut -d '.' -f 2`
            changequote([,])dnl
@@ -278,7 +296,7 @@ if test "$ac_cv_prog_gnu_ld" = "yes"; then
            if test "$ac_cv_gnu_ld_vernr_major" -lt 2 || test "$ac_cv_gnu_ld_vernr_minor" -lt 14; then
              ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
            fi
-           if test "$ac_cv_gnu_ld_vernr_major" -gt 2 || test "$ac_cv_gnu_ld_vernr_major"=2 && test "$ac_cv_gnu_ld_vernr_minor" -ge 12; then
+           if test "$ac_cv_gnu_ld_vernr_major" -gt 2 || test "$ac_cv_gnu_ld_vernr_major" = 2 && test "$ac_cv_gnu_ld_vernr_minor" -ge 12; then
              ac_cv_gnu_ld_version_script=yes
            fi
         fi
@@ -414,14 +432,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_svcctl 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_spoolss 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"
+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 vfs_preopen"
 
 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
 
 #
@@ -653,6 +671,7 @@ SAVE_CPPFLAGS="${CPPFLAGS}"
 CPPFLAGS="${CPPFLAGS} ${SAMBA_CONFIGURE_CPPFLAGS}"
 
 AC_LIBREPLACE_BROKEN_CHECKS
+AC_CHECK_FUNCS([syslog],[],[AC_MSG_ERROR([Required function not found])])
 AC_LIBREPLACE_NETWORK_CHECKS
 
 CPPFLAGS="${SAVE_CPPFLAGS}"
@@ -703,18 +722,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.
@@ -783,6 +790,7 @@ if test x$enable_cups != xno; then
                        x"$ac_cv_header_cups_language_h" = xyes; then
                        AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
                        samba_cv_HAVE_CUPS=yes
+                       AC_CHECK_LIB_EXT(cups, PRINT_LIBS, httpConnectEncrypt)
                else
                        AC_MSG_WARN([cups-config around but cups-devel not installed])
                        CFLAGS=$ac_save_CFLAGS
@@ -872,7 +880,7 @@ fi
 
 AC_CHECK_FUNCS(dirfd)
 if test x"$ac_cv_func_dirfd" = x"yes"; then
-       default_shared_modules="$default_shared_modules vfs_syncops"
+       default_shared_modules="$default_shared_modules vfs_syncops vfs_dirsort"
 fi
 
 AC_CACHE_CHECK([for struct sigevent type],samba_cv_struct_sigevent, [
@@ -1027,7 +1035,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)
@@ -1041,7 +1049,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)
@@ -1056,6 +1064,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"
@@ -1096,8 +1107,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"
@@ -1183,13 +1197,10 @@ if test x"$LIBUNWIND_PTRACE" != x"" ; then
 #endif
            ],
            [
-               int main(int argc, const char ** argv)
-               {
-                       pid_t me = (pid_t)-1;
-                       ptrace(PTRACE_ATTACH, me, 0, 0);
-                       ptrace(PTRACE_DETACH, me, 0, 0);
-                       return 0;
-               }
+               pid_t me = (pid_t)-1;
+               ptrace(PTRACE_ATTACH, me, 0, 0);
+               ptrace(PTRACE_DETACH, me, 0, 0);
+               return 0;
            ],
            [
                AC_MSG_RESULT(yes)
 
 #################################################
 # Check whether struct stat has timestamps with sub-second resolution.
-# At least IRIX and Solaris have these.  FREEBSD does as well,
-# but with different members
-#
-# 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 timespec timestamps],
-    samba_cv_stat_timespec_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 = s.st_mtimespec;
-         t = s.st_ctimespec;
-         t = s.st_atimespec;
-       ],
-      samba_cv_stat_timespec_hires=yes, samba_cv_stat_timespec_hires=no)
-      ])
-
-if test x"$samba_cv_stat_timespec_hires" = x"yes" ; then
-    AC_DEFINE(HAVE_STAT_ST_MTIMESPEC, 1, [whether struct stat contains st_mtimepec])
-    AC_DEFINE(HAVE_STAT_ST_ATIMESPEC, 1, [whether struct stat contains st_atimespec])
-    AC_DEFINE(HAVE_STAT_ST_CTIMESPEC, 1, [whether struct stat contains st_ctimespec])
-    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], 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 suffixed nsec], 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_notimespec=yes, samba_cv_stat_hires_notimespec=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 suffixed nsec])
-fi
-
-dnl AIX stype sub-second timestamps:
-AC_CACHE_CHECK([whether struct stat has sub-second timestamps without struct timespec suffixed _n], samba_cv_stat_hires_notimespec_n,
-    [
-       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_mtime_n;
-               t.tv_sec = s.st_ctime;
-               t.tv_nsec = s.st_ctime_n;
-               t.tv_sec = s.st_atime;
-               t.tv_nsec = s.st_atime_n;
-           ],
-           samba_cv_stat_hires_notimespec_n=yes, samba_cv_stat_hires_notimespec_n=no)
-    ])
-
-if test x"$samba_cv_stat_hires_notimespec_n" = x"yes" ; then
-    AC_DEFINE(HAVE_STAT_ST_MTIME_N, 1, [whether struct stat contains st_mtime_n])
-    AC_DEFINE(HAVE_STAT_ST_ATIME_N, 1, [whether struct stat contains st_atime_n])
-    AC_DEFINE(HAVE_STAT_ST_CTIME_N, 1, [whether struct stat contains st_ctime_n])
-    AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
-           [whether struct stat has sub-second timestamps without struct timespec suffixed _n])
-fi
-
-dnl Tru64 has _micro_second_ resolution:
-AC_CACHE_CHECK([whether struct stat has sub-second timestamps in st_uXtime], samba_cv_stat_hires_uxtime,
-    [
-       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_umtime * 1000;
-               t.tv_sec = s.st_ctime;
-               t.tv_nsec = s.st_uctime * 1000;
-               t.tv_sec = s.st_atime;
-               t.tv_nsec = s.st_uatime * 1000;
-           ],
-           samba_cv_stat_hires_uxtime=yes, samba_cv_stat_hires_uxtime=no)
-    ])
-
-if test x"$samba_cv_stat_hires_uxtime" = x"yes" ; then
-    AC_DEFINE(HAVE_STAT_ST_UMTIME, 1, [whether struct stat contains st_umtime])
-    AC_DEFINE(HAVE_STAT_ST_UATIME, 1, [whether struct stat contains st_uatime])
-    AC_DEFINE(HAVE_STAT_ST_UCTIME, 1, [whether struct stat contains st_uctime])
-    AC_DEFINE(HAVE_STAT_HIRES_TIMESTAMPS, 1,
-           [whether struct stat has sub-second timestamps in st_uXtime])
-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_st_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_st_birthtimensec=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_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_st_birthtime=no)
-    ])
-
-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,
     [
@@ -3467,7 +3206,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
@@ -3539,6 +3278,9 @@ if test x"$with_ads_support" != x"no"; then
   ac_save_CPPFLAGS=$CPPFLAGS
   ac_save_LDFLAGS=$LDFLAGS
 
+  # remove needless evil rpath stuff as early as possible:
+  LIB_REMOVE_USR_LIB(KRB5_LIBS)
+  LIB_REMOVE_USR_LIB(KRB5_LDFLAGS)
   CFLAGS="$KRB5_CFLAGS $CFLAGS"
   CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS"
   LDFLAGS="$KRB5_LDFLAGS $LDFLAGS"
@@ -4180,6 +3922,10 @@ if test x"$with_ads_support" != x"no"; then
 LIBS="$ac_save_LIBS"
 fi
 
+if test x"$use_ads" != xyes; then
+       merged_build_possible=no
+fi
+
 AC_CHECK_LIB_EXT(nscd, NSCD_LIBS, nscd_flush_cache)
 PASSDB_LIBS="$PASSDB_LIBS $NSCD_LIBS"
 
@@ -5000,7 +4746,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)
@@ -5071,6 +4816,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)])
@@ -5950,6 +5712,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.
@@ -6031,6 +5821,7 @@ AC_ARG_WITH(winbind,
   case "$withval" in
        yes)
                HAVE_WINBIND=yes
+               HAVE_WBCLIENT=no
                ;;
         no)
                HAVE_WINBIND=no
@@ -6054,27 +5845,38 @@ 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,
+                    [LIBWBCLIENT_LIBS="-lwbclient"], AC_MSG_ERROR([Could not find wbclient]), [$WBCLIENT_LDFLAGS])
+       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)"
 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_TARGET=$LIBWBCLIENT_SHARED_TARGET
+               LIBWBCLIENT=libwbclient
+               INSTALL_LIBWBCLIENT=installlibwbclient
+               UNINSTALL_LIBWBCLIENT=uninstalllibwbclient
+               LIBWBCLIENT_LIBS="-lwbclient"
+       else
+               LIBWBCLIENT_STATIC=$LIBWBCLIENT_STATIC_TARGET
+               LIBWBCLIENT_TARGET=$LIBWBCLIENT_STATIC_TARGET
+               LIBWBCLIENT_LIBS=$LIBWBCLIENT_STATIC_TARGET
+       fi
 fi
 
 if test x"$HAVE_WINBIND" = x"yes"; then
@@ -6093,7 +5895,9 @@ else
 fi
 
 AC_CHECK_LIB(pthread, pthread_mutex_lock, [WINBIND_NSS_PTHREAD="-lpthread"
-                       AC_DEFINE(HAVE_PTHREAD, 1, [whether pthread exists])])
+                       AC_DEFINE(HAVE_PTHREAD, 1, [whether pthread exists])
+                       samba_cv_HAVE_PTHREAD=yes],
+                       samba_cv_HAVE_PTHREAD=no)
 
 AC_SUBST(WINBIND_NSS_PTHREAD)
 AC_SUBST(WINBIND_NSS)
@@ -6181,10 +5985,10 @@ AC_SUBST(FLAGS1)
 # Check if user wants DNS service discovery support
 
 AC_ARG_ENABLE(dnssd,
-[AS_HELP_STRING([--enable-dnssd], [Enable DNS service discovery support (default=auto)])])
+[AS_HELP_STRING([--enable-dnssd], [Enable DNS service discovery support (default=no)])])
 
 AC_SUBST(DNSSD_LIBS)
-if test x"$enable_dnssd" != x"no"; then
+if test x"$enable_dnssd" == x"yes"; then
     have_dnssd_support=yes
 
     AC_CHECK_HEADERS(dns_sd.h)
@@ -6212,6 +6016,53 @@ if test x"$enable_dnssd" != x"no"; then
 
 fi
 
+#################################################
+# Check if user wants avahi support
+
+AC_ARG_ENABLE(avahi,
+[AS_HELP_STRING([--enable-avahi], [Enable Avahi support (default=auto)])])
+
+AC_SUBST(AVAHI_LIBS)
+if test x"$enable_avahi" != x"no"; then
+    have_avahi_support=yes
+
+    AC_CHECK_HEADERS(avahi-common/watch.h)
+    if test x"$ac_cv_header_avahi_common_watch_h" != x"yes"; then
+       have_avahi_support=no
+    fi
+
+    AC_CHECK_HEADERS(avahi-client/client.h)
+    if test x"$ac_cv_header_avahi_common_watch_h" != x"yes"; then
+       have_avahi_support=no
+    fi
+
+    AC_CHECK_LIB_EXT(avahi-client, AVAHI_LIBS, avahi_client_new)
+    if test x"$ac_cv_lib_ext_avahi_client_avahi_client_new" != x"yes"; then
+       have_avahi_support=no
+    fi
+
+    if test x"$have_avahi_support" = x"yes"; then
+       AC_DEFINE(WITH_AVAHI_SUPPORT, 1,
+               [Whether to enable avahi support])
+       AC_SUBST(AVAHI_OBJ, "lib/avahi.o smbd/avahi_register.o")
+    else
+       if test x"$enable_avahi" = x"yes"; then
+           AC_MSG_ERROR(avahi support not available)
+       fi
+    fi
+fi
+
+#################################################
+# Check if user wants pthreadpool support
+
+AC_ARG_ENABLE(pthreadpool,
+[AS_HELP_STRING([--enable-pthreadpool], [Enable pthreads pool helper support (default=auto)])])
+
+if test x"$enable_pthreadpool" != x"no" -a x"$samba_cv_HAVE_PTHREAD" = x"yes"; then
+    AC_DEFINE(WITH_PTHREADPOOL, 1, [Whether to include pthreadpool helpers])
+    AC_SUBST(PTHREADPOOL_OBJ, "lib/pthreadpool.o")
+fi
+
 #################################################
 # Check to see if we should use the included iniparser
 
@@ -6326,6 +6177,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)
 
 
@@ -6340,7 +6192,7 @@ SMB_MODULE(rpc_netlogon, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RP
 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_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)
@@ -6368,6 +6220,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)
@@ -6408,6 +6261,7 @@ 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_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)
 SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", VFS)
@@ -6415,9 +6269,15 @@ 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_MODULE(vfs_dirsort, \$(VFS_DIRSORT_OBJ), "bin/dirsort.$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)
@@ -6519,6 +6379,11 @@ AC_ARG_ENABLE(merged-build,
 [AS_HELP_STRING([--enable-merged-build], [Build Samba 4 as well])], 
 [ enable_merged_build=$enableval ], [ enable_merged_build=auto ])
 
+if test x"$enable_merged_build" = x"yes" -a \
+       x"$merged_build_possible" = x"no" ; then
+       AC_MSG_ERROR(Merged build required but not possible)
+fi
+
 m4_include(../lib/zlib/zlib.m4)
 
 if test x$enable_merged_build = xauto; then
@@ -6537,7 +6402,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)
@@ -6556,7 +6424,6 @@ AC_ZLIB([ZLIB_OBJS=""], [
 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
 LIB_REMOVE_USR_LIB(LDFLAGS)
 LIB_REMOVE_USR_LIB(LIBS)
-LIB_REMOVE_USR_LIB(KRB5_LIBS)
 
 dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)