r15163: packaging updates for RHEL/Fedora and break out 'pre' tag to the RPM release...
[ira/wip.git] / source3 / configure.in
index 7c465179103b0ce52173f6aa6cc8a92e3859a43c..c479d2d290f5e914bffa16ee20c2909560628a80 100644 (file)
@@ -22,12 +22,14 @@ fi
 # ones...
 AC_PREFIX_DEFAULT(/usr/local/samba)
 
+rootsbindir="\${SBINDIR}"
 lockdir="\${VARDIR}/locks"
 piddir="\${VARDIR}/locks"
-mandir="\${prefix}/man"
+test "${mandir}" || mandir="\${prefix}/man"
 logfilebase="\${VARDIR}"
 privatedir="\${prefix}/private"
-libdir="\${prefix}/lib"
+test "${libdir}" || libdir="\${prefix}/lib"
+pammodulesdir="\${LIBDIR}/security"
 configdir="\${LIBDIR}"
 swatdir="\${prefix}/swat"
 
@@ -62,6 +64,22 @@ AC_ARG_WITH(privatedir,
     ;;
   esac])
 
+#################################################
+# set root sbin directory location
+AC_ARG_WITH(rootsbindir,
+[  --with-rootsbindir=DIR  Which directory to use for root sbin ($ac_default_prefix/sbin)],
+[ case "$withval" in
+  yes|no)
+  #
+  # Just in case anybody calls it without argument
+  #
+    AC_MSG_WARN([--with-rootsbindir called without argument - will use default])
+  ;;
+  * )
+    rootsbindir="$withval"
+    ;;
+  esac])
+
 #################################################
 # set lock directory location
 AC_ARG_WITH(lockdir,
@@ -159,7 +177,23 @@ AC_ARG_WITH(libdir,
   esac])
 
 #################################################
-# set lib directory location
+# set PAM modules directory location
+AC_ARG_WITH(pammodulesdir,
+[  --with-pammodulesdir=DIR  Which directory to use for PAM modules ($ac_default_prefix/$libdir/security)],
+[ case "$withval" in
+  yes|no)
+  #
+  # Just in case anybody calls it without argument
+  #
+    AC_MSG_WARN([--with-pammodulesdir called without argument - will use default])
+  ;;
+  * )
+    pammodulesdir="$withval"
+    ;;
+  esac])
+
+#################################################
+# set man directory location
 AC_ARG_WITH(mandir,
 [  --with-mandir=DIR       Where to put man pages ($mandir)],
 [ case "$withval" in
@@ -201,11 +235,14 @@ AC_SUBST(privatedir)
 AC_SUBST(swatdir)
 AC_SUBST(bindir)
 AC_SUBST(sbindir)
+AC_SUBST(rootsbindir)
+AC_SUBST(pammodulesdir)
 
 dnl Unique-to-Samba variables we'll be playing with.
 AC_SUBST(SHELL)
 AC_SUBST(LDSHFLAGS)
 AC_SUBST(SONAMEFLAG)
+AC_SUBST(NSSSONAMEVERSIONSUFFIX)
 AC_SUBST(SHLD)
 AC_SUBST(HOST_OS)
 AC_SUBST(PICFLAGS)
@@ -214,11 +251,21 @@ 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(INSTALLLIBCMD_SH)
+AC_SUBST(INSTALLLIBCMD_A)
+AC_SUBST(UNINSTALLLIBCMD_SH)
+AC_SUBST(UNINSTALLLIBCMD_A)
+AC_SUBST(INSTALL_LIBMSRPC)
+AC_SUBST(UNINSTALL_LIBMSRPC)
+AC_SUBST(LIBMSRPC_SHARED)
+AC_SUBST(LIBMSRPC)
+AC_SUBST(INSTALL_LIBSMBCLIENT)
+AC_SUBST(UNINSTALL_LIBSMBCLIENT)
 AC_SUBST(LIBSMBCLIENT_SHARED)
 AC_SUBST(LIBSMBCLIENT)
+AC_SUBST(INSTALL_LIBSMBSHAREMODES)
+AC_SUBST(LIBSMBSHAREMODES_SHARED)
+AC_SUBST(LIBSMBSHAREMODES)
 AC_SUBST(PRINT_LIBS)
 AC_SUBST(AUTH_LIBS)
 AC_SUBST(ACL_LIBS)
@@ -227,12 +274,20 @@ AC_SUBST(IDMAP_LIBS)
 AC_SUBST(KRB5_LIBS)
 AC_SUBST(LDAP_LIBS)
 AC_SUBST(SHLIB_PROGS)
+AC_SUBST(PAM_MODULES)
+AC_SUBST(INSTALL_PAM_MODULES)
+AC_SUBST(UNINSTALL_PAM_MODULES)
 AC_SUBST(SMBWRAPPER)
 AC_SUBST(SMBWRAP_OBJS)
 AC_SUBST(SMBWRAP_INC)
 AC_SUBST(EXTRA_BIN_PROGS)
+AC_SUBST(CIFSMOUNT_PROGS)
+AC_SUBST(INSTALL_CIFSMOUNT)
+AC_SUBST(UNINSTALL_CIFSMOUNT)
 AC_SUBST(EXTRA_SBIN_PROGS)
 AC_SUBST(EXTRA_ALL_TARGETS)
+AC_SUBST(CONFIG_LIBS)
+AC_SUBST(NSCD_LIBS)
 
 # Set defaults
 PIE_CFLAGS=""
@@ -273,6 +328,41 @@ AC_ARG_ENABLE(socket-wrapper,
        SOCKWRAP="\$(SOCKET_WRAPPER_OBJ)"
     fi])
 
+#################################################
+# set prefix for 'make test'
+selftest_prefix="./"
+AC_SUBST(selftest_prefix)
+AC_ARG_WITH(selftest-prefix,
+[  --with-selftest-prefix=DIR    The prefix where make test will be runned ($selftest_prefix)],
+[ case "$withval" in
+  yes|no)
+    AC_MSG_WARN([--with-selftest-prefix called without argument - will use default])
+  ;;
+  * )
+    selftest_prefix="$withval"
+    ;;
+  esac
+])
+
+#################################################
+# set path of samba4's smbtorture
+smbtorture4_path=""
+AC_SUBST(smbtorture4_path)
+AC_ARG_WITH(smbtorture4_path,
+[  --with-smbtorture4-path=PATH    The path to a samba4 smbtorture for make test (none)],
+[ case "$withval" in
+  yes|no)
+    AC_MSG_ERROR([--with-smbtorture4-path should take a path])
+  ;;
+  * )
+    smbtorture4_path="$withval"
+    if test -z "$smbtorture4_path" -a ! -f $smbtorture4_path; then
+       AC_MSG_ERROR(['$smbtorture_path' does not  exist!]) 
+    fi
+  ;;
+ esac
+])
+
 # 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"
@@ -357,9 +447,9 @@ if test "$ac_cv_prog_gnu_ld" = "yes"; then
        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
+       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
@@ -455,10 +545,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_svcctl rpc_net rpc_dfs rpc_srv rpc_spoolss rpc_eventlog auth_rhosts auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin printerdb_file"
+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_netdfs 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"
@@ -729,16 +819,17 @@ AC_HEADER_DIRENT
 AC_HEADER_TIME
 AC_HEADER_SYS_WAIT
 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)
+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)
+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_macros.h dlfcn.h)
-AC_CHECK_HEADERS(sys/syslog.h syslog.h execinfo.h)
+AC_CHECK_HEADERS(sys/syslog.h syslog.h)
 AC_CHECK_HEADERS(langinfo.h locale.h)
+AC_CHECK_HEADERS(sys/dmi.h xfs/dmapi.h sys/jfsdmapi.h sys/dmapi.h)
 
 AC_CHECK_HEADERS(rpcsvc/yp_prot.h,,,[[
 #if HAVE_RPC_RPC_H
@@ -787,8 +878,11 @@ esac
 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(syscall.h sys/syscall.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/ea.h sys/proplist.h)
+
 AC_CHECK_HEADERS(sys/cdefs.h glob.h)
 
 AC_CHECK_HEADERS(netinet/ip.h,,,[[
@@ -820,6 +914,7 @@ AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
  
 AC_CHECK_SIZEOF(int,cross)
 AC_CHECK_SIZEOF(long,cross)
+AC_CHECK_SIZEOF(long long,cross)
 AC_CHECK_SIZEOF(short,cross)
 
 AC_C_CONST
@@ -860,6 +955,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])
@@ -956,7 +1062,16 @@ AC_CACHE_CHECK([for struct timespec type],samba_cv_struct_timespec, [
 #include <stdlib.h>
 #include <stddef.h>
 #endif
-#include <time.h>
+#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
@@ -1079,11 +1194,11 @@ AC_CHECK_FUNCS(connect)
 if test x"$ac_cv_func_connect" = x"no"; then
     case "$LIBS" in
     *-lnsl*) ;;
-    *) AC_CHECK_LIB(nsl_s, printf) ;;
+    *) AC_CHECK_LIB(nsl_s, connect) ;;
     esac
     case "$LIBS" in
     *-lnsl*) ;;
-    *) AC_CHECK_LIB(nsl, printf) ;;
+    *) AC_CHECK_LIB(nsl, connect) ;;
     esac
     case "$LIBS" in
     *-lsocket*) ;;
@@ -1120,17 +1235,57 @@ AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk
 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 chsize stat64 fstat64)
-AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
+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(getdents getdents64)
 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)
+AC_CHECK_FUNCS(setbuffer shmget shm_open)
+
+# Find a method of generating a stack trace
+AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
+AC_CHECK_FUNCS(backtrace_symbols)
 AC_CHECK_LIB(exc, trace_back_stack)
 
+# Note that all the libunwind symbols in the API are defined to internal
+# platform-specific version, so we must include libunwind.h before checking
+# any of them.
+AC_MSG_CHECKING([for libunwind])
+save_LIBS=$LIBS
+if test x"$UNAME_P" != xunknown ; then
+    # This probably won't link without the platform-specific libunwind.
+    LIBS="$LIBS -lunwind"
+else
+    # Add the platform-specific libunwind module. uname -p seems the most
+    # plausible option and works for ia64, where libunwind is most useful.
+    LIBS="$LIBS -lunwind -lunwind-$UNAME_P"
+fi
+
+AC_TRY_LINK(
+    [
+#ifdef HAVE_LIBUNWIND_H
+#include <libunwind.h>
+#endif
+    ],
+    [
+       unw_context_t ctx; unw_cursor_t cur;
+       char buf[256]; unw_word_t off; 
+       unw_getcontext(&ctx); unw_init_local(&cur, &ctx);
+       unw_get_proc_name(&cur, buf, sizeof(buf), &off);
+    ],
+    [
+       AC_MSG_RESULT(yes)
+       AC_DEFINE(HAVE_LIBUNWIND, 1, [Whether libunwind is available])
+    ],
+    [
+       AC_MSG_RESULT(no)
+       LIBS=$save_LIBS
+    ])
+
 # syscall() is needed for smbwrapper.
 AC_CHECK_FUNCS(syscall)
 
@@ -1141,13 +1296,22 @@ AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
 AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
 AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
 AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
-AC_CHECK_FUNCS(getdents _getdents __getdents _lseek __lseek _read __read)
+AC_CHECK_FUNCS(getdents __getdents _lseek __lseek _read __read)
 AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
 AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
 AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
 AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
 AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
 AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
+AC_CHECK_FUNCS(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]),[])
 
 #
 # 
@@ -1278,6 +1442,45 @@ if test x"$samba_stat_hires" = x"yes" ; then
            [whether struct stat has sub-second timestamps])
 fi
 
+AC_CACHE_CHECK([whether struct stat has sub-second timestamps without struct timespec], samba_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_stat_hires=yes, samba_stat_hires=no)
+    ])
+
+if test x"$samba_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
+
 #####################################
 # we might need the resolv library on some systems
 AC_CHECK_LIB(resolv, dn_expand)
@@ -1306,14 +1509,29 @@ AC_LIBTESTFUNC(sec, bigcrypt)
 AC_LIBTESTFUNC(security, getprpwnam)
 AC_LIBTESTFUNC(sec, getprpwnam)
 
+AC_CHECK_FUNCS(strsignal)
+
 ############################################
 # Check if we have libattr
-AC_SEARCH_LIBS(getxattr, [attr])
-AC_CHECK_FUNCS(getxattr lgetxattr fgetxattr listxattr llistxattr)
-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)
+case "$host_os" in
+  *osf*)
+       AC_SEARCH_LIBS(getproplist, [proplist])
+       AC_CHECK_FUNCS(getproplist fgetproplist setproplist fsetproplist)
+       AC_CHECK_FUNCS(delproplist fdelproplist add_proplist_entry get_proplist_entry)
+       AC_CHECK_FUNCS(sizeof_proplist_entry)
+  ;;
+  *)
+       AC_SEARCH_LIBS(getxattr, [attr])
+       AC_CHECK_FUNCS(getxattr lgetxattr fgetxattr listxattr llistxattr)
+       AC_CHECK_FUNCS(getea fgetea lgetea listea flistea llistea)
+       AC_CHECK_FUNCS(removeea fremoveea lremoveea setea fsetea lsetea)
+       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)
+  ;;
+esac
+
 # Check if we have extattr
 case "$host_os" in
   *freebsd4* | *dragonfly* )
@@ -1334,6 +1552,7 @@ BLDSHARED="false"
 HOST_OS="$host_os"
 LDSHFLAGS="-shared"
 SONAMEFLAG="#"
+NSSSONAMEVERSIONSUFFIX=""
 SHLD="\${CC} \${CFLAGS}"
 PICFLAGS=""
 PICSUFFIX="po"
@@ -1358,6 +1577,7 @@ if test "$enable_shared" = "yes"; then
                        DYNEXP="-Wl,--export-dynamic"
                        PICFLAGS="-fPIC"
                        SONAMEFLAG="-Wl,-soname="
+                       NSSSONAMEVERSIONSUFFIX=".2"
                        AC_DEFINE(STAT_ST_BLOCKSIZE,512)
                        ;;
                *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
@@ -1366,6 +1586,8 @@ if test "$enable_shared" = "yes"; then
                        SONAMEFLAG="-h "
                        if test "${GCC}" = "yes"; then
                                PICFLAGS="-fPIC"
+                               SONAMEFLAG="-Wl,-soname="
+                               NSSSONAMEVERSIONSUFFIX=".1"
                                if test "${ac_cv_prog_gnu_ld}" = "yes"; then
                                        DYNEXP="-Wl,-E"
                                fi
@@ -1422,8 +1644,8 @@ if test "$enable_shared" = "yes"; then
                        ;;
                *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
                        BLDSHARED="true"
-                       LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry,-berok"
-                       DYNEXP="-Wl,-brtl,-bexpall"
+                       LDSHFLAGS="-Wl,-G,-bexpall"
+                       DYNEXP="-Wl,-brtl,-bexpall,-bbigtoc"
                        PICFLAGS="-O2"
                        if test "${GCC}" != "yes"; then
                                ## for funky AIX compiler using strncpy()
@@ -1447,10 +1669,10 @@ if test "$enable_shared" = "yes"; then
                        fi
                        if test "$host_cpu" = "ia64"; then
                                SHLIBEXT="so"
-                               DYNEXP="-Wl,-E,+b /usr/local/lib/hpux32:/usr/lib/hpux32"
+                               DYNEXP="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32"
                        else
                                SHLIBEXT="sl"
-                               DYNEXP="-Wl,-E,+b /usr/local/lib:/usr/lib"
+                               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])
@@ -1591,7 +1813,11 @@ if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
 fi
 
 AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
-AC_TRY_RUN([#include <stdio.h>
+AC_TRY_RUN([
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+#include <stdio.h>
 #include <sys/stat.h>
 main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
 samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
@@ -1612,6 +1838,19 @@ if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
     AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
 fi
 
+AC_CACHE_CHECK([for 64 bit dev_t],samba_cv_SIZEOF_DEV_T,[
+AC_TRY_RUN([
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+#include <stdio.h>
+#include <sys/stat.h>
+main() { exit((sizeof(dev_t) == 8) ? 0 : 1); }],
+samba_cv_SIZEOF_DEV_T=yes,samba_cv_SIZEOF_DEV_T=no,samba_cv_SIZEOF_DEV_T=cross)])
+if test x"$samba_cv_SIZEOF_DEV_T" = x"yes"; then
+    AC_DEFINE(SIZEOF_DEV_T,8,[The size of the 'dev_t' type])
+fi
+
 AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
 AC_TRY_RUN([
 #if defined(HAVE_UNISTD_H)
@@ -1625,6 +1864,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)
@@ -1766,15 +2018,15 @@ if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
 fi
 
-AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
+AC_CACHE_CHECK([for broken readdir name],samba_cv_HAVE_BROKEN_READDIR_NAME,[
 AC_TRY_RUN([#include <sys/types.h>
 #include <dirent.h>
 main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
 if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
 di->d_name[0] == 0) exit(0); exit(1);} ],
-samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
-if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
-    AC_DEFINE(HAVE_BROKEN_READDIR,1,[Whether readdir() is broken])
+samba_cv_HAVE_BROKEN_READDIR_NAME=yes,samba_cv_HAVE_BROKEN_READDIR_NAME=no,samba_cv_HAVE_BROKEN_READDIR_NAME=cross)])
+if test x"$samba_cv_HAVE_BROKEN_READDIR_NAME" = x"yes"; then
+    AC_DEFINE(HAVE_BROKEN_READDIR_NAME,1,[Whether readdir() returns the wrong name offset])
 fi
 
 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
@@ -1945,14 +2197,14 @@ 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
 
@@ -1960,7 +2212,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
@@ -2096,6 +2348,65 @@ if test x"$samba_cv_HAVE_KERNEL_CHANGE_NOTIFY" = x"yes"; then
     AC_DEFINE(HAVE_KERNEL_CHANGE_NOTIFY,1,[Whether kernel notifies changes])
 fi
 
+#################################################
+# Check if FAM notifications are available. For FAM info, see
+#      http://oss.sgi.com/projects/fam/
+#      http://savannah.nongnu.org/projects/fam/
+
+AC_CHECK_HEADERS(fam.h, [samba_cv_HAVE_FAM_H=yes], [samba_cv_HAVE_FAM_H=no])
+if test x"$samba_cv_HAVE_FAM_H" = x"yes"; then
+    # On IRIX, libfam requires libC, but other FAM implementations might not
+    # need it.
+    AC_CHECK_LIB(fam, FAMOpen2,
+           [samba_cv_HAVE_LIBFAM=yes; samba_fam_libs="-lfam"],
+           [samba_cv_HAVE_LIBFAM=no])
+
+    if test x"$samba_cv_HAVE_LIBFAM" = x"no" ; then
+       samba_fam_xtra=-lC
+       AC_CHECK_LIB_EXT(fam, samba_fam_xtra, FAMOpen2,
+               [samba_cv_HAVE_LIBFAM=yes; samba_fam_libs="-lfam -lC"],
+               [samba_cv_HAVE_LIBFAM=no])
+       unset samba_fam_xtra
+    fi
+fi
+
+if test x"$samba_cv_HAVE_LIBFAM" = x"yes" ; then
+    AC_DEFINE(HAVE_FAM_CHANGE_NOTIFY, 1,
+           [Whether FAM is file notifications are available])
+    AC_TRY_COMPILE([#include <fam.h>],
+               [FAMCodes code = FAMChanged;],
+               AC_DEFINE(HAVE_FAM_H_FAMCODES_TYPEDEF, 1,
+                   [Whether fam.h contains a typedef for enum FAMCodes]),
+               [])
+fi
+
+#################################################
+# Check for DMAPI interfaces in libdm/libjfsdm/libxsdm
+
+AC_CHECK_LIB(dm, dm_get_eventlist,
+       [samba_cv_HAVE_LIBDM=yes; samba_dmapi_libs="-ldm"],
+       [samba_cv_HAVE_LIBDM=no])
+
+if test x"$samba_cv_HAVE_LIBDM" = x"yes" ; then
+       AC_DEFINE(HAVE_LIBDM, 1, [Whether dmapi libdm is available])
+fi
+
+AC_CHECK_LIB(jfsdm, dm_get_eventlist,
+       [samba_cv_HAVE_LIBJFSDM=yes; samba_dmapi_libs="-ljfsdm"],
+       [samba_cv_HAVE_LIBJFSDM=no])
+
+if test x"$samba_cv_HAVE_LIBJFSDM" = x"yes" ; then
+       AC_DEFINE(HAVE_LIBJFSDM, 1, [Whether dmapi libjfsdm is available])
+fi
+
+AC_CHECK_LIB(xdsm, dm_get_eventlist,
+       [samba_cv_HAVE_LIBXDSM=yes; samba_dmapi_libs="-lxdsm"],
+       [samba_cv_HAVE_LIBXDSM=no])
+
+if test x"$samba_cv_HAVE_LIBXDSM" = x"yes" ; then
+       AC_DEFINE(HAVE_LIBXDSM, 1, [Whether dmapi libxdsm is available])
+fi
+
 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
 AC_TRY_RUN([
 #include <sys/types.h>
@@ -2116,8 +2427,6 @@ if test x"$samba_cv_HAVE_KERNEL_SHARE_MODES" = x"yes"; then
 fi
 
 
-
-
 AC_CACHE_CHECK([for IRIX kernel oplock type definitions],samba_cv_HAVE_KERNEL_OPLOCKS_IRIX,[
 AC_TRY_COMPILE([#include <sys/types.h>
 #include <fcntl.h>],
@@ -2127,22 +2436,46 @@ if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_IRIX" = x"yes"; then
     AC_DEFINE(HAVE_KERNEL_OPLOCKS_IRIX,1,[Whether IRIX kernel oplock type definitions are available])
 fi
 
-AC_CACHE_CHECK([for irix specific capabilities],samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES,[
-AC_TRY_RUN([#include <sys/types.h>
+#################################################
+# Check for POSIX capability support
+
+AC_CHECK_HEADER(sys/capability.h, [samba_cv_HAVE_SYS_CAPABILITY_H=yes;
+    AC_DEFINE(HAVE_SYS_CAPABILITY_H, 1, Whether sys/capability.h is present)],
+    [], [])
+
+if test x"$samba_cv_HAVE_SYS_CAPABILITY_H" = x"yes"; then
+
+    ac_save_LIBS=$LIBS
+    AC_LIBTESTFUNC(cap, cap_get_proc)
+
+    AC_CACHE_CHECK([for POSIX capabilities],
+           samba_cv_HAVE_POSIX_CAPABILITIES,
+           [
+               AC_TRY_RUN([
+#include <sys/types.h>
 #include <sys/capability.h>
 main() {
  cap_t cap;
- if ((cap = cap_get_proc()) == NULL)
+ cap_value_t vals[1];
+ if (!(cap = cap_get_proc()))
    exit(1);
cap->cap_effective |= CAP_NETWORK_MGT;
- cap->cap_inheritable |= CAP_NETWORK_MGT;
vals[0] = CAP_CHOWN;
+ cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
  cap_set_proc(cap);
  exit(0);
-}
-],
-samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=yes,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=no,samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES=cross)])
-if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
-    AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES,1,[Whether IRIX specific capabilities are available])
+}],
+               samba_cv_HAVE_POSIX_CAPABILITIES=yes,
+               samba_cv_HAVE_POSIX_CAPABILITIES=no,
+               samba_cv_HAVE_POSIX_CAPABILITIES=cross)
+           ])
+
+if test x"$samba_cv_HAVE_POSIX_CAPABILITIES" = x"yes"; then
+    AC_DEFINE(HAVE_POSIX_CAPABILITIES, 1,
+           [Whether POSIX capabilities are available])
+else
+    LIBS=$ac_save_LIBS
+fi
+
 fi
 
 #
@@ -2302,6 +2635,24 @@ if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
     AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
 fi
 
+AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
+       AC_TRY_RUN([#include "${srcdir-.}/tests/os2_delete.c"],
+               [samba_cv_HAVE_BROKEN_READDIR=no],
+                       [samba_cv_HAVE_BROKEN_READDIR=yes],
+                       [samba_cv_HAVE_BROKEN_READDIR="assuming not"])])
+
+if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
+AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[
+       AC_TRY_RUN([
+#include "${srcdir-.}/lib/repdir.c"
+#include "${srcdir-.}/tests/os2_delete.c"],
+       samba_cv_REPLACE_READDIR=yes,samba_cv_REPLACE_READDIR=no)])
+fi
+
+if test x"$samba_cv_REPLACE_READDIR" = x"yes"; then
+       AC_DEFINE(REPLACE_READDIR,1,[replace readdir])
+fi
+
 AC_CACHE_CHECK([for sysconf(_SC_NGROUPS_MAX)],samba_cv_SYSCONF_SC_NGROUPS_MAX,[
 AC_TRY_RUN([#include <unistd.h>
 main() { exit(sysconf(_SC_NGROUPS_MAX) == -1 ? 1 : 0); }],
@@ -2750,8 +3101,6 @@ if test x"$with_ldap_support" != x"no"; then
   # now see if we can find the ldap libs in standard paths
   AC_CHECK_LIB_EXT(ldap, LDAP_LIBS, ldap_init)
 
-  AC_CHECK_FUNC_EXT(ldap_domain2hostlist,$LDAP_LIBS)
-  
   ########################################################
   # If we have LDAP, does it's rebind procedure take 2 or 3 arguments?
   # Check found in pam_ldap 145.
@@ -2770,11 +3119,13 @@ if test x"$with_ldap_support" != x"no"; then
   
   AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $smb_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc])
 
-  AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)        
+  AC_CHECK_FUNC_EXT(ldap_dn2ad_canonical,$LDAP_LIBS)   
   
-  if test x"$ac_cv_lib_ext_ldap_ldap_init" = x"yes" -a x"$ac_cv_func_ext_ldap_domain2hostlist" = x"yes"; then
+  if test x"$ac_cv_lib_ext_ldap_ldap_init" = 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
@@ -2814,12 +3165,52 @@ FOUND_KRB5=no
 KRB5_LIBS=""
 
 if test x"$with_ldap_support" != x"yes"; then
+
     if test x"$with_ads_support" = x"yes"; then
        AC_MSG_ERROR(Active Directory Support requires LDAP support)
-    elif test x"$with_ads_support" != x"no"; then
-       AC_MSG_WARN(Active Directory Support requires LDAP support)
+    elif test x"$with_ads_support" = x"auto"; then
+       AC_MSG_WARN(Disabling Active Directory support (requires LDAP support))
+       with_ads_support=no
+    fi
+
+else
+
+    # Check to see whether there is enough LDAP functionality to be able
+    # to build AD support.
+
+    AC_CHECK_FUNC_EXT(ldap_initialize,$LDAP_LIBS)
+
+    if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
+       if test x"$with_ads_support" = x"yes"; then
+           AC_MSG_ERROR(Active Directory support requires ldap_initialize)
+       elif test x"$with_ads_support" = x"auto"; then
+           AC_MSG_WARN(Disabling Active Directory support (requires ldap_initialize))
+           with_ads_support=no
+       fi
+    fi
+
+    AC_CHECK_FUNC_EXT(ldap_domain2hostlist,$LDAP_LIBS)
+
+    if test x"$ac_cv_func_ext_ldap_domain2hostlist" != x"yes"; then
+       if test x"$with_ads_support" = x"yes"; then
+           AC_MSG_ERROR(Active Directory support requires ldap_domain2hostlist)
+       elif test x"$with_ads_support" = x"auto"; then
+           AC_MSG_WARN(Disabling Active Directory support (requires ldap_domain2hostlist))
+           with_ads_support=no
+       fi
+    fi
+
+    AC_CHECK_FUNC_EXT(ldap_add_result_entry,$LDAP_LIBS)
+
+    if test x"$ac_cv_func_ext_ldap_add_result_entry" != x"yes"; then
+       if test x"$with_ads_support" = x"yes"; then
+           AC_MSG_ERROR(Active Directory support requires ldap_add_result_entry)
+       elif test x"$with_ads_support" = x"auto"; then
+           AC_MSG_WARN(Disabling Active Directory support (requires ldap_add_result_entry))
+           with_ads_support=no
+       fi
     fi
-    with_ads_support=no
+
 fi
 
 if test x"$with_ads_support" != x"no"; then
@@ -3003,9 +3394,80 @@ if test x"$with_ads_support" != x"no"; then
   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)
+  AC_CHECK_FUNC_EXT(krb5_get_init_creds_opt_set_pac_request, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_get_renewed_creds, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_get_kdc_cred, $KRB5_LIBS)
 
   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>],
@@ -3133,6 +3595,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>],
@@ -3222,47 +3708,7 @@ if test x"$with_ads_support" != x"no"; then
 LIBS="$ac_save_LIBS"
 fi
 
-########################################################
-# Compile experimental passdb backends?
-# (pdb_xml, pdb_mysql, pdb_pgsql)
-AC_MSG_CHECKING(whether to build experimental passdb libraries)
-AC_ARG_WITH(expsam,
-[  --with-expsam=<list>    Include experimental passdb libraries (default=no)]
-[                          Valid choices include (comma separated list): ]
-[                              xml, mysql & pgsql],
-[ expsam_pdb_modules=`echo "$withval" | sed 's/,/ /g'`
-  if test "z$expsam_pdb_modules" = "zyes"; then
-    expsam_pdb_modules="xml mysql pgsql"
-  fi
-  AC_MSG_RESULT($expsam_pdb_modules)
-  for i in $expsam_pdb_modules
-  do 
-    case "$i" in
-    xml|all|yes)
-      ## pdb_xml
-         AM_PATH_XML2([2.0.0],[default_shared_modules="$default_shared_modules pdb_xml"],[AC_MSG_ERROR([Can't find XML libraries while XML support is requested])])
-      CFLAGS="$CFLAGS $XML_CFLAGS"
-      ;;
-    mysql|all|yes)
-      ## pdb_mysql
-         AM_PATH_MYSQL([default_shared_modules="$default_shared_modules pdb_mysql"],[AC_MSG_ERROR([Can't find MySQL libraries while MySQL support is requested])])
-      CFLAGS="$CFLAGS $MYSQL_CFLAGS"
-      ;;
-     pgsql|all|yes)
-      ## pdb_pgsql
-      AM_PATH_PGSQL([default_shared_modules="$default_shared_modules pdb_pgsql"],[])
-      CFLAGS="$CFLAGS $PGSQL_CFLAGS"
-      ;;
-    no)
-      ;;
-    *)
-      echo "Unknown module name \"$i\"!  Exiting..."
-      exit 1
-      ;;
-    esac
-  done ],
-  AC_MSG_RESULT(no)
-)
+AC_CHECK_LIB_EXT(nscd, NSCD_LIBS, nscd_flush_cache)
 
 #################################################
 # check for automount support
@@ -3306,6 +3752,46 @@ AC_ARG_WITH(smbmount,
   AC_MSG_RESULT(no)
 )
 
+#################################################
+# check for mount- and umount.cifs support
+CIFSMOUNT_PROGS=""
+INSTALL_CIFSMOUNT=""
+UNINSTALL_CIFSMOUNT=""
+AC_MSG_CHECKING(whether to build mount.cifs and umount.cifs)
+AC_ARG_WITH(cifsmount,
+[  --with-cifsmount        Include mount.cifs and umount.cifs (Linux only) support (default=yes)],
+[ case "$withval" in
+  no)
+       AC_MSG_RESULT(no)
+       ;;
+  *)
+       case "$host_os" in
+       *linux*)
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(WITH_CIFSMOUNT,1,[Whether to build mount.cifs and umount.cifs])
+               CIFSMOUNT_PROGS="bin/mount.cifs bin/umount.cifs"
+               INSTALL_CIFSMOUNT="installcifsmount"
+               UNINSTALL_CIFSMOUNT="uninstallcifsmount"
+               ;;
+       *)
+               AC_MSG_ERROR(not on a linux system!)
+               ;;
+       esac
+    ;;
+  esac ],
+[ case "$host_os" in
+  *linux*)
+       AC_MSG_RESULT(yes)
+       AC_DEFINE(WITH_CIFSMOUNT,1,[Whether to build mount.cifs and umount.cifs])
+       CIFSMOUNT_PROGS="bin/mount.cifs bin/umount.cifs"
+       INSTALL_CIFSMOUNT="installcifsmount"
+       UNINSTALL_CIFSMOUNT="uninstallcifsmount"
+       ;;
+  *)
+       AC_MSG_RESULT(no)
+       ;;
+  esac ]
+)
 
 
 #################################################
@@ -3340,6 +3826,9 @@ AC_CHECK_LIB(pam, pam_get_data, [AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is avai
 
 #################################################
 # check for pam_smbpass support
+PAM_MODULES=""
+INSTALL_PAM_MODULES=""
+UNINSTALL_PAM_MODULES=""
 AC_MSG_CHECKING(whether to use pam_smbpass)
 AC_ARG_WITH(pam_smbpass,
 [  --with-pam_smbpass      Build PAM module for authenticating against passdb backends (default=no)],
@@ -3357,7 +3846,9 @@ AC_ARG_WITH(pam_smbpass,
           AC_MSG_ERROR([No libpam found])
        else
          AUTH_LIBS="$AUTH_LIBS -lpam"
-          SHLIB_PROGS="$SHLIB_PROGS bin/pam_smbpass.$SHLIBEXT"
+          PAM_MODULES="pam_smbpass"
+          INSTALL_PAM_MODULES="installpammodules"
+          UNINSTALL_PAM_MODULES="uninstallpammodules"
        fi
     ;;
   *)
@@ -3481,8 +3972,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,
@@ -3545,18 +4036,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)
@@ -3569,6 +4055,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>])
@@ -3744,7 +4252,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-.}/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
@@ -3805,12 +4313,70 @@ else
         AC_MSG_RESULT(no$utmp_no_reason)
 fi
 
+INSTALLLIBCMD_SH=:
+INSTALLLIBCMD_A=:
+UNINSTALLLIBCMD_SH=:
+UNINSTALLLIBCMD_A=:
+
+if test $BLDSHARED = true; then
+       INSTALLLIBCMD_SH="\$(INSTALLCMD)"
+       UNINSTALLLIBCMD_SH="rm -f"
+fi
+if test $enable_static = yes; then
+       INSTALLLIBCMD_A="\$(INSTALLCMD)"
+       UNINSTALLLIBCMD_A="rm -f"
+fi
+
 #################################################
-# should we build libsmbclient?
+# should we build libmsrpc?
+INSTALL_LIBMSRPC=
+UNINSTALL_LIBMSRPC=
+LIBMSRPC_SHARED=
+LIBMSRPC=
+AC_MSG_CHECKING(whether to build the libmsrpc shared library)
+AC_ARG_WITH(libmsrpc,
+[  --with-libmsrpc         Build the libmsrpc shared library (default=yes if shared libs supported)],
+[ case "$withval" in
+  no) 
+     AC_MSG_RESULT(no)
+     ;;
+  *)
+     if test $BLDSHARED = true; then
+        LIBMSRPC_SHARED=bin/libmsrpc.$SHLIBEXT
+        LIBMSRPC=libmsrpc
+        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
+        LIBMSRPC=libmsrpc
+     fi
+     INSTALL_LIBMSRPC=installlibmsrpc
+     UNINSTALL_LIBMSRPC=uninstalllibmsrpc
+     ;;
+  esac ],
+[
+# if unspecified, default is to built it if possible.
+  if test $BLDSHARED = true; then
+     LIBMSRPC_SHARED=bin/libmsrpc.$SHLIBEXT
+     LIBMSRPC=libmsrpc
+     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
+     LIBMSRPC=libmsrpc
+  fi]
+  INSTALL_LIBMSRPC=installlibmsrpc
+  UNINSTALL_LIBMSRPC=uninstalllibmsrpc
+)
 
-INSTALLCLIENTCMD_SH=:
-INSTALLCLIENTCMD_A=:
-INSTALLCLIENT=
+#################################################
+# should we build libsmbclient?
+INSTALL_LIBSMBCLIENT=
+UNINSTALL_LIBSMBCLIENT=
 LIBSMBCLIENT_SHARED=
 LIBSMBCLIENT=
 AC_MSG_CHECKING(whether to build the libsmbclient shared library)
@@ -3822,9 +4388,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)
@@ -3833,16 +4396,15 @@ 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
+     INSTALL_LIBSMBCLIENT=installclientlib
+     UNINSTALL_LIBSMBCLIENT=uninstallclientlib
      ;;
   esac ],
 [
-# if unspecified, default is to built it iff possible.
+# if unspecified, default is to built it if possible.
   if test $BLDSHARED = true; then
-     INSTALLCLIENTCMD_SH="\$(INSTALLCMD)"
      LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
      LIBSMBCLIENT=libsmbclient
      AC_MSG_RESULT(yes)
@@ -3851,12 +4413,52 @@ 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
+  INSTALL_LIBSMBCLIENT=installclientlib
+  UNINSTALL_LIBSMBCLIENT=uninstallclientlib
 )
 
+INSTALL_LIBSMBSHAREMODES=
+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
+     INSTALL_LIBSMBSHAREMODES=installlibsmbsharemodes
+     ;;
+  esac ],
+[
+# if unspecified, default is to built it if 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]
+  INSTALL_LIBSMBSHAREMODES=installlibsmbsharemodes
+)
 
 #################################################
 # these tests are taken from the GNU fileutils package
@@ -4106,6 +4708,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)
@@ -4205,10 +4808,11 @@ AC_ARG_WITH(aio-support,
        AC_MSG_RESULT(yes)
        case "$host_os" in
        *)
-               AC_CHECK_LIB(rt,aio_read,[AIO_LIBS="$ACL_LIBS -lrt"])
+               AC_CHECK_LIB(rt,aio_read,[AIO_LIBS="$LIBS -lrt"])
+               AC_CHECK_LIB(aio,aio_read,[AIO_LIBS="$LIBS -laio"])
                AC_CACHE_CHECK([for asynchronous io support],samba_cv_HAVE_AIO,[
                aio_LIBS=$LIBS
-               LIBS="$LIBS -lrt"
+               LIBS=$AIO_LIBS
                AC_TRY_LINK([#include <sys/types.h>
 #include <aio.h>],
 [ struct aiocb a; return aio_read(&a);],
@@ -4216,7 +4820,7 @@ 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"
+               LIBS=$AIO_LIBS
                AC_TRY_LINK([#include <sys/types.h>
 #include <aio.h>],
 [ struct aiocb64 a; return aio_read64(&a);],
@@ -4225,10 +4829,10 @@ samba_cv_HAVE_AIO64=yes,samba_cv_HAVE_AIO64=no)
                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"
+                       LIBS=$AIO_LIBS
                elif test x"$samba_cv_HAVE_AIO" = x"yes"; then
                        AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
-                       LIBS="$LIBS -lrt"
+                       LIBS=$AIO_LIBS
                fi
 
                if test x"$samba_cv_HAVE_AIO" = x"yes"; then
@@ -4690,7 +5294,9 @@ if test x"$HAVE_WINBIND" = x"yes"; then
                SHLIB_PROGS="$SHLIB_PROGS $WINBIND_NSS $WINBIND_WINS_NSS"
 
                if test x"$with_pam" = x"yes"; then
-                       SHLIB_PROGS="$SHLIB_PROGS nsswitch/pam_winbind.$SHLIBEXT"
+                       PAM_MODULES="$PAM_MODULES pam_winbind"
+                       INSTALL_PAM_MODULES="installpammodules"
+                       UNINSTALL_PAM_MODULES="uninstallpammodules"
                fi
        fi
 else
@@ -4756,6 +5362,43 @@ AC_SUBST(BUILD_POPT)
 AC_SUBST(POPTLIBS)
 AC_SUBST(FLAGS1)
 
+#################################################
+# Check to see if we should use the included iniparser 
+
+AC_ARG_WITH(included-iniparser,
+[  --with-included-iniparser    use bundled iniparser library, not from system],
+[ 
+  case "$withval" in
+       yes)
+               INCLUDED_INIPARSER=yes
+               ;;
+        no)
+               INCLUDED_INIPARSER=no
+                ;;
+  esac ],
+)
+if test x"$INCLUDED_INIPARSER" != x"yes"; then
+    AC_CHECK_LIB(iniparser, iniparser_load,
+                INCLUDED_INIPARSER=no, INCLUDED_INIPARSER=yes)
+fi
+
+AC_MSG_CHECKING(whether to use included iniparser)
+if test x"$INCLUDED_INIPARSER" = x"yes"; then
+    AC_MSG_RESULT(yes)
+    BUILD_INIPARSER='$(INIPARSER_OBJ)'
+       INIPARSERLIBS=""
+    FLAGS1="$FLAGS1 -I$srcdir/iniparser/src"
+else
+    AC_MSG_RESULT(no)
+       BUILD_INIPARSER=""
+    INIPARSERLIBS="-liniparser"
+fi
+AC_SUBST(BUILD_INIPARSER)
+AC_SUBST(INIPARSERLIBS)
+AC_SUBST(FLAGS1)
+
+
+
 #################################################
 # Check if the user wants Python
 
@@ -4784,12 +5427,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
@@ -4800,7 +5443,6 @@ do
 done
 
 dnl Always built these modules static
-MODULE_pdb_guest=STATIC
 MODULE_rpc_spoolss=STATIC
 MODULE_rpc_srv=STATIC
 MODULE_idmap_tdb=STATIC
@@ -4808,7 +5450,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
@@ -4817,39 +5459,27 @@ 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
 fi ])
 
-###########################################################################
-## contributed pdb_modules
-
-SMB_MODULE(pdb_xml, passdb/pdb_xml.o, "bin/xml.$SHLIBEXT", PDB,
-                 [ PASSDB_LIBS="$PASSDB_LIBS $XML_LIBS" ] )
-SMB_MODULE(pdb_mysql, passdb/pdb_mysql.o, "bin/mysql.$SHLIBEXT", PDB, 
-                  [ PASSDB_LIBS="$PASSDB_LIBS $MYSQL_LIBS" ]   )
-SMB_MODULE(pdb_pgsql, passdb/pdb_pgsql.o, "bin/pgsql.$SHLIBEXT", PDB, 
-                  [ PASSDB_LIBS="$PASSDB_LIBS $PGSQL_LIBS" ]   )
-
-## end of contributed pdb_modules
-###########################################################################
-
 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_netdfs, \$(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)
@@ -4857,10 +5487,10 @@ 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_MODULE(idmap_ldap, sam/idmap_ldap.o, "bin/ldap.$SHLIBEXT", IDMAP)
+SMB_MODULE(idmap_tdb, sam/idmap_tdb.o, "bin/tdb.$SHLIBEXT", IDMAP)
+SMB_MODULE(idmap_rid, sam/idmap_rid.o, "bin/rid.$SHLIBEXT", IDMAP)
+SMB_MODULE(idmap_ad, sam/idmap_ad.o, "bin/ad.$SHLIBEXT", IDMAP)
 SMB_SUBSYSTEM(IDMAP,sam/idmap.o)
 
 SMB_MODULE(charset_weird, modules/weird.o, "bin/weird.$SHLIBEXT", CHARSET)
@@ -4876,6 +5506,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)
@@ -4890,7 +5521,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_MODULE(vfs_catia, \$(VFS_CATIA_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])
@@ -4927,6 +5558,11 @@ AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
 builddir=`pwd`
 AC_SUBST(builddir)
 
+# Stuff the smbd-only libraries at the end of the smbd link
+# path (if we have them).
+SMBD_LIBS="$samba_fam_libs $samba_dmapi_libs"
+AC_SUBST(SMBD_LIBS)
+
 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
 LIB_REMOVE_USR_LIB(LDFLAGS)
 LIB_REMOVE_USR_LIB(LIBS)
@@ -4935,7 +5571,7 @@ dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
 
-AC_OUTPUT(include/stamp-h Makefile script/findsmb smbadduser script/gen-8bit-gap.sh)
+AC_OUTPUT(include/stamp-h Makefile script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh)
 
 #################################################
 # Print very concise instructions on building/use