r3417: BUG 350: patch from Matt Selsky <selsky@columbia.edu> to use autoconf feature...
[ira/wip.git] / source3 / configure.in
index 8e0434971caca14046bb3a688821bb21d6d39164..c7335c5df0ca6f625b5c6230cce1f2a68639ce72 100644 (file)
@@ -8,28 +8,43 @@ AC_CONFIG_HEADER(include/config.h)
 AC_DISABLE_STATIC
 AC_ENABLE_SHARED
 
+SMB_VERSION_STRING=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_OFFICIAL_STRING' | cut -d '"' -f2`
+echo "SAMBA VERSION: ${SMB_VERSION_STRING}"
+
+SAMBA_VERSION_SVN_REVISION=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_SVN_REVISION' | cut -d ' ' -f3-`
+if test -n "${SAMBA_VERSION_SVN_REVISION}";then
+       echo "BUILD REVISION: ${SAMBA_VERSION_SVN_REVISION}"
+fi
+
 #################################################
 # Directory handling stuff to support both the
 # legacy SAMBA directories and FHS compliant
 # ones...
 AC_PREFIX_DEFAULT(/usr/local/samba)
 
+lockdir="\${VARDIR}/locks"
+piddir="\${VARDIR}/locks"
+mandir="\${prefix}/man"
+logfilebase="\${VARDIR}"
+privatedir="\${prefix}/private"
+libdir="\${prefix}/lib"
+configdir="\${LIBDIR}"
+swatdir="\${prefix}/swat"
+
 AC_ARG_WITH(fhs, 
 [  --with-fhs              Use FHS-compliant paths (default=no)],
-    configdir="${sysconfdir}/samba"
+[ case "$withval" in
+  yes)
     lockdir="\${VARDIR}/lib/samba"
     piddir="\${VARDIR}/run"
     mandir="\${prefix}/share/man"
     logfilebase="\${VARDIR}/log/samba"
     privatedir="\${CONFIGDIR}/private"
     libdir="\${prefix}/lib/samba"
-    swatdir="\${DATADIR}/samba/swat",
-    configdir="\${LIBDIR}"
-    logfilebase="\${VARDIR}"
-    lockdir="\${VARDIR}/locks"
-    piddir="\${VARDIR}/locks"
-    privatedir="\${prefix}/private"
-    swatdir="\${prefix}/swat")
+    configdir="${sysconfdir}/samba"
+    swatdir="\${DATADIR}/samba/swat"
+    ;;
+  esac])
 
 #################################################
 # set private directory location
@@ -98,7 +113,7 @@ AC_ARG_WITH(swatdir,
 #################################################
 # set configuration directory location
 AC_ARG_WITH(configdir,
-[  --with-configdir=DIR    Where to put configuration files (\$libdir)],
+[  --with-configdir=DIR    Where to put configuration files ($libdir)],
 [ case "$withval" in
   yes|no)
   #
@@ -114,7 +129,7 @@ AC_ARG_WITH(configdir,
 #################################################
 # set log directory location
 AC_ARG_WITH(logfilebase,
-[  --with-logfilebase=DIR  Where to put log files (\$(VARDIR))],
+[  --with-logfilebase=DIR  Where to put log files ($VARDIR)],
 [ case "$withval" in
   yes|no)
   #
@@ -127,6 +142,38 @@ AC_ARG_WITH(logfilebase,
     ;;
   esac])
 
+#################################################
+# set lib directory location
+AC_ARG_WITH(libdir,
+[  --with-libdir=DIR       Where to put libdir ($libdir)],
+[ case "$withval" in
+  yes|no)
+  #
+  # Just in case anybody does it
+  #
+    AC_MSG_WARN([--with-libdir without argument - will use default])
+  ;;
+  * )
+    libdir="$withval"
+    ;;
+  esac])
+
+#################################################
+# set lib directory location
+AC_ARG_WITH(mandir,
+[  --with-mandir=DIR       Where to put man pages ($mandir)],
+[ case "$withval" in
+  yes|no)
+  #
+  # Just in case anybody does it
+  #
+    AC_MSG_WARN([--with-mandir without argument - will use default])
+  ;;
+  * )
+    mandir="$withval"
+    ;;
+  esac])
+
 AC_ARG_WITH(cfenc,
 [  --with-cfenc=HEADERDIR  Use internal CoreFoundation encoding API
                          for optimization (Mac OS X/Darwin only)],
@@ -241,6 +288,21 @@ dnl Check if we use GNU ld
 LD=ld
 AC_PROG_LD_GNU
 
+dnl Certain versions of GNU ld the default is not to have the 
+dnl --allow-shlib-undefined flag defined.  This causes a stackload of
+dnl warnings when building modules.
+if test "$ac_cv_prog_gnu_ld" = "yes"; then
+       ac_cv_gnu_ld_version=`$LD -v 2>/dev/null | head -1`
+       AC_MSG_CHECKING(GNU ld release date)
+       changequote(,)dnl
+       ac_cv_gnu_ld_date=`echo $ac_cv_gnu_ld_version | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'`
+       changequote([,])dnl
+       AC_MSG_RESULT(${ac_cv_gnu_ld_date})
+       if test "$ac_cv_gnu_ld_date" -lt 20030217; then
+               ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
+       fi
+fi
+
 dnl needed before AC_TRY_COMPILE
 AC_ISC_POSIX
 
@@ -321,7 +383,7 @@ dnl These have to be built static:
 default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_reg rpc_lsa_ds rpc_wks rpc_net rpc_dfs rpc_srv rpc_spoolss auth_rhosts auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin"
 
 dnl These are preferably build shared, and static if dlopen() is not available
-default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap 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"
 
 if test "x$developer" = xyes; then
    default_static_modules="$default_static_modules rpc_echo"
@@ -330,7 +392,8 @@ fi
 
 #
 # Config CPPFLAG settings for strange OS's that must be set
-# before other tests.
+# before other tests. Do NOT invoke AC_CHECK_HEADERS within this
+# case statement; its first reference must be unconditional.
 #
 case "$host_os" in
 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
@@ -366,7 +429,6 @@ case "$host_os" in
                                AC_DEFINE(_MAX_ALIGNMENT, 4, [Maximum alignment])
                                ;;
       esac
-      DYNEXP="-Wl,-E"
       ;;
 
 #
@@ -398,7 +460,7 @@ case "$host_os" in
        *solaris*)
                AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
                case `uname -r` in
-                       5.0*|5.1*|5.2*|5.3*|5.5*)
+                       5.0|5.0.*|5.1|5.1.*|5.2|5.2.*|5.3|5.3.*|5.5|5.5.*)
                                AC_MSG_RESULT([no large file support])
                                ;;
                        5.*)
@@ -409,17 +471,20 @@ case "$host_os" in
                                rm -fr conftest.c
                                case "$ac_cv_gcc_compiler_version_number" in
                                        *"gcc version 2.6"*|*"gcc version 2.7"*)
-                                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
+                                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE -D_REENTRANT"
+                                               LDFLAGS="$LDFLAGS -lthread"
                                                AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
                                                ;;
                                        *)
-                                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+                                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
+                                               LDFLAGS="$LDFLAGS -lthread"
                                                AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
                                                AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
                                                ;;
                                esac
                        else
-                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_REENTRANT -D_FILE_OFFSET_BITS=64"
+                               LDFLAGS="$LDFLAGS -lthread"
                                AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
                                AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
                        fi
@@ -432,7 +497,7 @@ case "$host_os" in
        *irix*)
                AC_DEFINE(SYSV, 1, [Whether to enable System V compatibility])
                ;;
-       *freebsd*)
+       *freebsd*|*DragonFly*)
                AC_DEFINE(FREEBSD, 1, [Whether the host os is FreeBSD])
                ;;
 #
@@ -443,8 +508,8 @@ case "$host_os" in
          *-D_POSIX_C_SOURCE*)
                ;;
          *)
-               CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=199506L"
-               AC_DEFINE(_POSIX_C_SOURCE, 199506L, [Whether to enable POSIX support])
+               CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
+               AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
                ;;
     esac
     case "$CPPFLAGS" in
@@ -542,27 +607,23 @@ main() {
 # is so horribly broken....
 #
     *darwin*)
-               AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
+       AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
 # Add Fink directories for various packages, like dlcompat.
 # Note: iconv does that explicitly below, but other packages
 # don't.
-               CPPFLAGS="$CPPFLAGS -I/sw/include"
-               LDFLAGS="$LDFLAGS -L/sw/lib"
+       CPPFLAGS="$CPPFLAGS -I/sw/include"
+       LDFLAGS="$LDFLAGS -L/sw/lib"
 
 # If we have dlsym_prepend_underscore (from Fink's dlcompat),
 # use that instead of plain dlsym.
 
-               AC_CHECK_LIB(dl,dlopen)
-               AC_CHECK_FUNCS(dlsym_prepend_underscore,[CPPFLAGS="$CPPFLAGS -Ddlsym=dlsym_prepend_underscore"])
+       AC_CHECK_LIB(dl,dlopen)
+       AC_CHECK_FUNCS(dlsym_prepend_underscore,[CPPFLAGS="$CPPFLAGS -Ddlsym=dlsym_prepend_underscore"])
 
-#Add a system specific charset module.
+# Add a system specific charset module.
 
-               default_shared_modules="$default_shared_modules charset_macosxfs"
-               old_CPPFLAGS="$CPPFLAGS"
-               CPPFLAGS="-Iinclude $CPPFLAGS" 
-               AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEADERS([CFStringEncodingConverter.h])])
-               CPPFLAGS="$old_CPPFLAGS"
-               ;;
+       default_shared_modules="$default_shared_modules charset_macosxfs"
+       ;;
     *hurd*)
         AC_MSG_CHECKING([for LFS support])
         old_CPPFLAGS="$CPPFLAGS"
@@ -593,16 +654,22 @@ AC_HEADER_DIRENT
 AC_HEADER_TIME
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(arpa/inet.h sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h)
-AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h net/if.h)
+AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h)
 AC_CHECK_HEADERS(rpc/rpc.h rpcsvc/nis.h rpcsvc/yp_prot.h rpcsvc/ypclnt.h)
 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/mode.h)
 AC_CHECK_HEADERS(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 dlfcn.h)
+AC_CHECK_HEADERS(sys/sysmacros.h security/_pam_macros.h dlfcn.h)
 AC_CHECK_HEADERS(sys/syslog.h syslog.h execinfo.h)
 AC_CHECK_HEADERS(langinfo.h locale.h)
 
+# Look for Darwin headers
+old_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="-Iinclude $CPPFLAGS"
+AC_CHECK_HEADERS([CoreFoundation/CFStringEncodingConverter.h], [], [AC_CHECK_HEADERS([CFStringEncodingConverter.h])])
+CPPFLAGS="$old_CPPFLAGS"
+
 # In valgrind 1.0.x, it's just valgrind.h.  In 1.9.x+ there's a
 # subdirectory of headers.
 AC_CHECK_HEADERS(valgrind.h valgrind/valgrind.h valgrind/memcheck.h)
@@ -620,11 +687,13 @@ case "$host_os" in
                fi
        ;;
 esac
-AC_CHECK_HEADERS(shadow.h netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
-AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h security/pam_appl.h security/pam_modules.h)
+AC_CHECK_HEADERS(shadow.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
+AC_CHECK_HEADERS(nss.h nss_common.h nsswitch.h ns_api.h sys/security.h security/pam_appl.h)
 AC_CHECK_HEADERS(stropts.h poll.h)
 AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
-AC_CHECK_HEADERS(sys/acl.h sys/attributes.h attr/xattr.h sys/cdefs.h glob.h)
+AC_CHECK_HEADERS(sys/acl.h sys/attributes.h attr/xattr.h sys/xattr.h sys/cdefs.h glob.h)
+# These faile to compile on Solaris so just check for their presence
+AC_CHECK_HEADERS(security/pam_modules.h net/if.h netinet/ip.h, [], [], -)
 
 # For experimental utmp support (lastlog on some BSD-like systems)
 AC_CHECK_HEADERS(utmp.h utmpx.h lastlog.h)
@@ -662,10 +731,12 @@ if test x$enable_cups != xno; then
        AC_PATH_PROG(CUPS_CONFIG, cups-config)
 
         if test "x$CUPS_CONFIG" != x; then
-                        AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
+                AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
                CFLAGS="$CFLAGS `$CUPS_CONFIG --cflags`"
                LDFLAGS="$LDFLAGS `$CUPS_CONFIG --ldflags`"
                PRINT_LIBS="$PRINT_LIBS `$CUPS_CONFIG --libs`"
+       elif test x"$enable_cups" = x"yes"; then
+               AC_MSG_ERROR(Cups support required but cups-config not located.  Make sure cups-devel related files are installed.)
         fi
 fi
 
@@ -907,7 +978,7 @@ if test x"$ac_cv_func_execl" = x"no"; then
 fi
 
 AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
-AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync bzero memset strlcpy strlcat setpgid)
+AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync memset strlcpy strlcat setpgid)
 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
@@ -919,6 +990,8 @@ AC_CHECK_FUNCS(syslog vsyslog timegm)
 AC_CHECK_FUNCS(setlocale nl_langinfo)
 # setbuffer, shmget, shm_open are needed for smbtorture
 AC_CHECK_FUNCS(setbuffer shmget shm_open backtrace_symbols)
+AC_CHECK_HEADERS(libexc.h)
+AC_CHECK_LIB(exc, trace_back_stack)
 
 # syscall() is needed for smbwrapper.
 AC_CHECK_FUNCS(syscall)
@@ -1076,7 +1149,11 @@ if test "$enable_shared" = "yes"; then
   case "$host_os" in
                *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
                        BLDSHARED="true"
-                       LDSHFLAGS="-shared" 
+                       if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
+                               LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined" 
+                       else
+                               LDSHFLAGS="-shared -Wl,-Bsymbolic" 
+                       fi
                        DYNEXP="-Wl,--export-dynamic"
                        PICFLAGS="-fPIC"
                        SONAMEFLAG="-Wl,-soname="
@@ -1109,7 +1186,8 @@ if test "$enable_shared" = "yes"; then
                        AC_DEFINE(STAT_ST_BLOCKSIZE,512)
                        AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly])
                        ;;
-               *netbsd* | *freebsd*)  BLDSHARED="true"
+               *netbsd* | *freebsd* | *DragonFly* )  
+                       BLDSHARED="true"
                        LDSHFLAGS="-shared"
                        DYNEXP="-Wl,--export-dynamic"
                        SONAMEFLAG="-Wl,-soname,"
@@ -1152,15 +1230,17 @@ if test "$enable_shared" = "yes"; then
                        fi
 
                        AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
+                       AC_DEFINE(BROKEN_STRNLEN,1,[Does strnlen work correctly])
+                       AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
                        ;;
                *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
                        SHLIBEXT="sl"
                        # Use special PIC flags for the native HP-UX compiler.
                        if test $ac_cv_prog_cc_Ae = yes; then
                                BLDSHARED="true"
-                               SHLD="/usr/bin/ld"
-                               LDSHFLAGS="-B symbolic -b -z"
-                               SONAMEFLAG="+h "
+                               SHLD="cc"
+                               LDSHFLAGS="-b -Wl,-B,symbolic,-b,-z"
+                               SONAMEFLAG="-Wl,+h "
                                PICFLAGS="+z"
                        elif test "${GCC}" = "yes"; then
                                PICFLAGS="-fPIC"
@@ -1245,13 +1325,14 @@ fi
 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
+   ac_cv_shlib_works=no
+   # The $SHLD and $LDSHFLAGS variables may contain references to other
+   # variables so they need to be eval'ed.
    $CC $CPPFLAGS $CFLAGS $PICFLAGS -c -o \
        shlib.$PICSUFFIX ${srcdir-.}/tests/shlib.c && \
-       $CC $CPPFLAGS $CFLAGS `eval echo $LDSHFLAGS` -o "shlib.$SHLIBEXT" \
-       shlib.$PICSUFFIX && \
-       ac_cv_shlib_works=yes
+   `eval echo $SHLD` `eval echo $LDSHFLAGS` -o "shlib.$SHLIBEXT" \
+        shlib.$PICSUFFIX && ac_cv_shlib_works=yes
    rm -f "shlib.$SHLIBEXT" shlib.$PICSUFFIX
 ])
 if test $ac_cv_shlib_works = no; then
@@ -1375,6 +1456,18 @@ if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
     AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
 fi
 
+AC_CACHE_CHECK([for makedev macro],samba_cv_HAVE_MAKEDEV,[
+AC_TRY_RUN([
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+#include <sys/types.h>
+main() { dev_t dev = makedev(1,2); return 0; }],
+samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
+if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
+    AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
+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); }],
@@ -1612,7 +1705,7 @@ fi
 
 
 ICONV_LOCATION=standard
-LOOK_DIRS="/usr /usr/local /sw"
+LOOK_DIRS="/usr /usr/local /sw /opt"
 AC_ARG_WITH(libiconv,
 [  --with-libiconv=BASEDIR Use libiconv in BASEDIR/lib and BASEDIR/include (default=auto) ],
 [
@@ -1626,23 +1719,39 @@ AC_ARG_WITH(libiconv,
   fi
 ])
 
-ICONV_FOUND="no"
 for i in $LOOK_DIRS ; do
     save_LIBS=$LIBS
     save_LDFLAGS=$LDFLAGS
     save_CPPFLAGS=$CPPFLAGS
+    ICONV_FOUND="no"
+    unset libext
     CPPFLAGS="$CPPFLAGS -I$i/include"
 dnl This is here to handle -withval stuff for --with-libiconv
 dnl Perhaps we should always add a -L
-    LDFLAGS="$LDFLAGS -L$i/lib"
-    LIBS=
-    export LDFLAGS LIBS CPPFLAGS
+
+dnl Check lib and lib32 library variants to cater for IRIX ABI-specific
+dnl installation paths. This gets a little tricky since we might have iconv
+dnl in both libiconv and in libc. In this case the jm_ICONV test will always
+dnl succeed when the header is found. To counter this, make sure the 
+dnl library directory is there and check the ABI directory first (which
+dnl should be harmless on other systems.
+    for l in "lib32" "lib" ; do
+        if test -d "$i/$l" ; then
+                LDFLAGS="$save_LDFLAGS -L$i/$l"
+                LIBS=
+                export LDFLAGS LIBS CPPFLAGS
 dnl Try to find iconv(3)
-    jm_ICONV($i)
+                jm_ICONV($i/$l)
+                if test x"$ICONV_FOUND" = "xyes" ; then
+                    libext="$l"
+                    break;
+                fi
+        fi
+    done
 
-    if test "$ICONV_FOUND" = yes; then
+    if test x"$ICONV_FOUND" = "xyes" ; then
        LDFLAGS=$save_LDFLAGS
-        LIB_ADD_DIR(LDFLAGS, "$i/lib")
+        LIB_ADD_DIR(LDFLAGS, "$i/$libext")
         CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
         LIBS="$save_LIBS"
         ICONV_LOCATION=$i
@@ -1654,7 +1763,7 @@ dnl there might be a working iconv further down the list of LOOK_DIRS
         # check for iconv in libc
         ic_save_LIBS="$LIBS"
         if test x"$ICONV_PATH_SPEC" = "xyes" ; then
-           LIBS="$LIBS -L$ICONV_LOCATION/lib"
+           LIBS="$LIBS -L$ICONV_LOCATION/$libext"
         fi
         if test x"$jm_cv_lib_iconv" != x; then
            LIBS="$LIBS -l$jm_cv_lib_iconv"
@@ -1718,7 +1827,7 @@ dnl ])
            fi
           dnl Add the flags we need to CPPFLAGS and LDFLAGS
           CFLAGS_ADD_DIR(CPPFLAGS, "$i/include")
-          LIB_ADD_DIR(LDFLAGS, "$i/lib")
+          LIB_ADD_DIR(LDFLAGS, "$i/$libext")
           export CPPFLAGS
            AC_DEFINE(HAVE_NATIVE_ICONV,1,[Whether to use native iconv])
           AC_DEFINE_UNQUOTED(DEFAULT_DOS_CHARSET,$default_dos_charset,[Default dos charset name])
@@ -1734,6 +1843,7 @@ dnl We only need to clean these up here for the next pass through the loop
     LIBS=$save_LIBS
     export LDFLAGS LIBS CPPFLAGS
 done
+unset libext
 
 
 if test x"$ICONV_FOUND" = x"no" -o x"$samba_cv_HAVE_NATIVE_ICONV" != x"yes" ; then
@@ -2222,6 +2332,19 @@ if test x"$samba_cv_BROKEN_NISPLUS_INCLUDE_FILES" = x"yes"; then
        AC_DEFINE(BROKEN_NISPLUS_INCLUDE_FILES,1,[Whether the nisplus include files are broken])
 fi
 
+AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
+AC_TRY_RUN([
+#include <stdio.h>
+#include <limits.h>
+main() {
+       char *newpath = realpath("/tmp", NULL);
+       exit ((newpath != NULL) ? 0 : 1);
+}
+],
+samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
+if test x"$samba_cv_REALPATH_TAKES_NULL" = x"yes"; then
+    AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
+fi
 
 #################################################
 # check for smbwrapper support
@@ -2322,9 +2445,31 @@ if test x"$samba_cv_WITH_AFS" != x"no" ||
     fi
 fi
 
-if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" == x"yes"; then
+if test x"$samba_cv_WITH_FAKE_KASERVER" != x"no" && test x"$have_afs_headers" = x"yes"; then
     AC_DEFINE(WITH_FAKE_KASERVER,1,[Whether to include AFS fake-kaserver support])
 fi
+
+#################################################
+# check whether to compile AFS/NT ACL mapping module
+samba_cv_WITH_VFS_AFSACL=no
+AC_MSG_CHECKING(whether to use AFS fake-kaserver)
+AC_ARG_WITH(vfs-afsacl,
+[  --with-vfs-afsacl       Include AFS to NT ACL mapping module (default=no) ],
+[ case "$withval" in
+  yes|auto)
+    AC_MSG_RESULT($withval)
+    samba_cv_WITH_VFS_AFSACL=yes
+    ;;
+  *)
+    AC_MSG_RESULT(no)
+    ;;
+  esac ],
+  AC_MSG_RESULT(no)
+)
+
+if test x"$samba_cv_WITH_VFS_AFSACL" = x"yes"; then
+   default_shared_modules="$default_shared_modules vfs_afsacl"
+fi
        
 if test x"$samba_cv_WITH_AFS" != x"no" && test x"$have_afs_headers" = x"yes"; then
     AC_DEFINE(WITH_AFS,1,[Whether to include AFS clear-text auth support])
@@ -2614,6 +2759,7 @@ if test x"$with_ads_support" != x"no"; then
   # now see if we can find the krb5 libs in standard paths
   # or as specified above
   AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_mk_req_extended)
+  AC_CHECK_LIB_EXT(krb5, KRB5_LIBS, krb5_kt_compare)
 
   ########################################################
   # now see if we can find the gssapi libs in standard paths
@@ -2636,6 +2782,12 @@ if test x"$with_ads_support" != x"no"; then
   AC_CHECK_FUNC_EXT(krb5_free_ktypes, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_free_data_contents, $KRB5_LIBS)
   AC_CHECK_FUNC_EXT(krb5_principal_get_comp_string, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_free_unparsed_name, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_free_keytab_entry_contents, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_kt_free_entry, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_krbhst_get_addrinfo, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_c_enctype_compare, $KRB5_LIBS)
+  AC_CHECK_FUNC_EXT(krb5_enctypes_compatible_keys, $KRB5_LIBS)
 
   LIBS="$LIBS $KRB5_LIBS"
   
@@ -2674,6 +2826,30 @@ if test x"$with_ads_support" != x"no"; then
               [Whether the krb5_ticket struct has a enc_part2 property])
   fi
 
+  AC_CACHE_CHECK([for keyblock in krb5_creds],
+                 samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_creds creds; krb5_keyblock kb; creds.keyblock = kb;],
+      samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=yes,
+      samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_KEYBLOCK_IN_CREDS" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_KEYBLOCK_IN_CREDS,1,
+              [Whether the krb5_creds struct has a keyblock property])
+  fi
+
+  AC_CACHE_CHECK([for session in krb5_creds],
+                 samba_cv_HAVE_KRB5_SESSION_IN_CREDS,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_creds creds; krb5_keyblock kb; creds.session = kb;],
+      samba_cv_HAVE_KRB5_SESSION_IN_CREDS=yes,
+      samba_cv_HAVE_KRB5_SESSION_IN_CREDS=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_SESSION_IN_CREDS" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_SESSION_IN_CREDS,1,
+              [Whether the krb5_creds struct has a session property])
+  fi
+
   AC_CACHE_CHECK([for keyvalue in krb5_keyblock],
                  samba_cv_HAVE_KRB5_KEYBLOCK_KEYVALUE,[
     AC_TRY_COMPILE([#include <krb5.h>],
@@ -2718,6 +2894,18 @@ if test x"$with_ads_support" != x"no"; then
               [Whether the AP_OPTS_USE_SUBKEY ap option is available])
   fi
 
+  AC_CACHE_CHECK([for KV5M_KEYTAB],
+                 samba_cv_HAVE_KV5M_KEYTAB,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_keytab_entry entry; entry.magic = KV5M_KEYTAB;],
+      samba_cv_HAVE_KV5M_KEYTAB=yes,
+      samba_cv_HAVE_KV5M_KEYTAB=no)])
+
+  if test x"$samba_cv_HAVE_KV5M_KEYTAB" = x"yes"; then
+      AC_DEFINE(HAVE_KV5M_KEYTAB,1,
+             [Whether the KV5M_KEYTAB option is available])
+  fi
+
   AC_CACHE_CHECK([for the krb5_princ_component macro],
                 samba_cv_HAVE_KRB5_PRINC_COMPONENT,[
     AC_TRY_LINK([#include <krb5.h>],
@@ -2730,28 +2918,6 @@ if test x"$with_ads_support" != x"no"; then
                [Whether krb5_princ_component is available])
   fi
 
-  AC_CACHE_CHECK([for memory keytab support],
-                samba_cv_HAVE_MEMORY_KEYTAB,[
-    AC_TRY_RUN([
-#include<krb5.h>
-  main()
-  {
-    krb5_context context;
-    krb5_keytab keytab;
-    
-    krb5_init_context(&context);
-    if (krb5_kt_resolve(context, "MEMORY:", &keytab))
-      exit(1);
-    exit(0);
-  }], 
-  samba_cv_HAVE_MEMORY_KEYTAB=yes,
-  samba_cv_HAVE_MEMORY_KEYTAB=no)])
-
-  if test x"$samba_cv_HAVE_MEMORY_KEYTAB" = x"yes"; then
-      AC_DEFINE(HAVE_MEMORY_KEYTAB,1,
-               [Whether in-memory keytabs are supported])
-  fi
-
   AC_CACHE_CHECK([for key in krb5_keytab_entry],
                  samba_cv_HAVE_KRB5_KEYTAB_ENTRY_KEY,[
     AC_TRY_COMPILE([#include <krb5.h>],
@@ -2790,7 +2956,45 @@ if test x"$with_ads_support" != x"no"; then
     KRB5_LIBS=""
     with_ads_support=no 
   fi
-  LIBS="$ac_save_LIBS"
+
+  AC_CACHE_CHECK([for WRFILE: keytab support],
+                samba_cv_HAVE_WRFILE_KEYTAB,[
+    AC_TRY_RUN([
+#include<krb5.h>
+  main()
+  {
+    krb5_context context;
+    krb5_keytab keytab;
+
+    krb5_init_context(&context);
+    if (krb5_kt_resolve(context, "WRFILE:api", &keytab))
+      exit(0);
+    exit(1);
+  }],
+  samba_cv_HAVE_WRFILE_KEYTAB=no,
+  samba_cv_HAVE_WRFILE_KEYTAB=yes)])
+
+  if test x"$samba_cv_HAVE_WRFILE_KEYTAB" = x"yes"; then
+      AC_DEFINE(HAVE_WRFILE_KEYTAB,1,
+               [Whether the WRFILE:-keytab is supported])
+  fi
+
+  AC_CACHE_CHECK([for krb5_princ_realm returns krb5_realm or krb5_data],
+               samba_cv_KRB5_PRINC_REALM_RETURNS_REALM,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+    [
+    krb5_context context;
+    krb5_principal principal;
+    krb5_realm realm; realm = *krb5_princ_realm(context, principal);],
+    samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=yes,
+    samba_cv_KRB5_PRINC_REALM_RETURNS_REALM=no)])
+
+  if test x"$samba_cv_KRB5_PRINC_REALM_RETURNS_REALM" = x"yes"; then
+    AC_DEFINE(KRB5_PRINC_REALM_RETURNS_REALM,1,
+              [Whether krb5_princ_realm returns krb5_realm or krb5_data])
+  fi
+
+LIBS="$ac_save_LIBS"
 fi
 
 ########################################################
@@ -2878,6 +3082,7 @@ AC_ARG_WITH(smbmount,
 )
 
 
+
 #################################################
 # check for a PAM clear-text auth, accounts, password and session support
 with_pam_for_crypt=no
@@ -2962,6 +3167,7 @@ if test x"$samba_cv_HAVE_TRUNCATED_SALT" = x"yes"; then
 fi
 fi
 
+
 ########################################################################################
 ##
 ## TESTS FOR SAM BACKENDS.  KEEP THESE GROUPED TOGETHER
@@ -3114,7 +3320,7 @@ AC_ARG_WITH(sys-quotas,
   AC_MSG_RESULT(${samba_cv_TRY_SYS_QUOTAS})
 )
 
-if test x"$samba_cv_TRY_SYS_QUOTAS" = x"auto"; then
+if test x"$samba_cv_TRY_SYS_QUOTAS" != x"no"; then
 AC_MSG_CHECKING(whether to try the lib/sysquotas.c interface on ${host_os})
   case "$host_os" in
        *linux*)
@@ -3851,7 +4057,7 @@ samba_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,samba_cv_HAVE_BROKEN_LINUX_SENDFILE=no)]
        fi
 
        ;;
-       *freebsd*)
+       *freebsd* | *DragonFly* )
                AC_CACHE_CHECK([for freebsd sendfile support],samba_cv_HAVE_SENDFILE,[
                AC_TRY_LINK([\
 #include <sys/types.h>
@@ -4041,6 +4247,8 @@ case "$host_os" in
                # the Linux version.
                WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_freebsd.o \
                    nsswitch/winbind_nss_linux.o"
+               WINBIND_NSS="nsswitch/nss_winbind.$SHLIBEXT"
+               WINBIND_WINS_NSS="nsswitch/nss_wins.$SHLIBEXT"
                ;;
        *irix*)
                # IRIX has differently named shared libraries
@@ -4078,7 +4286,7 @@ AC_SUBST(WINBIND_NSS_LDSHFLAGS)
 AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
 AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
 
-# Check the setting of --with-winbindd
+# Check the setting of --with-winbind
 
 AC_ARG_WITH(winbind,
 [  --with-winbind          Build winbind (default, if supported by OS)],
@@ -4111,7 +4319,7 @@ if test x"$HAVE_WINBIND" = x"yes"; then
 
        EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/wbinfo\$(EXEEXT)"
        EXTRA_SBIN_PROGS="$EXTRA_SBIN_PROGS bin/winbindd\$(EXEEXT)"
-        if test x"$BLDSHARED" = x"true"; then
+        if test $BLDSHARED = true; then
                SHLIB_PROGS="$SHLIB_PROGS $WINBIND_NSS $WINBIND_WINS_NSS"
 
                if test x"$with_pam" = x"yes"; then
@@ -4133,6 +4341,14 @@ AC_CHECK_MEMBER(struct passwd.pw_age,
                AC_DEFINE(HAVE_PASSWD_PW_AGE, 1, [Defined if struct passwd has pw_age field]),,
                [#include <pwd.h>])
 
+# AIX 4.3.x and 5.1 do not have as many members in
+# struct secmethod_table as AIX 5.2
+AC_CHECK_MEMBERS([struct secmethod_table.method_attrlist], , ,
+       [#include <usersec.h>])
+AC_CHECK_MEMBERS([struct secmethod_table.method_version], , ,
+       [#include <usersec.h>])
+
+
 #################################################
 # Check to see if we should use the included popt 
 
@@ -4203,10 +4419,10 @@ done
 
 for i in `echo $default_shared_modules | sed -e's/,/ /g'`
 do
-       dnl Fall back to static if dlopen() is not available
+       dnl Fall back to static if we cannot build shared libraries
        eval MODULE_DEFAULT_$i=STATIC
 
-       if test x"$ac_cv_func_dlopen" = xyes; then
+       if test $BLDSHARED = true; then
                eval MODULE_DEFAULT_$i=SHARED
        fi
 done
@@ -4269,6 +4485,7 @@ 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_SUBSYSTEM(IDMAP,sam/idmap.o)
 
 SMB_MODULE(charset_weird, modules/weird.o, "bin/weird.$SHLIBEXT", CHARSET)
@@ -4289,11 +4506,15 @@ SMB_SUBSYSTEM(AUTH,auth/auth.o)
 SMB_MODULE(vfs_recycle, \$(VFS_RECYCLE_OBJ), "bin/recycle.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_audit, \$(VFS_AUDIT_OBJ), "bin/audit.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_extd_audit, \$(VFS_EXTD_AUDIT_OBJ), "bin/extd_audit.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_full_audit, \$(VFS_FULL_AUDIT_OBJ), "bin/full_audit.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_netatalk, \$(VFS_NETATALK_OBJ), "bin/netatalk.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_fake_perms, \$(VFS_FAKE_PERMS_OBJ), "bin/fake_perms.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_default_quota, \$(VFS_DEFAULT_QUOTA_OBJ), "bin/default_quota.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_readonly, \$(VFS_READONLY_OBJ), "bin/readonly.$SHLIBEXT", VFS)
 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_SUBSYSTEM(VFS,smbd/vfs.o)
 
 AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules])