]> git.sur5r.net Git - openldap/blobdiff - configure.in
Add select args type & vfork tests for experimentation purposes.
[openldap] / configure.in
index 36de8f6483c2202cde48f0c2f589d614425a0b76..3ab2aa6df7cc1236e29579cefa0c1da115e413ff 100644 (file)
@@ -49,14 +49,17 @@ OL_ARG_ENABLE(cldap,[  --enable-cldap       enable connectionless ldap], no)dnl
 OL_ARG_ENABLE(x_compile,[  --enable-x-compile  enable cross compiling],
        no, [yes no])dnl
 
-
 dnl General "with" options
 OL_ARG_ENABLE(dmalloc,[  --enable-dmalloc      enable debug malloc support], no)dnl
 
-OL_ARG_WITH(kerberos,[  --with-kerberos        use Kerberos],
+OL_ARG_WITH(kerberos,[  --with-kerberos        with Kerberos support],
        auto, [auto k5 k4 afs yes no])
+OL_ARG_WITH(readline,[  --with-readline  with readline support],
+       auto, [auto yes no] )
 OL_ARG_WITH(threads,[  --with-threads  use threads],
        auto, [auto posix mach lwp yes no manual] )
+OL_ARG_WITH(tls,[  --with-tls  with TLS/SSL support],
+       auto, [auto ssleay openssl yes no] )
 OL_ARG_WITH(yielding_select,[  --with-yielding-select  with implicitly yielding select],
        auto, [auto yes no manual] )
 
@@ -80,13 +83,14 @@ dnl SLAPD Backend options
 OL_ARG_ENABLE(bdb2,[    --enable-bdb2  enable bdb2 backend], no)dnl
 OL_ARG_ENABLE(ldbm,[    --enable-ldbm  enable ldbm backend], yes)dnl
 OL_ARG_WITH(ldbm_api,[      --with-ldbm-api    use LDBM API], auto,
-       [auto db2 db gdbm ndbm manual])
+       [auto db2 db mdbm gdbm ndbm manual])
 OL_ARG_WITH(ldbm_type,[      --with-ldbm-type  use LDBM type], auto,
        [auto btree hash])
 
 OL_ARG_ENABLE(passwd,[    --enable-passwd      enable passwd backend], no)dnl
 OL_ARG_ENABLE(perl,[    --enable-perl  enable perl backend], no)dnl
 OL_ARG_ENABLE(shell,[    --enable-shell        enable shell backend], no)dnl
+OL_ARG_ENABLE(tcl,[    --enable-tcl    enable tcl backend], no)dnl
 
 dnl SLURPD OPTIONS
 AC_ARG_WITH(xxslurpdoptions,[SLURPD Options:])
@@ -126,6 +130,9 @@ if test $ol_enable_slapd = no ; then
        if test $ol_enable_shell = yes ; then
                AC_MSG_WARN([slapd disabled, ignoring --enable_shell argument])
        fi
+       if test $ol_enable_tcl = yes ; then
+               AC_MSG_WARN([slapd disabled, ignoring --enable_tcl argument])
+       fi
        if test $ol_enable_aclgroups = yes ; then
                AC_MSG_WARN([slapd disabled, ignoring --enable_aclgroups argument])
        fi
@@ -154,6 +161,7 @@ if test $ol_enable_slapd = no ; then
        ol_enable_passwd=no
        ol_enable_perl=no
        ol_enable_shell=no
+       ol_enable_tcl=no
        ol_enable_aclgroups=no
        ol_enable_wrappers=no
        ol_enable_phonetic=no
@@ -179,7 +187,8 @@ elif test $ol_enable_ldbm = no ; then
 
        if test $ol_enable_passwd = no -a \
                $ol_enable_perl = no -a \
-               $ol_enable_shell = no ; then
+               $ol_enable_shell = no -a \
+               $ol_enable_tcl = no ; then
                AC_MSG_ERROR([slapd requires a backend])
        fi
 
@@ -211,6 +220,10 @@ else
                $ol_with_ldbm_type = btree ; then
                AC_MSG_ERROR([GDBM only supports LDBM type hash])
        fi
+       if test $ol_with_ldbm_api = mdbm -a \
+               $ol_with_ldbm_type = btree ; then
+               AC_MSG_ERROR([MDBM only supports LDBM type hash])
+       fi
        if test $ol_with_ldbm_api = ndbm -a \
                $ol_with_ldbm_type = btree ; then
                AC_MSG_ERROR([NDBM only supports LDBM type hash])
@@ -226,8 +239,6 @@ fi
 
 AC_MSG_RESULT(done)
 
-AC_CANONICAL_HOST
-
 ## Initialize vars
 LDAP_LIBS=
 LDBM_LIBS=
@@ -247,24 +258,38 @@ BUILD_LDBM=no
 BUILD_PASSWD=no
 BUILD_PERL=no
 BUILD_SHELL=no
+BUILD_TCL=no
 BUILD_THREAD=no
 
 SLAPD_PERL_LDFLAGS=
 SLAPD_PERL_CPPFLAGS=
 
 KRB_LIBS=
+READLINE_LIBS=
 TERMCAP_LIBS=
+TLS_LIBS=
 
 dnl ----------------------------------------------------------------
 dnl Checks for programs
 
 AC_PROG_INSTALL
+
+dnl The default compiler is cc (NOT gcc)
+CC=${CC-"cc"}
+dnl The default CFLAGS is empty NOT whatever AC_PROG_CC sets.
+dnl CFLAGS=${CFLAGS-""}
+
 AM_PROG_LIBTOOL
 dnl AC_PROG_MAKE_SET
 
 AC_PROG_AWK
+OL_PROG_LN_H
 AC_PROG_LN_S
 
+if test "$LN_H" = "cp" -a "$LN_S" = "ln"; then
+       LN_S="$LN_H"
+fi
+
 AC_PATH_PROG(SENDMAIL, sendmail, /usr/lib/sendmail,
        $PATH:/usr/libexec:/usr/lib:/usr/sbin:/usr/etc:/etc)
 AC_PATH_PROG(EDITOR, vi, /usr/ucb/vi, $PATH:/usr/ucb)
@@ -300,6 +325,9 @@ AC_AIX
 AC_ISC_POSIX
 AC_MINIX
 
+dnl BeOS requires -lbe -lroot
+AC_CHECK_LIB(be, be_app, [LIBS="$LIBS -lbe -lroot"], :, [-lroot])
+
 dnl Checks for system services
 AC_CYGWIN
 AC_MINGW32
@@ -416,7 +444,7 @@ des_debug = 1;
                                LIBS="$save_LIBS"
                        ])
 
-                       if test $ol_cv_var_des_debug= yes ; then
+                       if test $ol_cv_var_des_debug = yes ; then
                                AC_DEFINE(HAVE_DES_DEBUG,1,
                                        [define if you have Kerberos des_debug])
                        fi
@@ -445,6 +473,91 @@ if test $ol_link_kerberos = yes ; then
        AC_DEFINE(HAVE_KERBEROS, 1, [define if you have Kerberos])
 fi
 
+dnl
+dnl Check for SSL/TLS
+dnl
+ol_link_tls=no
+if test $ol_with_tls != no ; then
+       
+       AC_CHECK_HEADERS(ssl.h)
+       
+       if test $ac_cv_header_ssl_h = yes ; then
+               AC_CHECK_LIB(ssl, SSLeay_add_ssl_algorithms, 
+                       [have_ssleay=yes
+                       need_rsaref=no],
+                       [have_ssleay=no],
+                       [-lcrypto])
+                       
+               if test $have_ssleay = no ; then
+                       AC_CHECK_LIB(ssl, ssl3_accept, 
+                               [have_ssleay=yes
+                               need_rsaref=yes], [have_ssleay=no],
+                               [-lcrypto -lRSAglue -lrsaref])
+               fi
+
+               if test $have_ssleay = yes ; then
+                       ol_with_tls=found
+                       ol_link_tls=yes
+
+                       AC_DEFINE(HAVE_SSLEAY, 1, 
+                               [define if you have SSLeay or OpenSSL])
+
+                       if test $need_rsaref = yes; then
+                               AC_DEFINE(HAVE_RSAREF, 1, 
+                                       [define if you have RSAref])
+
+                               TLS_LIBS="-lssl -lcrypto -lRSAglue -lrsaref"
+                       else
+                               TLS_LIBS="-lssl -lcrypto"
+                       fi
+               fi
+       fi
+fi
+
+if test $ol_link_tls = yes ; then
+       AC_DEFINE(HAVE_TLS, 1, [define if you have TLS])
+fi     
+
+dnl Tests for reentrant functions necessary to build a
+dnl thread_safe -lldap.
+AC_CHECK_FUNCS(                \
+       ctime_r                 \
+       gethostbyname_r gethostbyaddr_r \
+)
+
+if test "$ac_cv_func_ctime_r" = no ; then
+       ol_cv_func_ctime_r_nargs=0
+else
+       OL_FUNC_CTIME_R_NARGS
+dnl    OL_FUNC_CTIME_R_TYPE
+fi
+
+if test "$ac_cv_func_gethostbyname_r" = yes ; then
+       OL_FUNC_GETHOSTBYNAME_R_NARGS
+else
+       ol_cv_func_gethostbyname_r_nargs=0
+fi
+if test "$ac_cv_func_gethostbyaddr_r" = yes ; then
+       OL_FUNC_GETHOSTBYADDR_R_NARGS
+else
+       ol_cv_func_gethostbyaddr_r_nargs=0
+fi
+
+if test "$ac_cv_func_ctime_r" = yes \
+       -a "$ol_cv_func_ctime_r_nargs" -ge 2 \
+       -a "$ol_cv_func_ctime_r_nargs" -le 3 \
+       -a "$ac_cv_func_gethostbyname_r" = yes \
+       -a "$ol_cv_func_gethostbyname_r_nargs" -ge 5 \
+       -a "$ol_cv_func_gethostbyname_r_nargs" -le 6 \
+       -a "$ac_cv_func_gethostbyaddr_r" = yes \
+       -a "$ol_cv_func_gethostbyaddr_r_nargs" -ge 5 \
+       -a "$ol_cv_func_gethostbyaddr_r_nargs" -le 6 \
+       ; then
+       AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_REENTRANT,1)
+fi
+
 ol_link_threads=no
 if test $ol_with_threads = auto -o $ol_with_threads = yes \
        -o $ol_with_threads = posix ; then
@@ -482,6 +595,7 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
                dnl     pthread_create() in $LIBS
                dnl
                dnl Check special pthread (final) flags
+               dnl     pthread_create() with -mt (Solaris)
                dnl     pthread_create() with -kthread (FreeBSD)
                dnl     pthread_create() with -pthread (FreeBSD/Digital Unix)
                dnl     pthread_create() with -pthreads (?)
@@ -491,23 +605,92 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
                dnl     pthread_mutex_unlock() in -lpthread -lmach -lexc -lc_r (OSF/1)
                dnl     pthread_mutex_lock() in -lpthread -lmach -lexc (OSF/1)
                dnl     pthread_mutex_trylock() in -lpthread -lexc (OSF/1)
+               dnl     pthread_join() -Wl,-woff,85 -lpthread (IRIX)
                dnl     pthread_create() in -lpthread (many)
                dnl     pthread_create() in -lc_r (FreeBSD)
-               dnl     pthread_create() in -lpthreads (many)
-               dnl     pthread_join() -Wl,-woff,85 -lpthreads (IRIX)
-               dnl     pthread_create() in HP-UX -lpthread (HP-UX 11)
                dnl
-               dnl Check pthread (draft4) flags (to be depreciated)
+               dnl Check pthread (draft4) flags (depreciated)
                dnl     pthread_create() with -threads (OSF/1)
                dnl
-               dnl Check pthread (final) libraries (to be depreciated)
+               dnl Check pthread (draft4) libraries (depreciated)
                dnl     pthread_mutex_unlock() in -lpthreads -lmach -lexc -lc_r (OSF/1)
                dnl     pthread_mutex_lock() in -lpthreads -lmach -lexc (OSF/1)
                dnl     pthread_mutex_trylock() in -lpthreads -lexc (OSF/1)
+               dnl     pthread_create() in -lpthreads (many)
                dnl
 
                dnl pthread_create in $LIBS
-               AC_CHECK_FUNC(pthread_create,[ol_link_threads=yes])
+               AC_MSG_CHECKING([for pthread_create in default libraries])
+               AC_CACHE_VAL(ol_cv_pthread_create,[
+               AC_TRY_RUN([
+#include <pthread.h>
+#ifndef NULL
+#define NULL (void*)0
+#endif
+
+static void *task(p)
+       void *p;
+{
+       return (void *) (p == NULL);
+}
+
+int main(argc, argv)
+       int argc;
+       char **argv;
+{
+       pthread_t t;
+       int status;
+
+       /* make sure pthread_create() isn't just a stub */
+#if HAVE_PTHREADS_D4
+       status = pthread_create(&t, pthread_attr_default, task, NULL));
+#else
+       status = pthread_create(&t, NULL, task, NULL);
+#endif
+
+       if( status ) return status;
+
+       /* make sure pthread_detach() isn't just a stub */
+#if HAVE_PTHREADS_D4
+       status = pthread_detach( &t );
+#else
+       status = pthread_detach( t );
+#endif
+
+       if( status ) return status;
+
+       return status;
+}
+],
+                       [ol_cv_pthread_create=yes],
+                       [ol_cv_pthread_create=no],
+                       [dnl assume yes
+                       ol_cv_pthread_create=yes])])
+               AC_MSG_RESULT($ol_cv_pthread_create)
+
+               if test $ol_cv_pthread_create != no ; then
+                       ol_link_threads=posix
+               fi
+
+               if test $ol_link_threads = no ; then
+                       dnl try -mt
+                       AC_CACHE_CHECK([for pthread_create with -mt],
+                               [ol_cv_pthread_mt_flag], [
+                               dnl save the flags
+                               save_LIBS="$LIBS"
+                               LIBS="-mt $LIBS"
+                               AC_TRY_LINK([char pthread_create();],
+                                       [pthread_create();],
+                                       [ol_cv_pthread_mt_flag=yes], [ol_cv_pthread_mt_flag=no])
+                               dnl restore the LIBS
+                               LIBS="$save_LIBS"
+                       ])
+
+                       if test $ol_cv_pthread_mt_flag = yes ; then
+                               LTHREAD_LIBS="$LTHREAD_LIBS -mt"
+                               ol_link_threads=posix
+                       fi
+               fi
 
                if test $ol_link_threads = no ; then
                        dnl try -kthread
@@ -516,8 +699,15 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
                                dnl save the flags
                                save_LIBS="$LIBS"
                                LIBS="-kthread $LIBS"
-                               AC_TRY_LINK([#include <pthread.h>],
-                                       [pthread_create(NULL,NULL,NULL,NULL);],
+                               AC_TRY_LINK([#include <pthread.h>],[
+#if HAVE_PTHREADS_D4
+       pthread_create(NULL,pthread_attr_default,NULL,NULL);
+#else
+       pthread_t t;
+       pthread_create(&t,NULL,NULL,NULL);
+       pthread_detach(t);
+#endif
+],
                                        [ol_cv_kthread_flag=yes], [ol_cv_kthread_flag=no])
                                dnl restore the LIBS
                                LIBS="$save_LIBS"
@@ -536,8 +726,13 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
                                dnl save the flags
                                save_LIBS="$LIBS"
                                LIBS="-pthread $LIBS"
-                               AC_TRY_LINK([#include <pthread.h>],
-                                       [pthread_create(NULL,NULL,NULL,NULL);],
+                               AC_TRY_LINK([#include <pthread.h>],[
+#if HAVE_PTHREADS_D4
+       pthread_create(NULL,pthread_attr_default,NULL,NULL);
+#else
+       pthread_create(NULL,NULL,NULL,NULL);
+#endif
+],
                                        [ol_cv_pthread_flag=yes], [ol_cv_pthread_flag=no])
                                dnl restore the LIBS
                                LIBS="$save_LIBS"
@@ -556,8 +751,13 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
                                dnl save the flags
                                save_LIBS="$LIBS"
                                LIBS="-pthreads $LIBS"
-                               AC_TRY_LINK([#include <pthread.h>],
-                                       [pthread_create(NULL,NULL,NULL,NULL);],
+                               AC_TRY_LINK([#include <pthread.h>],[
+#if HAVE_PTHREADS_D4
+       pthread_create(NULL,pthread_attr_default,NULL,NULL);
+#else
+       pthread_create(NULL,NULL,NULL,NULL);
+#endif
+],
                                        [ol_cv_pthreads_flag=yes], [ol_cv_pthreads_flag=no])
                                dnl restore the LIBS
                                LIBS="$save_LIBS"
@@ -595,9 +795,9 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
                        AC_CHECK_LIB(pthread, pthread_mutex_unlock, [
                                ol_link_threads=posix
                                LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lmach -lexc -lc_r"
-                               if test $ol_with_yielding_select = auto ; then
-                                       ol_with_yielding_select=yes
-                               fi
+dnl                            if test $ol_with_yielding_select = auto ; then
+dnl                                    ol_with_yielding_select=yes
+dnl                            fi
                                ],:,[-lmach -lexc -lc_r])
                        LIBS="$save_LIBS"
                fi
@@ -608,9 +808,9 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
                        AC_CHECK_LIB(pthread, pthread_mutex_lock, [
                                ol_link_threads=posix
                                LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lmach -lexc"
-                               if test $ol_with_yielding_select = auto ; then
-                                       ol_with_yielding_select=yes
-                               fi
+dnl                            if test $ol_with_yielding_select = auto ; then
+dnl                                    ol_with_yielding_select=yes
+dnl                            fi
                                ],:,[-lmach -lexc])
                        LIBS="$save_LIBS"
                fi
@@ -621,97 +821,57 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
                        AC_CHECK_LIB(pthread, pthread_mutex_trylock, [
                                ol_link_threads=posix
                                LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lexc"
-                               if test $ol_with_yielding_select = auto ; then
-                                       ol_with_yielding_select=yes
-                               fi
+dnl                            if test $ol_with_yielding_select = auto ; then
+dnl                                    ol_with_yielding_select=yes
+dnl                            fi
                                ],:,[-lexc])
                        LIBS="$save_LIBS"
                fi
 
+               dnl IRIX Pthread check
                if test $ol_link_threads = no ; then
-                       dnl try -lpthread
+                       dnl try IRIX Pthreads -Wl,-woff,85 -lpthread
                        save_LIBS="$LIBS"
-                       AC_CHECK_LIB(pthread, pthread_create, [
+                       AC_CHECK_LIB(pthread, pthread_join, [
                                ol_link_threads=posix
-                               LTHREAD_LIBS="$LTHREAD_LIBS -lpthread"],:)
-                       LIBS="$save_LIBS"
-               fi
-
-               if test $ol_link_threads = no ; then
-                       dnl try -lc_r
-                       save_LIBS="$LIBS"
-                       AC_CHECK_LIB(c_r, pthread_create, [
-                               ol_link_threads=posix
-                               LTHREAD_LIBS="$LTHREAD_LIBS -lc_r"],:)
+                               LTHREAD_LIBS="$LTHREAD_LIBS -lpthread"
+                               ],:,[-Wl,-woff,85])
                        LIBS="$save_LIBS"
                fi
 
                if test $ol_link_threads = no ; then
-                       dnl try -lpthreads
+                       dnl try -lpthread
                        save_LIBS="$LIBS"
-                       AC_CHECK_LIB(pthreads, pthread_create, [
+                       AC_CHECK_LIB(pthread, pthread_create, [
                                ol_link_threads=posix
-                               LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads"],:)
+                               LTHREAD_LIBS="$LTHREAD_LIBS -lpthread"],:)
                        LIBS="$save_LIBS"
                fi
 
-               dnl IRIX Pthread check
                if test $ol_link_threads = no ; then
-                       dnl try IRIX Pthreads -Wl,-woff,85 -lpthreads
+                       dnl try -lc_r
                        save_LIBS="$LIBS"
-                       AC_CHECK_LIB(pthreads, pthread_join, [
+                       AC_CHECK_LIB(c_r, pthread_create, [
                                ol_link_threads=posix
-                               LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads"
-                               ],:,[-Wl,-woff,85])
-                       LIBS="$save_LIBS"
-               fi
-
-               dnl HP-UX 11 Pthread check
-               if test $ol_link_threads = no; then
-                       save_LIBS="$LIBS"
-                       LIBS="$LIBS -lpthread"
-                       AC_MSG_CHECKING([for pthread_create() in HP-UX -lpthread])
-                       ol_try_pthread_hpux_11=no
-                       AC_CACHE_VAL(ol_cv_pthread_hpux_11,[
-                               AC_TRY_LINK([
-#include <pthread.h>
-#include <elf.h>
-#ifndef ELFABI_HPUX_REL11
-       die horribly
-#endif
-                               ], [pthread_create(NULL, NULL, NULL, NULL);],
-                                       ol_try_pthread_hpux_11=yes
-                                       ol_cv_pthread_hpux_11=yes,
-                                       ol_cv_pthread_hpux_11=no)])
-                       AC_MSG_RESULT(yes)
+                               LTHREAD_LIBS="$LTHREAD_LIBS -lc_r"],:)
                        LIBS="$save_LIBS"
-
-                       if test $ol_cv_pthread_hpux_11=yes ; then
-                               ol_link_threads=posix
-                               LTHREAD_LIBS="$LTHREAD_LIBS -lpthread"
-                               if test $ol_try_pthread_hpux_11=yes ; then
-                                       dnl Some tests below may fail, cause we aint including
-                                       dnl pthread.h. Force appropriate ones to yes
-                                       ac_cv_func_pthread_attr_init=yes
-                               fi
-                       fi
                fi
 
                if test $ol_link_threads = no ; then
                        dnl try -threads
                        AC_CACHE_CHECK([for pthread_create with -threads],
-                               [ol_cv_thread_flag], [
+                               [ol_cv_threads_flag], [
                                dnl save the flags
                                save_LIBS="$LIBS"
                                LIBS="-threads $LIBS"
                                AC_TRY_LINK([char pthread_create();],[
                                        pthread_create();
-                                       ], ol_cv_thread_flag=yes, ol_cv_thread_flag=no)
+                                       ], ol_cv_threads_flag=yes, ol_cv_threads_flag=no)
                                dnl restore the LIBS
                                LIBS="$save_LIBS"
                        ])
 
-                       if test $ol_cv_thread_flag = yes ; then
+                       if test $ol_cv_threads_flag = yes ; then
                                LTHREAD_LIBS="$LTHREAD_LIBS -threads"
                                ol_link_threads=posix
                        fi
@@ -723,9 +883,9 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
                        AC_CHECK_LIB(pthreads, pthread_mutex_unlock, [
                                ol_link_threads=posix
                                LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads -lmach -lexc -lc_r"
-                               if test $ol_with_yielding_select = auto ; then
-                                       ol_with_yielding_select=yes
-                               fi
+dnl                            if test $ol_with_yielding_select = auto ; then
+dnl                                    ol_with_yielding_select=yes
+dnl                            fi
                                ],:,[-lmach -lexc -lc_r])
                        LIBS="$save_LIBS"
                fi
@@ -736,9 +896,9 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
                        AC_CHECK_LIB(pthreads, pthread_mutex_lock, [
                                ol_link_threads=posix
                                LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads -lmach -lexc"
-                               if test $ol_with_yielding_select = auto ; then
-                                       ol_with_yielding_select=yes
-                               fi
+dnl                            if test $ol_with_yielding_select = auto ; then
+dnl                                    ol_with_yielding_select=yes
+dnl                            fi
                                ],:,[-lmach -lexc])
                        LIBS="$save_LIBS"
                fi
@@ -749,13 +909,22 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
                        AC_CHECK_LIB(pthreads, pthread_mutex_trylock, [
                                ol_link_threads=posix
                                LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads -lexc"
-                               if test $ol_with_yielding_select = auto ; then
-                                       ol_with_yielding_select=yes
-                               fi
+dnl                            if test $ol_with_yielding_select = auto ; then
+dnl                                    ol_with_yielding_select=yes
+dnl                            fi
                                ],:,[-lexc])
                        LIBS="$save_LIBS"
                fi
 
+               if test $ol_link_threads = no ; then
+                       dnl try -lpthreads
+                       save_LIBS="$LIBS"
+                       AC_CHECK_LIB(pthreads, pthread_create, [
+                               ol_link_threads=posix
+                               LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads"],:)
+                       LIBS="$save_LIBS"
+               fi
+
                if test $ol_link_threads != no ; then
                        AC_DEFINE(HAVE_PTHREADS,1,
                                [define if you have POSIX Threads])
@@ -799,7 +968,12 @@ if test $ol_with_threads = auto -o $ol_with_threads = yes \
                        AC_CACHE_CHECK([for pthread_detach with <pthread.h>],
                                [ol_cv_func_pthread_detach], [
                                dnl save the flags
-                               AC_TRY_LINK([#include <pthread.h>],
+                               AC_TRY_LINK([
+#include <pthread.h>
+#ifndef NULL
+#define NULL (void*)0
+#endif
+],
                                        [pthread_detach(NULL);],
                                        [ol_cv_func_pthread_detach=yes],
                                        [ol_cv_func_pthread_detach=no])
@@ -839,7 +1013,11 @@ int main(argc, argv)
        char **argv;
 {
        pthread_t t;
+#if HAVE_PTHREADS_D4
+       exit(pthread_create(&t, pthread_attr_default, task, NULL));
+#else
        exit(pthread_create(&t, NULL, task, NULL));
+#endif
 }
 ],
                                [ol_cv_pthread_create_works=yes],
@@ -849,7 +1027,7 @@ int main(argc, argv)
                        AC_MSG_RESULT($ol_cv_pthread_create_works)
 
                        if test $ol_cv_pthread_create_works = no ; then
-                               AC_MSG_ERROR([pthread.h and pthread_create are not compatible])
+                               AC_MSG_ERROR([pthread_create is not usable, check environment settings])
                        fi
 
                        dnl Check if select causes an yield
@@ -913,7 +1091,11 @@ int main(argc, argv)
 #endif
 #endif
 
+#if HAVE_PTHREADS_D4
+       pthread_create(&t, pthread_attr_default, task, NULL);
+#else
        pthread_create(&t, NULL, task, NULL);
+#endif
 
 #if HAVE_SCHED_YIELD
        sched_yield();  /* make sure task runs first */
@@ -1126,7 +1308,6 @@ dnl       save_CPPFLAGS="$CPPFLAGS"
 dnl    save_LIBS="$LIBS"
 dnl    LIBS="$LTHREAD_LIBS $LIBS"
 dnl    AC_CHECK_FUNCS( \
-dnl            strtok_r \
 dnl            gmtime_r \
 dnl            gethostbyaddr_r gethostbyname_r \
 dnl            feof_unlocked unlocked_feof \
@@ -1137,8 +1318,6 @@ dnl       CPPFLAGS="$save_CPPFLAGS"
 dnl    LIBS="$save_LIBS"
 fi  
 
-dnl ----------------------------------------------------------------
-
 if test $ol_link_threads = no ; then
        if test $ol_with_threads = yes ; then
                AC_MSG_ERROR([no suitable thread support])
@@ -1154,6 +1333,12 @@ if test $ol_link_threads = no ; then
        LTHREAD_LIBS=""
 fi
 
+if test $ol_link_threads != no ; then
+       AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE,1)
+fi
+
+dnl ----------------------------------------------------------------
+
 ol_link_ldbm=no 
 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db2 ; then
        OL_BERKELEY_DB2
@@ -1216,6 +1401,18 @@ if test $ol_link_ldbm = no -a $ol_with_ldbm_type = btree ; then
        ol_with_ldbm_api=none
 fi
 
+if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = mdbm ; then
+       OL_MDBM
+
+       if test $ol_cv_mdbm = yes ; then
+               ol_link_ldbm=mdbm
+               ol_with_ldbm_api=mdbm
+               if test $ol_cv_lib_mdbm != yes ; then
+                       LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_mdbm"
+               fi
+       fi
+fi
+
 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = gdbm ; then
        OL_GDBM
 
@@ -1291,6 +1488,39 @@ if test $ol_enable_dmalloc != no ; then
        AC_CHECK_LIB(dmalloc, dmalloc_shutdown)
 fi
 
+if test $ol_enable_tcl != no ; then
+       AC_CHECK_HEADERS(tcl.h)
+
+       if test $ac_cv_header_tcl_h != yes ; then
+               have_tcl=no
+       else
+               AC_CHECK_LIB(tcl,main,
+                       [have_tcl=yes; SLAPD_LIBS="$SLAPD_LIBS -ltcl"],
+                       [have_tcl=no])
+
+               if test $have_tcl != yes; then
+                       AC_CHECK_LIB(tcl7.6,main,
+                               [have_tcl=yes; SLAPD_LIBS="$SLAPD_LIBS -ltcl7.6"],
+                               [have_tcl=no])
+               fi
+
+               if test $have_tcl != yes; then
+                       AC_CHECK_LIB(tcl8.0,main,
+                               [have_tcl=yes; SLAPD_LIBS="$SLAPD_LIBS -ltcl8.0"],
+                               [have_tcl=no])
+               fi
+       fi
+
+       if test $have_tcl != yes ; then
+               AC_MSG_WARN([could not find -ltcl])
+               if test $ol_enable_tcl = yes ; then
+                       AC_MSG_ERROR([could not find tcl, select appropriate options or disable])
+               fi
+
+               ol_enable_tcl=no
+       fi
+fi
+
 # ud needs termcap (should insert check here)
 ol_link_termcap=no
 AC_CHECK_HEADERS(termcap.h ncurses.h)
@@ -1318,6 +1548,34 @@ if test $ol_link_termcap = no ; then
        TERMCAP_LIBS=
 fi
 
+dnl
+dnl Check for GNU readline
+dnl
+ol_link_readline=no
+if test $ol_with_readline != no ; then
+       AC_CHECK_HEADERS(readline/readline.h readline/history.h)
+
+       if test $ac_cv_header_readline_readline_h = yes ; then
+               save_LIBS="$LIBS"
+               LIBS="$TERMCAP_LIBS $LIBS"
+               AC_CHECK_LIB(readline, readline, 
+                       [have_readline=yes], [have_readline=no])
+               LIBS="$save_LIBS"
+                       
+               if test $have_readline = yes ; then
+                       ol_with_readline=found
+                       ol_link_readline=yes
+
+                       READLINE_LIBS="-lreadline"
+               fi
+       fi
+fi
+
+if test $ol_link_readline = yes ; then
+       AC_DEFINE(HAVE_READLINE, 1, [define if you have -lreadline])
+fi
+
+
 # FreeBSD (and others) have crypt(3) in -lcrypt
 if test $ol_enable_crypt != no ; then
        AC_CHECK_FUNC(crypt, [have_crypt=yes], [
@@ -1353,10 +1611,10 @@ fi
 
 dnl ----------------------------------------------------------------
 dnl Checks for header files.
-AC_HEADER_STDC
+OL_HEADER_STDC
 
-if test $ac_cv_header_stdc != yes; then
-       AC_MSG_WARN([could not Standard C compliant headers])
+if test $ol_cv_header_stdc != yes; then
+       AC_MSG_WARN([could not locate Standard C compliant headers])
 fi
 
 AC_HEADER_DIRENT
@@ -1368,14 +1626,18 @@ if test $am_cv_sys_posix_termios = yes ; then
 fi
 
 AC_CHECK_HEADERS(      \
+       arpa/inet.h             \
        arpa/nameser.h  \
+       assert.h                \
        crypt.h                 \
        errno.h                 \
        fcntl.h                 \
        filio.h                 \
        getopt.h                \
+       grp.h                   \
        libutil.h               \
        limits.h                \
+       locale.h                \
        malloc.h                \
        memory.h                \
        regex.h                 \
@@ -1416,6 +1678,7 @@ AC_TYPE_SIZE_T
 AC_STRUCT_ST_BLKSIZE
 AC_HEADER_TIME
 AC_STRUCT_TM
+OL_STRUCT_PASSWD_PW_GECOS
 
 OL_C_UPPER_LOWER
 AC_C_CONST
@@ -1436,6 +1699,7 @@ AC_FUNC_MEMCMP
 dnl AM_FUNC_MKTIME dnl checks for sys/time.h and unistd.h
 AC_FUNC_STRFTIME
 dnl AM_FUNC_STRTOD
+AC_FUNC_VFORK
 AC_FUNC_VPRINTF
 
 if test $ac_cv_func_vprintf = yes ; then
@@ -1445,15 +1709,21 @@ fi
 
 AC_CHECK_FUNCS(                \
        bcopy                   \
+       endgrent                \
+       endpwent                \
        flock                   \
-       getdtablesize   \
+       getdtablesize           \
+       getgrgid                \
        gethostname             \
+       getpass                 \
        getpwuid                \
-       gettimeofday    \
+       gettimeofday            \
        lockf                   \
        memcpy                  \
        memmove                 \
        mkstemp                 \
+       recv                    \
+       recvfrom                \
        select                  \
        setpwfile               \
        setsid                  \
@@ -1467,41 +1737,18 @@ AC_CHECK_FUNCS(         \
        strrchr                 \
        strsep                  \
        strstr                  \
-       strtok                  \
        strtol                  \
        strtoul                 \
        strspn                  \
        sysconf                 \
        waitpid                 \
+       wait4                   \
 )
 
-# these functions are required to build a thread_safe -lldap
-AC_CHECK_FUNCS(                \
-       strtok_r                \
-       ctime_r                 \
-       gethostbyaddr_r \
-       gethostbyname_r \
-)
-
-if test "$ac_cv_func_ctime_r" = yes ; then
-       OL_FUNC_CTIME_R_NARGS
-else
-       ol_cv_func_ctime_r=0
-fi
-
-if test "$ac_cv_func_strtok_r" = yes \
-       -a "$ac_cv_func_ctime_r" = yes \
-       -a "$ol_cv_func_ctime_r_nargs" -ge 2 -a "$ol_cv_func_ctime_r_nargs" -le 3 \
-       -a "$ac_cv_func_gethostbyaddr_r" = yes \
-       -a "$ac_cv_func_gethostbyname_r" = yes \
-       ; then
-
-       AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_REENTRANT, 1)
-fi
-
-if test $ol_link_threads != no ; then
-       AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE, 1)
-fi
+dnl Select arg types
+dnl (if this detection becomes permenent, it and the select() detection
+dnl should be done before the yielding select test) 
+AC_FUNC_SELECT_ARGTYPES
 
 dnl We actually may need to replace more than this.
 AC_REPLACE_FUNCS(getopt tempnam)
@@ -1510,6 +1757,10 @@ dnl ----------------------------------------------------------------
 # Check Configuration
 OL_SYS_ERRLIST
 
+dnl ----------------------------------------------------------------
+dnl Check our declaration of strdup()
+OL_DECL_STRDUP
+
 dnl ----------------------------------------------------------------
 dnl Sort out defines
 
@@ -1584,6 +1835,12 @@ if test "$ol_enable_shell" != no ; then
        BUILD_SHELL=yes
 fi
 
+if test "$ol_enable_tcl" != no ; then
+       AC_DEFINE(SLAPD_TCL,1)
+       BUILD_SLAPD=yes
+       BUILD_TCL=yes
+fi
+
 if test "$ol_enable_slurpd" != no -a "$ol_link_threads" != no -a \
        $BUILD_SLAPD = yes ; then
        BUILD_SLURPD=yes
@@ -1602,6 +1859,7 @@ AC_SUBST(BUILD_SLAPD)
   AC_SUBST(BUILD_PASSWD)
   AC_SUBST(BUILD_PERL)
   AC_SUBST(BUILD_SHELL)
+  AC_SUBST(BUILD_TCL)
 AC_SUBST(BUILD_SLURPD)
 
 AC_SUBST(LDAP_LIBS)
@@ -1616,7 +1874,9 @@ AC_SUBST(SLAPD_PERL_CPPFLAGS)
 AC_SUBST(SLAPD_PERL_LDFLAGS)
 
 AC_SUBST(KRB_LIBS)
+AC_SUBST(READLINE_LIBS)
 AC_SUBST(TERMCAP_LIBS)
+AC_SUBST(TLS_LIBS)
 
 dnl ----------------------------------------------------------------
 dnl final output
@@ -1655,10 +1915,15 @@ servers/slapd/back-ldbm/Makefile:build/top.mk:servers/slapd/back-ldbm/Makefile.i
 servers/slapd/back-passwd/Makefile:build/top.mk:servers/slapd/back-passwd/Makefile.in:build/srv.mk \
 servers/slapd/back-perl/Makefile:build/top.mk:servers/slapd/back-perl/Makefile.in:build/srv.mk \
 servers/slapd/back-shell/Makefile:build/top.mk:servers/slapd/back-shell/Makefile.in:build/srv.mk \
+servers/slapd/back-tcl/Makefile:build/top.mk:servers/slapd/back-tcl/Makefile.in:build/srv.mk \
 servers/slapd/shell-backends/Makefile:build/top.mk:servers/slapd/shell-backends/Makefile.in:build/srv.mk \
 servers/slapd/tools/Makefile:build/top.mk:servers/slapd/tools/Makefile.in \
 servers/slurpd/Makefile:build/top.mk:servers/slurpd/Makefile.in:build/srv.mk \
-tests/Makefile:build/top.mk:tests/Makefile.in \
+tests/Makefile:build/top.mk:tests/Makefile.in:build/dir.mk \
+tests/progs/Makefile:build/top.mk:tests/progs/Makefile.in:build/rules.mk \
+contrib/Makefile:build/top.mk:contrib/Makefile.in:build/dir.mk \
+contrib/saucer/Makefile:build/top.mk:contrib/saucer/Makefile.in:build/rules.mk \
+contrib/web_ldap/Makefile:build/top.mk:contrib/web_ldap/Makefile.in:build/rules.mk \
 ,[
 date > stamp-h
 echo Please \"make depend\" to build dependencies