Make --with-ldapsam 'go away'. This is now a standard, stable, feature
[kai/samba.git] / source3 / configure.in
index 78a0d2e9af1c869c0c66c5c86c2806924bb3ef24..537c5a7a59ea889b6ad40069e52b42e1bd538aa2 100644 (file)
@@ -1,9 +1,153 @@
+dnl -*- mode: m4-mode -*-
 dnl Process this file with autoconf to produce a configure script.
 AC_INIT(include/includes.h)
 AC_CONFIG_HEADER(include/config.h)
-# we want to be compatibe with older versions of Samba
+
+#################################################
+# Directory handling stuff to support both the
+# legacy SAMBA directories and FHS compliant
+# ones...
 AC_PREFIX_DEFAULT(/usr/local/samba)
 
+AC_ARG_WITH(fhs, 
+[  --with-fhs              Use FHS-compliant paths (default=no)],
+    codepagedir="\$(DATADIR)/samba/codepages"
+    configdir="${sysconfdir}/samba"
+    lockdir="\${VARDIR}/cache/samba"
+    piddir="\$(VARDIR)/run/samba"
+    logfilebase="\${VARDIR}/log/samba"
+    privatedir="\${CONFIGDIR}/private"
+    swatdir="\${DATADIR}/samba/swat",
+    codepagedir="\$(LIBDIR)/codepages"
+    configdir="\$(LIBDIR)"
+    logfilebase="\$(VARDIR)"
+    lockdir="\${VARDIR}/locks"
+    piddir="\$(VARDIR)/locks"
+    privatedir="\${prefix}/private"
+    swatdir="\${prefix}/swat")
+
+#################################################
+# set private directory location
+AC_ARG_WITH(privatedir,
+[  --with-privatedir=DIR   Where to put smbpasswd ($ac_default_prefix/private)],
+[ case "$withval" in
+  yes|no)
+  #
+  # Just in case anybody calls it without argument
+  #
+    AC_MSG_WARN([--with-privatedir called without argument - will use default])
+  ;;
+  * )
+    privatedir="$withval"
+    ;;
+  esac])
+
+#################################################
+# set lock directory location
+AC_ARG_WITH(lockdir,
+[  --with-lockdir=DIR      Where to put lock files ($ac_default_prefix/var/locks)],
+[ case "$withval" in
+  yes|no)
+  #
+  # Just in case anybody calls it without argument
+  #
+    AC_MSG_WARN([--with-lockdir called without argument - will use default])
+  ;;
+  * )
+    lockdir="$withval"
+    ;;
+  esac])
+
+#################################################
+# set pid directory location
+AC_ARG_WITH(piddir,
+[  --with-piddir=DIR       Where to put pid files ($ac_default_prefix/var/locks)],
+[ case "$withval" in
+  yes|no)
+  #
+  # Just in case anybody calls it without argument
+  #
+    AC_MSG_WARN([--with-piddir called without argument - will use default])
+  ;;
+  * )
+    piddir="$withval"
+    ;;
+  esac])
+
+#################################################
+# set SWAT directory location
+AC_ARG_WITH(swatdir,
+[  --with-swatdir=DIR      Where to put SWAT files ($ac_default_prefix/swat)],
+[ case "$withval" in
+  yes|no)
+  #
+  # Just in case anybody does it
+  #
+    AC_MSG_WARN([--with-swatdir called without argument - will use default])
+  ;;
+  * )
+    swatdir="$withval"
+    ;;
+  esac])
+
+#################################################
+# set configuration directory location
+AC_ARG_WITH(configdir,
+[  --with-configdir=DIR    Where to put configuration files (\$libdir)],
+[ case "$withval" in
+  yes|no)
+  #
+  # Just in case anybody does it
+  #
+    AC_MSG_WARN([--with-configdir called without argument - will use default])
+  ;;
+  * )
+    configdir="$withval"
+    ;;
+  esac])
+
+#################################################
+# 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])
+
+#################################################
+# set log directory location
+AC_ARG_WITH(logfilebase,
+[  --with-logfilebase=DIR  Where to put log files (\$(VARDIR))],
+[ case "$withval" in
+  yes|no)
+  #
+  # Just in case anybody does it
+  #
+    AC_MSG_WARN([--with-logfilebase called without argument - will use default])
+  ;;
+  * )
+    logfilebase="$withval"
+    ;;
+  esac])
+
+AC_SUBST(codepagedir)
+AC_SUBST(configdir)
+AC_SUBST(lockdir)
+AC_SUBST(piddir)
+AC_SUBST(logfilebase)
+AC_SUBST(privatedir)
+AC_SUBST(swatdir)
+AC_SUBST(bindir)
+AC_SUBST(sbindir)
+
 dnl Unique-to-Samba variables we'll be playing with.
 AC_SUBST(SHELL)
 AC_SUBST(RUNPROG)
@@ -18,22 +162,45 @@ AC_SUBST(PICFLAG)
 AC_SUBST(PICSUFFIX)
 AC_SUBST(POBAD_CC)
 AC_SUBST(SHLIBEXT)
-AC_SUBST(BLDSHARED)
+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 compiler debugging information (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])
+
+AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer      turn on developer warnings and debugging, except -Wstrict-prototypes [default=no]],
+    [if eval "test x$enable_krb5developer = xyes"; then
+       CFLAGS="${CFLAGS} -g -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -DDEBUG_PASSWORD -DDEVELOPER"
+    fi])
+
+AC_ARG_ENABLE(dmalloc, [  --enable-dmalloc          enable heap debugging [default=no]])
+
+if test "x$enable_dmalloc" = xyes
+then
+       AC_DEFINE(ENABLE_DMALLOC, 1, [Define to turn on dmalloc debugging])
+       AC_DEFINE(DMALLOC_FUNC_CHECK, 1, 
+                  [Define to check invariants around some common functions])
+       LIBS="$LIBS -ldmalloc"  
+fi
 
 dnl Checks for programs.
 AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_AWK
 
+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
 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
@@ -62,6 +229,8 @@ esac
 
 AC_VALIDATE_CACHE_SYSTEM_TYPE
 
+DYNEXP=
+
 #
 # Config CPPFLAG settings for strange OS's that must be set
 # before other tests.
@@ -69,6 +238,7 @@ AC_VALIDATE_CACHE_SYSTEM_TYPE
 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)
@@ -82,15 +252,33 @@ case "$host_os" in
 #
       case `uname -r` in
                        *9*|*10*)
-                               CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE"
+                               CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4"
                                AC_DEFINE(USE_BOTH_CRYPT_CALLS)
+                               AC_DEFINE(_HPUX_SOURCE)
+                               AC_DEFINE(_POSIX_SOURCE)
+                               AC_DEFINE(_ALIGNMENT_REQUIRED,1)
+                               AC_DEFINE(_MAX_ALIGNMENT,4)
                                ;;
                        *11*)
-                               CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE"
+                               CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4"
                                AC_DEFINE(USE_BOTH_CRYPT_CALLS)
+                               AC_DEFINE(_HPUX_SOURCE)
+                               AC_DEFINE(_POSIX_SOURCE)
+                               AC_DEFINE(_LARGEFILE64_SOURCE)
+                               AC_DEFINE(_ALIGNMENT_REQUIRED,1)
+                               AC_DEFINE(_MAX_ALIGNMENT,4)
                                ;;
       esac
+      DYNEXP="-Wl,-E"
       ;;
+
+#
+# CRAY Unicos has broken const handling
+       *unicos*)
+         AC_MSG_RESULT([disabling const])
+         CPPFLAGS="$CPPFLAGS -Dconst="
+         ;;
+       
 #
 # AIX4.x doesn't even admit to having large
 # files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
@@ -98,6 +286,7 @@ case "$host_os" in
     *aix4*)
          AC_MSG_RESULT([enabling large file support])
       CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
+      AC_DEFINE(_LARGE_FILES)
       ;;    
 #
 # Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
@@ -121,13 +310,18 @@ case "$host_os" in
                                case "$ac_cv_gcc_compiler_version_number" in
                                        *"gcc version 2.6"*|*"gcc version 2.7"*)
                                                CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
+                                               AC_DEFINE(_LARGEFILE64_SOURCE)
                                                ;;
                                        *)
                                                CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+                                               AC_DEFINE(_LARGEFILE64_SOURCE)
+                                               AC_DEFINE(_FILE_OFFSET_BITS,64)
                                                ;;
                                esac
                        else
                                CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+                               AC_DEFINE(_LARGEFILE64_SOURCE)
+                               AC_DEFINE(_FILE_OFFSET_BITS,64)
                        fi
                        ;;
                esac
@@ -152,6 +346,7 @@ exit(1);
         CPPFLAGS="$old_CPPFLAGS"
         if test x$SINIX_LFS_SUPPORT = xyes ; then
           CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
+          AC_DEFINE(_LARGEFILE64_SOURCE)
           CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
           LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
           LIBS="`getconf LFS64_LIBS` $LIBS"
@@ -204,6 +399,9 @@ main() {
         CPPFLAGS="$old_CPPFLAGS"
         if test x$LINUX_LFS_SUPPORT = xyes ; then
           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
+          AC_DEFINE(_LARGEFILE64_SOURCE)
+          AC_DEFINE(_FILE_OFFSET_BITS,64)
+          AC_DEFINE(_GNU_SOURCE)
         fi
        AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
                ;;
@@ -224,6 +422,8 @@ exit(1);
         CPPFLAGS="$old_CPPFLAGS"
         if test x$GLIBC_LFS_SUPPORT = xyes ; then
           CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
+          AC_DEFINE(_LARGEFILE64_SOURCE)
+          AC_DEFINE(_GNU_SOURCE)
         fi
       AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
     ;;
@@ -242,7 +442,7 @@ AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/i
 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)
+AC_CHECK_HEADERS(security/pam_modules.h security/_pam_macros.h ldap.h lber.h dlfcn.h)
 
 #
 # HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
@@ -258,7 +458,7 @@ 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 nss_common.h sys/security.h security/pam_appl.h security/pam_modules.h)
+AC_CHECK_HEADERS(nss.h nss_common.h ns_api.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)
@@ -269,6 +469,9 @@ AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
 # For quotas on Veritas VxFS filesystems
 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
 
+# For quotas on Linux XFS filesystems
+AC_CHECK_HEADERS(linux/xqm.h)
+
 AC_CHECK_SIZEOF(int,cross)
 AC_CHECK_SIZEOF(long,cross)
 AC_CHECK_SIZEOF(short,cross)
@@ -301,18 +504,21 @@ AC_CHECK_LIB(cups,httpConnect)
 
 if test x"$ac_cv_lib_cups_httpConnect" = x"yes"; then
         AC_CHECK_HEADERS(cups/cups.h cups/language.h)
-        if x"$ac_cv_header_cups_cups_h" = x"yes"; then
-                if x"$ac_cv_header_cups_language_h" = x"yes"; then
+        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)])
-
+# we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the new VFS code
+AC_CHECK_FUNCS(dlopen)
+if test x"$ac_cv_func_dlopen" = x"no"; then
+    AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl";
+       AC_DEFINE(HAVE_DLOPEN)])
+fi
+# dlopen/dlclose/dlsym/dlerror will be checked again later and defines will be set then
 
 ############################################
 # check if the compiler can do immediate structures
@@ -320,9 +526,15 @@ 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);   
+   #define X_FOOBAR(x) ((FOOBAR) { x })
+   #define FOO_ONE X_FOOBAR(1)
+   FOOBAR f = FOO_ONE;   
+   static struct {
+       FOOBAR y; 
+       } f2[] = {
+               {FOO_ONE}
+       };   
 ],
        samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
 if test x"$samba_cv_immediate_structures" = x"yes"; then
@@ -477,6 +689,15 @@ AC_ARG_WITH(readline,
 AC_SUBST(TERMLIBS)
 AC_SUBST(TERMLDFLAGS)
 
+# The readline API changed slightly from readline3 to readline4, so
+# code will generate warnings on one of them unless we have a few
+# special cases.
+AC_CHECK_LIB(readline, rl_completion_matches,
+            [AC_DEFINE(HAVE_NEW_LIBREADLINE, 1, 
+                       [Do we have rl_completion_matches?])],
+            [],
+            [$TERMLIBS])
+
 # The following test taken from the cvs sources
 # If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
 # The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
@@ -527,15 +748,16 @@ else
     RUNPROG=""
 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(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
+AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync bzero memset strlcpy strlcat setpgid)
 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
-AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction innetgr setnetgrent getnetgrent endnetgrent)
-AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf)
+AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
+AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
+AC_CHECK_FUNCS(syslog vsyslog)
 # setbuffer is needed for smbtorture
 AC_CHECK_FUNCS(setbuffer)
 
@@ -603,16 +825,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,
@@ -650,25 +865,31 @@ PICFLAG=""
 PICSUFFIX="po"
 POBAD_CC="#"
 SHLIBEXT="so"
+# Assume non-shared by default and override below
 BLDSHARED="false"
+AC_MSG_CHECKING([ability to build shared libraries])
 
 # and these are for particular systems
 case "$host_os" in
                *linux*)   AC_DEFINE(LINUX)
                        BLDSHARED="true"
                        LDSHFLAGS="-shared" 
+                       DYNEXP="-Wl,--export-dynamic"
                        PICFLAG="-fPIC"
+                       AC_DEFINE(STAT_ST_BLOCKSIZE,512)
                ;;
-               *solaris*) AC_DEFINE(SUNOS5)
+               *solaris*) 
+                       AC_DEFINE(SUNOS5)
                        BLDSHARED="true"
-                       LDSHFLAGS="-Wl,-h,\$@.so -G"
-                       if test "${ac_cv_prog_CC}" = "gcc"; then
+                       LDSHFLAGS="-h \$@ -G"
+                       if test "${GCC}" = "yes"; then
                                PICFLAG="-fPIC"
                        else
                                PICFLAG="-KPIC"
                                POBAD_CC=""
                                PICSUFFIX="po.o"
                        fi
+                       AC_DEFINE(STAT_ST_BLOCKSIZE,512)
                ;;
                *sunos*) AC_DEFINE(SUNOS4)
                        BLDSHARED="true"
@@ -677,7 +898,9 @@ case "$host_os" in
                ;;
                *bsd*)  BLDSHARED="true"
                        LDSHFLAGS="-Wl,-soname,\$@ -shared"
+                       DYNEXP="-Wl,-Bdynamic"
                        PICFLAG="-fPIC"
+                       AC_DEFINE(STAT_ST_BLOCKSIZE,512)
                ;;
                *irix*) AC_DEFINE(IRIX)
                        case "$host_os" in
@@ -686,26 +909,32 @@ case "$host_os" in
                        esac
                        ATTEMPT_WRAP32_BUILD=yes
                        BLDSHARED="true"
-                       LDSHFLAGS="-Wl,-soname,\$@ -shared"
-                       if test "${ac_cv_prog_CC}" = "gcc"; then
+                       LDSHFLAGS="-soname \$@ -shared"
+                       SHLD="\${LD}"
+                       if test "${GCC}" = "yes"; then
                                PICFLAG="-fPIC"
                        else 
                                PICFLAG="-KPIC"
                        fi
+                       AC_DEFINE(STAT_ST_BLOCKSIZE,512)
                ;;
                *aix*) AC_DEFINE(AIX)
                        BLDSHARED="true"
                        LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry"
                        PICFLAG="-O2 -qmaxmem=6000"
+                       AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE)
                ;;
                *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
-                               #BLDSHARED="true"
-                               LDSHFLAGS="-b -z +h \$@"
+                               SHLD="/usr/bin/ld"
+                               BLDSHARED="true"
+                               LDSHFLAGS="-B symbolic -b -z +h \$@"
                                PICFLAG="+z"
                        fi
+                       DYNEXP="-Wl,-E"
+                       AC_DEFINE(STAT_ST_BLOCKSIZE,8192)
                ;;
                *qnx*) AC_DEFINE(QNX);;
                *osf*) AC_DEFINE(OSF1)
@@ -713,7 +942,9 @@ case "$host_os" in
                        LDSHFLAGS="-Wl,-soname,\$@ -shared"
                        PICFLAG="-fPIC"
                ;;
-               *sco*) AC_DEFINE(SCO);;
+               *sco*) 
+                       AC_DEFINE(SCO)
+               ;;
                *unixware*) AC_DEFINE(UNIXWARE)
                        BLDSHARED="true"
                        LDSHFLAGS="-Wl,-soname,\$@ -shared"
@@ -723,21 +954,57 @@ case "$host_os" in
                *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man]);;
                *sysv4*)
                        case "$host" in
-                               *-univel-*)     if [ test "$GCC" != yes ]; then
-                                                                       AC_DEFINE(HAVE_MEMSET)
-                                                               fi
-                                                               LDSHFLAGS="-G"
+                               *-univel-*)
+                                       if [ test "$GCC" != yes ]; then
+                                               AC_DEFINE(HAVE_MEMSET)
+                                       fi
+                                       LDSHFLAGS="-G"
+                                       DYNEXP="-Bexport"
                                ;;
-                               *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX);;
+                               *mips-sni-sysv4*)
+                                       AC_DEFINE(RELIANTUNIX)
+                               ;;
                        esac
-                       ;;
+               ;;
+
                *sysv5*)
                        if [ test "$GCC" != yes ]; then
                                AC_DEFINE(HAVE_MEMSET)
                        fi
                        LDSHFLAGS="-G"
-                       ;;
+               ;;
 esac
+AC_SUBST(DYNEXP)
+AC_MSG_RESULT($BLDSHARED)
+AC_MSG_CHECKING([linker flags for shared libraries])
+AC_MSG_RESULT([$LDSHFLAGS])
+AC_MSG_CHECKING([compiler flags for position-independent code])
+AC_MSG_RESULT([$PICFLAGS])
+
+#######################################################
+# test whether building a shared library actually works
+if test $BLDSHARED = true; then
+AC_CACHE_CHECK([whether building shared libraries actually works], 
+               [ac_cv_shlib_works],[
+   ac_cv_shlib_works=no
+   # try building a trivial shared library
+   $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.po ${srcdir-.}/tests/shlib.c &&
+     $CC $CPPFLAGS $CFLAGS $LDSHFLAGS -o shlib.so shlib.po &&
+     ac_cv_shlib_works=yes
+   rm -f shlib.so shlib.po
+])
+if test $ac_cv_shlib_works = no; then
+   BLDSHARED=false
+fi
+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
 
 ################
 
@@ -805,6 +1072,19 @@ if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
     AC_DEFINE(HAVE_INO64_T)
 fi
 
+AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
+AC_TRY_RUN([
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+#include <stdio.h>
+#include <sys/stat.h>
+main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
+samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
+if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
+    AC_DEFINE(HAVE_DEV64_T)
+fi
+
 AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
 AC_TRY_COMPILE([
 #if defined(HAVE_UNISTD_H)
@@ -818,6 +1098,30 @@ if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes"; then
     AC_DEFINE(HAVE_STRUCT_DIRENT64)
 fi
 
+AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
+AC_TRY_RUN([
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+#include <sys/types.h>
+main() { dev_t dev; int i = major(dev); return 0; }],
+samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
+if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
+    AC_DEFINE(HAVE_DEVICE_MAJOR_FN)
+fi
+
+AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
+AC_TRY_RUN([
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+#include <sys/types.h>
+main() { dev_t dev; int i = minor(dev); return 0; }],
+samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
+if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
+    AC_DEFINE(HAVE_DEVICE_MINOR_FN)
+fi
+
 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
 AC_TRY_RUN([#include <stdio.h>
 main() { char c; c=250; exit((c > 0)?0:1); }],
@@ -869,6 +1173,14 @@ if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ)
 fi
 
+AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE_VA_COPY,[
+AC_TRY_LINK([#include <stdarg.h>
+va_list ap1,ap2;], [__va_copy(ap1,ap2);],
+samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)])
+if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
+    AC_DEFINE(HAVE_VA_COPY)
+fi
+
 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
 AC_TRY_RUN([
 #include <sys/types.h>
@@ -878,6 +1190,11 @@ void foo(const char *format, ...) {
        int len;
        char buf[5];
 
+       va_start(ap, format);
+       len = vsnprintf(buf, 0, format, ap);
+       va_end(ap);
+       if (len != 5) exit(1);
+
        va_start(ap, format);
        len = vsnprintf(0, 0, format, ap);
        va_end(ap);
@@ -1256,7 +1573,7 @@ fi
 
 AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
 SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/smbwrapper"
+CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/popt -I${srcdir-.}/ubiqx -I${srcdir-.}/smbwrapper"
 AC_TRY_COMPILE([
 #define REPLACE_GETPASS 1
 #define NO_CONFIG_H 1
@@ -1487,12 +1804,40 @@ exit(1);
   fi
 fi
 
+AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>],
+[struct stat st;  st.st_blocks = 0;],
+samba_cv_HAVE_STAT_ST_BLOCKS=yes,samba_cv_HAVE_STAT_ST_BLOCKS=no,samba_cv_HAVE_STAT_ST_BLOCKS=cross)])
+if test x"$samba_cv_HAVE_STAT_ST_BLOCKS" = x"yes"; then
+    AC_DEFINE(HAVE_STAT_ST_BLOCKS)
+fi 
+
+case "$host_os" in
+*linux*)
+AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
+AC_TRY_COMPILE([
+#ifdef HAVE_SYS_VFS_H
+#include <sys/vfs.h>
+#endif
+#ifdef HAVE_SYS_CAPABILITY_H
+#include <sys/capability.h>
+#endif
+],[int i;],
+   samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
+if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
+   AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS)
+fi
+;;
+esac
+
 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)
 #include <rpcsvc/nis.h>
 #endif],
-[return 0;],
+[int i;],
 samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=no,samba_cv_BROKEN_NISPLUS_INCLUDE_FILES=yes)])
 if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
     AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES)
@@ -1536,10 +1881,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 (default=no) ],
+[  --with-afs              Include AFS clear-text auth support (default=no) ],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
@@ -1554,10 +1899,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-dce-dfs          Include DCE/DFS support (default=no)],
+[  --with-dce-dfs          Include DCE/DFS clear-text auth support (default=no)],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
@@ -1570,49 +1915,76 @@ 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 (default=no)],
-[ case "$withval" in
-  yes)
+# see if this box has the RedHat location for kerberos
+AC_MSG_CHECKING(for /usr/kerberos)
+if test -d /usr/kerberos; then
+    LDFLAGS="$LDFLAGS -L/usr/kerberos/lib"
+    CFLAGS="$CFLAGS -I/usr/kerberos/include"
+    CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
     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_DEFINE_UNQUOTED(KRB4_DIR, ${withval})
-    ;;
-  *)
+else
     AC_MSG_RESULT(no)
-    ;;
-  esac ],
-  AC_MSG_RESULT(no)
-)
+fi
 
 #################################################
-# 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 (default=no)],
+[  --with-krb5=base-dir    Locate Kerberos 5 support (default=/usr)],
 [ case "$withval" in
-  yes)
+  no)
+    AC_MSG_RESULT(no)
+    ;;
+  *)
     AC_MSG_RESULT(yes)
-    AC_DEFINE(KRB5_AUTH)
-    LIBS="$LIBS -ldes425 -lkrb5 -lcrypto -lcom_err"
+    LIBS="$LIBS -lkrb5"
     CFLAGS="$CFLAGS -I$withval/include"
+    CPPFLAGS="$CPPFLAGS -I$withval/include"
     LDFLAGS="$LDFLAGS -L$withval/lib"
-    AC_DEFINE_UNQUOTED(KRB5_DIR,${withval})
-    ;;
-  *)
-    AC_MSG_RESULT(no)
     ;;
   esac ],
   AC_MSG_RESULT(no)
 )
 
+# now check for krb5.h. Some systems have the libraries without the headers!
+# note that this check is done here to allow for different kerberos
+# include paths
+AC_CHECK_HEADERS(krb5.h)
+
+# now check for gssapi headers.  This is also done here to allow for
+# different kerberos include paths
+AC_CHECK_HEADERS(gssapi/gssapi_generic.h gssapi/gssapi.h)
+
+##################################################################
+# 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"])
+
+########################################################
+# now see if we can find the krb5 libs in standard paths
+# or as specified above
+AC_CHECK_LIB(krb5, krb5_mk_req_extended, [LIBS="$LIBS -lkrb5";
+       AC_DEFINE(HAVE_KRB5)])
+
+########################################################
+# now see if we can find the gssapi libs in standard paths
+AC_CHECK_LIB(gssapi_krb5, gss_display_status, [LIBS="$LIBS -lgssapi_krb5";
+       AC_DEFINE(HAVE_GSSAPI)])
+
+##################################################################
+# we might need the lber lib on some systems. To avoid link errors
+# this test must be before the libldap test
+AC_CHECK_LIB(lber, ber_scanf, [LIBS="$LIBS -llber"])
+
+########################################################
+# now see if we can find the ldap libs in standard paths
+if test x$have_ldap != xyes; then
+AC_CHECK_LIB(ldap, ldap_domain2hostlist, [LIBS="$LIBS -lldap";
+       AC_DEFINE(HAVE_LDAP)])
+fi
+
 #################################################
 # check for automount support
 AC_MSG_CHECKING(whether to use AUTOMOUNT)
@@ -1659,11 +2031,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 (default=no)],
+[  --with-pam              Include PAM support (default=no)],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
@@ -1737,15 +2109,22 @@ fi
 fi
 
 
+
+########################################################################################
+##
+## TESTS FOR SAM BACKENDS.  KEEP THESE GROUPED TOGETHER
+##
+########################################################################################
+
 #################################################
 # 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 (default=no)],
+[  --with-tdbsam           Include experimental TDB SAM support (default=no)],
 [ case "$withval" in
   yes)
     AC_MSG_RESULT(yes)
-    AC_DEFINE(WITH_TDBSAM)
+    AC_DEFINE(WITH_TDB_SAM)
     ;;
   *)
     AC_MSG_RESULT(no)
@@ -1755,15 +2134,14 @@ AC_ARG_WITH(tdbsam,
 )
 
 #################################################
-# check for a LDAP password database
-AC_MSG_CHECKING(whether to use LDAP password database)
-AC_ARG_WITH(ldap,
-[  --with-ldapsam          Include Experimental LDAP-Sam support (default=no)],
+# check for a NISPLUS password database
+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_LDAP)
-    AC_MSG_ERROR([LDAP password database not supported in this version.])
+    AC_DEFINE(WITH_NISPLUS_SAM)
     ;;
   *)
     AC_MSG_RESULT(no)
@@ -1772,23 +2150,11 @@ AC_ARG_WITH(ldap,
   AC_MSG_RESULT(no)
 )
 
-#################################################
-# commented out by --jerry
-# 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
-#[ case "$withval" in
-#  yes)
-#    AC_MSG_RESULT(yes)
-#    AC_DEFINE(WITH_NISPLUS)
-#    ;;
-#  *)
-#    AC_MSG_RESULT(no)
-#    ;;
-#  esac ],
-#  AC_MSG_RESULT(no)
-#)
+########################################################################################
+##
+## END OF TESTS FOR SAM BACKENDS.  
+##
+########################################################################################
 
 #################################################
 # check for a NISPLUS_HOME support 
@@ -1807,61 +2173,6 @@ AC_ARG_WITH(nisplus-home,
   AC_MSG_RESULT(no)
 )
 
-#################################################
-# check for the secure socket layer
-AC_MSG_CHECKING(whether to use SSL)
-AC_ARG_WITH(ssl,
-[  --with-ssl              Include SSL support (default=no)
-  --with-sslinc=DIR       Where the SSL includes are (defaults to /usr/local/ssl)],
-[ case "$withval" in
-  yes)
-    AC_MSG_RESULT(yes)
-    AC_DEFINE(WITH_SSL)
-    withval="/usr/local/ssl"     # default
-
-    if test "${with_sslinc+set}" = set; then
-
-       withval="$with_sslinc"
-       case "$withval" in
-       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"
-         AC_DEFINE(SSL_DIR, "/usr/local/ssl")
-       ;;
-        * )
-          CFLAGS="-I${withval} $CFLAGS"
-         LIBS="-lssl -lcrypto $LIBS"
-         LDFLAGS="-L${withval}/lib $LDFLAGS"
-         AC_DEFINE_UNQUOTED(SSL_DIR, "${withval}", Used for determining the compile time options)
-       ;;
-       esac
-
-    else
-
-       CFLAGS="-I/usr/local/ssl/include $CFLAGS"   
-       LIBS="-lssl -lcrypto $LIBS"
-       LDFLAGS="-L/usr/local/ssl/lib $LDFLAGS"
-       AC_DEFINE(SSL_DIR, "/usr/local/ssl")
-
-    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 
-
-    CFLAGS="-DHAVE_CRYPT_DECL $CFLAGS"  # Damn, SSLeay defines its own
-
-    ;;
-  *)
-    AC_MSG_RESULT(no)
-    ;;
-  esac ],
-  AC_MSG_RESULT(no)
-)
-
 #################################################
 # check for syslog logging
 AC_MSG_CHECKING(whether to use syslog logging)
@@ -1907,6 +2218,26 @@ AC_ARG_WITH(quotas,
 [ 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)
     ;;
@@ -1999,6 +2330,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)
@@ -2239,32 +2594,36 @@ AC_ARG_WITH(acl-support,
 [ case "$withval" in
   yes)
 
-        case "$host_os" in
-        *sysv5*)
-            AC_MSG_RESULT(Using UnixWare ACLs)
-            AC_DEFINE(HAVE_UNIXWARE_ACLS)
-            ;;
-        *solaris*)
-            AC_MSG_RESULT(Using solaris ACLs)
-            AC_DEFINE(HAVE_SOLARIS_ACLS)
-            ;;
-               *irix*)
-                       AC_MSG_RESULT(Using IRIX ACLs)
-                       AC_DEFINE(HAVE_IRIX_ACLS)
-                       ;;
-               *aix*)
-                       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"
-                       ;;
+       case "$host_os" in
+       *sysv5*)
+               AC_MSG_RESULT(Using UnixWare ACLs)
+               AC_DEFINE(HAVE_UNIXWARE_ACLS)
+               ;;
+       *solaris*)
+               AC_MSG_RESULT(Using solaris ACLs)
+               AC_DEFINE(HAVE_SOLARIS_ACLS)
+               ;;
+       *hpux*)
+               AC_MSG_RESULT(Using HPUX ACLs)
+               AC_DEFINE(HAVE_HPUX_ACLS)
+               ;;
+       *irix*)
+               AC_MSG_RESULT(Using IRIX ACLs)
+               AC_DEFINE(HAVE_IRIX_ACLS)
+               ;;
+       *aix*)
+               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,[
-                       AC_TRY_LINK([#include <sys/types.h>
+               AC_CHECK_LIB(acl,acl_get_file)
+               AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
+               AC_TRY_LINK([#include <sys/types.h>
 #include <sys/acl.h>],
 [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
 samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)])
@@ -2301,14 +2660,23 @@ AC_MSG_CHECKING(whether to build winbind)
 
 # Initially, the value of $host_os decides whether winbind is supported
 
-case "$host_os" in 
-        *linux*|*solaris*)
+case "$host_os" in
+       *linux*|*irix*)
                HAVE_WINBIND=yes
-                ;;
-        *)
+               ;;
+       *solaris*)
+               HAVE_WINBIND=yes
+               WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
+               WINBIND_NSS_EXTRA_LIBS="-lsocket"
+               ;;
+       *hpux11*)
+               HAVE_WINBIND=yes
+               WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_solaris.o"
+               ;;
+       *)
                HAVE_WINBIND=no
-                winbind_no_reason=", unsupported on $host_os"
-                ;;
+               winbind_no_reason=", unsupported on $host_os"
+               ;;
 esac
 
 # Check the setting of --with-winbindd
@@ -2338,25 +2706,24 @@ fi
 
 # Display test results
 
-if test x"$HAVE_WINBIND" = x"yes"; then
+WINBIND_TARGETS=""
+WINBIND_STARGETS=""
+WINBIND_LTARGETS=""
+WINBIND_PAM_PROGS=""
 
+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
+       WINBIND_TARGETS="bin/wbinfo"
+       WINBIND_STARGETS="bin/winbindd"
+        if test x"$BLDSHARED" = x"true"; then
+               WINBIND_LTARGETS="nsswitch/libnss_winbind.so"
+               if test x"$with_pam" = x"yes"; then
+                       WINBIND_PAM_TARGETS="nsswitch/pam_winbind.so"
+               fi
+       fi
 else
         AC_MSG_RESULT(no$winbind_no_reason)
-
-       WINBIND_TARGETS=""
-       WINBIND_STARGETS=""
-       WINBIND_LTARGETS=""
-       WINBIND_PAM_PROGS=""
 fi
 
 # Substitution time!
@@ -2364,17 +2731,94 @@ fi
 AC_SUBST(WINBIND_TARGETS)
 AC_SUBST(WINBIND_STARGETS)
 AC_SUBST(WINBIND_LTARGETS)
-AC_SUBST(WINBIND_PAM_PROGS)
+AC_SUBST(WINBIND_PAM_TARGETS)
+AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
+AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
+
+# Solaris has some extra fields in struct passwd that need to be
+# initialised otherwise nscd crashes.  Unfortunately autoconf < 2.50
+# doesn't have the AC_CHECK_MEMBER macro which would be handy for checking
+# this. 
+
+#AC_CHECK_MEMBER(struct passwd.pw_comment,
+#              AC_DEFINE(HAVE_PASSWD_PW_COMMENT, 1, [Defined if struct passwd has pw_comment field]),
+#              [#include <pwd.h>])
+
+AC_CACHE_CHECK([whether struct passwd has pw_comment],samba_cv_passwd_pw_comment, [
+    AC_TRY_COMPILE([#include <pwd.h>],[struct passwd p; p.pw_comment;],
+       samba_cv_passwd_pw_comment=yes,samba_cv_passwd_pw_comment=no)])
+if test x"$samba_cv_passwd_pw_comment" = x"yes"; then
+   AC_DEFINE(HAVE_PASSWD_PW_COMMENT)
+fi
+
+#AC_CHECK_MEMBER(struct passwd.pw_age,
+#              AC_DEFINE(HAVE_PASSWD_PW_AGE, 1, [Defined if struct passwd has pw_age field]),
+#              [#include <pwd.h>])
+
+AC_CACHE_CHECK([whether struct passwd has pw_age],samba_cv_passwd_pw_age, [
+    AC_TRY_COMPILE([#include <pwd.h>],[struct passwd p; p.pw_age;],
+       samba_cv_passwd_pw_age=yes,samba_cv_passwd_pw_age=no)])
+if test x"$samba_cv_passwd_pw_age" = x"yes"; then
+   AC_DEFINE(HAVE_PASSWD_PW_AGE)
+fi
+
+#################################################
+# 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)'
+    FLAGS1="-I$srcdir/popt"
+else
+    AC_MSG_RESULT(no)
+    LIBS="$LIBS -lpopt"
+fi
+AC_SUBST(BUILD_POPT)
+AC_SUBST(FLAGS1)
+
+#################################################
+# do extra things if we are running insure
+
+if test "${ac_cv_prog_CC}" = "insure"; then
+       CPPFLAGS="$CPPFLAGS -D__INSURE__"
+fi
 
 #################################################
 # final configure stuff
 
-echo "checking configure summary"
+AC_MSG_CHECKING([configure summary])
 AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
-           echo "configure OK";,
-          AC_MSG_ERROR([summary failure. Aborting config]),:)
+           AC_MSG_RESULT(yes),
+          AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
+          AC_MSG_WARN([cannot run when cross-compiling]))
 
 builddir=`pwd`
 AC_SUBST(builddir)
 
-AC_OUTPUT(include/stamp-h Makefile)
+AC_OUTPUT(include/stamp-h Makefile script/findsmb)
+
+#################################################
+# Print very concise instructions on building/use
+if test "x$enable_dmalloc" = xyes
+then
+       AC_MSG_RESULT([Note: The dmalloc debug library will be included.  To turn it on use])
+       AC_MSG_RESULT([      \$ eval \`dmalloc samba\`.])
+fi