Cosmetic fix for libpopt-checking test.
[ira/wip.git] / source3 / configure.in
index c6f1b29e72f680800a953aff29d149305303c300..433665eeef81da3016519325980b6996447c2b33 100644 (file)
@@ -9,28 +9,37 @@ AC_SUBST(SHELL)
 AC_SUBST(RUNPROG)
 AC_SUBST(MPROGS)
 AC_SUBST(LDSHFLAGS)
+AC_SUBST(SHLD)
 AC_SUBST(HOST_OS)
 AC_SUBST(PAM_MOD)
 AC_SUBST(WRAP)
 AC_SUBST(WRAP32)
 AC_SUBST(PICFLAG)
+AC_SUBST(PICSUFFIX)
+AC_SUBST(POBAD_CC)
 AC_SUBST(SHLIBEXT)
+AC_SUBST(LIBSMBCLIENT_SHARED)
 
 # compile with optimisation and without debugging by default
 CFLAGS="-O ${CFLAGS}"
 
-AC_ARG_ENABLE(debug, [  --enable-debug        turn on debugging [default=no]],
+AC_ARG_ENABLE(debug, [  --enable-debug          turn on debugging [default=no]],
     [if eval "test x$enable_debug = xyes"; then
        CFLAGS="${CFLAGS} -g"
     fi])
 
+AC_ARG_ENABLE(developer, [  --enable-developer      turn on developer warnings and debugging [default=no]],
+    [if eval "test x$enable_developer = xyes"; then
+       CFLAGS="${CFLAGS} -g -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -DDEBUG_PASSWORD -DDEVELOPER"
+    fi])
 
 dnl Checks for programs.
 AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_AWK
-AC_PROG_LIBTOOL
-AC_SUBST(LIBTOOL_DEPS)
+
+dnl needed before AC_TRY_COMPILE
+AC_ISC_POSIX
 
 dnl Check if C compiler understands -c and -o at the same time
 AC_PROG_CC_C_O
@@ -50,23 +59,6 @@ if test x"$samba_cv_volatile" = x"yes"; then
 fi
 
 
-#################################################
-# set codepage directory location
-AC_ARG_WITH(codepagedir,
-[  --with-codepagedir=DIR     Where to put codepage files (\$libdir/codepages)],
-[ case "$withval" in
-  yes|no)
-  #
-  # Just in case anybody does it
-  #
-    AC_MSG_WARN([--with-codepagedir called without argument - will use default])
-  ;;
-  * )
-    codepagedir="$withval"
-    ;;
-  esac])
-
-
 AC_CANONICAL_SYSTEM
 
 dnl Add #include for broken IRIX header files
@@ -85,6 +77,8 @@ case "$host_os" in
 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
     *hpux*)
       AC_PROG_CC_FLAG(Ae)
+      # mmap on HPUX is completely broken...
+      AC_DEFINE(MMAP_BLACKLIST)
       if test $ac_cv_prog_cc_Ae = yes; then
         CPPFLAGS="$CPPFLAGS -Ae"
       fi
@@ -122,7 +116,10 @@ case "$host_os" in
 #
        *solaris*)
                case `uname -r` in
-                       5.6*|5.7*)
+                       5.0*|5.1*|5.2*|5.3*|5.5*)
+                               AC_MSG_RESULT([no large file support])
+                               ;;
+                       5.*)
                        AC_MSG_RESULT([enabling large file support])
                        if test "$ac_cv_prog_gcc" = yes; then
                                ${CC-cc} -v >conftest.c 2>&1
@@ -175,7 +172,7 @@ exit(1);
     *linux*)
         AC_MSG_CHECKING([for LFS support])
         old_CPPFLAGS="$CPPFLAGS"
-        CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
+        CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
        AC_TRY_RUN([
 #include <unistd.h>
 #include <sys/utsname.h>
@@ -213,7 +210,7 @@ main() {
 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
         CPPFLAGS="$old_CPPFLAGS"
         if test x$LINUX_LFS_SUPPORT = xyes ; then
-          CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
+          CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
         fi
        AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
                ;;
@@ -248,10 +245,12 @@ 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(compat.h rpc/rpc.h rpcsvc/nis.h rpcsvc/yp_prot.h rpcsvc/ypclnt.h)
-AC_CHECK_HEADERS(sys/param.h ctype.h sys/un.h sys/wait.h sys/resource.h sys/ioctl.h sys/mode.h)
-AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h string.h strings.h stdlib.h sys/socket.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(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/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(security/pam_modules.h security/_pam_macros.h)
+
 #
 # 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.
@@ -266,10 +265,10 @@ case "$host_os" in
        ;;
 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 sys/security.h security/pam_appl.h security/pam_modules.h)
+AC_CHECK_HEADERS(nss.h nss_common.h sys/security.h security/pam_appl.h security/pam_modules.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/cdefs.h glob.h acl/acl.h)
+AC_CHECK_HEADERS(sys/acl.h sys/cdefs.h glob.h)
 
 # For experimental utmp support (lastlog on some BSD-like systems)
 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
@@ -300,13 +299,74 @@ AC_CHECK_TYPE(offset_t,loff_t)
 AC_CHECK_TYPE(ssize_t, int)
 AC_CHECK_TYPE(wchar_t, unsigned short)
 
-# we need libcups for CUPS support...
+############################################
+# for cups support we need libcups, and a handful of header files
+
 AC_CHECK_LIB(cups,httpConnect)
 
+# I wonder if there is a nicer way of doing this?
+
+if test x"$ac_cv_lib_cups_httpConnect" = x"yes"; then
+        AC_CHECK_HEADERS(cups/cups.h cups/language.h)
+        if test x"$ac_cv_header_cups_cups_h" = x"yes"; then
+                if test x"$ac_cv_header_cups_language_h" = x"yes"; then
+                        AC_DEFINE(HAVE_CUPS)
+                fi
+        fi
+fi
+
+############################################
 # we need libdl for PAM and the new VFS code
 AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl";
        AC_DEFINE(HAVE_LIBDL)])
 
+############################################
+# check if the compiler can do immediate structures
+AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
+    AC_TRY_COMPILE([
+#include <stdio.h>],
+[
+   #define X_FOOBAR(x) ((FOOBAR) { x })
+   typedef struct {unsigned x;} FOOBAR;
+   FOOBAR f = X_FOOBAR(1);   
+],
+       samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
+if test x"$samba_cv_immediate_structures" = x"yes"; then
+   AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES)
+fi
+
+############################################
+# check for unix domain sockets
+AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
+    AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <sys/socket.h>
+#include <sys/un.h>],
+[
+  struct sockaddr_un sunaddr; 
+  sunaddr.sun_family = AF_UNIX;
+],
+       samba_cv_unixsocket=yes,samba_cv_unixsocket=no)])
+if test x"$samba_cv_unixsocket" = x"yes"; then
+   AC_DEFINE(HAVE_UNIXSOCKET)
+fi
+
+
+AC_CACHE_CHECK([for socklen_t type],samba_cv_socklen_t, [
+    AC_TRY_COMPILE([
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+#include <sys/socket.h>],[socklen_t i = 0],
+       samba_cv_socklen_t=yes,samba_cv_socklen_t=no)])
+if test x"$samba_cv_socklen_t" = x"yes"; then
+   AC_DEFINE(HAVE_SOCKLEN_T_TYPE)
+fi
+
 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
     AC_TRY_COMPILE([
 #include <sys/types.h>
@@ -320,28 +380,14 @@ if test x"$samba_cv_sig_atomic_t" = x"yes"; then
    AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE)
 fi
 
-AC_CACHE_CHECK([for errno in errno.h],samba_cv_errno, [
-    AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
-       samba_cv_errno=yes,samba_cv_have_errno=no)])
-if test x"$samba_cv_errno" = x"yes"; then
-   AC_DEFINE(HAVE_ERRNO_DECL)
-fi
-
-# stupid glibc has the functions but no declaration. grrrr.
-AC_CACHE_CHECK([for setresuid declaration],samba_cv_have_setresuid_decl,[
-    AC_TRY_COMPILE([#include <unistd.h>],[int i = (int)setresuid],
-        samba_cv_have_setresuid_decl=yes,samba_cv_have_setresuid_decl=no)])
-if test x"$samba_cv_have_setresuid_decl" = x"yes"; then
-    AC_DEFINE(HAVE_SETRESUID_DECL)
-fi
-
-# stupid glibc has the functions but no declaration. grrrr.
-AC_CACHE_CHECK([for setresgid declaration],samba_cv_have_setresgid_decl,[
-    AC_TRY_COMPILE([#include <unistd.h>],[int i = (int)setresgid],
-        samba_cv_have_setresgid_decl=yes,samba_cv_have_setresgid_decl=no)])
-if test x"$samba_cv_have_setresgid_decl" = x"yes"; then
-    AC_DEFINE(HAVE_SETRESGID_DECL)
-fi
+# stupid headers have the functions but no declaration. grrrr.
+AC_HAVE_DECL(errno, [#include <errno.h>])
+AC_HAVE_DECL(setresuid, [#include <unistd.h>])
+AC_HAVE_DECL(setresgid, [#include <unistd.h>])
+AC_HAVE_DECL(asprintf, [#include <stdio.h>])
+AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
+AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
+AC_HAVE_DECL(snprintf, [#include <stdio.h>])
 
 # and glibc has setresuid under linux but the function does
 # nothing until kernel 2.1.44! very dumb.
@@ -382,8 +428,7 @@ test "${with_readline+set}" != "set" && with_readline=yes
 # test for where we get readline() from
 AC_MSG_CHECKING(whether to use readline)
 AC_ARG_WITH(readline,
-[  --with-readline[=DIR]   Look for readline include/libs in DIR
-  --without-readline      Don't include readline support],
+[  --with-readline[=DIR]   Look for readline include/libs in DIR (default=auto) ],
 [  case "$with_readline" in
   yes)
     AC_MSG_RESULT(yes)
@@ -490,13 +535,15 @@ fi
 
 AC_CHECK_FUNCS(waitpid getcwd strdup strtoul strerror chown fchown chmod fchmod chroot)
 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync bzero memset)
-AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf setsid glob strpbrk pipe crypt16 getauthuid)
-AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction innetgr setnetgrent getnetgrent endnetgrent)
+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)
 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(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
-AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl)
+AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
+# setbuffer is needed for smbtorture
+AC_CHECK_FUNCS(setbuffer)
 
 # syscall() is needed for smbwrapper.
 AC_CHECK_FUNCS(syscall)
@@ -562,16 +609,9 @@ if test x$ac_cv_func_fstat64 = xno ; then
   fi
 fi
 
-#
-# If no strcasecmp, check for it in some known places
-# It is in -lresolv on ReliantUNIX and UnixWare
-#   -lresolve *must* follow -lnsl for name resolution to work properly
-#
-
-if test x$ac_cv_func_strcasecmp = xno ; then
-       AC_CHECK_LIB(resolv,strcasecmp,[LIBS="$LIBS -lresolv"]
-               AC_DEFINE(HAVE_STRCASECMP))
-fi
+#####################################
+# we might need the resolv library on some systems
+AC_CHECK_LIB(resolv, dn_expand)
 
 #
 # Check for the functions putprpwnam, set_auth_parameters,
@@ -604,19 +644,39 @@ AC_LIBTESTFUNC(sec, getprpwnam)
 # these are the defaults, good for lots of systems
 HOST_OS="$host_os"
 LDSHFLAGS="-shared"
+SHLD="\${CC}"
 PICFLAG=""
+PICSUFFIX="po"
+POBAD_CC="#"
 SHLIBEXT="so"
+BLDSHARED="false"
 
 # and these are for particular systems
 case "$host_os" in
-               *linux*)   AC_DEFINE(LINUX);;
+               *linux*)   AC_DEFINE(LINUX)
+                       BLDSHARED="true"
+                       LDSHFLAGS="-shared" 
+                       PICFLAG="-fPIC"
+               ;;
                *solaris*) AC_DEFINE(SUNOS5)
-                                       LDSHFLAGS="-G"
+                       BLDSHARED="true"
+                       LDSHFLAGS="-Wl,-h,\$@.so -G"
+                       if test "${ac_cv_prog_CC}" = "gcc"; then
+                               PICFLAG="-fPIC"
+                       else
+                               PICFLAG="-KPIC"
+                               POBAD_CC=""
+                               PICSUFFIX="po.o"
+                       fi
                ;;
                *sunos*) AC_DEFINE(SUNOS4)
-                                       LDSHFLAGS=""
+                       BLDSHARED="true"
+                       LDSHFLAGS="-Wl,-h,\$@ -G"
+                       PICFLAG="-KPIC"   # Is this correct for SunOS
                ;;
-               *bsd*) LDSHFLAGS="-shared -Bshareable"
+               *bsd*)  BLDSHARED="true"
+                       LDSHFLAGS="-Wl,-soname,\$@ -shared"
+                       PICFLAG="-fPIC"
                ;;
                *irix*) AC_DEFINE(IRIX)
                        case "$host_os" in
@@ -624,19 +684,40 @@ case "$host_os" in
                        ;;
                        esac
                        ATTEMPT_WRAP32_BUILD=yes
+                       BLDSHARED="true"
+                       LDSHFLAGS="-Wl,-soname,\$@ -shared"
+                       if test "${ac_cv_prog_CC}" = "gcc"; then
+                               PICFLAG="-fPIC"
+                       else 
+                               PICFLAG="-KPIC"
+                       fi
+               ;;
+               *aix*) AC_DEFINE(AIX)
+                       BLDSHARED="true"
+                       LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry"
+                       PICFLAG="-O2 -qmaxmem=6000"
                ;;
-               *aix*) AC_DEFINE(AIX);;
                *hpux*) AC_DEFINE(HPUX)
                        SHLIBEXT="sl"
                        # Use special PIC flags for the native HP-UX compiler.
                        if test $ac_cv_prog_cc_Ae = yes; then
-                               LDSHFLAGS="-b"
+                               #BLDSHARED="true"
+                               LDSHFLAGS="-b -z +h \$@"
                                PICFLAG="+z"
                        fi
                ;;
                *qnx*) AC_DEFINE(QNX);;
-               *osf*) AC_DEFINE(OSF1);;
+               *osf*) AC_DEFINE(OSF1)
+                       BLDSHARED="true"
+                       LDSHFLAGS="-Wl,-soname,\$@ -shared"
+                       PICFLAG="-fPIC"
+               ;;
                *sco*) AC_DEFINE(SCO);;
+               *unixware*) AC_DEFINE(UNIXWARE)
+                       BLDSHARED="true"
+                       LDSHFLAGS="-Wl,-soname,\$@ -shared"
+                       PICFLAG="-KPIC"
+               ;;
                *next2*) AC_DEFINE(NEXT2);;
                *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man]);;
                *sysv4*)
@@ -657,22 +738,11 @@ case "$host_os" in
                        ;;
 esac
 
-# try to work out how to produce pic code with this compiler
-AC_PROG_CC_FLAG(fpic)
-if test $ac_cv_prog_cc_fpic = yes; then
-    PICFLAG="-fpic";
-fi
-if test x$PICFLAG = x; then
-  AC_PROG_CC_FLAG(KPIC)
-  if test $ac_cv_prog_cc_KPIC = yes; then
-    PICFLAG="-KPIC";
-  fi
-fi
-if test x$PICFLAG = x; then
-  AC_PROG_CC_FLAG(Kpic)
-  if test $ac_cv_prog_cc_Kpic = yes; then
-    PICFLAG="-Kpic";
-  fi
+# this updates our target list if we can build shared libs
+if test $BLDSHARED = true; then
+   LIBSMBCLIENT_SHARED=bin/libsmbclient.$SHLIBEXT
+else
+   LIBSMBCLIENT_SHARED=
 fi
 
 ################
@@ -812,11 +882,16 @@ AC_TRY_RUN([
 void foo(const char *format, ...) { 
        va_list ap;
        int len;
+       char buf[5];
+
        va_start(ap, format);
        len = vsnprintf(0, 0, format, ap);
        va_end(ap);
-       if (len == 5) exit(0);
-       exit(1);
+       if (len != 5) exit(1);
+
+       if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
+
+       exit(0);
 }
 main() { foo("hello"); }
 ],
@@ -962,6 +1037,45 @@ if test x"$samba_cv_HAVE_UX_UT_SYSLEN" = x"yes"; then
     AC_DEFINE(HAVE_UX_UT_SYSLEN)
 fi 
 
+
+#################################################
+# check for libiconv support
+AC_MSG_CHECKING(whether to use libiconv)
+AC_ARG_WITH(libiconv,
+[  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
+[ case "$withval" in
+  no)
+    AC_MSG_RESULT(no)
+    ;;
+  *)
+    AC_MSG_RESULT(yes)
+    CFLAGS="$CFLAGS -I$withval/include"
+    LDFLAGS="$LDFLAGS -L$withval/lib"
+    AC_CHECK_LIB(iconv, iconv_open)
+    AC_DEFINE_UNQUOTED(WITH_LIBICONV, "${withval}")
+    ;;
+  esac ],
+  AC_MSG_RESULT(no)
+)
+
+
+############
+# check for iconv in libc
+AC_CACHE_CHECK([for working iconv],samba_cv_HAVE_NATIVE_ICONV,[
+AC_TRY_RUN([
+#include <iconv.h>
+main() {
+       iconv_t cd = iconv_open("ASCII", "UCS-2LE");
+       if (cd == 0 || cd == (iconv_t)-1) return -1;
+       return 0;
+}
+],
+samba_cv_HAVE_NATIVE_ICONV=yes,samba_cv_HAVE_NATIVE_ICONV=no,samba_cv_HAVE_NATIVE_ICONV=cross)])
+if test x"$samba_cv_HAVE_NATIVE_ICONV" = x"yes"; then
+    AC_DEFINE(HAVE_NATIVE_ICONV)
+fi
+
+
 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
 AC_TRY_RUN([
 #include <sys/types.h>
@@ -1129,6 +1243,16 @@ if test x"$samba_cv_HAVE_FTRUNCATE_EXTEND" = x"yes"; then
     AC_DEFINE(HAVE_FTRUNCATE_EXTEND)
 fi
 
+AC_CACHE_CHECK([for AF_LOCAL socket support], samba_cv_HAVE_WORKING_AF_LOCAL, [
+AC_TRY_RUN([#include "${srcdir-.}/tests/unixsock.c"],
+          samba_cv_HAVE_WORKING_AF_LOCAL=yes,
+          samba_cv_HAVE_WORKING_AF_LOCAL=no,
+          samba_cv_HAVE_WORKING_AF_LOCAL=cross)])
+if test x"$samba_cv_HAVE_WORKING_AF_LOCAL" != xno
+then
+    AC_DEFINE(HAVE_WORKING_AF_LOCAL, 1, [Define if you have working AF_LOCAL sockets])
+fi
+
 AC_CACHE_CHECK([for broken getgroups],samba_cv_HAVE_BROKEN_GETGROUPS,[
 AC_TRY_RUN([#include "${srcdir-.}/tests/getgroups.c"],
            samba_cv_HAVE_BROKEN_GETGROUPS=yes,samba_cv_HAVE_BROKEN_GETGROUPS=no,samba_cv_HAVE_BROKEN_GETGROUPS=cross)])
@@ -1369,13 +1493,6 @@ exit(1);
   fi
 fi
 
-AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
-AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
-           samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)])
-if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
-    AC_DEFINE(HAVE_TRUNCATED_SALT)
-fi
-
 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
 AC_TRY_COMPILE([#include <sys/acl.h>
 #if defined(HAVE_RPCSVC_NIS_H)
@@ -1392,8 +1509,7 @@ fi
 # check for smbwrapper support
 AC_MSG_CHECKING(whether to use smbwrapper)
 AC_ARG_WITH(smbwrapper,
-[  --with-smbwrapper     Include SMB wrapper support
-  --without-smbwrapper  Don't include SMB wrapper support (default)],
+[  --with-smbwrapper       Include SMB wrapper support (default=no) ],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
@@ -1426,11 +1542,10 @@ AC_ARG_WITH(smbwrapper,
 )
 
 #################################################
-# check for the AFS filesystem
-AC_MSG_CHECKING(whether to use AFS)
+# check for AFS clear-text auth support
+AC_MSG_CHECKING(whether to use AFS clear-text auth)
 AC_ARG_WITH(afs,
-[  --with-afs     Include AFS support
-  --without-afs  Don't include AFS support (default)],
+[  --with-afs              Include AFS clear-text auth support (default=no) ],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
@@ -1445,11 +1560,10 @@ AC_ARG_WITH(afs,
 
 
 #################################################
-# check for the DFS auth system
-AC_MSG_CHECKING(whether to use DFS auth)
+# check for the DFS clear-text auth system
+AC_MSG_CHECKING(whether to use DFS clear-text auth)
 AC_ARG_WITH(dfs,
-[  --with-dfs     Include DFS support
-  --without-dfs  Don't include DFS support (default)],
+[  --with-dce-dfs          Include DCE/DFS clear-text auth support (default=no)],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
@@ -1462,41 +1576,46 @@ AC_ARG_WITH(dfs,
   AC_MSG_RESULT(no)
 )
 
-#################################################
-# check for Kerberos IV auth system
-AC_MSG_CHECKING(whether to use Kerberos IV)
-AC_ARG_WITH(krb4,
-[  --with-krb4=base-dir     Include Kerberos IV support
-  --without-krb4          Don't include Kerberos IV support (default)],
-[   AC_MSG_RESULT(yes)
-    AC_DEFINE(KRB4_AUTH)
-    AC_CHECK_LIB(resolv, dn_expand)
-    LIBS="$LIBS -lkrb -ldes"
-    CFLAGS="$CFLAGS -I$withval/include"
-    LDFLAGS="$LDFLAGS -L$withval/lib"],
-  AC_MSG_RESULT(no)
-)
 
 #################################################
-# check for Kerberos 5 auth system
-AC_MSG_CHECKING(whether to use Kerberos 5)
+# check for location of Kerberos 5 install
+AC_MSG_CHECKING(for kerberos 5 install path)
 AC_ARG_WITH(krb5,
-[  --with-krb5=base-dir     Include Kerberos 5 support
-  --without-krb5          Don't include Kerberos 5 support (default)],
-[   AC_MSG_RESULT(yes)
-    AC_DEFINE(KRB5_AUTH)
-    LIBS="$LIBS -ldes425 -lkrb5 -lcrypto -lcom_err"
+[  --with-krb5=base-dir    Locate Kerberos 5 support (default=/usr)],
+[ case "$withval" in
+  no)
+    AC_MSG_RESULT(no)
+    ;;
+  *)
+    AC_MSG_RESULT(yes)
+    LIBS="$LIBS -lkrb5"
     CFLAGS="$CFLAGS -I$withval/include"
-    LDFLAGS="$LDFLAGS -L$withval/lib"],
+    LDFLAGS="$LDFLAGS -L$withval/lib"
+    AC_DEFINE(HAVE_KRB5)
+    have_krb5=yes;
+    ;;
+  esac ],
   AC_MSG_RESULT(no)
 )
 
+
+########################################################
+# now see if we can find the krb5 libs in standard paths
+if test x$have_krb5 != xyes; then
+AC_CHECK_LIB(krb5, krb5_mk_req_extended, [LIBS="$LIBS -lkrb5";
+       AC_DEFINE(HAVE_KRB5)])
+fi
+
+##################################################################
+# we might need the k5crypto and com_err libraries on some systems
+AC_CHECK_LIB(com_err, _et_list, [LIBS="$LIBS -lcom_err"])
+AC_CHECK_LIB(k5crypto, krb5_encrypt_data, [LIBS="$LIBS -lk5crypto"])
+
 #################################################
 # check for automount support
 AC_MSG_CHECKING(whether to use AUTOMOUNT)
 AC_ARG_WITH(automount,
-[  --with-automount     Include AUTOMOUNT support
-  --without-automount  Don't include AUTOMOUNT support (default)],
+[  --with-automount        Include AUTOMOUNT support (default=no)],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
@@ -1513,13 +1632,19 @@ AC_ARG_WITH(automount,
 # check for smbmount support
 AC_MSG_CHECKING(whether to use SMBMOUNT)
 AC_ARG_WITH(smbmount,
-[  --with-smbmount     Include SMBMOUNT (Linux only) support
-  --without-smbmount  Don't include SMBMOUNT support (default)],
+[  --with-smbmount         Include SMBMOUNT (Linux only) support (default=no)],
 [ case "$withval" in
   yes)
-    AC_MSG_RESULT(yes)
-    AC_DEFINE(WITH_SMBMOUNT)
-    MPROGS="bin/smbmount bin/smbmnt bin/smbumount"
+       case "$host_os" in
+       *linux*)
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(WITH_SMBMOUNT)
+               MPROGS="bin/smbmount bin/smbmnt bin/smbumount"
+               ;;
+       *)
+               AC_MSG_ERROR(not on a linux system!)
+               ;;
+       esac
     ;;
   *)
     AC_MSG_RESULT(no)
@@ -1532,12 +1657,11 @@ AC_ARG_WITH(smbmount,
 
 
 #################################################
-# check for a PAM password database
+# check for a PAM clear-text auth, accounts, password and session support
 with_pam_for_crypt=no
-AC_MSG_CHECKING(whether to use PAM password database)
+AC_MSG_CHECKING(whether to use PAM)
 AC_ARG_WITH(pam,
-[  --with-pam     Include PAM password database support
-  --without-pam  Don't include PAM password database support (default)],
+[  --with-pam              Include PAM support (default=no)],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
@@ -1559,8 +1683,7 @@ AC_CHECK_LIB(pam, pam_get_data, [AC_DEFINE(HAVE_LIBPAM)])
 # check for pam_smbpass support
 AC_MSG_CHECKING(whether to use pam_smbpass)
 AC_ARG_WITH(pam_smbpass,
-[  --with-pam_smbpass     Include the smbpass PAM module
-  --without-pam_smbpass  Don't include the smbpass PAM module (default)],
+[  --with-pam_smbpass      Build a PAM module to allow other applications to use our smbpasswd file (default=no)],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
@@ -1574,7 +1697,6 @@ AC_ARG_WITH(pam_smbpass,
           AC_MSG_RESULT([No libpam found -- disabling pam_smbpass])
           PAM_MOD=""
        else
-          AC_DEFINE(WITH_PAM_SMBPASS)
           PAM_MOD="bin/pam_smbpass.so"
        fi
     ;;
@@ -1597,18 +1719,43 @@ if test x"$ac_cv_func_crypt" = x"no"; then
 fi
 fi
 
+##
+## moved after the check for -lcrypt in order to
+## ensure that the necessary libraries are included
+## check checking for truncated salt.  Wrapped by the
+## $with_pam_for_crypt variable as above   --jerry
+##
+if test $with_pam_for_crypt = no; then
+AC_CACHE_CHECK([for a crypt that needs truncated salt],samba_cv_HAVE_TRUNCATED_SALT,[
+AC_TRY_RUN([#include "${srcdir-.}/tests/crypttest.c"],
+       samba_cv_HAVE_TRUNCATED_SALT=no,samba_cv_HAVE_TRUNCATED_SALT=yes,samba_cv_HAVE_TRUNCATED_SALT=cross)])
+if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
+       AC_DEFINE(HAVE_TRUNCATED_SALT)
+fi
+fi
+
+
+
+########################################################################################
+##
+## TESTS FOR SAM BACKENDS.  KEEP THESE GROUPED TOGETHER
+##
+########################################################################################
+
+## set the with_smbpasswd_sam as the default
+with_smbpasswd_sam=yes
+
 
 #################################################
 # check for a TDB password database
-AC_MSG_CHECKING(whether to use TDB password database)
+AC_MSG_CHECKING(whether to use TDB SAM database)
 AC_ARG_WITH(tdbsam,
-[  --with-tdbsam   Include experimental TDB password database
-  --without-tdbsam  Don't include experimental TDB password database (default)],
+[  --with-tdbsam           Include experimental TDB SAM support (default=no)],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
-    AC_DEFINE(WITH_TDBPWD)
-#    AC_MSG_ERROR([TDB password database not supported in this version.])
+    AC_DEFINE(WITH_TDB_SAM)
+    with_smbpasswd_sam=no
     ;;
   *)
     AC_MSG_RESULT(no)
@@ -1619,15 +1766,15 @@ AC_ARG_WITH(tdbsam,
 
 #################################################
 # check for a LDAP password database
-AC_MSG_CHECKING(whether to use LDAP password database)
-AC_ARG_WITH(ldap,
-[  --with-ldap     Include LDAP support
-  --without-ldap  Don't include LDAP support (default)],
+AC_MSG_CHECKING(whether to use LDAP SAM database)
+AC_ARG_WITH(ldapsam,
+[  --with-ldapsam          Include experimental LDAP SAM support (default=no)],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
-    AC_DEFINE(WITH_LDAP)
-    AC_MSG_ERROR([LDAP password database not supported in this version.])
+    AC_DEFINE(WITH_LDAP_SAM)
+    LIBS="-lldap -llber $LIBS"
+    with_smbpasswd_sam=no
     ;;
   *)
     AC_MSG_RESULT(no)
@@ -1638,14 +1785,14 @@ AC_ARG_WITH(ldap,
 
 #################################################
 # check for a NISPLUS password database
-AC_MSG_CHECKING(whether to use NISPLUS password database)
-AC_ARG_WITH(nisplus,
-[  --with-nisplus     Include NISPLUS password database support
-  --without-nisplus  Don't include NISPLUS password database support (default)],
+AC_MSG_CHECKING(whether to use NISPLUS SAM database)
+AC_ARG_WITH(nisplussam,
+[  --with-nisplussam       Include NISPLUS SAM support (default=no)],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
-    AC_DEFINE(WITH_NISPLUS)
+    AC_DEFINE(WITH_NISPLUS_SAM)
+    with_smbpasswd_sam=no
     ;;
   *)
     AC_MSG_RESULT(no)
@@ -1654,12 +1801,29 @@ AC_ARG_WITH(nisplus,
   AC_MSG_RESULT(no)
 )
 
+################################################
+# This test should come last because the
+# smbpasswd SAM is only used if another format
+# has not been defined
+AC_MSG_CHECKING(whether to use traditional smbpasswd file)
+if test $with_smbpasswd_sam = yes; then
+       AC_MSG_RESULT(yes)
+       AC_DEFINE(WITH_SMBPASSWD_SAM)
+else
+       AC_MSG_RESULT(no)
+fi
+
+########################################################################################
+##
+## END OF TESTS FOR SAM BACKENDS.  
+##
+########################################################################################
+
 #################################################
 # check for a NISPLUS_HOME support 
 AC_MSG_CHECKING(whether to use NISPLUS_HOME)
 AC_ARG_WITH(nisplus-home,
-[  --with-nisplus-home     Include NISPLUS_HOME support
-  --without-nisplus-home  Don't include NISPLUS_HOME support (default)],
+[  --with-nisplus-home     Include NISPLUS_HOME support (default=no)],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
@@ -1676,9 +1840,9 @@ AC_ARG_WITH(nisplus-home,
 # check for the secure socket layer
 AC_MSG_CHECKING(whether to use SSL)
 AC_ARG_WITH(ssl,
-[  --with-ssl     Include SSL support
-  --without-ssl  Don't include SSL support (default)
-  --with-sslinc=DIR Where the SSL includes are (defaults to /usr/local/ssl)],
+[  --with-ssl              Include SSL support (default=no)
+  --with-sslinc=DIR          Where the SSL includes are (defaults to /usr/local/ssl/include)
+  --with-ssllib=DIR          Where the SSL libraries are (defaults to /usr/local/ssl/lib)],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
@@ -1692,28 +1856,43 @@ AC_ARG_WITH(ssl,
        yes|no)
          echo "configure: warning: --with-sslinc called without argument - will use default" 1>&w
          CFLAGS="-I/usr/local/ssl/include $CFLAGS"
-         LIBS="-lssl -lcrypto $LIBS"
-         LDFLAGS="=L/usr/local/ssl/lib $LDFLAGS"
        ;;
         * )
-          CFLAGS="-I${withval}/include $CFLAGS"
-         LIBS="-lssl -lcrypto $LIBS"
-         LDFLAGS="-L${withval}/lib $LDFLAGS"
+          CFLAGS="-I${withval} $CFLAGS"
        ;;
        esac
 
     else
 
        CFLAGS="-I/usr/local/ssl/include $CFLAGS"   
-       LIBS="-lssl -lcrypto $LIBS"
+
+    fi
+
+    if test "${with_ssllib+set}" = set; then
+
+       withval="$with_ssllib"
+       case "$withval" in
+       yes|no)
+         echo "configure: warning: --with-ssllib called without argument - will use default" 1>&w
+         LDFLAGS="-L/usr/local/ssl/lib $LDFLAGS"
+       ;;
+        * )
+         LDFLAGS="-L${withval}/lib $LDFLAGS"
+       ;;
+       esac
+
+    else
+
        LDFLAGS="-L/usr/local/ssl/lib $LDFLAGS"
 
     fi
 
-    if test ! -d ${withval}; then
-      echo "configure: error: called with --with-ssl, but ssl base directory ${withval} does not exist or is not a directory. Aborting config" 1>&2
-      exit 1
-    fi 
+    LIBS="-lssl -lcrypto $LIBS"
+
+#    if test ! -d ${withval}; then
+#      echo "configure: error: called with --with-ssl, but ssl base directory ${withval} does not exist or is not a directory. Aborting config" 1>&2
+#      exit 1
+#    fi 
 
     CFLAGS="-DHAVE_CRYPT_DECL $CFLAGS"  # Damn, SSLeay defines its own
 
@@ -1729,8 +1908,7 @@ AC_ARG_WITH(ssl,
 # check for syslog logging
 AC_MSG_CHECKING(whether to use syslog logging)
 AC_ARG_WITH(syslog,
-[  --with-syslog     Include experimental SYSLOG support
-  --without-syslog  Don't include SYSLOG support (default)],
+[  --with-syslog           Include experimental SYSLOG support (default=no)],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
@@ -1746,9 +1924,8 @@ AC_ARG_WITH(syslog,
 #################################################
 # check for a shared memory profiling support
 AC_MSG_CHECKING(whether to use profiling)
-AC_ARG_WITH(profile,
-[  --with-profile     Include profile support
-  --without-profile  Don't include profile support (default)],
+AC_ARG_WITH(profiling-data,
+[  --with-profiling-data   Include gathering source code profile information (default=no)],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
@@ -1762,36 +1939,38 @@ AC_ARG_WITH(profile,
 )
 
 
-#################################################
-# check for experimental netatalk resource fork support
-AC_MSG_CHECKING(whether to support netatalk)
-AC_ARG_WITH(netatalk,
-[  --with-netatalk     Include experimental Netatalk support
-  --without-netatalk  Don't include experimental Netatalk support (default)],
-[ case "$withval" in
-  yes)
-    AC_MSG_RESULT(yes)
-    AC_DEFINE(WITH_NETATALK)
-    ;;
-  *)
-    AC_MSG_RESULT(no)
-    ;;
-  esac ],
-  AC_MSG_RESULT(no)
-)
-
 #################################################
 # check for experimental disk-quotas support
 QUOTAOBJS=smbd/noquotas.o
 
 AC_MSG_CHECKING(whether to support disk-quotas)
 AC_ARG_WITH(quotas,
-[  --with-quotas     Include experimental disk-quota support
-  --without-quotas  Don't include experimental disk-quota support (default)],
+[  --with-quotas           Include experimental disk-quota support (default=no)],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
+    case "$host_os" in
+      *linux*)
+        # Check for kernel 2.4.x quota braindamage...
+        AC_CACHE_CHECK([for linux 2.4.x quota braindamage..],samba_cv_linux_2_4_quota_braindamage, [
+        AC_TRY_COMPILE([#include <stdio.h>
+#include <sys/types.h>
+#include <asm/types.h>
+#include <linux/quota.h>
+#include <mntent.h>
+#include <linux/unistd.h>],[struct mem_dqblk D;],
+      samba_cv_linux_2_4_quota_braindamage=yes,samba_cv_linux_2_4_quota_braindamage=no)])
+if test x"$samba_cv_linux_2_4_quota_braindamage" = x"yes"; then
+        AC_DEFINE(LINUX_QUOTAS_2)
+else
+        AC_DEFINE(LINUX_QUOTAS_1)
+fi
+        ;;
+      *)
+        ;;
+    esac
     QUOTAOBJS=smbd/quotas.o
+    AC_DEFINE(WITH_QUOTAS)
     ;;
   *)
     AC_MSG_RESULT(no)
@@ -1806,8 +1985,7 @@ AC_SUBST(QUOTAOBJS)
 
 AC_MSG_CHECKING(whether to support utmp accounting)
 AC_ARG_WITH(utmp,
-[  --with-utmp     Include experimental utmp accounting
-  --without-utmp  Don't include experimental utmp accounting (default)],
+[  --with-utmp             Include experimental utmp accounting (default=no)],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
@@ -1820,29 +1998,10 @@ AC_ARG_WITH(utmp,
   AC_MSG_RESULT(no)
 )
 
-#################################################
-# check for MS Dfs support
-
-AC_MSG_CHECKING(whether to support Microsoft Dfs)
-AC_ARG_WITH(msdfs,
-[  --with-msdfs                Include MS Dfs support
-  --without-msdfs      Don't include MS Dfs support (default)],
-[ case "$withval" in
-  yes)
-     AC_MSG_RESULT(yes)
-     AC_DEFINE(WITH_MSDFS)
-     ;;
-  *)
-    AC_MSG_RESULT(no)
-    ;;
-  esac ],
-  AC_MSG_RESULT(no)
-)
-
 #################################################
 # set private directory location
 AC_ARG_WITH(privatedir,
-[  --with-privatedir=DIR     Where to put smbpasswd ($ac_default_prefix/private)],
+[  --with-privatedir=DIR   Where to put smbpasswd ($ac_default_prefix/private)],
 [ case "$withval" in
   yes|no)
   #
@@ -1863,7 +2022,7 @@ AC_ARG_WITH(privatedir,
 #################################################
 # set lock directory location
 AC_ARG_WITH(lockdir,
-[  --with-lockdir=DIR     Where to put lock files ($ac_default_prefix/var/locks)],
+[  --with-lockdir=DIR      Where to put lock files ($ac_default_prefix/var/locks)],
 [ case "$withval" in
   yes|no)
   #
@@ -1884,7 +2043,7 @@ AC_ARG_WITH(lockdir,
 #################################################
 # set SWAT directory location
 AC_ARG_WITH(swatdir,
-[  --with-swatdir=DIR     Where to put SWAT files ($ac_default_prefix/swat)],
+[  --with-swatdir=DIR      Where to put SWAT files ($ac_default_prefix/swat)],
 [ case "$withval" in
   yes|no)
   #
@@ -1902,6 +2061,30 @@ AC_ARG_WITH(swatdir,
    AC_SUBST(swatdir)]
 )
 
+#################################################
+# 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/,/ /"`   # replacing commas with spaces to produce a list
+  AC_SUBST(manlangs)],
+
+  [manlangs="en"
+  AC_MSG_RESULT($manlangs)
+  AC_SUBST(manlangs)]
+)
+
 #################################################
 # these tests are taken from the GNU fileutils package
 AC_CHECKING(how to get filesystem space usage)
@@ -2105,14 +2288,12 @@ __COMPILE_ERROR_
 [int i],
 samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
 if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
-       AC_MSG_RESULT(yes)
     AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT)
-else
-       AC_MSG_RESULT(no)
 fi
 AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
 
-AC_ARG_WITH(spinlocks, [  --with-spinlocks        use spin locks instead of fcntl locks ])
+AC_ARG_WITH(spinlocks, 
+[  --with-spinlocks        Use spin locks instead of fcntl locks (default=no) ])
 if test "x$with_spinlocks" = "xyes"; then
     AC_DEFINE(USE_SPINLOCKS)
 
@@ -2140,8 +2321,7 @@ fi
 
 AC_MSG_CHECKING(whether to support ACLs)
 AC_ARG_WITH(acl-support,
-[  --with-acl-support        Include ACL support
-  --without-acl-support  Don't include ACL support (default)],
+[  --with-acl-support      Include ACL support (default=no)],
 [ case "$withval" in
   yes)
 
@@ -2162,6 +2342,11 @@ AC_ARG_WITH(acl-support,
                        AC_MSG_RESULT(Using AIX ACLs)
                        AC_DEFINE(HAVE_AIX_ACLS)
                        ;;
+               *osf*)
+                       AC_MSG_RESULT(Using Tru64 ACLs)
+                       AC_DEFINE(HAVE_TRU64_ACLS)
+                       LIBS="$LIBS -lpacl"
+                       ;;
         *)
                        AC_CHECK_LIB(acl,acl_get_file)
                        AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
@@ -2181,15 +2366,6 @@ samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)])
                                        AC_DEFINE(HAVE_ACL_GET_PERM_NP)
                                fi
                        fi
-                       AC_CACHE_CHECK([for XFS ACL support],samba_cv_HAVE_XFS_ACLS,[
-                       AC_TRY_COMPILE([#include <sys/types.h>
-#include <acl/acl.h>],
-[ char test_str[13] = SGI_ACL_FILE; ],
-samba_cv_HAVE_XFS_ACLS=yes,samba_cv_XFS_POSIX_ACLS=no)])
-                       if test x"$samba_cv_HAVE_XFS_ACLS" = x"yes"; then
-                               AC_MSG_RESULT(Using XFS ACLs)
-                               AC_DEFINE(HAVE_XFS_ACLS)
-                       fi
             ;;
         esac
         ;;
@@ -2201,6 +2377,115 @@ samba_cv_HAVE_XFS_ACLS=yes,samba_cv_XFS_POSIX_ACLS=no)])
   AC_DEFINE(HAVE_NO_ACLS)
   AC_MSG_RESULT(no)
 )
+
+#################################################
+# Check whether winbind is supported on this platform.  If so we need to
+# build and install client programs (WINBIND_TARGETS), sbin programs
+# (WINBIND_STARGETS) and shared libraries (WINBIND_LTARGETS).
+
+AC_MSG_CHECKING(whether to build winbind)
+
+# Initially, the value of $host_os decides whether winbind is supported
+
+case "$host_os" in 
+        *linux*|*solaris*)
+               HAVE_WINBIND=yes
+                ;;
+        *)
+               HAVE_WINBIND=no
+                winbind_no_reason=", unsupported on $host_os"
+                ;;
+esac
+
+# Check the setting of --with-winbindd
+
+AC_ARG_WITH(winbind,
+[  --with-winbind          Build winbind (default, if supported by OS)],
+[ 
+  case "$withval" in
+       yes)
+               HAVE_WINBIND=yes
+               ;;
+        no)
+               HAVE_WINBIND=no
+                winbind_reason=""
+                ;;
+  esac ],
+)
+
+# We need unix domain sockets for winbind
+
+if test x"$HAVE_WINBIND" = x"yes"; then
+       if test x"$samba_cv_unixsocket" = x"no"; then
+               winbind_no_reason=", no unix domain socket support on $host_os"
+               HAVE_WINBIND=no
+       fi
+fi
+
+# Display test results
+
+if test x"$HAVE_WINBIND" = x"yes"; then
+
+        AC_MSG_RESULT(yes)
+
+       WINBIND_TARGETS="\$(WINBIND_PROGS)"
+       WINBIND_STARGETS="\$(WINBIND_SPROGS)"
+       WINBIND_LTARGETS="\$(WINBIND_LPROGS)"
+       case "$with_pam" in
+               yes)
+                       WINBIND_PAM_PROGS="\$(WINBIND_PAM_PROGS)"
+               ;;
+       esac
+else
+        AC_MSG_RESULT(no$winbind_no_reason)
+
+       WINBIND_TARGETS=""
+       WINBIND_STARGETS=""
+       WINBIND_LTARGETS=""
+       WINBIND_PAM_PROGS=""
+fi
+
+# Substitution time!
+
+AC_SUBST(WINBIND_TARGETS)
+AC_SUBST(WINBIND_STARGETS)
+AC_SUBST(WINBIND_LTARGETS)
+AC_SUBST(WINBIND_PAM_PROGS)
+
+#################################################
+# Check to see if we should use the included popt 
+
+AC_ARG_WITH(included-popt,
+[  --with-included-popt    use bundled popt library, not from system],
+[ 
+  case "$withval" in
+       yes)
+               INCLUDED_POPT=yes
+               ;;
+        no)
+               INCLUDED_POPT=no
+                ;;
+  esac ],
+)
+if test x"$INCLUDED_POPT" != x"yes"; then
+    AC_CHECK_LIB(popt, poptGetContext,
+                INCLUDED_POPT=no, INCLUDED_POPT=yes)
+fi
+
+AC_MSG_CHECKING(whether to use included popt)
+if test x"$INCLUDED_POPT" = x"yes"; then
+    AC_MSG_RESULT($srcdir/popt)
+    BUILD_POPT='$(POPT_OBJS)'
+    CFLAGS="$CFLAGS -I$srcdir/popt"
+else
+    AC_MSG_RESULT(no)
+    LIBS="$LIBS -lpopt"
+fi
+AC_SUBST(BUILD_POPT)
+
+#################################################
+# final configure stuff
+
 echo "checking configure summary"
 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
            echo "configure OK";,