r11167: -lsec should be include in $ACL_LIBS and not $LIBS on solaris
[ira/wip.git] / source3 / configure.in
index 0e172727e54de20ccd980f2aa3351e3ca80e3122..1de82464b4a67808ce3a40a8f99a95329531f409 100644 (file)
@@ -210,12 +210,17 @@ AC_SUBST(SHLD)
 AC_SUBST(HOST_OS)
 AC_SUBST(PICFLAGS)
 AC_SUBST(PICSUFFIX)
+AC_SUBST(libc_cv_fpie)
+AC_SUBST(PIE_CFLAGS)
+AC_SUBST(PIE_LDFLAGS)
 AC_SUBST(SHLIBEXT)
 AC_SUBST(INSTALLCLIENT)
 AC_SUBST(INSTALLCLIENTCMD_SH)
 AC_SUBST(INSTALLCLIENTCMD_A)
 AC_SUBST(LIBSMBCLIENT_SHARED)
 AC_SUBST(LIBSMBCLIENT)
+AC_SUBST(LIBSMBSHAREMODES_SHARED)
+AC_SUBST(LIBSMBSHAREMODES)
 AC_SUBST(PRINT_LIBS)
 AC_SUBST(AUTH_LIBS)
 AC_SUBST(ACL_LIBS)
@@ -225,9 +230,37 @@ AC_SUBST(KRB5_LIBS)
 AC_SUBST(LDAP_LIBS)
 AC_SUBST(SHLIB_PROGS)
 AC_SUBST(SMBWRAPPER)
+AC_SUBST(SMBWRAP_OBJS)
+AC_SUBST(SMBWRAP_INC)
 AC_SUBST(EXTRA_BIN_PROGS)
 AC_SUBST(EXTRA_SBIN_PROGS)
 AC_SUBST(EXTRA_ALL_TARGETS)
+AC_SUBST(CONFIG_LIBS)
+
+# Set defaults
+PIE_CFLAGS=""
+PIE_LDFLAGS=""
+AC_ARG_ENABLE(pie, [  --enable-pie            Turn on pie support if available (default=yes)])
+
+if test "x$enable_pie" != xno
+then
+       AC_CACHE_CHECK(for -fPIE, libc_cv_fpie, [dnl
+               cat > conftest.c <<EOF
+int foo;
+main () { return 0;}
+EOF
+               if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fPIE -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
+               then
+                       libc_cv_fpie=yes
+                       PIE_CFLAGS="-fPIE"
+                       PIE_LDFLAGS="-pie"
+               fi
+               rm -f conftest*])
+fi
+if test "x$PIE_CFLAGS" = x
+then
+       libc_cv_fpie=no
+fi
 
 AC_ARG_ENABLE(debug, 
 [  --enable-debug          Turn on compiler debugging information (default=no)],
@@ -235,10 +268,45 @@ AC_ARG_ENABLE(debug,
        CFLAGS="${CFLAGS} -g"
     fi])
 
+AC_SUBST(SOCKWRAP)
+AC_ARG_ENABLE(socket-wrapper, 
+[  --enable-socket-wrapper         Turn on socket wrapper library (default=no)],
+    [if eval "test x$enable_socket_wrapper = xyes"; then
+        AC_DEFINE(SOCKET_WRAPPER,1,[Use socket wrapper library])
+       SOCKWRAP="\$(SOCKET_WRAPPER_OBJ)"
+    fi])
+
+# compile with optimization and without debugging by default, but
+# allow people to set their own preference.
+# 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
+
+CFLAGS="${CFLAGS} -D_SAMBA_BUILD_"
+
 AC_ARG_ENABLE(developer, [  --enable-developer      Turn on developer warnings and debugging (default=no)],
     [if eval "test x$enable_developer = xyes"; then
         developer=yes
-       CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
+       CFLAGS="${CFLAGS} -gstabs -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
+       # Add -Wdeclaration-after-statement if compiler supports it
+       AC_CACHE_CHECK(
+          [that the C compiler understands -Wdeclaration-after-statement],
+          samba_cv_HAVE_Wdeclaration_after_statement, [
+         AC_TRY_RUN_STRICT([
+           int main(void)
+           {
+               return 0;
+           }],[-Wdeclaration-after-statement],[$CPPFLAGS],[$LDFLAGS],
+           samba_cv_HAVE_Wdeclaration_after_statement=yes,
+           samba_cv_HAVE_Wdeclaration_after_statement=no,
+           samba_cv_HAVE_Wdeclaration_after_statement=cross)
+       ])
+       if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
+           CFLAGS="${CFLAGS} -Wdeclaration-after-statement"
+       fi
     fi])
 
 AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer  Turn on developer warnings and debugging, except -Wstrict-prototypes (default=no)],
@@ -277,17 +345,42 @@ AC_PATH_PROG(PERL, perl)
 
 AC_CHECK_TOOL(AR, ar)
 
-# compile with optimization and without debugging by default, but
-# allow people to set their own preference.
-if test "x$CFLAGS" = x
-then
-  CFLAGS="-O ${CFLAGS}"
-fi
-
 dnl Check if we use GNU ld
 LD=ld
 AC_PROG_LD_GNU
 
+dnl Certain versions of GNU ld the default is not to have the 
+dnl --allow-shlib-undefined flag defined.  This causes a stackload of
+dnl warnings when building modules.
+if test "$ac_cv_prog_gnu_ld" = "yes"; then
+       ac_cv_gnu_ld_version=`$LD -v 2>/dev/null | head -1`
+       AC_MSG_CHECKING(GNU ld release date)
+       changequote(,)dnl
+       ac_cv_gnu_ld_date=`echo $ac_cv_gnu_ld_version | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'`
+       changequote([,])dnl
+       AC_MSG_RESULT(${ac_cv_gnu_ld_date})
+        if test -n "$ac_cv_gnu_ld_date"; then
+       if test "$ac_cv_gnu_ld_date" -lt 20030217; then
+               ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
+       fi
+        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_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
+           AC_MSG_RESULT(${ac_cv_gnu_ld_vernr})
+           AC_MSG_CHECKING(GNU ld release version major)
+           AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_major})
+           AC_MSG_CHECKING(GNU ld release version minor)
+           AC_MSG_RESULT(${ac_cv_gnu_ld_vernr_minor})
+           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
+        fi
+fi
+
 dnl needed before AC_TRY_COMPILE
 AC_ISC_POSIX
 
@@ -365,10 +458,10 @@ DYNEXP=
 
 dnl Add modules that have to be built by default here
 dnl These have to be built static:
-default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_reg rpc_lsa_ds rpc_wks rpc_net rpc_dfs rpc_srv rpc_spoolss auth_rhosts auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin"
+default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_reg rpc_lsa_ds rpc_wks rpc_svcctl rpc_ntsvcs rpc_net rpc_dfs rpc_srv rpc_spoolss rpc_eventlog auth_rhosts auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin"
 
 dnl These are preferably build shared, and static if dlopen() is not available
-default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy charset_CP850 charset_CP437"
+default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy charset_CP850 charset_CP437 auth_script"
 
 if test "x$developer" = xyes; then
    default_static_modules="$default_static_modules rpc_echo"
@@ -414,7 +507,6 @@ case "$host_os" in
                                AC_DEFINE(_MAX_ALIGNMENT, 4, [Maximum alignment])
                                ;;
       esac
-      DYNEXP="-Wl,-E"
       ;;
 
 #
@@ -446,7 +538,7 @@ case "$host_os" in
        *solaris*)
                AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
                case `uname -r` in
-                       5.0*|5.1*|5.2*|5.3*|5.5*)
+                       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.*)
@@ -457,17 +549,20 @@ case "$host_os" in
                                rm -fr conftest.c
                                case "$ac_cv_gcc_compiler_version_number" in
                                        *"gcc version 2.6"*|*"gcc version 2.7"*)
-                                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
+                                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE -D_REENTRANT"
+                                               LDFLAGS="$LDFLAGS -lthread"
                                                AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
                                                ;;
                                        *)
-                                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+                                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
+                                               LDFLAGS="$LDFLAGS -lthread"
                                                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"
+                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
+                               LDFLAGS="$LDFLAGS -lthread"
                                AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
                                AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
                        fi
@@ -480,7 +575,7 @@ case "$host_os" in
        *irix*)
                AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
                ;;
-       *freebsd*|*DragonFly*)
+       *freebsd*|*dragonfly*)
                AC_DEFINE(FREEBSD, 1, [Whether the host os is FreeBSD])
                ;;
 #
@@ -636,17 +731,27 @@ AC_HEADER_STDC
 AC_HEADER_DIRENT
 AC_HEADER_TIME
 AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS(arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h)
-AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h net/if.h)
-AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/yp_prot.h rpcsvc/ypclnt.h)
-AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/mode.h)
+AC_CHECK_HEADERS(aio.h arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h rpc/nettype.h)
+AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h alloca.h)
+AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/ypclnt.h)
+AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/prctl.h)
 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
+AC_CHECK_HEADERS(sys/un.h)
 AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h)
 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
-AC_CHECK_HEADERS(sys/sysmacros.h security/pam_modules.h security/_pam_macros.h dlfcn.h)
+AC_CHECK_HEADERS(sys/sysmacros.h security/_pam_macros.h dlfcn.h)
 AC_CHECK_HEADERS(sys/syslog.h syslog.h execinfo.h)
 AC_CHECK_HEADERS(langinfo.h locale.h)
 
+AC_CHECK_HEADERS(rpcsvc/yp_prot.h,,,[[
+#if HAVE_RPC_RPC_H
+#include <rpc/rpc.h>
+#endif
+]])
+
+## These fail to compile on IRIX so just check for their presence
+AC_CHECK_HEADERS(sys/mode.h,,,)
+
 # Look for Darwin headers
 old_CPPFLAGS="$CPPFLAGS"
 CPPFLAGS="-Iinclude $CPPFLAGS"
@@ -657,6 +762,18 @@ 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.
@@ -670,11 +787,36 @@ case "$host_os" in
                fi
        ;;
 esac
-AC_CHECK_HEADERS(shadow.h netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
-AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h security/pam_appl.h security/pam_modules.h)
+AC_CHECK_HEADERS(shadow.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
+AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h security/pam_appl.h)
 AC_CHECK_HEADERS(stropts.h poll.h)
 AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
-AC_CHECK_HEADERS(sys/acl.h sys/attributes.h attr/xattr.h sys/xattr.h sys/cdefs.h glob.h)
+AC_CHECK_HEADERS(sys/acl.h sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h)
+AC_CHECK_HEADERS(sys/cdefs.h glob.h)
+
+AC_CHECK_HEADERS(netinet/ip.h,,,[[
+#include <sys/types.h>
+#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#include <netinet/in.h>
+#if HAVE_NETINET_IN_SYSTM_H
+#include <netinet/in_systm.h>
+#endif
+]])
+
+AC_CHECK_HEADERS(net/if.h,,,[[
+#include <sys/types.h>
+#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+]])
+
+AC_CHECK_HEADERS(security/pam_modules.h,,,[[
+#if HAVE_SECURITY_PAM_APPL_H
+#include <security/pam_appl.h>
+#endif
+]])
 
 # For experimental utmp support (lastlog on some BSD-like systems)
 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
@@ -721,6 +863,17 @@ if test x$enable_cups != xno; then
         fi
 fi
 
+AC_ARG_ENABLE(iprint,
+[  --enable-iprint         Turn on iPrint support (default=yes if cups is yes)])
+
+if test x$enable_iprint != xno; then
+       if test "x$CUPS_CONFIG" != x; then
+                AC_DEFINE(HAVE_IPRINT,1,[Whether we have iPrint])
+       elif test x"$enable_iprint" = x"yes"; then
+               AC_MSG_ERROR(iPrint support required but cups not enabled.  Make sure cups-devel related files are installed and that cups is enabled.)
+        fi
+fi
+
 ############################################
 # we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the plugin loading code
 AC_SEARCH_LIBS(dlopen, [dl])
@@ -810,6 +963,32 @@ if test x"$samba_cv_sig_atomic_t" = x"yes"; then
    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
 fi
 
+AC_CACHE_CHECK([for struct timespec type],samba_cv_struct_timespec, [
+    AC_TRY_COMPILE([
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+#if HAVE_AIO_H
+#include <aio.h>
+#endif
+],[struct timespec ts;],
+       samba_cv_struct_timespec=yes,samba_cv_struct_timespec=no)])
+if test x"$samba_cv_struct_timespec" = x"yes"; then
+   AC_DEFINE(HAVE_STRUCT_TIMESPEC,1,[Whether we have struct timespec])
+fi
+
 # stupid headers have the functions but no declaration. grrrr.
 AC_HAVE_DECL(errno, [#include <errno.h>])
 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
@@ -959,16 +1138,18 @@ if test x"$ac_cv_func_execl" = x"no"; then
 fi
 
 AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
-AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync bzero memset strlcpy strlcat setpgid)
+AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync memset strlcpy strlcat setpgid)
 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
-AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
-AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
+AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate chsize stat64 fstat64)
+AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64)
 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
+AC_CHECK_FUNCS(opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64)
 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
 AC_CHECK_FUNCS(syslog vsyslog timegm)
 AC_CHECK_FUNCS(setlocale nl_langinfo)
+AC_CHECK_FUNCS(nanosleep)
 # setbuffer, shmget, shm_open are needed for smbtorture
 AC_CHECK_FUNCS(setbuffer shmget shm_open backtrace_symbols)
 AC_CHECK_HEADERS(libexc.h)
@@ -991,6 +1172,15 @@ AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readd
 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(prctl)
+
+AC_TRY_COMPILE([
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#endif
+],
+[int i; i = prtcl(0); ],
+AC_DEFINE(HAVE_PRCTL, 1, [Whether prctl is available]),[])
 
 #
 # 
@@ -1070,6 +1260,57 @@ if test x$ac_cv_func_fstat64 = xno ; then
   fi
 fi
 
+#################################################
+# 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_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_stat_hires=yes, samba_stat_hires=no)
+    ])
+
+if test x"$samba_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
+
 #####################################
 # we might need the resolv library on some systems
 AC_CHECK_LIB(resolv, dn_expand)
@@ -1106,6 +1347,18 @@ AC_CHECK_FUNCS(flistxattr removexattr lremovexattr fremovexattr)
 AC_CHECK_FUNCS(setxattr lsetxattr fsetxattr)
 AC_CHECK_FUNCS(attr_get attr_list attr_set attr_remove)
 AC_CHECK_FUNCS(attr_getf attr_listf attr_setf attr_removef)
+# Check if we have extattr
+case "$host_os" in
+  *freebsd4* | *dragonfly* )
+    AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
+    ;;
+  *)
+    AC_CHECK_FUNCS(extattr_delete_fd extattr_delete_file extattr_delete_link)
+    AC_CHECK_FUNCS(extattr_get_fd extattr_get_file extattr_get_link)
+    AC_CHECK_FUNCS(extattr_list_fd extattr_list_file extattr_list_link)
+    AC_CHECK_FUNCS(extattr_set_fd extattr_set_file extattr_set_link)
+    ;;
+esac
 
 # Assume non-shared by default and override below
 BLDSHARED="false"
@@ -1121,7 +1374,7 @@ SHLIBEXT="so"
 
 if test "$enable_shared" = "yes"; then
   # this bit needs to be modified for each OS that is suported by
-  # smbwrapper. You need to specify how to created a shared library and
+  # smbwrapper. You need to specify how to create a shared library and
   # how to compile C code to produce PIC object files
 
   AC_MSG_CHECKING([ability to build shared libraries])
@@ -1130,7 +1383,11 @@ if test "$enable_shared" = "yes"; then
   case "$host_os" in
                *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
                        BLDSHARED="true"
-                       LDSHFLAGS="-shared -Wl,-Bsymbolic" 
+                       if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
+                               LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined" 
+                       else
+                               LDSHFLAGS="-shared -Wl,-Bsymbolic" 
+                       fi
                        DYNEXP="-Wl,--export-dynamic"
                        PICFLAGS="-fPIC"
                        SONAMEFLAG="-Wl,-soname="
@@ -1163,7 +1420,7 @@ if test "$enable_shared" = "yes"; then
                        AC_DEFINE(STAT_ST_BLOCKSIZE,512)
                        AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
                        ;;
-               *netbsd* | *freebsd* | *DragonFly* )  
+               *netbsd* | *freebsd* | *dragonfly* )  
                        BLDSHARED="true"
                        LDSHFLAGS="-shared"
                        DYNEXP="-Wl,--export-dynamic"
@@ -1211,18 +1468,23 @@ if test "$enable_shared" = "yes"; then
                        AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
                        ;;
                *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
-                       SHLIBEXT="sl"
                        # Use special PIC flags for the native HP-UX compiler.
                        if test $ac_cv_prog_cc_Ae = yes; then
                                BLDSHARED="true"
-                               SHLD="/usr/bin/ld"
-                               LDSHFLAGS="-B symbolic -b -z"
-                               SONAMEFLAG="+h "
+                               SHLD="cc"
+                               LDSHFLAGS="-b -Wl,-B,symbolic,-b,-z"
+                               SONAMEFLAG="-Wl,+h "
                                PICFLAGS="+z"
                        elif test "${GCC}" = "yes"; then
                                PICFLAGS="-fPIC"
                        fi
-                       DYNEXP="-Wl,-E"
+                       if test "$host_cpu" = "ia64"; then
+                               SHLIBEXT="so"
+                               DYNEXP="-Wl,-E,+b /usr/local/lib/hpux32:/usr/lib/hpux32"
+                       else
+                               SHLIBEXT="sl"
+                               DYNEXP="-Wl,-E,+b /usr/local/lib:/usr/lib"
+                       fi
                        AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
                        AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
                        ;;
@@ -1396,6 +1658,19 @@ 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)
@@ -1712,17 +1987,18 @@ dnl in both libiconv and in libc. In this case the jm_ICONV test will always
 dnl succeed when the header is found. To counter this, make sure the 
 dnl library directory is there and check the ABI directory first (which
 dnl should be harmless on other systems.
-    for l in "lib32" "lib" ; do
+dnl For IA64 HPUX systems, the libs are located in lib/hpux32 instead of lib.
+    for l in "lib32" "lib" "lib/hpux32"; do
         if test -d "$i/$l" ; then
                 LDFLAGS="$save_LDFLAGS -L$i/$l"
-                LIBS=
-                export LDFLAGS LIBS CPPFLAGS
+        LIBS=
+        export LDFLAGS LIBS CPPFLAGS
 dnl Try to find iconv(3)
                 jm_ICONV($i/$l)
                 if test x"$ICONV_FOUND" = "xyes" ; then
-                    libext="$l"
-                    break;
-                fi
+            libext="$l"
+            break;
+        fi
         fi
     done
 
@@ -1730,7 +2006,7 @@ dnl Try to find iconv(3)
        LDFLAGS=$save_LDFLAGS
         LIB_ADD_DIR(LDFLAGS, "$i/$libext")
         CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
-        LIBS="$save_LIBS"
+       LIBS="$save_LIBS"
         ICONV_LOCATION=$i
         export LDFLAGS LIBS CPPFLAGS
 dnl Now, check for a working iconv ... we want to do it here because
@@ -2018,7 +2294,7 @@ fi
 
 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
 SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper"
+CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt"
 AC_TRY_COMPILE([
 #define REPLACE_GETPASS 1
 #define NO_PROTO_H 1
@@ -2202,13 +2478,6 @@ if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
     AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
 fi
 
-AC_CACHE_CHECK([for ftruncate needs root],samba_cv_FTRUNCATE_NEEDS_ROOT,[
-AC_TRY_RUN([#include "${srcdir-.}/tests/ftruncroot.c"],
-           samba_cv_FTRUNCATE_NEEDS_ROOT=yes,samba_cv_FTRUNCATE_NEEDS_ROOT=no,samba_cv_FTRUNCATE_NEEDS_ROOT=cross)])
-if test x"$samba_cv_FTRUNCATE_NEEDS_ROOT" = x"yes"; then
-    AC_DEFINE(FTRUNCATE_NEEDS_ROOT,1,[Whether ftruncate() needs root])
-fi
-
 AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
 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)])
@@ -2334,6 +2603,8 @@ AC_ARG_WITH(smbwrapper,
     AC_DEFINE(WITH_SMBWRAPPER,1,[Whether to include smbwrapper support])
        WRAPPROG="bin/smbsh\$(EXEEXT)"
        WRAP="bin/smbwrapper.$SHLIBEXT"
+       WRAP_OBJS="\$(SMBW_OBJ1) \$(SMBWRAPPER_OBJ1)"
+       WRAP_INC="-I\$(srcdir)/smbwrapper"
 
 # Conditions under which smbwrapper should not be built.
 
@@ -2341,13 +2612,19 @@ AC_ARG_WITH(smbwrapper,
           echo No support for PIC code - disabling smbwrapper and smbsh
           WRAPPROG=""
           WRAP=""
+          WRAP_OBJS=""
+          WRAP_INC=""
        elif test x$ac_cv_func_syscall = xno; then
           AC_MSG_RESULT([No syscall() -- disabling smbwrapper and smbsh])
           WRAPPROG=""
           WRAP=""
+          WRAP_OBJS=""
+          WRAP_INC=""
        fi
        EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WRAPPROG $WRAP"
        SMBWRAPPER="$WRAPPROG $WRAP"
+       SMBWRAP_OBJS="$WRAP_OBJS"
+       SMBWRAP_INC="$WRAP_INC"
     ;;
   *)
     AC_MSG_RESULT(no)
@@ -2487,6 +2764,8 @@ AC_MSG_RESULT($with_ldap_support)
 
 SMBLDAP=""
 AC_SUBST(SMBLDAP)
+SMBLDAPUTIL=""
+AC_SUBST(SMBLDAPUTIL)
 if test x"$with_ldap_support" != x"no"; then
 
   ##################################################################
@@ -2541,8 +2820,11 @@ if test x"$with_ldap_support" != x"no"; then
   
   if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes" -a x"$ac_cv_func_ext_ldap_domain2hostlist" = x"yes"; then
     AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])
+    CPPFLAGS="$CPPFLAGS -DLDAP_DEPRECATED"
     default_static_modules="$default_static_modules pdb_ldap idmap_ldap";
+    default_shared_modules="$default_shared_modules";
     SMBLDAP="lib/smbldap.o"
+    SMBLDAPUTIL="lib/smbldap_util.o"
     with_ldap_support=yes
     AC_MSG_CHECKING(whether LDAP support is used)
     AC_MSG_RESULT(yes)
@@ -2592,27 +2874,7 @@ if test x"$with_ads_support" != x"no"; then
 
   # Do no harm to the values of CFLAGS and LIBS while testing for
   # Kerberos support.
-
-  #################################################
-  # check for krb5-config from recent MIT and Heimdal kerberos 5
-  AC_PATH_PROG(KRB5_CONFIG, krb5-config)
-  AC_MSG_CHECKING(for working krb5-config)
-  if test -x "$KRB5_CONFIG"; then
-    ac_save_CFLAGS=$CFLAGS
-    CFLAGS="";export CFLAGS
-    ac_save_LDFLAGS=$LDFLAGS
-    LDFLAGS="";export LDFLAGS
-    KRB5_LIBS="`$KRB5_CONFIG --libs gssapi`"
-    KRB5_CFLAGS="`$KRB5_CONFIG --cflags | sed s/@INCLUDE_des@//`" 
-    KRB5_CPPFLAGS="`$KRB5_CONFIG --cflags | sed s/@INCLUDE_des@//`"
-    CFLAGS=$ac_save_CFLAGS;export CFLAGS
-    LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
-    FOUND_KRB5=yes
-    AC_MSG_RESULT(yes)
-  else
-    AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
-  fi
-  
   if test x$FOUND_KRB5 = x"no"; then
     #################################################
     # check for location of Kerberos 5 install
@@ -2633,12 +2895,36 @@ if test x"$with_ads_support" != x"no"; then
         KRB5_CPPFLAGS="-I$withval/include"
         KRB5_LDFLAGS="-L$withval/lib"
         FOUND_KRB5=yes
+       if test -x "$withval/bin/krb5-config"; then
+               KRB5CONFIG=$withval/bin/krb5-config
+       fi
         ;;
       esac ],
       AC_MSG_RESULT(no krb5-path given)
     )
   fi
 
+  #################################################
+  # 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
+    ac_save_CFLAGS=$CFLAGS
+    CFLAGS="";export CFLAGS
+    ac_save_LDFLAGS=$LDFLAGS
+    LDFLAGS="";export LDFLAGS
+    KRB5_LIBS="`$KRB5CONFIG --libs gssapi`"
+    KRB5_LDFLAGS="`$KRB5CONFIG --libs gssapi | sed s/-lgss.*//`"
+    KRB5_CFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`" 
+    KRB5_CPPFLAGS="`$KRB5CONFIG --cflags | sed s/@INCLUDE_des@//`"
+    CFLAGS=$ac_save_CFLAGS;export CFLAGS
+    LDFLAGS=$ac_save_LDFLAGS;export LDFLAGS
+    FOUND_KRB5=yes
+    AC_MSG_RESULT(yes)
+  else
+    AC_MSG_RESULT(no. Fallback to previous krb5 detection strategy)
+  fi
   if test x$FOUND_KRB5 = x"no"; then
     #################################################
     # see if this box has the SuSE location for the heimdal krb implementation
@@ -2677,9 +2963,9 @@ if test x"$with_ads_support" != x"no"; then
   ac_save_CPPFLAGS=$CPPFLAGS
   ac_save_LDFLAGS=$LDFLAGS
 
-  CFLAGS="$CFLAGS $KRB5_CFLAGS"
-  CPPFLAGS="$CPPFLAGS $KRB5_CPPFLAGS"
-  LDFLAGS="$LDFLAGS $KRB5_LDFLAGS"
+  CFLAGS="$KRB5_CFLAGS $CFLAGS"
+  CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS"
+  LDFLAGS="$KRB5_LDFLAGS $LDFLAGS"
 
   KRB5_LIBS="$KRB5_LDFLAGS $KRB5_LIBS"
 
@@ -2763,9 +3049,91 @@ if test x"$with_ads_support" != x"no"; then
   AC_CHECK_FUNC_EXT(krb5_free_keytab_entry_contents, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_crypto_init, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_crypto_destroy, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_decode_ap_req, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(decode_krb5_ap_req, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_free_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)
+
+  LIBS="$KRB5_LIBS $LIBS"
+
+  AC_CACHE_CHECK(whether krb5_verify_checksum takes 7 arguments, smb_krb5_verify_checksum, [
+    AC_TRY_COMPILE([
+       #include <krb5.h>], 
+       [krb5_verify_checksum(0, 0, 0, 0, 0, 0, 0);], 
+       [smb_krb5_verify_checksum=7], 
+       [smb_krb5_verify_checksum=6], 
+    ) 
+  ])
+  AC_DEFINE_UNQUOTED(KRB5_VERIFY_CHECKSUM_ARGS, $smb_krb5_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>],
+      [krb5_checksum cksum; cksum.checksum.length = 0;],
+      samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=yes,
+      samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM=no)])
+
+  if test x"$samba_cv_HAVE_CHECKSUM_IN_KRB5_CHECKSUM" = x"yes"; then
+    AC_DEFINE(HAVE_CHECKSUM_IN_KRB5_CHECKSUM,1,
+               [Whether the krb5_checksum struct has a checksum property])
+  fi
+
+  AC_CACHE_CHECK([for etype in EncryptedData],
+                samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [EncryptedData edata; edata.etype = 0;],
+      samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=yes,
+      samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA=no)])
+
+  if test x"$samba_cv_HAVE_ETYPE_IN_ENCRYPTEDDATA" = x"yes"; then
+    AC_DEFINE(HAVE_ETYPE_IN_ENCRYPTEDDATA,1,
+               [Whether the EncryptedData struct has a etype property])
+  fi
+
+  AC_CACHE_CHECK([for ticket pointer in krb5_ap_req],
+                samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_ap_req *ap_req; ap_req->ticket = NULL;],
+      samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=yes,
+      samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ=no)])
+
+  if test x"$samba_cv_HAVE_TICKET_POINTER_IN_KRB5_AP_REQ" = x"yes"; then
+    AC_DEFINE(HAVE_TICKET_POINTER_IN_KRB5_AP_REQ,1,
+               [Whether the krb5_ap_req struct has a ticket pointer])
+  fi
+
+  AC_CACHE_CHECK([for krb5_crypto type],
+                samba_cv_HAVE_KRB5_CRYPTO,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_crypto crypto;],
+      samba_cv_HAVE_KRB5_CRYPTO=yes,
+      samba_cv_HAVE_KRB5_CRYPTO=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_CRYPTO" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_CRYPTO,1,
+               [Whether the type krb5_crypto exists])
+  fi
+
+  AC_CACHE_CHECK([for krb5_encrypt_block type],
+                samba_cv_HAVE_KRB5_ENCRYPT_BLOCK,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_encrypt_block block;],
+      samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=yes,
+      samba_cv_HAVE_KRB5_ENCRYPT_BLOCK=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_ENCRYPT_BLOCK" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_ENCRYPT_BLOCK,1,
+               [Whether the type krb5_encrypt_block exists])
+  fi
 
-  LIBS="$LIBS $KRB5_LIBS"
-  
   AC_CACHE_CHECK([for addrtype in krb5_address],
                 samba_cv_HAVE_ADDRTYPE_IN_KRB5_ADDRESS,[
     AC_TRY_COMPILE([#include <krb5.h>],
@@ -2801,6 +3169,30 @@ if test x"$with_ads_support" != x"no"; then
               [Whether the krb5_ticket struct has a enc_part2 property])
   fi
 
+  AC_CACHE_CHECK([for keyblock in krb5_creds],
+                 samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_creds creds; krb5_keyblock kb; creds.keyblock = kb;],
+      samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=yes,
+      samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_KEYBLOCK_IN_CREDS,1,
+              [Whether the krb5_creds struct has a keyblock property])
+  fi
+
+  AC_CACHE_CHECK([for session in krb5_creds],
+                 samba_cv_HAVE_KRB5_SESSION_IN_CREDS,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_creds creds; krb5_keyblock kb; creds.session = kb;],
+      samba_cv_HAVE_KRB5_SESSION_IN_CREDS=yes,
+      samba_cv_HAVE_KRB5_SESSION_IN_CREDS=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_SESSION_IN_CREDS" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_SESSION_IN_CREDS,1,
+              [Whether the krb5_creds struct has a session property])
+  fi
+
   AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
                  samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
     AC_TRY_COMPILE([#include <krb5.h>],
@@ -2857,6 +3249,30 @@ if test x"$with_ads_support" != x"no"; then
              [Whether the KV5M_KEYTAB option is available])
   fi
 
+  AC_CACHE_CHECK([for KRB5_KU_OTHER_CKSUM],
+                 samba_cv_HAVE_KRB5_KU_OTHER_CKSUM,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_keyusage usage = KRB5_KU_OTHER_CKSUM;],
+      samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=yes,
+      samba_cv_HAVE_KRB5_KU_OTHER_CKSUM=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_KU_OTHER_CKSUM" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_KU_OTHER_CKSUM,1,
+              [Whether KRB5_KU_OTHER_CKSUM is available])
+  fi
+  
+  AC_CACHE_CHECK([for KRB5_KEYUSAGE_APP_DATA_CKSUM],
+                 samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_keyusage usage = KRB5_KEYUSAGE_APP_DATA_CKSUM;],
+      samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=yes,
+      samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_KEYUSAGE_APP_DATA_CKSUM,1,
+              [Whether KRB5_KEYUSAGE_APP_DATA_CKSUM is available])
+  fi
+
   AC_CACHE_CHECK([for the krb5_princ_component macro],
                 samba_cv_HAVE_KRB5_PRINC_COMPONENT,[
     AC_TRY_LINK([#include <krb5.h>],
@@ -2918,12 +3334,10 @@ if test x"$with_ads_support" != x"no"; then
     krb5_keytab keytab;
 
     krb5_init_context(&context);
-    if (krb5_kt_resolve(context, "WRFILE:api", &keytab))
-      exit(0);
-    exit(1);
+    return krb5_kt_resolve(context, "WRFILE:api", &keytab);
   }],
-  samba_cv_HAVE_WRFILE_KEYTAB=no,
-  samba_cv_HAVE_WRFILE_KEYTAB=yes)])
+  samba_cv_HAVE_WRFILE_KEYTAB=yes,
+  samba_cv_HAVE_WRFILE_KEYTAB=no)])
 
   if test x"$samba_cv_HAVE_WRFILE_KEYTAB" = x"yes"; then
       AC_DEFINE(HAVE_WRFILE_KEYTAB,1,
@@ -3207,8 +3621,8 @@ samba_cv_WITH_QUOTAS=auto
 samba_cv_TRY_QUOTAS=no
 samba_cv_RUN_QUOTA_TESTS=auto
 samba_cv_WITH_SYS_QUOTAS=auto
-samba_cv_TRY_SYS_QUOTAS=no
-samba_cv_SYSQUOTA_FOUND=no;
+samba_cv_TRY_SYS_QUOTAS=auto
+samba_cv_SYSQUOTA_FOUND=no
 
 AC_MSG_CHECKING(whether to try disk-quotas support)
 AC_ARG_WITH(quotas,
@@ -3271,18 +3685,13 @@ AC_ARG_WITH(sys-quotas,
   AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
 )
 
-if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then
+if test x"$samba_cv_TRY_SYS_QUOTAS" = x"auto"; then
 AC_MSG_CHECKING(whether to try the lib/sysquotas.c interface on ${host_os})
   case "$host_os" in
        *linux*)
            AC_MSG_RESULT(yes)
             samba_cv_TRY_SYS_QUOTAS=yes
             samba_cv_RUN_QUOTA_TESTS=yes
-            samba_cv_SYSQUOTA_FOUND=yes
-            AC_DEFINE(HAVE_QUOTACTL_LINUX,1,[Whether Linux quota support is available])
-            samba_cv_sysquotas_file="lib/sysquotas_linux.c"
-            AC_DEFINE(HAVE_LINUX_XFS_QUOTAS,1,[Whether Linux xfs quota support is available])
-            samba_cv_found_xfs_header=yes
            ;;
        *)
            AC_MSG_RESULT(no)
@@ -3295,6 +3704,28 @@ fi
 # only check for quota stuff if --with-quotas
 if test x"$samba_cv_RUN_QUOTA_TESTS" != x"no"; then
 
+case "$host_os" in
+       # on linux we didn't need to test we have builtin support
+       *linux*)
+           samba_cv_SYSQUOTA_FOUND=yes
+           AC_DEFINE(HAVE_QUOTACTL_LINUX,1,[Whether Linux quota support is available])
+           samba_cv_sysquotas_file="lib/sysquotas_linux.c"
+           AC_MSG_CHECKING(whether to use the lib/sysquotas_linux.c builtin support)
+           AC_MSG_RESULT(yes)
+
+           AC_DEFINE(HAVE_LINUX_XFS_QUOTAS,1,[Whether Linux xfs quota support is available])
+           samba_cv_found_xfs_header=yes
+           AC_MSG_CHECKING(whether to use the lib/sysquotas_xfs.c builtin support)
+           AC_MSG_RESULT(yes)
+           ;;
+       *solaris*)
+           # need to set this define when using static linking (BUG 1473)
+           CPPFLAGS="$CPPFLAGS -DSUNOS5"
+           ;;
+       *)
+           ;;
+esac
+
 # some broken header files need this
 AC_CHECK_HEADER(asm/types.h,[
            AC_DEFINE(HAVE_ASM_TYPES_H,1,[check for <asm/types.h>])
@@ -3423,7 +3854,7 @@ fi
 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no"; then
 AC_CACHE_CHECK([whether the sys_quota interface works],samba_cv_SYSQUOTA_WORKS,[
 SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper -I${srcdir-.}/nsswitch"
+CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt -I${srcdir-.}/nsswitch"
 AC_TRY_COMPILE([
 #include "confdefs.h"
 #define NO_PROTO_H 1
@@ -3450,7 +3881,7 @@ fi
 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no" -a x"$samba_cv_found_xfs_header" = x"yes"; then
 AC_CACHE_CHECK([whether the sys_quota interface works with XFS],samba_cv_SYSQUOTA_WORKS_XFS,[
 SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper -I${srcdir-.}/nsswitch"
+CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt -I${srcdir-.}/nsswitch"
 AC_TRY_COMPILE([
 #include "confdefs.h"
 #define NO_PROTO_H 1
@@ -3470,7 +3901,7 @@ fi
 
 AC_CACHE_CHECK([whether the old quota support works],samba_cv_QUOTA_WORKS,[
 SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper -I${srcdir-.}/nsswitch"
+CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I. -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt -I${srcdir-.}/nsswitch -I${srcdir-.}/smbwrapper"
 AC_TRY_COMPILE([
 #include "confdefs.h"
 #define NO_PROTO_H 1
@@ -3531,35 +3962,19 @@ else
         AC_MSG_RESULT(no$utmp_no_reason)
 fi
 
-#################################################
-# choose native language(s) of man pages
-AC_MSG_CHECKING(chosen man pages' language(s))
-AC_ARG_WITH(manpages-langs,
-[  --with-manpages-langs={en,ja,pl}  Choose man pages' language(s). (en)],
-[ case "$withval" in
-  yes|no)
-    AC_MSG_WARN(--with-manpages-langs called without argument - will use default)
-    manlangs="en"
-  ;;
-  *)
-    manlangs="$withval"
-  ;;
-  esac
-
-  AC_MSG_RESULT($manlangs)
-  manlangs=`echo $manlangs | sed "s/,/ /g"`   # replacing commas with spaces to produce a list
-  AC_SUBST(manlangs)],
-
-  [manlangs="en"
-  AC_MSG_RESULT($manlangs)
-  AC_SUBST(manlangs)]
-)
-
 #################################################
 # should we build libsmbclient?
 
 INSTALLCLIENTCMD_SH=:
 INSTALLCLIENTCMD_A=:
+
+if test $BLDSHARED = true; then
+       INSTALLCLIENTCMD_SH="\$(INSTALLCMD)"
+fi
+if test $enable_static = yes; then
+       INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
+fi
+
 INSTALLCLIENT=
 LIBSMBCLIENT_SHARED=
 LIBSMBCLIENT=
@@ -3572,9 +3987,6 @@ AC_ARG_WITH(libsmbclient,
      ;;
   *)
      if test $BLDSHARED = true; then
-        INSTALLCLIENTCMD_SH="\$(INSTALLCMD)"
-       ## build the static version of libsmbclient as well
-       INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
         LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
         LIBSMBCLIENT=libsmbclient
         AC_MSG_RESULT(yes)
@@ -3583,7 +3995,6 @@ AC_ARG_WITH(libsmbclient,
         AC_MSG_RESULT(no shared library support -- will supply static library)
      fi
      if test $enable_static = yes; then
-        INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
         LIBSMBCLIENT=libsmbclient
      fi
      INSTALLCLIENT=installclientlib
@@ -3592,7 +4003,6 @@ AC_ARG_WITH(libsmbclient,
 [
 # if unspecified, default is to built it iff possible.
   if test $BLDSHARED = true; then
-     INSTALLCLIENTCMD_SH="\$(INSTALLCMD)"
      LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
      LIBSMBCLIENT=libsmbclient
      AC_MSG_RESULT(yes)
@@ -3601,12 +4011,51 @@ AC_ARG_WITH(libsmbclient,
      AC_MSG_RESULT(no shared library support -- will supply static library)
    fi
    if test $enable_static = yes; then
-     INSTALLCLIENTCMD_A="\$(INSTALLCMD)"
      LIBSMBCLIENT=libsmbclient
   fi]
   INSTALLCLIENT=installclientlib
 )
 
+INSTALLCLIENT=
+LIBSMBSHAREMODES_SHARED=
+LIBSMBSHAREMODES=
+AC_MSG_CHECKING(whether to build the libsmbsharemodes shared library)
+AC_ARG_WITH(libsmbsharemodes,
+[  --with-libsmbsharemodes     Build the libsmbsharemodes shared library (default=yes if shared libs supported)],
+[ case "$withval" in
+  no)
+     AC_MSG_RESULT(no)
+     ;;
+  *)
+     if test $BLDSHARED = true; then
+        LIBSMBSHAREMODES_SHARED=bin/libsmbsharemodes.$SHLIBEXT
+        LIBSMBSHAREMODES=libsmbsharemodes
+        AC_MSG_RESULT(yes)
+     else
+        enable_static=yes
+        AC_MSG_RESULT(no shared library support -- will supply static library)
+     fi
+     if test $enable_static = yes; then
+        LIBSMBSHAREMODES=libsmbsharemodes
+     fi
+     INSTALLCLIENT=installclientlib
+     ;;
+  esac ],
+[
+# if unspecified, default is to built it iff possible.
+  if test $BLDSHARED = true; then
+     LIBSMBSHAREMODES_SHARED=bin/libsmbsharemodes.$SHLIBEXT
+     LIBSMBSHAREMODES=libsmbsharemodes
+     AC_MSG_RESULT(yes)
+   else
+     enable_static=yes
+     AC_MSG_RESULT(no shared library support -- will supply static library)
+   fi
+   if test $enable_static = yes; then
+     LIBSMBSHAREMODES=libsmbsharemodes
+  fi]
+  INSTALLCLIENT=installclientlib
+)
 
 #################################################
 # these tests are taken from the GNU fileutils package
@@ -3856,6 +4305,7 @@ AC_ARG_WITH(acl-support,
        *solaris*)
                AC_MSG_RESULT(Using solaris ACLs)
                AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
+               ACL_LIBS="$ACL_LIBS -lsec"
                ;;
        *hpux*)
                AC_MSG_RESULT(Using HPUX ACLs)
@@ -3874,7 +4324,7 @@ AC_ARG_WITH(acl-support,
                AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
                ACL_LIBS="$ACL_LIBS -lpacl"
                ;;
-       *freebsd5*)
+       *freebsd[[5-9]]*)
                AC_MSG_RESULT(Using FreeBSD posix ACLs)
                AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether FreeBSD POSIX ACLs are available])
                AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
@@ -3943,6 +4393,143 @@ samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)
   AC_MSG_RESULT(no)
 )
 
+#################################################
+# check for AIO support
+
+AC_MSG_CHECKING(whether to support asynchronous io)
+AC_ARG_WITH(aio-support,
+[  --with-aio-support      Include asynchronous io support (default=no)],
+[ case "$withval" in
+  yes)
+
+       AC_MSG_RESULT(yes)
+       case "$host_os" in
+       *)
+               AC_CHECK_LIB(rt,aio_read,[AIO_LIBS="$ACL_LIBS -lrt"])
+               AC_CACHE_CHECK([for asynchronous io support],samba_cv_HAVE_AIO,[
+               aio_LIBS=$LIBS
+               LIBS="$LIBS -lrt"
+               AC_TRY_LINK([#include <sys/types.h>
+#include <aio.h>],
+[ 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="$LIBS -lrt"
+               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="$LIBS -lrt"
+               elif test x"$samba_cv_HAVE_AIO" = x"yes"; then
+                       AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
+                       LIBS="$LIBS -lrt"
+               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); }],
+[AC_DEFINE(HAVE_AIO_READ, 1, [Have aio_read]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+                       AC_MSG_CHECKING(for aio_write)
+                       AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_write(&a); }],
+[AC_DEFINE(HAVE_AIO_WRITE, 1, [Have aio_write]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+                       AC_MSG_CHECKING(for aio_fsync)
+                       AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_fsync(1, &a); }],
+[AC_DEFINE(HAVE_AIO_FSYNC, 1, [Have aio_fsync]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+                       AC_MSG_CHECKING(for aio_return)
+                       AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_return(&a); }],
+[AC_DEFINE(HAVE_AIO_RETURN, 1, [Have aio_return]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+                       AC_MSG_CHECKING(for aio_error)
+                       AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_error(&a); }],
+[AC_DEFINE(HAVE_AIO_ERROR, 1, [Have aio_error]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+                       AC_MSG_CHECKING(for aio_cancel)
+                       AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_cancel(1, &a); }],
+[AC_DEFINE(HAVE_AIO_CANCEL, 1, [Have aio_cancel]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+                       AC_MSG_CHECKING(for aio_suspend)
+                       AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_suspend(&a, 1, NULL); }],
+[AC_DEFINE(HAVE_AIO_SUSPEND, 1, [Have aio_suspend]) AC_MSG_RESULT(yes)],
+[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
+        ;;
+  *)
+    AC_MSG_RESULT(no)
+    AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support is available])
+    ;;
+  esac ],
+  AC_DEFINE(HAVE_NO_AIO,1,[Whether no asynchronous io support should be built in])
+  AC_MSG_RESULT(no)
+)
+
 #################################################
 # check for sendfile support
 
@@ -4008,7 +4595,7 @@ samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)]
        fi
 
        ;;
-       *freebsd* | *DragonFly* )
+       *freebsd* | *dragonfly* )
                AC_CACHE_CHECK([for freebsd sendfile support],samba_cv_HAVE_SENDFILE,[
                AC_TRY_LINK([\
 #include <sys/types.h>
@@ -4159,7 +4746,36 @@ samba_cv_HAVE_SENDFILEV=yes,samba_cv_HAVE_SENDFILEV=no)])
                AC_MSG_RESULT(no);
        fi
        ;;
+       *aix*)
+               AC_CACHE_CHECK([for AIX send_file support],samba_cv_HAVE_SENDFILE,[
+               AC_TRY_LINK([\
+#include <sys/socket.h>],
+[\
+       int fromfd, tofd;
+       size_t total=0;
+       struct sf_parms hdtrl;
+       ssize_t nwritten;
+       off64_t offset;
+
+       hdtrl.header_data = 0;
+       hdtrl.header_length = 0;
+       hdtrl.file_descriptor = fromfd;
+       hdtrl.file_offset = 0;
+       hdtrl.file_bytes = 0;
+       hdtrl.trailer_data = 0;
+       hdtrl.trailer_length = 0;
 
+       nwritten = send_file(&tofd, &hdtrl, 0);
+],
+samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
+       if test x"$samba_cv_HAVE_SENDFILE" = x"yes"; then
+               AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
+               AC_DEFINE(AIX_SENDFILE_API,1,[Whether the AIX send_file() API is available])
+               AC_DEFINE(WITH_SENDFILE,1,[Whether to include sendfile() support])
+       else
+               AC_MSG_RESULT(no);
+       fi
+       ;;
        *)
        ;;
         esac
@@ -4193,7 +4809,7 @@ case "$host_os" in
        *linux*)
                WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_linux.o"
                ;;
-       *freebsd5*)
+       *freebsd[[5-9]]*)
                # FreeBSD winbind client is implemented as a wrapper around
                # the Linux version.
                WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_freebsd.o \
@@ -4281,6 +4897,11 @@ else
         AC_MSG_RESULT(no$winbind_no_reason)
 fi
 
+# Solaris 10 does have new member in nss_XbyY_key
+AC_CHECK_MEMBER(union nss_XbyY_key.ipnode.af_family,
+               AC_DEFINE(HAVE_NSS_XBYY_KEY_IPNODE, 1, [Defined if union nss_XbyY_key has ipnode field]),,
+               [#include <nss_dbdefs.h>])
+
 # Solaris has some extra fields in struct passwd that need to be
 # initialised otherwise nscd crashes.  
  
@@ -4292,6 +4913,14 @@ AC_CHECK_MEMBER(struct passwd.pw_age,
                AC_DEFINE(HAVE_PASSWD_PW_AGE, 1, [Defined if struct passwd has pw_age field]),,
                [#include <pwd.h>])
 
+# AIX 4.3.x and 5.1 do not have as many members in
+# struct secmethod_table as AIX 5.2
+AC_CHECK_MEMBERS([struct secmethod_table.method_attrlist], , ,
+       [#include <usersec.h>])
+AC_CHECK_MEMBERS([struct secmethod_table.method_version], , ,
+       [#include <usersec.h>])
+
+
 #################################################
 # Check to see if we should use the included popt 
 
@@ -4355,12 +4984,12 @@ AC_ARG_WITH(python,
   esac ])
 AC_SUBST(PYTHON)
 
-for i in `echo $default_static_modules | sed -e's/,/ /g'`
+for i in `echo $default_static_modules | sed -e 's/,/ /g'`
 do
        eval MODULE_DEFAULT_$i=STATIC
 done
 
-for i in `echo $default_shared_modules | sed -e's/,/ /g'`
+for i in `echo $default_shared_modules | sed -e 's/,/ /g'`
 do
        dnl Fall back to static if we cannot build shared libraries
        eval MODULE_DEFAULT_$i=STATIC
@@ -4379,7 +5008,7 @@ MODULE_idmap_tdb=STATIC
 AC_ARG_WITH(static-modules,
 [  --with-static-modules=MODULES  Comma-seperated list of names of modules to statically link in],
 [ if test $withval; then
-       for i in `echo $withval | sed -e's/,/ /g'`
+       for i in `echo $withval | sed -e 's/,/ /g'`
        do
                eval MODULE_$i=STATIC
        done
@@ -4388,7 +5017,7 @@ fi ])
 AC_ARG_WITH(shared-modules,
 [  --with-shared-modules=MODULES  Comma-seperated list of names of modules to build shared],
 [ if test $withval; then
-       for i in `echo $withval | sed -e's/,/ /g'`
+       for i in `echo $withval | sed -e 's/,/ /g'`
        do
                        eval MODULE_$i=SHARED
        done
@@ -4407,27 +5036,33 @@ SMB_MODULE(pdb_pgsql, passdb/pdb_pgsql.o, "bin/pgsql.$SHLIBEXT", PDB,
 ## end of contributed pdb_modules
 ###########################################################################
 
-SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o, "bin/ldapsam.$SHLIBEXT", PDB, 
+SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o passdb/pdb_nds.o, "bin/ldapsam.$SHLIBEXT", PDB, 
                   [ PASSDB_LIBS="$PASSDB_LIBS $LDAP_LIBS" ] )
 SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, "bin/smbpasswd.$SHLIBEXT", PDB)
 SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, "bin/tdbsam.$SHLIBEXT", PDB)
 SMB_MODULE(pdb_guest, passdb/pdb_guest.o, "bin/guest.$SHLIBEXT", PDB)
 SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o)
 
+
 SMB_MODULE(rpc_lsa, \$(RPC_LSA_OBJ), "bin/librpc_lsarpc.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_reg, \$(RPC_REG_OBJ), "bin/librpc_winreg.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_lsa_ds, \$(RPC_LSA_DS_OBJ), "bin/librpc_lsa_ds.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_wks, \$(RPC_WKS_OBJ), "bin/librpc_wkssvc.$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_net, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_dfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_srv, \$(RPC_SVC_OBJ), "bin/librpc_srvsvc.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
+SMB_MODULE(rpc_eventlog, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_echo, \$(RPC_ECHO_OBJ), "bin/librpc_echo.$SHLIBEXT", RPC)
 SMB_SUBSYSTEM(RPC,smbd/server.o)
 
 SMB_MODULE(idmap_ldap, sam/idmap_ldap.o, "bin/idmap_ldap.$SHLIBEXT", IDMAP)
 SMB_MODULE(idmap_tdb, sam/idmap_tdb.o, "bin/idmap_tdb.$SHLIBEXT", IDMAP)
+SMB_MODULE(idmap_rid, sam/idmap_rid.o, "bin/idmap_rid.$SHLIBEXT", IDMAP)
+SMB_MODULE(idmap_ad, sam/idmap_ad.o, "bin/idmap_ad.$SHLIBEXT", IDMAP)
 SMB_SUBSYSTEM(IDMAP,sam/idmap.o)
 
 SMB_MODULE(charset_weird, modules/weird.o, "bin/weird.$SHLIBEXT", CHARSET)
@@ -4443,6 +5078,7 @@ SMB_MODULE(auth_winbind, \$(AUTH_WINBIND_OBJ), "bin/winbind.$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)
+SMB_MODULE(auth_script, \$(AUTH_SCRIPT_OBJ), "bin/script.$SHLIBEXT", AUTH)
 SMB_SUBSYSTEM(AUTH,auth/auth.o)
 
 SMB_MODULE(vfs_recycle, \$(VFS_RECYCLE_OBJ), "bin/recycle.$SHLIBEXT", VFS)
@@ -4457,6 +5093,7 @@ SMB_MODULE(vfs_cap, \$(VFS_CAP_OBJ), "bin/cap.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_expand_msdfs, \$(VFS_EXPAND_MSDFS_OBJ), "bin/expand_msdfs.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_shadow_copy, \$(VFS_SHADOW_COPY_OBJ), "bin/shadow_copy.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_afsacl, \$(VFS_AFSACL_OBJ), "bin/afsacl.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_catia, \$(VFS_AFSACL_OBJ), "bin/catia.$SHLIBEXT", VFS)
 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
 
 AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules])