]> git.sur5r.net Git - openldap/blob - configure.in
179ee6944fcdd8f3cdf3d7910c411fb93bce8194
[openldap] / configure.in
1 dnl $OpenLDAP$
2 dnl This work is part of OpenLDAP Software <http://www.openldap.org/>.
3 dnl
4 dnl Copyright 1998-2005 The OpenLDAP Foundation.
5 dnl All rights reserved.
6 dnl
7 dnl Redistribution and use in source and binary forms, with or without
8 dnl modification, are permitted only as authorized by the OpenLDAP
9 dnl Public License.
10 dnl
11 dnl A copy of this license is available in the file LICENSE in the
12 dnl top-level directory of the distribution or, alternatively, at
13 dnl <http://www.OpenLDAP.org/license.html>.
14 dnl
15 dnl ----------------------------------------------------------------
16 dnl
17 dnl Redefine AC_INIT_BINSH to provide RCS IDs and copyright notice
18 dnl at top of generated configure script.  Prints simple copyright.
19 define([AC_INIT_BINSH],
20 [[#! /bin/sh
21 # $]OpenLDAP[$
22 # from] translit([$OpenLDAP$], $")] [
23
24 # This work is part of OpenLDAP Software <http://www.openldap.org/>.
25 #
26 # Copyright 1998-2005 The OpenLDAP Foundation.
27 # All rights reserved.
28 #
29 # Redistribution and use in source and binary forms, with or without
30 # modification, are permitted only as authorized by the OpenLDAP
31 # Public License.
32 #
33 # A copy of this license is available in the file LICENSE in the
34 # top-level directory of the distribution or, alternatively, at
35 # <http://www.OpenLDAP.org/license.html>.
36
37 echo "Copyright 1998-2005 The OpenLDAP Foundation. All rights reserved."
38 echo "  Restrictions apply, see COPYRIGHT and LICENSE files."
39 ])dnl
40 dnl ----------------------------------------------------------------
41 dnl OpenLDAP Autoconf Macros
42 builtin(include, build/openldap.m4)dnl
43 dnl ----------------------------------------------------------------
44 dnl Disable config.cache!
45 define([AC_CACHE_LOAD], )dnl
46 define([AC_CACHE_SAVE], )dnl
47 dnl ================================================================
48 dnl Configure.in for OpenLDAP
49 AC_INIT
50 AC_CONFIG_SRCDIR(build/version.sh)dnl
51
52 # set unset (borrowed from autoconf 2.49c)
53 if (OL_FOO=OL_FOO; unset OL_FOO) >/dev/null 2>&1; then
54   ol_unset=unset
55 else
56   ol_unset=false
57 fi
58 # unset CDPATH
59 $ol_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=:; export CDPATH; }
60
61 AC_CONFIG_AUX_DIR(build)dnl
62
63 eval `$ac_aux_dir/version.sh`
64 if test -z "$OL_STRING"; then
65         AC_MSG_ERROR([could not determine version])
66 fi
67
68 if test -f "$ac_aux_dir/shtool" -a ! -d $ac_aux_dir/shtool; then
69         ac_cv_shtool="$ac_aux_dir/shtool"
70 else
71         AC_MSG_ERROR([no shtool found in $ac_aux_dir])
72 fi
73
74 SHTOOL="$ac_cv_shtool"
75 dnl AC_SUBST(SHTOOL)dnl
76
77 TB="`$SHTOOL echo -e '%B' 2>/dev/null`"
78 TN="`$SHTOOL echo -e '%b' 2>/dev/null`"
79
80 OPENLDAP_CVS=""
81 if test -d $ac_aux_dir/CVS; then
82         OPENLDAP_CVS="(from CVS sources) "
83 fi
84
85 echo "Configuring ${TB}${OL_STRING}${TN} ${OPENLDAP_CVS}..."
86
87 dnl Determine host platform
88 dnl             we try not to use this for much
89 AC_CANONICAL_TARGET([])
90
91 AM_INIT_AUTOMAKE([$OL_PACKAGE],[$OL_VERSION], [no defines])dnl
92 AC_SUBST(PACKAGE)dnl
93 AC_SUBST(VERSION)dnl
94 AC_DEFINE_UNQUOTED(OPENLDAP_PACKAGE,"$PACKAGE",Package)
95 AC_DEFINE_UNQUOTED(OPENLDAP_VERSION,"$VERSION",Version)
96
97 AC_DEFINE_UNQUOTED(LDAP_VENDOR_VERSION,$OL_API_INC,Version)
98 AC_DEFINE_UNQUOTED(LDAP_VENDOR_VERSION_MAJOR,$OL_MAJOR,Major)
99 AC_DEFINE_UNQUOTED(LDAP_VENDOR_VERSION_MINOR,$OL_MINOR,Minor)
100 AC_DEFINE_UNQUOTED(LDAP_VENDOR_VERSION_PATCH,$OL_PATCH,Patch)
101
102 OPENLDAP_LIBRELEASE=$OL_API_LIB_RELEASE
103 AC_SUBST(OPENLDAP_LIBRELEASE)dnl
104
105 OPENLDAP_LIBVERSION=$OL_API_LIB_VERSION
106 AC_SUBST(OPENLDAP_LIBVERSION)dnl
107
108 OPENLDAP_RELEASE_DATE="$OL_RELEASE_DATE"
109 AC_SUBST(OPENLDAP_RELEASE_DATE)dnl
110
111 dnl We use autoconf features new to 2.59.  Later versions like won't work.
112 dnl aclocal.m4 should be built using aclocal from automake 1.5
113 dnl libtool 1.5 should be installed.
114 AC_PREREQ(2.59)dnl Required Autoconf version
115
116 AH_TOP([
117 /* begin of portable.h.pre */
118 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
119  *
120  * Copyright 1998-2005 The OpenLDAP Foundation
121  * All rights reserved.
122  *
123  * Redistribution and use in source and binary forms, with or without
124  * modification, are permitted only as authorized by the OpenLDAP
125  * Public License.
126  *
127  * A copy of this license is available in the file LICENSE in the
128  * top-level directory of the distribution or, alternatively, at
129  * <http://www.OpenLDAP.org/license.html>.
130  */
131
132 #ifndef _LDAP_PORTABLE_H
133 #define _LDAP_PORTABLE_H
134
135 /* define this if needed to get reentrant functions */
136 #ifndef REENTRANT
137 #undef REENTRANT
138 #endif
139 #ifndef _REENTRANT
140 #undef _REENTRANT
141 #endif
142
143 /* define this if needed to get threadsafe functions */
144 #ifndef THREADSAFE
145 #undef THREADSAFE
146 #endif
147 #ifndef _THREADSAFE
148 #undef _THREADSAFE
149 #endif
150 #ifndef THREAD_SAFE
151 #undef THREAD_SAFE
152 #endif
153 #ifndef _THREAD_SAFE
154 #undef _THREAD_SAFE
155 #endif
156
157 #ifndef _SGI_MP_SOURCE
158 #undef _SGI_MP_SOURCE
159 #endif
160
161 /* These are defined in ldap_features.h */
162 /*
163         LDAP_API_FEATURE_X_OPENLDAP_REENTRANT
164         LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
165         LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
166         LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
167 */
168
169 /* These are defined in lber_types.h */
170 /*
171         LBER_INT_T
172         LBER_LEN_T
173         LBER_SOCKET_T
174         LBER_TAG_T
175 */
176
177 /* end of portable.h.pre */
178 ])
179 AH_BOTTOM([
180 /* begin of portable.h.post */
181
182 #ifdef _WIN32
183         /* don't suck in all of the win32 api */
184 #       define WIN32_LEAN_AND_MEAN 1
185 #endif
186
187 #ifndef LDAP_NEEDS_PROTOTYPES
188 /* force LDAP_P to always include prototypes */
189 #define LDAP_NEEDS_PROTOTYPES 1
190 #endif
191
192 #ifndef LDAP_REL_ENG
193 #if (LDAP_VENDOR_VERSION == 000000) && !defined(LDAP_DEVEL)
194 #define LDAP_DEVEL
195 #endif
196 #if defined(LDAP_DEVEL) && !defined(LDAP_TEST)
197 #define LDAP_TEST
198 #endif
199 #endif
200
201 #ifdef HAVE_STDDEF_H
202 #       include <stddef.h>
203 #endif
204
205 #ifdef HAVE_EBCDIC 
206 /* ASCII/EBCDIC converting replacements for stdio funcs
207  * vsnprintf and snprintf are used too, but they are already
208  * checked by the configure script
209  */
210 #define fputs ber_pvt_fputs
211 #define fgets ber_pvt_fgets
212 #define printf ber_pvt_printf
213 #define fprintf ber_pvt_fprintf
214 #define vfprintf ber_pvt_vfprintf
215 #define vsprintf ber_pvt_vsprintf
216 #endif
217
218 #include "ac/fdset.h"
219
220 #include "ldap_cdefs.h"
221 #include "ldap_features.h"
222
223 #include "ac/assert.h"
224 #include "ac/localize.h"
225
226 #endif /* _LDAP_PORTABLE_H */
227 /* end of portable.h.post */
228 ])
229
230 AC_CONFIG_HEADERS([include/portable.h:include/portable.hin])
231 AC_CONFIG_HEADERS([include/ldap_features.h:include/ldap_features.hin])
232 AC_CONFIG_HEADERS([include/lber_types.h:include/lber_types.hin])
233
234 dnl ================================================================
235 dnl Start Args
236 AC_MSG_CHECKING(configure arguments)
237 AC_PREFIX_DEFAULT(/usr/local)
238
239 top_builddir=`pwd`
240 AC_SUBST(top_builddir)dnl
241
242 dnl ----------------------------------------------------------------
243 dnl --with-subdir
244 ldap_subdir="/openldap"
245
246 AC_ARG_WITH(subdir,
247 [  --with-subdir=DIR       change default subdirectory used for installs],
248 [case "$withval" in
249         no) ldap_subdir=""
250                 ;;
251         yes)
252                 ;;
253         /*|\\*)
254                 ldap_subdir="$withval"
255                 ;;
256         *)
257                 ldap_subdir="/$withval"
258                 ;;
259 esac
260 ])dnl
261
262 AC_SUBST(ldap_subdir)dnl
263
264 dnl ----------------------------------------------------------------
265 dnl General "enable" options
266 OL_ARG_ENABLE(debug,[  --enable-debug     enable debugging], yes)dnl
267 OL_ARG_ENABLE(dynamic,[  --enable-dynamic         enable linking built binaries with dynamic libs], no)dnl
268 OL_ARG_ENABLE(syslog,[  --enable-syslog   enable syslog support], auto)dnl
269 OL_ARG_ENABLE(proctitle,[  --enable-proctitle     enable proctitle support], yes)dnl
270 dnl OL_ARG_ENABLE(referrals,[  --enable-referrals         enable LDAPv2+ Referrals (experimental)], no)dnl
271 ol_enable_referrals=${ol_enable_referrals-no}
272 dnl OL_ARG_ENABLE(kbind,[  --enable-kbind         enable LDAPv2+ Kerberos IV bind (deprecated)], no)dnl
273 ol_enable_kbind=${ol_enable_kbind-no}
274 OL_ARG_ENABLE(ipv6,[  --enable-ipv6       enable IPv6 support], auto)dnl
275 OL_ARG_ENABLE(local,[  --enable-local     enable AF_LOCAL (AF_UNIX) socket support], auto)dnl
276
277 dnl ----------------------------------------------------------------
278 dnl General "with" options
279 dnl OL_ARG_ENABLE(dmalloc,[  --enable-dmalloc     enable debug malloc support], no)dnl
280
281 OL_ARG_WITH(cyrus_sasl,[  --with-cyrus-sasl       with Cyrus SASL support],
282         auto, [auto yes no] )
283 OL_ARG_WITH(fetch,[  --with-fetch                 with fetch(3) URL support],
284         auto, [auto yes no] )
285 dnl     OL_ARG_WITH(kerberos,[  --with-kerberos   with Kerberos support],
286 dnl             auto, [auto k5 k5only k425 kth k4 afs yes no])
287 ol_with_kerberos=${ol_with_kerberos-auto}
288 OL_ARG_WITH(threads,[  --with-threads     with threads],
289         auto, [auto nt posix mach pth lwp yes no manual] )
290 OL_ARG_WITH(tls,[  --with-tls             with TLS/SSL support],
291         auto, [auto ssleay openssl yes no] )
292 OL_ARG_WITH(yielding_select,[  --with-yielding-select  with implicitly yielding select],
293         auto, [auto yes no manual] )
294 OL_ARG_WITH(multiple_precision,[  --with-multiple-precision
295                           multiple precision support for statistics
296                           auto|bignum|gmp],
297         auto, [auto bignum gmp yes no] )
298
299 dnl ----------------------------------------------------------------
300 dnl Server options
301 dnl ----------------------------------------------------------------
302
303 dnl ----------------------------------------------------------------
304 dnl SLAPD OPTIONS
305 AC_ARG_WITH(xxslapdoptions,[
306 SLAPD (Standalone LDAP Daemon) Options:])
307 OL_ARG_ENABLE(slapd,[  --enable-slapd     enable building slapd], yes)dnl
308 OL_ARG_ENABLE(aci,[    --enable-aci       enable per-object ACIs (experimental)], no)dnl
309 OL_ARG_ENABLE(cleartext,[    --enable-cleartext   enable cleartext passwords], yes)dnl
310 OL_ARG_ENABLE(crypt,[    --enable-crypt   enable crypt(3) passwords], no)dnl
311 OL_ARG_ENABLE(lmpasswd,[    --enable-lmpasswd     enable LAN Manager passwords], no)dnl
312 OL_ARG_ENABLE(spasswd,[    --enable-spasswd       enable (Cyrus) SASL password verification], no)dnl
313 OL_ARG_ENABLE(modules,[    --enable-modules       enable dynamic module support], no)dnl
314 dnl OL_ARG_ENABLE(multimaster,[    --enable-multimaster  enable multimaster replication], no)dnl
315 ol_enable_multimaster=${ol_enable_multimaster-no}
316 OL_ARG_ENABLE(rewrite,[    --enable-rewrite       enable DN rewriting in back-ldap and rwm overlay], auto)dnl
317 OL_ARG_ENABLE(rlookups,[    --enable-rlookups     enable reverse lookups of client hostnames], no)dnl
318 OL_ARG_ENABLE(slapi,[    --enable-slapi        enable SLAPI support (experimental)], no)dnl
319 OL_ARG_ENABLE(slp,[    --enable-slp          enable SLPv2 support], no)dnl     
320 OL_ARG_ENABLE(wrappers,[    --enable-wrappers     enable tcp wrapper support], no)dnl
321
322 dnl ----------------------------------------------------------------
323 dnl SLAPD Backend Options
324 Backends="bdb dnssrv hdb ldap ldbm meta monitor null \
325         passwd perl relay shell sql"
326
327 AC_ARG_WITH(xxslapbackends,[
328 SLAPD Backend Options:])
329
330 OL_ARG_ENABLE(backends,[    --enable-backends     enable all available backends no|yes|mod],
331         --, [no yes mod])dnl
332 test -n "$ol_enable_backends" && ol_dflt_backends="$ol_enable_backends"
333 OL_ARG_ENABLE(bdb,[    --enable-bdb       enable Berkeley DB backend no|yes|mod],
334         ${ol_dflt_backends-yes}, [no yes mod])dnl
335 OL_ARG_ENABLE(dnssrv,[    --enable-dnssrv         enable dnssrv backend no|yes|mod],
336         ${ol_dflt_backends-no}, [no yes mod])dnl
337 OL_ARG_ENABLE(hdb,[    --enable-hdb       enable Hierarchical DB backend no|yes|mod],
338         ${ol_dflt_backends-yes}, [no yes mod])dnl
339 OL_ARG_ENABLE(ldap,[    --enable-ldap     enable ldap backend no|yes|mod],
340         ${ol_dflt_backends-no}, [no yes mod])dnl
341 OL_ARG_ENABLE(ldbm,[    --enable-ldbm     enable ldbm backend no|yes|mod],
342         ${ol_dflt_backends-no}, [no yes mod])dnl
343 OL_ARG_WITH(ldbm_api,[      --with-ldbm-api     with LDBM API auto|berkeley|bcompat|mdbm|gdbm],
344         auto, [auto berkeley bcompat mdbm gdbm])
345 OL_ARG_WITH(ldbm_type,[      --with-ldbm-type     use LDBM type auto|btree|hash],
346         auto, [auto btree hash])
347 OL_ARG_ENABLE(meta,[    --enable-meta     enable metadirectory backend no|yes|mod],
348         ${ol_dflt_backends-no}, [no yes mod])dnl
349 OL_ARG_ENABLE(monitor,[    --enable-monitor       enable monitor backend no|yes|mod],
350         ${ol_dflt_backends-yes}, [no yes mod])dnl
351 OL_ARG_ENABLE(null,[    --enable-null     enable null backend no|yes|mod],
352         ${ol_dflt_backends-no}, [no yes mod])dnl
353 OL_ARG_ENABLE(passwd,[    --enable-passwd         enable passwd backend no|yes|mod],
354         ${ol_dflt_backends-no}, [no yes mod])dnl
355 OL_ARG_ENABLE(perl,[    --enable-perl     enable perl backend no|yes|mod],
356         ${ol_dflt_backends-no}, [no yes mod])dnl
357 OL_ARG_ENABLE(relay,[    --enable-relay           enable relay backend no|yes|mod],
358         ${ol_dflt_backends-yes}, [no yes mod])dnl
359 OL_ARG_ENABLE(shell,[    --enable-shell   enable shell backend no|yes|mod],
360         ${ol_dflt_backends-no}, [no yes mod])dnl
361 OL_ARG_ENABLE(sql,[    --enable-sql       enable sql backend no|yes|mod],
362         ${ol_dflt_backends-no}, [no yes mod])dnl
363
364 dnl ----------------------------------------------------------------
365 dnl SLAPD Overlay Options
366 Overlays="accesslog denyop dyngroup dynlist glue lastmod ppolicy proxycache \
367         refint retcode rwm syncprov translucent unique"
368
369 AC_ARG_WITH(xxslapoverlays,[
370 SLAPD Overlay Options:])
371
372 OL_ARG_ENABLE(overlays,[    --enable-overlays     enable all available overlays no|yes|mod],
373         --, [no yes mod])dnl
374 test -n "$ol_enable_overlays" && ol_dflt_overlays="$ol_enable_overlays"
375 OL_ARG_ENABLE(accesslog,[    --enable-accesslog   In-Directory Access Logging overlay no|yes|mod],
376         ${ol_dflt_overlays-no}, [no yes mod])
377 OL_ARG_ENABLE(denyop,[    --enable-denyop         Deny Operation overlay no|yes|mod],
378         ${ol_dflt_overlays-no}, [no yes mod])
379 OL_ARG_ENABLE(dyngroup,[    --enable-dyngroup     Dynamic Group overlay no|yes|mod],
380         ${ol_dflt_overlays-no}, [no yes mod])
381 OL_ARG_ENABLE(dynlist,[    --enable-dynlist       Dynamic List overlay no|yes|mod],
382         ${ol_dflt_overlays-no}, [no yes mod])
383 OL_ARG_ENABLE(glue,[    --enable-glue     Backend Glue overlay no|yes|mod],
384         ${ol_dflt_overlays-yes}, [no yes mod])
385 OL_ARG_ENABLE(lastmod,[    --enable-lastmod       Last Modification overlay no|yes|mod],
386         ${ol_dflt_overlays-no}, [no yes mod])
387 OL_ARG_ENABLE(ppolicy,[    --enable-ppolicy       Password Policy overlay no|yes|mod],
388         ${ol_dflt_overlays-no}, [no yes mod])
389 OL_ARG_ENABLE(proxycache,[    --enable-proxycache         Proxy Cache overlay no|yes|mod],
390         ${ol_dflt_overlays-no}, [no yes mod])
391 OL_ARG_ENABLE(refint,[    --enable-refint         Referential Integrity overlay no|yes|mod],
392         ${ol_dflt_overlays-no}, [no yes mod])
393 OL_ARG_ENABLE(retcode,[    --enable-retcode       Return Code testing overlay no|yes|mod],
394         ${ol_dflt_overlays-no}, [no yes mod])
395 OL_ARG_ENABLE(rwm,[    --enable-rwm               Rewrite/Remap overlay no|yes|mod],
396         ${ol_dflt_overlays-no}, [no yes mod])
397 OL_ARG_ENABLE(syncprov,[    --enable-syncprov     Syncrepl Provider overlay no|yes|mod],
398         ${ol_dflt_overlays-yes}, [no yes mod])
399 OL_ARG_ENABLE(translucent,[    --enable-translucent  Translucent Proxy overlay no|yes|mod],
400         ${ol_dflt_overlays-no}, [no yes mod])
401 OL_ARG_ENABLE(unique,[    --enable-unique       Attribute Uniqueness overlay no|yes|mod],
402         ${ol_dflt_overlays-no}, [no yes mod])
403
404
405 dnl ----------------------------------------------------------------
406 dnl SLURPD OPTIONS
407 AC_ARG_WITH(xxslurpdoptions,[
408 SLURPD (Replication Daemon) Options:])
409 OL_ARG_ENABLE(slurpd,[  --enable-slurpd   enable building slurpd], auto)dnl
410
411 dnl ----------------------------------------------------------------
412 AC_ARG_WITH(xxliboptions,[
413 Library Generation & Linking Options])
414 AC_ENABLE_STATIC
415 AC_ENABLE_SHARED
416
417 dnl ----------------------------------------------------------------
418
419 # validate options
420 if test $ol_enable_slapd = no ; then
421         dnl SLAPD was specificallly disabled
422         if test $ol_enable_slapi = yes ; then
423                 AC_MSG_WARN([slapd disabled, ignoring --enable-slapi argument])
424         fi
425         case "$ol_enable_backends" in yes | mod)
426                 AC_MSG_WARN([slapd disabled, ignoring --enable-backends argument])
427         esac
428         for i in $Backends; do
429                 eval "ol_tmp=\$ol_enable_$i"
430                 if test $ol_tmp != no ; then
431                         AC_MSG_WARN([slapd disabled, ignoring --enable-$i argument])
432                         eval "ol_enable_$i=no"
433                 fi
434         done
435         if test $ol_enable_modules = yes ; then
436                 AC_MSG_WARN([slapd disabled, ignoring --enable-modules argument])
437         fi
438         if test $ol_enable_multimaster = yes ; then
439                 AC_MSG_WARN([slapd disabled, ignoring --enable-multimaster argument])
440         fi
441         if test $ol_enable_wrappers = yes ; then
442                 AC_MSG_WARN([slapd disabled, ignoring --enable-wrappers argument])
443         fi
444         if test $ol_enable_rlookups = yes ; then
445                 AC_MSG_WARN([slapd disabled, ignoring --enable-rlookups argument])
446         fi
447         if test $ol_enable_aci = yes ; then
448                 AC_MSG_WARN([slapd disabled, ignoring --enable-aci argument])
449         fi
450         if test $ol_with_ldbm_api != auto ; then
451                 AC_MSG_WARN([slapd disabled, ignoring --with-ldbm-api argument])
452         fi
453         if test $ol_with_ldbm_type != auto ; then
454                 AC_MSG_WARN([slapd disabled, ignoring --with-ldbm-type argument])
455         fi
456         if test $ol_enable_slurpd = yes ; then
457                 AC_MSG_ERROR([slurpd requires slapd])
458         fi
459         if test $ol_enable_rewrite = yes ; then
460                 AC_MSG_WARN([slapd disabled, ignoring --enable-rewrite argument])
461         fi
462         dnl overlays
463         case "$ol_enable_overlays" in yes | mod)
464                 AC_MSG_WARN([slapd disabled, ignoring --enable-overlays argument])
465         esac
466         for i in $Overlays; do
467                 eval "ol_tmp=\$ol_enable_$i"
468                 if test $ol_tmp != no ; then
469                         AC_MSG_WARN([slapd disabled, ignoring --enable-$i argument])
470                         eval "ol_enable_$i=no"
471                 fi
472         done
473
474         # force settings to no
475         ol_enable_slapi=no
476
477         ol_enable_backends=
478         ol_enable_overlays=
479         ol_enable_modules=no
480         ol_enable_multimaster=no
481         ol_enable_rlookups=no
482         ol_enable_aci=no
483         ol_enable_wrappers=no
484
485         ol_with_ldbm_api=no
486         ol_with_ldbm_type=no
487
488         ol_enable_slurpd=no
489
490         ol_enable_rewrite=no
491
492 elif test $ol_enable_ldbm = no ; then
493         dnl SLAPD without LDBM
494
495         if test $ol_with_ldbm_api != auto ; then
496                 AC_MSG_WARN([LDBM disabled, ignoring --with-ldbm-api argument])
497         fi
498
499         if test $ol_with_ldbm_type != auto ; then
500                 AC_MSG_WARN([LDBM disabled, ignoring --with-ldbm-type argument])
501         fi
502
503         if test $ol_enable_modules != yes -a \
504                 $ol_enable_bdb = no -a \
505                 $ol_enable_dnssrv = no -a \
506                 $ol_enable_hdb = no -a \
507                 $ol_enable_ldap = no -a \
508                 $ol_enable_meta = no -a \
509                 $ol_enable_monitor = no -a \
510                 $ol_enable_null = no -a \
511                 $ol_enable_passwd = no -a \
512                 $ol_enable_perl = no -a \
513                 $ol_enable_relay = no -a \
514                 $ol_enable_shell = no -a \
515                 $ol_enable_sql = no ; then
516
517                 if test $ol_enable_slapd = yes ; then
518                         AC_MSG_ERROR([slapd requires a backend])
519                 else
520                         AC_MSG_WARN([skipping slapd, no backend specified])
521                         ol_enable_slapd=no
522                 fi
523         fi
524
525         ol_with_ldbm_api=no
526         ol_with_ldbm_type=no
527
528         if test $ol_enable_bdb != no -o $ol_enable_hdb != no; then
529                 ol_with_ldbm_api=berkeley
530         fi
531
532 else
533         dnl SLAPD with LDBM
534         if test $ol_with_ldbm_api = gdbm -a \
535                 $ol_with_ldbm_type = btree ; then
536                 AC_MSG_ERROR([GDBM only supports LDBM type hash])
537         fi
538         if test $ol_with_ldbm_api = mdbm -a \
539                 $ol_with_ldbm_type = btree ; then
540                 AC_MSG_ERROR([MDBM only supports LDBM type hash])
541         fi
542         if test $ol_with_ldbm_api = ndbm -a \
543                 $ol_with_ldbm_type = btree ; then
544                 AC_MSG_ERROR([NDBM only supports LDBM type hash])
545         fi
546
547         if test $ol_enable_bdb != no -o $ol_enable_hdb != no ; then
548                 if test $ol_with_ldbm_api = auto ; then
549                         ol_with_ldbm_api=berkeley
550                 elif test $ol_with_ldbm_api != berkeley ; then
551                         AC_MSG_ERROR([LDBM API not compatible with BDB/HDB])
552                 fi
553         fi
554 fi
555
556 if test $ol_enable_meta = yes -a $ol_enable_ldap = no ; then
557         AC_MSG_ERROR([--enable-meta requires --enable-ldap])
558 fi
559
560 if test $ol_enable_slurpd = yes ; then
561         dnl SLURPD was specifically enabled
562         if test $ol_with_threads = no ; then
563                 AC_MSG_ERROR([slurpd requires threads])
564         fi
565 fi
566
567 if test $ol_enable_lmpasswd = yes ; then
568         if test $ol_with_tls = no ; then
569                 AC_MSG_ERROR([LAN Manager passwords require OpenSSL])
570         fi
571 fi
572
573 if test $ol_enable_kbind = yes ; then
574         if test $ol_with_kerberos = no ; then
575                 AC_MSG_ERROR([options require --with-kerberos])
576         elif test $ol_with_kerberos = auto ; then
577                 ol_with_kerberos=yes
578         fi
579
580 elif test $ol_enable_kbind = no ; then
581         if test $ol_with_kerberos = auto ; then
582                 ol_with_kerberos=no
583         elif test $ol_with_kerberos != no ; then
584                 AC_MSG_WARN([Kerberos detection enabled unnecessarily]);
585                 ol_with_kerberos=no
586         fi
587 fi
588
589 if test $ol_enable_spasswd = yes ; then
590         if test $ol_with_cyrus_sasl = no ; then
591                 AC_MSG_ERROR([options require --with-cyrus-sasl])
592         fi
593         ol_with_cyrus_sasl=yes
594 fi
595
596 AC_MSG_RESULT(done)
597
598 dnl ----------------------------------------------------------------
599 dnl Initialize vars
600 LDAP_LIBS=
601 LDBM_LIBS=
602 LTHREAD_LIBS=
603 LUTIL_LIBS=
604
605 SLAPD_LIBS=
606 SLURPD_LIBS=
607
608 BUILD_SLAPD=no
609 BUILD_SLURPD=no
610
611 BUILD_THREAD=no
612
613 BUILD_SLAPI=no
614 SLAPD_SLAPI_DEPEND=
615
616 BUILD_BDB=no
617 BUILD_DNSSRV=no
618 BUILD_HDB=no
619 BUILD_LDAP=no
620 BUILD_LDBM=no
621 BUILD_META=no
622 BUILD_MONITOR=no
623 BUILD_NULL=no
624 BUILD_PASSWD=no
625 BUILD_PERL=no
626 BUILD_RELAY=no
627 BUILD_SHELL=no
628 BUILD_SQL=no
629
630 BUILD_ACCESSLOG=no
631 BUILD_DENYOP=no
632 BUILD_DYNGROUP=no
633 BUILD_DYNLIST=no
634 BUILD_GLUE=no
635 BUILD_LASTMOD=no
636 BUILD_PPOLICY=no
637 BUILD_PROXYCACHE=no
638 BUILD_REFINT=no
639 BUILD_RETCODE=no
640 BUILD_RWM=no
641 BUILD_SYNCPROV=no
642 BUILD_TRANSLUCENT=no
643 BUILD_UNIQUE=no
644
645 SLAPD_STATIC_OVERLAYS=
646 SLAPD_DYNAMIC_OVERLAYS=
647
648 SLAPD_MODULES_LDFLAGS=
649 SLAPD_MODULES_CPPFLAGS=
650
651 SLAPD_STATIC_BACKENDS=back-ldif
652 SLAPD_DYNAMIC_BACKENDS=
653
654 SLAPD_PERL_LDFLAGS=
655 MOD_PERL_LDFLAGS=
656 PERL_CPPFLAGS=
657
658 SLAPD_SQL_LDFLAGS=
659 SLAPD_SQL_LIBS=
660 SLAPD_SQL_INCLUDES=
661
662 KRB4_LIBS=
663 KRB5_LIBS=
664 SASL_LIBS=
665 TLS_LIBS=
666 MODULES_LIBS=
667 SLAPI_LIBS=
668 LIBSLAPI=
669 LIBSLAPITOOLS=
670 AUTH_LIBS=
671
672 SLAPD_SLP_LIBS=
673 SLAPD_GMP_LIBS=
674
675 dnl ================================================================
676 dnl Checks for programs
677
678 AC_DEFINE(HAVE_MKVERSION, 1, [define this if you have mkversion])
679
680 dnl ----------------------------------------------------------------
681 dnl
682 dnl Determine which C translator to use
683 dnl
684
685 dnl AIX Thread requires we use cc_r or xlc_r.
686 dnl But only do this IF AIX and CC is not set
687 dnl and threads are auto|yes|posix.
688 dnl
689 dnl If we find cc_r|xlc_r, force pthreads and assume
690 dnl             pthread_create is in $LIBS (ie: don't bring in
691 dnl             any additional thread libraries)
692 dnl If we do not find cc_r|xlc_r, disable threads
693
694 ol_aix_threads=no
695 case "$target" in
696 *-*-aix*) dnl all AIX is not a good idea.
697         if test -z "$CC" ; then
698                 case "$ol_with_threads" in
699                 auto | yes |  posix) ol_aix_threads=yes ;;
700                 esac
701         fi
702 ;;
703 esac
704
705 if test $ol_aix_threads = yes ; then
706         if test -z "${CC}" ; then
707                 AC_CHECK_PROGS(CC,cc_r xlc_r cc)
708
709                 if test "$CC" = cc ; then
710                         dnl no CC! don't allow --with-threads
711                         if test $ol_with_threads != auto ; then
712                                 AC_MSG_ERROR([--with-threads requires cc_r (or other suitable compiler) on AIX])
713                         else
714                                 AC_MSG_WARN([disabling threads, no cc_r on AIX])
715                         fi
716                         ol_with_threads=no
717                 fi
718         fi
719
720         if test "${CC}" = "cc_r" -o "${CC}" = "xlc_r" ; then
721                 ol_with_threads=posix
722                 ol_cv_pthread_create=yes
723         fi
724 fi
725
726 if test -z "${CC}"; then
727         AC_CHECK_PROGS(CC,cc gcc,missing)
728
729         if test "${CC}" = "missing" ; then
730                 AC_MSG_ERROR([Unable to locate cc(1) or suitable replacement.  Check PATH or set CC.])
731         fi
732 fi
733
734 if test -z "${AR}"; then
735         AC_CHECK_PROGS(AR,ar gar,missing)
736
737         if test "${AR}" = "missing" ; then
738                 AC_MSG_ERROR([Unable to locate ar(1) or suitable replacement.  Check PATH or set AR.])
739         fi
740 fi
741
742 AC_LIBTOOL_WIN32_DLL
743 AC_LIBTOOL_DLOPEN
744 AC_PROG_LIBTOOL
745
746 dnl ----------------------------------------------------------------
747 dnl Perl
748 ol_link_perl=no
749 if test $ol_enable_perl != no ; then
750         AC_PATH_PROG(PERLBIN, perl, /usr/bin/perl)
751
752         if test "no$PERLBIN" = "no" ; then
753                 if test $ol_enable_perl = yes ; then
754                         AC_MSG_ERROR([could not locate perl])
755                 fi
756
757         else
758                 PERL_CPPFLAGS="`$PERLBIN -MExtUtils::Embed -e ccopts`"
759                 PERL_LDFLAGS="`$PERLBIN -MExtUtils::Embed -e ldopts|sed -e 's/ -lc / /' -e 's/ -lc$//'`"
760
761                 if test x"$ol_enable_perl" = "xyes" ; then
762                         SLAPD_PERL_LDFLAGS="$PERL_LDFLAGS"
763                 else
764                         MOD_PERL_LDFLAGS="$PERL_LDFLAGS"
765                 fi
766                 dnl should check perl version
767                 ol_link_perl=yes
768         fi
769 fi
770
771 AC_PROG_CPP
772
773 dnl ----------------------------------------------------------------
774 dnl Checks for UNIX Variants
775 dnl AC_AIX
776 dnl AC_ISC_POSIX
777 dnl AC_MINIX
778
779 dnl ----------------------------------------------------------------
780 dnl Checks for file extensions
781 AC_EXEEXT
782 AC_OBJEXT
783 AC_DEFINE_UNQUOTED(EXEEXT, "${EXEEXT}", [defined to be the EXE extension])
784
785 dnl ----------------------------------------------------------------
786 dnl BeOS requires -lbe -lroot -lnet
787 AC_CHECK_LIB(be, be_app, [LIBS="$LIBS -lbe -lroot -lnet"], :, [-lroot -lnet])
788
789 dnl ----------------------------------------------------------------
790 dnl OpenLDAP requires STDC features
791 AC_PROG_CC
792 if test "X${ac_cv_prog_cc_stdc}" = "Xno" ; then
793         AC_MSG_ERROR([OpenLDAP requires compiler to support STDC constructs.])
794 fi
795
796 dnl ----------------------------------------------------------------
797 dnl Check cc depend flags
798 OL_MKDEPEND
799 if test "${ol_cv_mkdep}" = no ; then
800         # this will soon become an error
801         AC_MSG_WARN([do not know how to generate dependencies])
802 fi
803
804 dnl ----------------------------------------------------------------
805 dnl Check for AIX security library
806 AC_CHECK_LIB(s, afopen, [
807         AUTH_LIBS=-ls
808         AC_DEFINE(HAVE_AIX_SECURITY,1,[define if you have AIX security lib])
809 ])
810
811 dnl ----------------------------------------------------------------
812 dnl Check for IBM OS/390
813 case "$target" in
814 *-ibm-openedition)
815         ac_cv_func_getopt=no
816         AC_DEFINE(BOTH_STRINGS_H,1,[define to use both <string.h> and <strings.h>])
817         ;;
818 esac
819
820 dnl ----------------------------------------------------------------
821 dnl Check for module support
822 ol_link_modules=no
823 WITH_MODULES_ENABLED=no
824 if test $ol_enable_modules != no ; then
825         AC_CHECK_HEADERS(ltdl.h)
826
827         if test $ac_cv_header_ltdl_h = no ; then
828                 AC_MSG_ERROR([could not locate libtool ltdl.h])
829         fi
830
831         AC_CHECK_LIB(ltdl, lt_dlinit, [
832                 MODULES_LIBS=-lltdl
833                 AC_DEFINE(HAVE_LIBLTDL,1,[define if you have libtool -ltdl])
834         ])
835
836         if test "$ac_cv_lib_ltdl_lt_dlinit" = no ; then
837                 AC_MSG_ERROR([could not locate libtool -lltdl])
838         fi
839         ol_link_modules=yes
840         WITH_MODULES_ENABLED=yes
841
842 else
843         for i in $Backends; do
844                 eval "ol_tmp=\$ol_enable_$i"
845                 if test $ol_tmp = mod ; then
846                         AC_MSG_WARN([building static $i backend])
847                         eval "ol_enable_$i=yes"
848                 fi
849         done
850         for i in $Overlays; do
851                 eval "ol_tmp=\$ol_enable_$i"
852                 if test $ol_tmp = mod ; then
853                         AC_MSG_WARN([building static $i overlay])
854                         eval "ol_enable_$i=yes"
855                 fi
856         done
857 fi
858
859 dnl ----------------------------------------------------------------
860 dnl Checks for header files.
861 OL_HEADER_STDC
862
863 if test $ol_cv_header_stdc != yes; then
864         AC_MSG_WARN([could not locate Standard C compliant headers])
865 fi
866
867 AC_HEADER_DIRENT
868 AC_HEADER_SYS_WAIT
869 AC_HEADER_TIOCGWINSZ
870
871 AC_CHECK_HEADERS(               \
872         arpa/inet.h             \
873         arpa/nameser.h          \
874         assert.h                \
875         bits/types.h            \
876         conio.h                 \
877         crypt.h                 \
878         direct.h                \
879         errno.h                 \
880         fcntl.h                 \
881         filio.h                 \
882         getopt.h                \
883         grp.h                   \
884         io.h                    \
885         libutil.h               \
886         limits.h                \
887         locale.h                \
888         netinet/tcp.h           \
889         malloc.h                \
890         memory.h                \
891         psap.h                  \
892         pwd.h                   \
893         process.h               \
894         resolv.h                \
895         sgtty.h                 \
896         shadow.h                \
897         stddef.h                \
898         string.h                \
899         strings.h               \
900         sysexits.h              \
901         sys/file.h              \
902         sys/filio.h             \
903         sys/errno.h             \
904         sys/ioctl.h             \
905         sys/param.h             \
906         sys/resource.h          \
907         sys/select.h            \
908         sys/socket.h            \
909         sys/stat.h              \
910         sys/syslog.h            \
911         sys/time.h              \
912         sys/types.h             \
913         sys/ucred.h             \
914         sys/uio.h               \
915         syslog.h                \
916         termios.h               \
917         unistd.h                \
918         utime.h                 \
919         winsock.h               \
920         winsock2.h              \
921 )
922
923 dnl ----------------------------------------------------------------
924 dnl Checks for libraries
925
926 AC_CHECK_FUNCS( sigaction sigset )
927
928 dnl HP-UX requires -lV3
929 dnl this is not needed on newer versions of HP-UX
930 if test $ac_cv_func_sigaction = no && test $ac_cv_func_sigaction = no ; then
931         AC_CHECK_LIB(V3, sigset)
932 fi
933
934 dnl The following is INTENTIONALLY scripted out because shell does not
935 dnl support variable names with the '@' character, which is what
936 dnl autoconf would try to generate if one merely used AC_SEARCH_LIBS
937 dnl
938 dnl Skip Winsock tests on Cygwin
939 if test "$ac_cv_cygwin" != yes && test "$ac_cv_header_winsock_h" = yes; then
940 AC_CACHE_CHECK([for winsock], [ol_cv_winsock],
941 save_LIBS="$LIBS"
942 for curlib in ws2_32 wsock32; do
943         LIBS="$LIBS -l$curlib"
944         AC_TRY_LINK([#include <winsock.h>
945                         ],
946                         [
947                         socket(0,0,0);
948                         select(0,NULL,NULL,NULL,NULL);
949                         closesocket(0);
950                         gethostname(NULL,0);
951                         ],
952                         ol_cv_winsock=yes, ol_cv_winsock=no)
953
954         if test $ol_cv_winsock = yes; then
955                 AC_DEFINE(HAVE_WINSOCK, 1, [define if you have winsock])
956                 ac_cv_func_socket=yes
957                 ac_cv_func_select=yes
958                 ac_cv_func_closesocket=yes
959                 ac_cv_func_gethostname=yes
960                 if test $curlib = ws2_32; then
961                         ol_cv_winsock=winsock2
962                         AC_DEFINE(HAVE_WINSOCK2, 1,
963                                   [define if you have winsock2])
964                 fi
965                 break
966         fi
967         LIBS="$save_LIBS"
968 done)
969 fi
970
971 dnl Find socket()
972 dnl Likely combinations:
973 dnl             -lsocket [ -lnsl_s | -lnsl ]
974 dnl             -linet
975
976 AC_CHECK_FUNC(socket, :, [      
977 dnl hopefully we won't include too many libraries
978         AC_CHECK_LIB(socket, main)
979         AC_CHECK_LIB(net, main)
980         AC_CHECK_LIB(nsl_s, main)
981         AC_CHECK_LIB(nsl, main)
982         AC_CHECK_LIB(inet, socket)
983         AC_CHECK_LIB(gen, main)
984 ])
985
986 dnl require select
987 AC_CHECK_FUNC(select, :, AC_MSG_ERROR([select() required.]))
988
989 if test "${ac_cv_header_winsock_h}" != yes; then
990         dnl Select arg types
991         dnl (if this detection becomes permenent, it and the select() detection
992         dnl should be done before the yielding select test) 
993         AC_FUNC_SELECT_ARGTYPES
994 fi
995
996 dnl check to see if system call automatically restart
997 dnl AC_SYS_RESTARTABLE_SYSCALLS
998
999 dnl ----------------------------------------------------------------
1000 AC_CHECK_FUNCS( poll )
1001 AC_CHECK_HEADERS( poll.h )
1002
1003 dnl ----------------------------------------------------------------
1004 AC_CHECK_HEADERS( sys/epoll.h )
1005 if test "${ac_cv_header_sys_epoll_h}" = yes; then
1006 AC_MSG_CHECKING(for epoll system call)
1007 AC_TRY_RUN(
1008 int main(int argc, char *argv[])
1009 {
1010         int epfd = epoll_create(256);
1011         exit (epfd == -1 ? 1 : 0);
1012 }, [AC_MSG_RESULT(yes)
1013 AC_DEFINE(HAVE_EPOLL,1, [define if your system supports epoll])],
1014 AC_MSG_RESULT(no),AC_MSG_RESULT(no))
1015 fi
1016
1017 dnl ----------------------------------------------------------------
1018 # strerror checks
1019 OL_STRERROR
1020
1021 dnl ----------------------------------------------------------------
1022 dnl require POSIX regex
1023 AC_CHECK_HEADERS( regex.h )
1024 if test "$ac_cv_header_regex_h" != yes ; then
1025         AC_MSG_ERROR([POSIX regex.h required.])
1026 fi
1027 AC_SEARCH_LIBS(regfree, [regex gnuregex],
1028         :, AC_MSG_ERROR([POSIX regex required.]))
1029
1030 OL_POSIX_REGEX
1031 if test "$ol_cv_c_posix_regex" = no ; then
1032         AC_MSG_ERROR([broken POSIX regex!])
1033 fi
1034
1035 dnl ----------------------------------------------------------------
1036 dnl UUID Support
1037
1038 have_uuid=no
1039 AC_CHECK_HEADERS(sys/uuid.h)
1040 if test $ac_cv_header_sys_uuid_h = yes ; then
1041         save_LIBS="$LIBS"
1042         AC_SEARCH_LIBS(uuid_to_str, uuid, [have_uuid=yes], :)
1043         LIBS="$save_LIBS"
1044
1045         if test have_uuid = yes ; then
1046                 AC_DEFINE(HAVE_UUID_TO_STR,1,
1047                         [define if you have uuid_to_str()])
1048
1049                 test "$ac_cv_search_uuid_to_str" = "none required" || \
1050                         SLAPD_LIBS="$SLAPD_LIBS $ac_cv_search_uuid_to_str"
1051         fi
1052 fi
1053
1054 dnl For windows, check for the need of RPCRT for UUID function support
1055 if test $have_uuid = no ; then
1056         AC_MSG_CHECKING(to see if -lrpcrt4 is needed for win32 UUID support)
1057         save_LIBS="$LIBS"
1058         LIBS="$LIBS -lrpcrt4"
1059         AC_TRY_LINK([
1060                 int __stdcall UuidCreate(void *);
1061                 int __stdcall UuidToStringA(void *,void **);
1062                 ],
1063                 [
1064                 UuidCreate(0);
1065                 UuidToStringA(0,0);
1066                 ],
1067                 need_rpcrt=yes, need_rpcrt=no)
1068         if test $need_rpcrt = yes; then
1069                 SLAPD_LIBS="$SLAPD_LIBS -lrpcrt4"
1070         fi
1071         LIBS="$save_LIBS"
1072         AC_MSG_RESULT($need_rpcrt)
1073 fi
1074
1075 dnl ----------------------------------------------------------------
1076 dnl Check for resolver routines
1077 OL_RESOLVER_LINK
1078
1079 ol_link_dnssrv=no
1080 if test "$ol_cv_lib_resolver" != no ; then
1081         AC_DEFINE(HAVE_RES_QUERY,1,
1082                 [define if you have res_query()])
1083
1084         if test "$ol_enable_dnssrv" != no ; then
1085                 ol_link_dnssrv=yes
1086         fi
1087
1088         if test "$ol_cv_lib_resolver" != yes ; then
1089                 LIBS="$ol_cv_lib_resolver $LIBS"
1090         fi
1091 fi
1092
1093 if test "$ol_enable_dnssrv" = yes -o "$ol_enable_dnssrv" = mod ; then
1094         if test "$ol_link_dnssrv" = no ; then
1095                 AC_MSG_ERROR([DNSSRV requires res_query()])
1096         fi
1097 else
1098         ol_enable_dnssrv=no
1099 fi
1100
1101 AC_CHECK_FUNCS( hstrerror )
1102
1103 dnl ----------------------------------------------------------------
1104 dnl PF_INET6 support requires getaddrinfo and INET6_ADDRSTRLEN
1105 dnl PF_LOCAL may use getaddrinfo in available
1106 AC_CHECK_FUNCS( getaddrinfo getnameinfo gai_strerror inet_ntop )
1107
1108 ol_link_ipv6=no
1109 if test $ac_cv_func_getaddrinfo = no -o $ac_cv_func_inet_ntop = no ; then
1110         if test $ol_enable_ipv6 = yes ; then
1111                 AC_MSG_ERROR([IPv6 support requires getaddrinfo() and inet_ntop()])
1112         fi
1113 elif test $ol_enable_ipv6 != no ; then
1114         AC_CACHE_CHECK([INET6_ADDRSTRLEN],[ol_cv_inet6_addrstrlen],[
1115                 AC_EGREP_CPP(__has_inet6_addrstrlen__,[
1116 #                       include <netinet/in.h>
1117 #                       ifdef INET6_ADDRSTRLEN
1118                                 __has_inet6_addrstrlen__;
1119 #                       endif
1120                 ], [ol_cv_inet6_addrstrlen=yes], [ol_cv_inet6_addrstrlen=no])])
1121
1122
1123         AC_CACHE_CHECK([struct sockaddr_storage],ol_cv_struct_sockaddr_storage,[
1124                 AC_TRY_COMPILE([
1125 #include <sys/types.h>
1126 #include <sys/socket.h>
1127 ],[
1128                         struct sockaddr_storage ss;
1129 ],                      [ol_cv_struct_sockaddr_storage=yes],
1130                         [ol_cv_struct_sockaddr_storage=no])])
1131
1132         if test $ol_cv_inet6_addrstrlen = yes \
1133                 -a $ol_cv_struct_sockaddr_storage = yes ; then
1134                 ol_link_ipv6=yes
1135         elif test $ol_enable_ipv6 = yes \
1136                         -a $ol_cv_inet6_addrstrlen = no ; then
1137                 AC_MSG_ERROR([IPv6 support requires INET6_ADDRSTRLEN])
1138         elif test $ol_enable_ipv6 = yes \
1139                         -a $ol_cv_struct_sockaddr_storage = no ; then
1140                 AC_MSG_ERROR([IPv6 support requires struct sockaddr_storage])
1141         fi
1142 fi
1143
1144 if test $ol_enable_local != no ; then
1145         AC_CHECK_HEADERS( sys/un.h )
1146
1147         if test $ol_enable_local = auto ; then
1148                 ol_enable_local=$ac_cv_header_sys_un_h
1149         elif test $ac_cv_header_sys_un_h = no ; then
1150                 AC_MSG_ERROR([AF_LOCAL domain support requires sys/un.h])
1151         fi
1152 fi
1153
1154 dnl ----------------------------------------------------------------
1155 dnl Kerberos
1156 ol_link_kbind=no
1157 ol_link_krb5=no
1158 ol_link_krb4=no
1159
1160 if test $ol_with_kerberos = yes -o $ol_with_kerberos = auto \
1161         -o $ol_with_kerberos = k5 -o $ol_with_kerberos = k5only \
1162         -o $ol_with_kerberos = k425 ; then
1163
1164         AC_CHECK_HEADERS(krb5.h)
1165
1166         if test $ac_cv_header_krb5_h = yes ; then
1167                 dnl lazy check for Heimdal Kerberos
1168                 AC_CHECK_HEADERS(heim_err.h)
1169                 if test $ac_cv_header_heim_err_h = yes ; then
1170                         krb5_impl=heimdal
1171                 else
1172                         krb5_impl=mit
1173                 fi
1174
1175                 if test $krb5_impl = mit; then
1176                         AC_CHECK_LIB(k5crypto, main,
1177                                 [krb5crypto=k5crypto],
1178                                 [krb5crypto=crypto])
1179
1180                         AC_CHECK_LIB(krb5, main,
1181                                 [have_krb5=yes
1182                                 KRB5_LIBS="-lkrb5 -l$krb5crypto -lcom_err"],
1183                                 [have_krb5=no],
1184                                 [-l$krb5crypto -lcom_err])
1185
1186                 elif test $krb5_impl = heimdal; then
1187                         AC_CHECK_LIB(des, main,
1188                                 [krb5crypto=des],
1189                                 [krb5crypto=crypto])
1190
1191                         AC_CHECK_LIB(krb5, main,
1192                                 [have_krb5=yes
1193                                 KRB5_LIBS="-lkrb5 -l$krb5crypto -lasn1 -lroken -lcom_err"],
1194                                 [have_krb5=no],
1195                                 [-l$krb5crypto -lasn1 -lroken -lcom_err])
1196
1197                         AC_DEFINE(HAVE_HEIMDAL_KERBEROS, 1,
1198                                 [define if you have HEIMDAL Kerberos])
1199
1200                 else
1201                         have_krb5=no
1202                         AC_MSG_WARN([Unrecognized Kerberos5 Implementation])
1203                 fi
1204
1205                 if test $have_krb5 = yes ; then
1206                         ol_link_krb5=yes
1207
1208                         AC_DEFINE(HAVE_KRB5, 1,
1209                                 [define if you have Kerberos V])
1210
1211                         if test $ol_with_kerberos = k5only ; then
1212                                 ol_with_kerberos=found
1213                         fi
1214
1215                 elif test $ol_with_kerberos != auto ; then
1216                         AC_MSG_ERROR([Required Kerberos 5 support not available])
1217                 fi
1218
1219         fi
1220 fi
1221
1222 if test $ol_link_krb5 = yes -a \( $ol_with_kerberos = yes -o \
1223         $ol_with_kerberos = auto -o $ol_with_kerberos = k425 \) ; then
1224
1225         AC_CHECK_HEADERS(kerberosIV/krb.h kerberosIV/des.h)
1226
1227         if test $ac_cv_header_kerberosIV_krb_h = yes ; then
1228                 if test $krb5_impl = mit; then
1229                         AC_CHECK_LIB(krb4, main, [have_k425=yes
1230                                 KRB4_LIBS="-lkrb4 -ldes425"], [have_k425=no],
1231                                 [-ldes425 -lkrb5 -l$krb5crypto -lcom_err])
1232
1233                 elif test $krb5_impl = heimdal; then
1234                         AC_CHECK_LIB(krb4, main, [have_k425=yes
1235                                 KRB4_LIBS="-lkrb4"], [have_k425=no],
1236                                 [-lkrb5 -l$krb5crypto -lasn1 -lroken -lcom_err])
1237
1238                 else
1239                         have_425=no
1240                         AC_MSG_WARN([Unrecongized Kerberos V Implementation])
1241                 fi
1242
1243                 if test $have_k425 = yes ; then
1244                         ol_with_kerberos=found
1245                         ol_link_krb4=yes
1246
1247                         AC_DEFINE(HAVE_KRB425, 1,
1248                                 [define if you have Kerberos V with IV support])
1249                         AC_DEFINE(HAVE_KRB4, 1,
1250                                 [define if you have Kerberos IV])
1251
1252                         AC_CACHE_CHECK([for des_debug in Kerberos libraries],
1253                                 [ol_cv_var_des_debug], [
1254                                 dnl save the flags
1255                                 save_LIBS="$LIBS"
1256                                 LIBS="$KRB4_LIBS $KRB5_LIBS $LIBS"
1257                                 AC_TRY_LINK([
1258 #include <kerberosIV/krb.h>
1259 #include <kerberosIV/des.h>
1260 extern int des_debug;
1261 ],[
1262 des_debug = 1;
1263 ],                              ol_cv_var_des_debug=yes, ol_cv_var_des_debug=no)
1264                                 dnl restore the LIBS
1265                                 LIBS="$save_LIBS"
1266                         ])
1267
1268                         if test $ol_cv_var_des_debug = yes ; then
1269                                 AC_DEFINE(HAVE_DES_DEBUG,1,
1270                                         [define if you have Kerberos des_debug])
1271                         fi
1272
1273                         LIBS="$save_LIBS"
1274                 fi
1275         fi
1276 fi
1277
1278 if test $ol_link_krb5 = yes ; then
1279         ol_with_kerberos=found
1280 fi
1281
1282 if test $ol_with_kerberos = yes -o $ol_with_kerberos = auto \
1283         -o $ol_with_kerberos = k4 -o $ol_with_kerberos = kth ; then
1284
1285         AC_CHECK_HEADERS(krb.h des.h krb-archaeology.h )
1286
1287         if test $ac_cv_header_krb_h = yes ; then
1288                 AC_CHECK_LIB(krb, main, [have_k4=yes], [have_k4=no], [-ldes])
1289
1290                 if test $have_k4 = yes ; then
1291                         ol_with_kerberos=found
1292                         ol_link_krb4=yes
1293
1294                         AC_DEFINE(HAVE_KRB4, 1,
1295                                 [define if you have Kerberos IV])
1296
1297                         KRB4_LIBS="-lkrb -ldes"
1298
1299                         if test $ac_cv_header_krb_archaeology_h = yes ; then
1300                                 AC_DEFINE(HAVE_KTH_KERBEROS, 1,
1301                                         [define if you have Kth Kerberos])
1302                         fi
1303                 fi
1304         fi
1305 fi
1306
1307 if test $ol_link_krb4 = yes -a $ol_enable_kbind != no ; then
1308         ol_link_kbind=yes
1309
1310 elif test $ol_enable_kbind = yes ; then
1311         AC_MSG_ERROR([Kerberos IV detection failed])
1312 fi
1313
1314 if test $ol_link_krb4 = yes -o $ol_link_krb5 = yes ; then
1315         AC_DEFINE(HAVE_KERBEROS, 1, [define if you have Kerberos])
1316
1317 elif test $ol_with_kerberos != auto -a $ol_with_kerberos != no ; then
1318         AC_MSG_ERROR([Kerberos detection failed])
1319 fi
1320
1321 dnl ----------------------------------------------------------------
1322 dnl TLS/SSL
1323         
1324 ol_link_tls=no
1325 if test $ol_with_tls != no ; then
1326         AC_CHECK_HEADERS(openssl/ssl.h ssl.h)
1327
1328         if test $ac_cv_header_openssl_ssl_h = yes \
1329                 -o $ac_cv_header_ssl_h = yes ; then
1330                 AC_CHECK_LIB(ssl, SSLeay_add_ssl_algorithms, 
1331                         [have_ssleay=yes
1332                         need_rsaref=no],
1333                         [have_ssleay=no],
1334                         [-lcrypto])
1335                         
1336                 if test $have_ssleay = no ; then
1337                         AC_CHECK_LIB(ssl, SSL_library_init,
1338                                 [have_ssleay=yes
1339                                 need_rsaref=no], [have_ssleay=no],
1340                                 [-lcrypto])
1341                 fi
1342
1343                 if test $have_ssleay = no ; then
1344                         AC_CHECK_LIB(ssl, ssl3_accept, 
1345                                 [have_ssleay=yes
1346                                 need_rsaref=yes], [have_ssleay=no],
1347                                 [-lcrypto -lRSAglue -lrsaref])
1348                 fi
1349
1350                 if test $have_ssleay = yes ; then
1351                         ol_with_tls=found
1352                         ol_link_tls=yes
1353
1354                         AC_DEFINE(HAVE_SSLEAY, 1, 
1355                                 [define if you have SSLeay or OpenSSL])
1356
1357                         if test $need_rsaref = yes; then
1358                                 AC_DEFINE(HAVE_RSAREF, 1, 
1359                                         [define if you have RSAref])
1360
1361                                 TLS_LIBS="-lssl -lcrypto -lRSAglue -lrsaref"
1362                         else
1363                                 TLS_LIBS="-lssl -lcrypto"
1364                         fi
1365                 fi
1366                 OL_SSL_COMPAT
1367                 if test $ol_cv_ssl_crl_compat = no ; then
1368                         ol_link_ssl=no
1369                 else 
1370                         AC_DEFINE(HAVE_OPENSSL_CRL, 1, 
1371                                 [define if you have OpenSSL with CRL checking capability])
1372                 fi
1373         fi
1374
1375 else
1376         AC_WARN([TLS data protection not supported!])
1377 fi
1378
1379 WITH_TLS=no
1380 if test $ol_link_tls = yes ; then
1381         AC_DEFINE(HAVE_TLS, 1, [define if you have TLS])
1382         WITH_TLS=yes
1383
1384 elif test $ol_with_tls = auto ; then
1385         AC_WARN([Could not locate TLS/SSL package])
1386         AC_WARN([TLS data protection not supported!])
1387
1388 elif test $ol_with_tls != no ; then
1389         AC_ERROR([Could not locate TLS/SSL package])
1390 fi
1391
1392 dnl ----------------------------------------------------------------
1393 dnl LAN Manger password checking requires DES from OpenSSL
1394 if test $ol_enable_lmpasswd != no; then
1395         if test $ol_link_tls != yes ; then
1396                 AC_ERROR([LAN Manager passwords require OpenSSL])
1397         fi
1398
1399         AC_DEFINE(SLAPD_LMHASH, 1, [define to support LAN Manager passwords])
1400 fi
1401
1402 dnl ----------------------------------------------------------------
1403 dnl Threads?
1404 ol_link_threads=no
1405
1406 if test $ol_with_threads = auto -o $ol_with_threads = yes \
1407         -o $ol_with_threads = nt ; then
1408
1409         OL_NT_THREADS
1410
1411         if test "$ol_cv_nt_threads" = yes ; then
1412                 ol_link_threads=nt
1413                 ol_with_threads=found
1414                 ol_with_yielding_select=yes
1415
1416                 AC_DEFINE(HAVE_NT_SERVICE_MANAGER,1,[if you have NT Service Manager])
1417                 AC_DEFINE(HAVE_NT_EVENT_LOG,1,[if you have NT Event Log])
1418         fi
1419
1420         if test $ol_with_threads = nt ; then
1421                 AC_MSG_ERROR([could not locate NT Threads])
1422         fi
1423 fi
1424
1425 if test $ol_with_threads = auto -o $ol_with_threads = yes \
1426         -o $ol_with_threads = posix ; then
1427
1428         AC_CHECK_HEADERS(pthread.h)
1429
1430         if test $ac_cv_header_pthread_h = yes ; then
1431                 OL_POSIX_THREAD_VERSION
1432
1433                 if test $ol_cv_pthread_version != 0 ; then
1434                         AC_DEFINE_UNQUOTED(HAVE_PTHREADS,$ol_cv_pthread_version,
1435                                 [define to pthreads API spec revision])
1436                 else
1437                         AC_MSG_ERROR([unknown pthread version])
1438                 fi
1439
1440                 # consider threads found
1441                 ol_with_threads=found
1442
1443                 OL_HEADER_LINUX_THREADS
1444                 OL_HEADER_GNU_PTH_PTHREAD_H
1445
1446                 if test $ol_cv_header_gnu_pth_pthread_h = no ; then
1447                         AC_CHECK_HEADERS(sched.h)
1448                 fi
1449
1450                 dnl Now the hard part, how to link?
1451                 dnl
1452                 dnl currently supported checks:
1453                 dnl
1454                 dnl Check for no flags 
1455                 dnl     pthread_create() in $LIBS
1456                 dnl
1457                 dnl Check special pthread (final) flags
1458                 dnl     [skipped] pthread_create() with -mt (Solaris) [disabled]
1459                 dnl     pthread_create() with -kthread (FreeBSD)
1460                 dnl     pthread_create() with -pthread (FreeBSD/Digital Unix)
1461                 dnl     pthread_create() with -pthreads (?)
1462                 dnl     pthread_create() with -mthreads (AIX)
1463                 dnl     pthread_create() with -thread (?)
1464                 dnl
1465                 dnl Check pthread (final) libraries
1466                 dnl     pthread_mutex_unlock() in -lpthread -lmach -lexc -lc_r (OSF/1)
1467                 dnl     pthread_mutex_lock() in -lpthread -lmach -lexc (OSF/1)
1468                 dnl     [skipped] pthread_mutex_trylock() in -lpthread -lexc (OSF/1)
1469                 dnl     pthread_join() -Wl,-woff,85 -lpthread (IRIX)
1470                 dnl     pthread_create() in -lpthread (many)
1471                 dnl     pthread_create() in -lc_r (FreeBSD)
1472                 dnl
1473                 dnl Check pthread (draft4) flags (depreciated)
1474                 dnl     pthread_create() with -threads (OSF/1)
1475                 dnl
1476                 dnl Check pthread (draft4) libraries (depreciated)
1477                 dnl     pthread_mutex_unlock() in -lpthreads -lmach -lexc -lc_r (OSF/1)
1478                 dnl     pthread_mutex_lock() in -lpthreads -lmach -lexc (OSF/1)
1479                 dnl     pthread_mutex_trylock() in -lpthreads -lexc (OSF/1)
1480                 dnl     pthread_create() in -lpthreads (many)
1481                 dnl
1482
1483                 dnl pthread_create in $LIBS
1484                 AC_CACHE_CHECK([for pthread_create in default libraries],
1485                         ol_cv_pthread_create,[
1486                 AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
1487                         [ol_cv_pthread_create=yes],
1488                         [ol_cv_pthread_create=no],
1489                         [AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
1490                                 [ol_cv_pthread_create=yes],
1491                                 [ol_cv_pthread_create=no])])])
1492
1493                 if test $ol_cv_pthread_create != no ; then
1494                         ol_link_threads=posix
1495                         ol_link_pthreads=""
1496                 fi
1497                 
1498 dnl             OL_PTHREAD_TRY([-mt],           [ol_cv_pthread_mt])
1499                 OL_PTHREAD_TRY([-kthread],      [ol_cv_pthread_kthread])
1500                 OL_PTHREAD_TRY([-pthread],      [ol_cv_pthread_pthread])
1501                 OL_PTHREAD_TRY([-pthreads],     [ol_cv_pthread_pthreads])
1502                 OL_PTHREAD_TRY([-mthreads],     [ol_cv_pthread_mthreads])
1503                 OL_PTHREAD_TRY([-thread],       [ol_cv_pthread_thread])
1504
1505                 OL_PTHREAD_TRY([-lpthread -lmach -lexc -lc_r],
1506                         [ol_cv_pthread_lpthread_lmach_lexc_lc_r])
1507                 OL_PTHREAD_TRY([-lpthread -lmach -lexc],
1508                         [ol_cv_pthread_lpthread_lmach_lexc])
1509 dnl             OL_PTHREAD_TRY([-lpthread -lexc],
1510 dnl                     [ol_cv_pthread_lpthread_lexc])
1511
1512                 OL_PTHREAD_TRY([-lpthread -Wl,-woff,85],
1513                         [ol_cv_pthread_lib_lpthread_woff])
1514
1515                 OL_PTHREAD_TRY([-lpthread],     [ol_cv_pthread_lpthread])
1516                 OL_PTHREAD_TRY([-lc_r],         [ol_cv_pthread_lc_r])
1517
1518                 OL_PTHREAD_TRY([-threads],      [ol_cv_pthread_threads])
1519
1520                 OL_PTHREAD_TRY([-lpthreads -lmach -lexc -lc_r],
1521                         [ol_cv_pthread_lpthreads_lmach_lexc_lc_r])
1522                 OL_PTHREAD_TRY([-lpthreads -lmach -lexc],
1523                         [ol_cv_pthread_lpthreads_lmach_lexc])
1524                 OL_PTHREAD_TRY([-lpthreads -lexc],
1525                         [ol_cv_pthread_lpthreads_lexc])
1526
1527                 OL_PTHREAD_TRY([-lpthreads],[ol_cv_pthread_lib_lpthreads])
1528
1529                 if test $ol_link_threads != no ; then
1530                         LTHREAD_LIBS="$LTHREAD_LIBS $ol_link_pthreads"
1531
1532                         dnl save flags
1533                         save_CPPFLAGS="$CPPFLAGS"
1534                         save_LIBS="$LIBS"
1535                         LIBS="$LTHREAD_LIBS $LIBS"
1536
1537                         dnl All POSIX Thread (final) implementations should have
1538                         dnl sched_yield instead of pthread yield.
1539                         dnl check for both, and thr_yield for Solaris
1540                         AC_CHECK_FUNCS(sched_yield pthread_yield thr_yield)
1541
1542                         if test $ac_cv_func_sched_yield = no -a \
1543                                 $ac_cv_func_pthread_yield = no -a \
1544                                 $ac_cv_func_thr_yield = no ; then
1545                                 dnl Digital UNIX has sched_yield() in -lrt
1546                                 AC_CHECK_LIB(rt, sched_yield,
1547                                         [LTHREAD_LIBS="$LTHREAD_LIBS -lrt"
1548                                         AC_DEFINE(HAVE_SCHED_YIELD,1,
1549                                                 [Define if you have the sched_yield function.])
1550                                         ac_cv_func_sched_yield=yes],
1551                                         [ac_cv_func_sched_yield=no])
1552                         fi
1553                         if test $ac_cv_func_sched_yield = no -a \
1554                                 $ac_cv_func_pthread_yield = no -a \
1555                                 "$ac_cv_func_thr_yield" = no ; then
1556                                 AC_MSG_WARN([could not locate sched_yield() or pthread_yield()])
1557                         fi
1558
1559                         dnl Check functions for compatibility
1560                         AC_CHECK_FUNCS(pthread_kill pthread_rwlock_destroy)
1561
1562                         dnl Check for pthread_detach with <pthread.h> inclusion
1563                         dnl as it's symbol may have been mangled.
1564                         AC_CACHE_CHECK([for pthread_detach with <pthread.h>],
1565                                 [ol_cv_func_pthread_detach], [
1566                                 dnl save the flags
1567                                 AC_TRY_LINK([
1568 #include <pthread.h>
1569 #ifndef NULL
1570 #define NULL (void*)0
1571 #endif
1572 ],
1573                                         [pthread_detach(NULL);],
1574                                         [ol_cv_func_pthread_detach=yes],
1575                                         [ol_cv_func_pthread_detach=no])
1576                         ])
1577
1578                         if test $ol_cv_func_pthread_detach = no ; then
1579                                 AC_MSG_ERROR([could not locate pthread_detach()])
1580                         fi
1581
1582                         AC_DEFINE(HAVE_PTHREAD_DETACH,1,
1583                                 [define if you have pthread_detach function])
1584
1585                         dnl Check for setconcurreny functions
1586                         AC_CHECK_FUNCS( \
1587                                 pthread_setconcurrency \
1588                                 pthread_getconcurrency \
1589                                 thr_setconcurrency \
1590                                 thr_getconcurrency \
1591                         )
1592
1593                         OL_SYS_LINUX_THREADS
1594                         OL_LINUX_THREADS
1595
1596                         if test $ol_cv_linux_threads = error; then
1597                                 AC_MSG_ERROR([LinuxThreads header/library mismatch]);
1598                         fi
1599
1600                         AC_CACHE_CHECK([if pthread_create() works],
1601                                 ol_cv_pthread_create_works,[
1602                         AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
1603                                 [ol_cv_pthread_create_works=yes],
1604                                 [ol_cv_pthread_create_works=no],
1605                                 [dnl assume yes
1606                                 ol_cv_pthread_create_works=yes])])
1607
1608                         if test $ol_cv_pthread_create_works = no ; then
1609                                 AC_MSG_ERROR([pthread_create is not usable, check environment settings])
1610                         fi
1611
1612                         dnl Check if select causes an yield
1613                         if test $ol_with_yielding_select = auto ; then
1614                                 AC_CACHE_CHECK([if select yields when using pthreads],
1615                                         ol_cv_pthread_select_yields,[
1616                                 AC_TRY_RUN([
1617 #include <sys/types.h>
1618 #include <sys/time.h>
1619 #include <unistd.h>
1620 #include <pthread.h>
1621 #ifndef NULL
1622 #define NULL (void*) 0
1623 #endif
1624
1625 static int fildes[2];
1626
1627 static void *task(p)
1628         void *p;
1629 {
1630         int i;
1631         struct timeval tv;
1632
1633         fd_set rfds;
1634
1635         tv.tv_sec=10;
1636         tv.tv_usec=0;
1637
1638         FD_ZERO(&rfds);
1639         FD_SET(fildes[0], &rfds);
1640
1641         /* we're not interested in any fds */
1642         i = select(FD_SETSIZE, &rfds, NULL, NULL, &tv);
1643
1644         if(i < 0) {
1645                 perror("select");
1646                 exit(10);
1647         }
1648
1649         exit(0); /* if we exit here, the select blocked the whole process */
1650 }
1651
1652 int main(argc, argv)
1653         int argc;
1654         char **argv;
1655 {
1656         pthread_t t;
1657
1658         /* create a pipe to select */
1659         if(pipe(&fildes[0])) {
1660                 perror("select");
1661                 exit(1);
1662         }
1663
1664 #ifdef HAVE_PTHREAD_SETCONCURRENCY
1665         (void) pthread_setconcurrency(2);
1666 #else
1667 #ifdef HAVE_THR_SETCONCURRENCY
1668         /* Set Solaris LWP concurrency to 2 */
1669         thr_setconcurrency(2);
1670 #endif
1671 #endif
1672
1673 #if HAVE_PTHREADS < 6
1674         pthread_create(&t, pthread_attr_default, task, NULL);
1675 #else
1676         pthread_create(&t, NULL, task, NULL);
1677 #endif
1678
1679         /* make sure task runs first */
1680 #if HAVE_THR_YIELD
1681         thr_yield();
1682 #elif defined( HAVE_SCHED_YIELD )
1683         sched_yield();
1684 #elif defined( HAVE_PTHREAD_YIELD )
1685         pthread_yield();
1686 #endif
1687
1688         exit(2);
1689 }],
1690                                 [ol_cv_pthread_select_yields=no],
1691                                 [ol_cv_pthread_select_yields=yes],
1692                                 [ol_cv_pthread_select_yields=cross])])
1693
1694                                 if test $ol_cv_pthread_select_yields = cross ; then
1695                                         AC_MSG_ERROR([crossing compiling: use --with-yielding_select=yes|no|manual])
1696                                 fi
1697
1698                                 if test $ol_cv_pthread_select_yields = yes ; then
1699                                         ol_with_yielding_select=yes
1700                                 fi
1701                         fi
1702
1703                         dnl restore flags
1704                         CPPFLAGS="$save_CPPFLAGS"
1705                         LIBS="$save_LIBS"
1706                 else
1707                         AC_MSG_ERROR([could not locate usable POSIX Threads])
1708                 fi
1709         fi
1710
1711         if test $ol_with_threads = posix ; then
1712                 AC_MSG_ERROR([could not locate POSIX Threads])
1713         fi
1714 fi
1715
1716 if test $ol_with_threads = auto -o $ol_with_threads = yes \
1717         -o $ol_with_threads = mach ; then
1718
1719         dnl check for Mach CThreads
1720         AC_CHECK_HEADERS(mach/cthreads.h cthreads.h)
1721         if test $ac_cv_header_mach_cthreads_h = yes ; then
1722                 ol_with_threads=found
1723
1724                 dnl check for cthreads support in current $LIBS
1725                 AC_CHECK_FUNC(cthread_fork,[ol_link_threads=yes])
1726
1727                 if test $ol_link_threads = no ; then
1728                         dnl try -all_load
1729                         dnl this test needs work
1730                         AC_CACHE_CHECK([for cthread_fork with -all_load],
1731                                 [ol_cv_cthread_all_load], [
1732                                 dnl save the flags
1733                                 save_LIBS="$LIBS"
1734                                 LIBS="-all_load $LIBS"
1735                                 AC_TRY_LINK([#include <mach/cthreads.h>],[
1736                                         cthread_fork((void *)0, (void *)0);
1737                                         ], ol_cv_cthread_all_load=yes, ol_cv_cthread_all_load=no)
1738                                 dnl restore the LIBS
1739                                 LIBS="$save_LIBS"
1740                         ])
1741
1742                         if test $ol_cv_cthread_all_load = yes ; then
1743                                 LTHREAD_LIBS="$LTHREAD_LIBS -all_load"
1744                                 ol_link_threads=mach
1745                                 ol_with_threads=found
1746                         fi
1747                 fi
1748
1749         elif test $ac_cv_header_cthreads_h = yes ; then
1750                 dnl Hurd variant of Mach Cthreads
1751                 dnl uses <cthreads.h> and -lthreads
1752
1753                 ol_with_threads=found
1754  
1755                 dnl save the flags
1756                 save_LIBS="$LIBS"
1757                 LIBS="$LIBS -lthreads"
1758                 AC_CHECK_FUNC(cthread_fork,[ol_link_threads=yes])
1759                 LIBS="$save_LIBS"
1760
1761                 if test $ol_link_threads = yes ; then
1762                         LTHREAD_LIBS="-lthreads"
1763                         ol_link_threads=mach
1764                         ol_with_threads=found
1765                 else
1766                         AC_MSG_ERROR([could not link with Mach CThreads])
1767                 fi
1768
1769         elif test $ol_with_threads = mach ; then
1770                 AC_MSG_ERROR([could not locate Mach CThreads])
1771         fi
1772
1773         if test $ol_link_threads = mach ; then
1774                 AC_DEFINE(HAVE_MACH_CTHREADS,1,
1775                         [define if you have Mach Cthreads])
1776         elif test $ol_with_threads = found ; then
1777                 AC_MSG_ERROR([could not link with Mach CThreads])
1778         fi
1779 fi
1780
1781 if test $ol_with_threads = auto -o $ol_with_threads = yes \
1782         -o $ol_with_threads = pth ; then
1783
1784         AC_CHECK_HEADERS(pth.h)
1785
1786         if test $ac_cv_header_pth_h = yes ; then
1787                 AC_CHECK_LIB(pth, pth_version, [have_pth=yes], [have_pth=no])
1788
1789                 if test $have_pth = yes ; then
1790                         AC_DEFINE(HAVE_GNU_PTH,1,[if you have GNU Pth])
1791                         LTHREAD_LIBS="$LTHREAD_LIBS -lpth"
1792                         ol_link_threads=pth
1793                         ol_with_threads=found
1794
1795                         if test $ol_with_yielding_select = auto ; then
1796                                 ol_with_yielding_select=yes
1797                         fi
1798                 fi
1799         fi
1800 fi
1801
1802 if test $ol_with_threads = auto -o $ol_with_threads = yes \
1803         -o $ol_with_threads = lwp ; then
1804
1805         dnl check for SunOS5 LWP
1806         AC_CHECK_HEADERS(thread.h synch.h)
1807         if test $ac_cv_header_thread_h = yes -a $ac_cv_header_synch_h = yes ; then
1808                 AC_CHECK_LIB(thread, thr_create, [have_thr=yes], [have_thr=no])
1809
1810                 if test $have_thr = yes ; then
1811                         AC_DEFINE(HAVE_THR,1,
1812                                 [if you have Solaris LWP (thr) package])
1813                         LTHREAD_LIBS="$LTHREAD_LIBS -lthread"
1814                         ol_link_threads=thr
1815
1816                         if test $ol_with_yielding_select = auto ; then
1817                                 ol_with_yielding_select=yes
1818                         fi
1819
1820                         dnl Check for setconcurreny functions
1821                         AC_CHECK_FUNCS( \
1822                                 thr_setconcurrency \
1823                                 thr_getconcurrency \
1824                         )
1825                 fi
1826         fi
1827
1828         dnl check for SunOS4 LWP
1829         AC_CHECK_HEADERS(lwp/lwp.h)
1830         if test $ac_cv_header_lwp_lwp_h = yes ; then
1831                 AC_CHECK_LIB(lwp, lwp_create, [have_lwp=yes], [have_lwp=no])
1832
1833                 if test $have_lwp = yes ; then
1834                         AC_DEFINE(HAVE_LWP,1,
1835                                 [if you have SunOS LWP package])
1836                         LTHREAD_LIBS="$LTHREAD_LIBS -llwp"
1837                         ol_link_threads=lwp
1838
1839                         if test $ol_with_yielding_select = auto ; then
1840                                 ol_with_yielding_select=no
1841                         fi
1842                 fi
1843         fi
1844 fi
1845
1846 if test $ol_with_yielding_select = yes ; then
1847         AC_DEFINE(HAVE_YIELDING_SELECT,1,
1848                 [define if select implicitly yields])
1849 fi
1850
1851 if test $ol_with_threads = manual ; then
1852         dnl User thinks he can manually configure threads.
1853         ol_link_threads=yes
1854
1855         AC_MSG_WARN([thread defines and link options must be set manually])
1856
1857         AC_CHECK_HEADERS(pthread.h sched.h)
1858         AC_CHECK_FUNCS(sched_yield pthread_yield)
1859         OL_HEADER_LINUX_THREADS
1860
1861         AC_CHECK_HEADERS(mach/cthreads.h)
1862         AC_CHECK_HEADERS(lwp/lwp.h)
1863         AC_CHECK_HEADERS(thread.h synch.h)
1864 fi
1865
1866 if test $ol_link_threads != no -a $ol_link_threads != nt ; then  
1867         dnl needed to get reentrant/threadsafe versions
1868         dnl
1869         AC_DEFINE(REENTRANT,1)
1870         AC_DEFINE(_REENTRANT,1)
1871         AC_DEFINE(THREAD_SAFE,1)
1872         AC_DEFINE(_THREAD_SAFE,1)
1873         AC_DEFINE(THREADSAFE,1)
1874         AC_DEFINE(_THREADSAFE,1)
1875         AC_DEFINE(_SGI_MP_SOURCE,1)
1876
1877         dnl The errno declaration may dependent upon _REENTRANT.
1878         dnl If it does, we must link with thread support.
1879         AC_CACHE_CHECK([for thread specific errno],
1880                 [ol_cv_errno_thread_specific], [
1881                 AC_TRY_LINK([#include <errno.h>], [errno = 0;],
1882                         [ol_cv_errno_thread_specific=yes],
1883                         [ol_cv_errno_thread_specific=no])
1884         ])
1885
1886         dnl The h_errno declaration may dependent upon _REENTRANT.
1887         dnl If it does, we must link with thread support.
1888         AC_CACHE_CHECK([for thread specific h_errno],
1889                 [ol_cv_h_errno_thread_specific], [
1890                 AC_TRY_LINK([#include <netdb.h>], [h_errno = 0;],
1891                         [ol_cv_h_errno_thread_specific=yes],
1892                         [ol_cv_h_errno_thread_specific=no])
1893         ])
1894
1895         if test $ol_cv_errno_thread_specific != yes \
1896                 -o $ol_cv_h_errno_thread_specific != yes ; then
1897                 LIBS="$LTHREAD_LIBS $LIBS"
1898                 LTHREAD_LIBS=""
1899         fi
1900
1901 dnl When in thread environment, use 
1902 dnl             #if defined( HAVE_REENTRANT_FUNCTIONS ) || defined( HAVE_FUNC_R )
1903 dnl                     func_r(...);
1904 dnl             #else
1905 dnl             #       if defined( HAVE_THREADS ) 
1906 dnl                             /* lock */
1907 dnl             #       endif
1908 dnl                             func(...);
1909 dnl             #       if defined( HAVE_THREADS ) 
1910 dnl                             /* unlock */
1911 dnl             #       endif
1912 dnl             #endif
1913 dnl
1914 dnl HAVE_REENTRANT_FUNCTIONS is derived from:
1915 dnl             _POSIX_REENTRANT_FUNCTIONS
1916 dnl             _POSIX_THREAD_SAFE_FUNCTIONS
1917 dnl             _POSIX_THREADSAFE_FUNCTIONS
1918 dnl
1919 dnl             and is currently defined in <ldap_pvt_thread.h>
1920 dnl
1921 dnl HAVE_THREADS is defined by <ldap_pvt_thread.h> iff -UNO_THREADS
1922 dnl 
1923 dnl libldap/*.c should only include <ldap_pvt_thread.h> iff
1924 dnl LDAP_R_COMPILE is defined.  ie:
1925 dnl             #ifdef LDAP_R_COMPILE
1926 dnl             #       include <ldap_pvt_thread.h>
1927 dnl             #endif
1928 dnl
1929 dnl LDAP_R_COMPILE is defined by libldap_r/Makefile.in
1930 dnl specifically for compiling the threadsafe version of
1931 dnl     the ldap library (-lldap_r).
1932 dnl             
1933 dnl     dnl check for reentrant/threadsafe functions
1934 dnl     dnl
1935 dnl     dnl note: these should only be used when linking
1936 dnl     dnl             with $LTHREAD_LIBS
1937 dnl     dnl
1938 dnl     save_CPPFLAGS="$CPPFLAGS"
1939 dnl     save_LIBS="$LIBS"
1940 dnl     LIBS="$LTHREAD_LIBS $LIBS"
1941 dnl     AC_CHECK_FUNCS( \
1942 dnl             gmtime_r \
1943 dnl             gethostbyaddr_r gethostbyname_r \
1944 dnl             feof_unlocked unlocked_feof \
1945 dnl             putc_unlocked unlocked_putc \
1946 dnl             flockfile ftrylockfile \
1947 dnl     )
1948 dnl     CPPFLAGS="$save_CPPFLAGS"
1949 dnl     LIBS="$save_LIBS"
1950 fi  
1951
1952 if test $ol_link_threads = no ; then
1953         if test $ol_with_threads = yes ; then
1954                 AC_MSG_ERROR([no suitable thread support])
1955         fi
1956
1957         if test $ol_with_threads = auto ; then
1958                 AC_MSG_WARN([no suitable thread support, disabling threads])
1959                 ol_with_threads=no
1960         fi
1961
1962         AC_DEFINE(NO_THREADS,1,
1963                 [define if you have (or want) no threads])
1964         LTHREAD_LIBS=""
1965 fi
1966
1967 if test $ol_link_threads != no ; then
1968         AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE,1)
1969 fi
1970
1971 dnl ----------------------------------------------------------------
1972 dnl Tests for reentrant functions necessary to build -lldap_r
1973 AC_CHECK_FUNCS(         \
1974         ctime_r                 \
1975         gethostbyname_r gethostbyaddr_r \
1976 )
1977
1978 if test "$ac_cv_func_ctime_r" = no ; then
1979         ol_cv_func_ctime_r_nargs=0
1980 else
1981         OL_FUNC_CTIME_R_NARGS
1982 dnl     OL_FUNC_CTIME_R_TYPE
1983 fi
1984
1985 if test "$ac_cv_func_gethostbyname_r" = yes ; then
1986         OL_FUNC_GETHOSTBYNAME_R_NARGS
1987 else
1988         ol_cv_func_gethostbyname_r_nargs=0
1989 fi
1990  
1991 if test "$ac_cv_func_gethostbyaddr_r" = yes ; then
1992         OL_FUNC_GETHOSTBYADDR_R_NARGS
1993 else
1994         ol_cv_func_gethostbyaddr_r_nargs=0
1995 fi
1996
1997 dnl ----------------------------------------------------------------
1998 ol_link_ldbm=no 
1999
2000 if test $ol_with_ldbm_api = auto \
2001         -o $ol_with_ldbm_api = berkeley \
2002         -o $ol_with_ldbm_api = bcompat ; then
2003
2004         if test $ol_with_ldbm_api = bcompat; then \
2005                 OL_BERKELEY_COMPAT_DB
2006         else
2007                 OL_BERKELEY_DB
2008         fi
2009
2010         if test $ol_cv_berkeley_db != no ; then
2011                 AC_DEFINE(HAVE_BERKELEY_DB,1,
2012                         [define this if Berkeley DB is available])
2013
2014                 ol_link_ldbm=berkeley
2015                 ol_with_ldbm_api=berkeley
2016
2017                 if test $ol_with_ldbm_type = hash ; then
2018                         AC_DEFINE(LDBM_USE_DBHASH,1,
2019                                 [define this to use DBHASH w/ LDBM backend])
2020                 else
2021                         AC_DEFINE(LDBM_USE_DBBTREE,1,
2022                                 [define this to use DBBTREE w/ LDBM backend])
2023                 fi
2024
2025                 dnl $ol_cv_lib_db should be yes or -ldb
2026                 dnl (it could be no, but that would be an error
2027                 if test $ol_cv_lib_db != yes ; then
2028                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_db"
2029                 fi
2030         fi
2031 fi
2032
2033 if test $ol_enable_bdb != no -o $ol_enable_hdb != no; then
2034         if test $ol_link_ldbm != berkeley ; then
2035                 AC_MSG_ERROR(BDB/HDB: BerkeleyDB not available)
2036         else
2037                 OL_BDB_COMPAT
2038
2039                 if test $ol_cv_bdb_compat != yes ; then
2040                         AC_MSG_ERROR([BDB/HDB: BerkeleyDB version incompatible])
2041                 fi
2042         fi
2043 fi
2044
2045 if test $ol_link_ldbm = no -a $ol_with_ldbm_type = btree ; then
2046         AC_MSG_WARN([Could not find LDBM with BTREE support])
2047         ol_with_ldbm_api=none
2048 fi
2049
2050 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = mdbm ; then
2051         OL_MDBM
2052
2053         if test $ol_cv_mdbm = yes ; then
2054                 ol_link_ldbm=mdbm
2055                 ol_with_ldbm_api=mdbm
2056                 if test $ol_cv_lib_mdbm != yes ; then
2057                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_mdbm"
2058                 fi
2059         fi
2060 fi
2061
2062 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = gdbm ; then
2063         OL_GDBM
2064
2065         if test $ol_cv_gdbm = yes ; then
2066                 ol_link_ldbm=gdbm
2067                 ol_with_ldbm_api=gdbm
2068
2069                 if test $ol_cv_lib_gdbm != yes ; then
2070                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_gdbm"
2071                 fi
2072         fi
2073 fi
2074
2075 if test $ol_with_ldbm_api = ndbm ; then
2076         OL_NDBM
2077
2078         if test $ol_cv_ndbm = yes ; then
2079                 ol_link_ldbm=ndbm
2080                 ol_with_ldbm_api=ndbm
2081
2082                 if test $ol_cv_lib_ndbm != yes ; then
2083                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_ndbm"
2084                 fi
2085         fi
2086 fi
2087
2088 if test $ol_link_ldbm = no -a $ol_enable_ldbm != no ; then
2089         AC_MSG_ERROR([could not find suitable LDBM backend])
2090 fi
2091
2092 if test $ol_enable_bdb = yes -o \
2093         $ol_enable_hdb = yes -o \
2094         $ol_enable_ldbm = yes ; then
2095         SLAPD_LIBS="$SLAPD_LIBS \$(LDBM_LIBS)"
2096 fi
2097
2098 dnl ----------------------------------------------------------------
2099
2100 if test $ol_enable_dynamic = yes -a $enable_shared = yes ; then
2101         BUILD_LIBS_DYNAMIC=shared
2102         AC_DEFINE(LDAP_LIBS_DYNAMIC, 1, [define if LDAP libs are dynamic])
2103         LTSTATIC=""
2104 else
2105         BUILD_LIBS_DYNAMIC=static
2106         LTSTATIC="-static"
2107 fi
2108 AC_SUBST(LTSTATIC)dnl
2109
2110 dnl ----------------------------------------------------------------
2111 if test $ol_enable_wrappers != no ; then
2112         AC_CHECK_HEADERS(tcpd.h,[
2113                 AC_MSG_CHECKING([for TCP wrappers library])
2114                 save_LIBS="$LIBS"
2115                 LIBS="$LIBS -lwrap"
2116                 AC_TRY_LINK([
2117 #include <tcpd.h>
2118 int allow_severity = 0;
2119 int deny_severity  = 0;
2120
2121 struct request_info *req;
2122                 ],[
2123 hosts_access(req)
2124                 ],[AC_MSG_RESULT([-lwrap])
2125                 have_wrappers=yes
2126                 LIBS="$save_LIBS"],[
2127                 dnl try with -lnsl
2128                 LIBS="$LIBS -lnsl"
2129                 AC_TRY_LINK([
2130 #include <tcpd.h>
2131 int allow_severity = 0;
2132 int deny_severity  = 0;
2133
2134 struct request_info *req;
2135                 ],[
2136 hosts_access(req)
2137                 ],[AC_MSG_RESULT([-lwrap -lnsl])
2138                 have_wrappers=yes
2139                 LIBS="$save_LIBS -lnsl"],[
2140                 AC_MSG_RESULT(no)
2141                 have_wrappers=no
2142                 LIBS=$save_LIBS])],[
2143                 have_wrappers=no])],[have_wrappers=no])
2144
2145         if test $have_wrappers = yes ; then
2146                 AC_DEFINE(HAVE_TCPD,1, [define if you have -lwrap])
2147                 WRAP_LIBS="-lwrap"
2148         elif test $ol_enable_wrappers = yes ; then
2149                 AC_MSG_ERROR([could not find TCP wrappers, select apppropriate options or disable])
2150         else
2151                 AC_MSG_WARN([could not find TCP wrappers, support disabled])
2152                 WRAP_LIBS=""
2153         fi
2154 fi
2155
2156 dnl ----------------------------------------------------------------
2157 if test $ol_enable_syslog != no ; then
2158         AC_CHECK_FUNC(openlog)
2159         if test $ac_cv_func_openlog = no -a $ol_enable_syslog = yes; then
2160                 AC_MSG_ERROR(could not find syslog, select appropriate options or disable)
2161         fi
2162         ol_enable_syslog=$ac_cv_func_openlog
2163 fi
2164
2165 dnl ----------------------------------------------------------------
2166 dnl dmalloc support (deprecated in favor of -DCSRIMALLOC support)
2167 dnl if test $ol_enable_dmalloc != no ; then
2168 dnl     AC_CHECK_HEADERS(dmalloc.h)
2169 dnl     AC_CHECK_LIB(dmalloc, dmalloc_shutdown)
2170 dnl fi
2171
2172 dnl ----------------------------------------------------------------
2173 dnl SQL
2174 ol_link_sql=no
2175 if test $ol_enable_sql != no ; then
2176         AC_CHECK_HEADERS(sql.h sqlext.h,[],[
2177                 AC_MSG_ERROR([could not locate SQL headers])
2178         ])
2179
2180         sql_LIBS="$LIBS"
2181         LIBS="$LTHREAD_LIBS"
2182
2183         AC_CHECK_LIB(iodbc,SQLDriverConnect,[have_iodbc=yes],[have_iodbc=no])
2184         if test $have_iodbc = yes ; then
2185                 ol_link_sql="-liodbc"
2186         else
2187                 AC_CHECK_LIB(odbc,SQLDriverConnect,[have_odbc=yes],[have_odbc=no])
2188                 if test $have_odbc = yes ; then
2189                         ol_link_sql="-lodbc"
2190                 fi
2191         fi
2192
2193         LIBS="$sql_LIBS"
2194
2195         if test $ol_link_sql != no ; then
2196                 SLAPD_SQL_LIBS="$ol_link_sql"
2197
2198         elif test $ol_enable_sql != auto ; then
2199                 AC_MSG_ERROR([could not locate suitable ODBC library])
2200         fi
2201 fi
2202
2203 dnl ----------------------------------------------------------------
2204 dnl
2205 dnl Check for Cyrus SASL
2206 dnl
2207 WITH_SASL=no
2208 ol_link_sasl=no
2209 ol_link_spasswd=no
2210 if test $ol_with_cyrus_sasl != no ; then
2211         AC_CHECK_HEADERS(sasl/sasl.h sasl.h)
2212
2213         if test $ac_cv_header_sasl_sasl_h = yes -o $ac_cv_header_sasl_h = yes; then
2214                 AC_CHECK_LIB(sasl2, sasl_client_init,
2215                         [ol_link_sasl="-lsasl2"],
2216                         [AC_CHECK_LIB(sasl, sasl_client_init,
2217                                 [ol_link_sasl="-lsasl"])])
2218         fi
2219
2220         if test $ol_link_sasl = no ; then
2221                 if test $ol_with_cyrus_sasl != auto ; then
2222                         AC_MSG_ERROR([Could not locate Cyrus SASL])
2223                 else
2224                         AC_MSG_WARN([Could not locate Cyrus SASL])
2225                         AC_MSG_WARN([SASL authentication not supported!])
2226                         if test $ol_link_tls = no ; then
2227                                 AC_MSG_WARN([Strong authentication not supported!])
2228                         fi
2229                 fi
2230         else
2231                 OL_SASL_COMPAT
2232                 if test $ol_cv_sasl_compat = no ; then
2233                         ol_link_sasl=no
2234                         AC_MSG_ERROR([Cyrus SASL library located but is incompatible])
2235                 fi
2236
2237                 AC_DEFINE(HAVE_CYRUS_SASL,1,[define if you have Cyrus SASL])
2238                 SASL_LIBS="$ol_link_sasl"
2239                 if test $ol_enable_spasswd != no ; then
2240                         ol_link_spasswd=yes
2241                 fi
2242
2243                 ac_save_LIBS="$LIBS"
2244                 LIBS="$LIBS $ol_link_sasl"
2245                 AC_CHECK_FUNC(sasl_version, [AC_DEFINE(HAVE_SASL_VERSION,1,
2246                         [define if your SASL library has sasl_version()])])
2247                 LIBS="$ac_save_LIBS"
2248
2249                 WITH_SASL=yes
2250         fi
2251
2252 else
2253         AC_MSG_WARN([SASL authentication not supported!])
2254         if test $ol_link_tls = no ; then
2255                 AC_MSG_WARN([Strong authentication not supported!])
2256         fi
2257 fi
2258
2259 dnl ----------------------------------------------------------------
2260 dnl Check for entropy sources
2261 if test $cross_compiling != yes -a "$ac_cv_mingw32" != yes ; then
2262         dev=no
2263         if test -r /dev/urandom ; then
2264                 dev="/dev/urandom";
2265         elif test -r /idev/urandom ; then
2266                 dev="/idev/urandom";
2267         elif test -r /dev/srandom ; then
2268                 dev="/dev/srandom";
2269         elif test -r /dev/random ; then
2270                 dev="/dev/random";
2271         elif test -r /idev/random ; then
2272                 dev="/idev/random";
2273         fi
2274
2275         if test $dev != no ; then
2276                 AC_DEFINE_UNQUOTED(URANDOM_DEVICE,"$dev",[set to urandom device])
2277         fi
2278 fi
2279
2280 dnl ----------------------------------------------------------------
2281 dnl
2282 dnl Check for fetch URL support
2283 dnl             should be extended to support other fetch URL APIs
2284 dnl
2285 ol_link_fetch=no
2286 if test $ol_with_fetch != no ; then
2287         OL_LIB_FETCH
2288
2289         if test $ol_cv_lib_fetch != no ; then
2290                 LUTIL_LIBS="$LUTIL_LIBS $ol_link_fetch"
2291                 ol_link_fetch=freebsd
2292
2293         elif test $ol_with_fetch != auto ; then
2294                 AC_MSG_ERROR(no suitable API for --with-fetch=$ol_with_fetch)
2295         fi 
2296 fi
2297
2298 dnl ----------------------------------------------------------------
2299 dnl FreeBSD (and others) have crypt(3) in -lcrypt
2300 if test $ol_enable_crypt != no ; then
2301         save_LIBS="$LIBS"
2302         LIBS="$TLS_LIBS $LIBS"
2303
2304         AC_CHECK_FUNC(crypt, [have_crypt=yes], [
2305                 LIBS="$save_LIBS"
2306                 AC_CHECK_LIB(crypt, crypt, [LUTIL_LIBS="$LUTIL_LIBS -lcrypt"
2307                         have_crypt=yes], [have_crypt=no])])
2308
2309         LIBS="$save_LIBS"
2310
2311         if test $have_crypt = yes ; then
2312                 AC_DEFINE(HAVE_CRYPT,1, [define if crypt(3) is available])
2313         else
2314                 AC_MSG_WARN([could not find crypt])
2315                 if test $ol_enable_crypt = yes ; then
2316                         AC_MSG_ERROR([could not find crypt, select appropriate options or disable])
2317                 fi
2318
2319                 AC_MSG_WARN([disabling crypt support])
2320                 ol_enable_crypt=no
2321         fi
2322 fi
2323
2324 dnl ----------------------------------------------------------------
2325 dnl FreeBSD (and others) have setproctitle(3) in -lutil
2326 if test $ol_enable_proctitle != no ; then
2327         AC_CHECK_FUNC(setproctitle,     [have_setproctitle=yes], [
2328                 AC_CHECK_LIB(util, setproctitle,
2329                         [have_setproctitle=yes
2330                         LUTIL_LIBS="$LUTIL_LIBS -lutil"],
2331                         [have_setproctitle=no
2332                         AC_LIBOBJ(setproctitle)
2333                         LIBSRCS="$LIBSRCS setproctitle.c"])])
2334
2335         if test $have_setproctitle = yes ; then
2336                 AC_DEFINE(HAVE_SETPROCTITLE,1,
2337                         [define if setproctitle(3) is available])
2338         fi
2339 fi
2340
2341 dnl ----------------------------------------------------------------
2342 dnl Check for SLPv2 Compliant API Library
2343 if test $ol_enable_slp != no ; then
2344         AC_CHECK_HEADERS( slp.h )
2345
2346         if test $ac_cv_header_slp_h = yes ; then
2347                 AC_CHECK_LIB(slp, SLPOpen, [have_slp=yes], [have_slp=no])
2348                 if test $have_slp = yes ; then
2349                         AC_DEFINE(HAVE_SLP, 1, [define if you have -lslp])
2350                         SLAPD_SLP_LIBS=-lslp
2351                 fi
2352
2353         elif test $ol_enable_slp = yes ; then
2354                 AC_MSG_ERROR([SLP not found])
2355         fi
2356 fi
2357
2358 dnl ----------------------------------------------------------------
2359 dnl Check for multiple precision support
2360 if test "$ol_with_multiple_precision" != "no" ; then
2361         ol_have_bignum=no
2362         ol_have_gmp=no
2363
2364         AC_CHECK_HEADERS(openssl/bn.h bn.h)
2365         AC_CHECK_HEADERS(openssl/crypto.h crypto.h)
2366         AC_CHECK_HEADERS( gmp.h )
2367
2368         if test "$ol_with_tls" = "found" ; then
2369                 ol_have_bn_h=no
2370                 ol_have_crypto_h=no
2371
2372                 if test "$ac_cv_header_openssl_bn_h" = "yes" \
2373                                 -o "$ac_cv_header_bn_h" = "yes" ; then
2374                         ol_have_bn_h=yes
2375                 fi
2376
2377                 if test "$ac_cv_header_openssl_crypto_h" = "yes" \
2378                                 -o "$ac_cv_header_crypto_h" = "yes" ; then
2379                         ol_have_crypto_h=yes
2380                 fi
2381
2382                 if test "$ol_have_bn_h" = "yes" \
2383                                 -a "$ol_have_crypto_h" = "yes" ; then
2384                         ol_have_bignum=yes
2385                 fi
2386         fi
2387
2388         if test $ac_cv_header_gmp_h = yes ; then
2389                 AC_CHECK_LIB(gmp, __gmpz_add_ui, [have_gmp=yes], [have_gmp=no])
2390                 if test $have_gmp = yes ; then
2391                         ol_have_gmp=yes
2392                 fi
2393         fi
2394
2395         AC_MSG_CHECKING([for multiple precision support])
2396
2397         ol_mp_support="none"
2398         case "$ol_with_multiple_precision" in
2399         auto)
2400                 dnl preferred sequence:
2401                 dnl - OpenSSL's BIGNUM (if libssl is already linked)
2402                 dnl - GNU's MP
2403                 dnl - unsigned long
2404                 if test "$ol_have_bignum" = "yes" ; then
2405                         ol_mp_support="bignum"
2406                 else
2407                         if test "$ol_have_gmp" = "yes" ; then
2408                                 ol_mp_support="gmp"
2409                         fi
2410                 fi
2411                 ;;
2412         bignum)
2413                 if test "$ol_have_bignum" != "yes" ; then
2414                         AC_MSG_ERROR([OpenSSL's BIGNUM not available])
2415                 fi
2416                 ol_mp_support="bignum"
2417                 ;;
2418         gmp)
2419                 if test "$ol_have_gmp" != "yes" ; then
2420                         AC_MSG_ERROR([GMP not available])
2421                 fi
2422                 ol_mp_support="gmp"
2423                 ;;
2424         yes)
2425                 if test "$ol_have_bignum" = "yes" ; then
2426                         ol_mp_support="bignum"
2427                 elif test "$ol_have_gmp" = "yes" ; then
2428                         ol_mp_support="gmp"
2429                 else
2430                         AC_MSG_ERROR([not available])
2431                 fi
2432                 ;;
2433         esac
2434
2435         case "$ol_mp_support" in
2436         bignum)
2437                 AC_DEFINE(HAVE_BIGNUM, 1,
2438                         [define if you have SSLeay or OpenSSL's BIGNUM])
2439                 ;;
2440         gmp)
2441                 AC_DEFINE(HAVE_GMP, 1, [define if you have -lgmp])
2442                 SLAPD_GMP_LIBS=-lgmp
2443                 ;;
2444         none)
2445                 ;;
2446         esac
2447
2448         AC_MSG_RESULT($ol_mp_support)
2449 fi
2450
2451 dnl ----------------------------------------------------------------
2452 dnl Checks for typedefs, structures, and compiler characteristics.
2453
2454 dnl Checks for long long
2455 AC_CACHE_CHECK([long long], ol_cv_type_long_long, [
2456         AC_TRY_COMPILE([], [long long x;],
2457                 [ol_cv_type_long_long=yes],
2458                 [ol_cv_type_long_long=no])])
2459 if test $ol_cv_type_long_long = yes; then
2460         AC_DEFINE(HAVE_LONG_LONG, 1, [define if you have 'long long'])
2461 fi
2462
2463 AC_TYPE_MODE_T
2464 AC_TYPE_OFF_T
2465 AC_TYPE_PID_T
2466 AC_CHECK_TYPES([ptrdiff_t])
2467 AC_TYPE_SIGNAL
2468 AC_TYPE_SIZE_T
2469
2470 AC_CHECK_TYPE(ssize_t, [signed int])
2471 AC_CHECK_TYPE(caddr_t,  [char *])
2472
2473 OL_TYPE_SOCKLEN_T
2474 AC_CHECK_MEMBERS([struct stat.st_blksize])
2475 AC_HEADER_TIME
2476 AC_STRUCT_TM
2477 AC_TYPE_UID_T
2478 OL_TYPE_SIG_ATOMIC_T
2479
2480 dnl AC_TYPE_GETGROUPS
2481
2482 OL_STRUCT_PASSWD_PW_GECOS
2483 OL_STRUCT_PASSWD_PW_PASSWD
2484
2485 OL_C_UPPER_LOWER
2486 AC_C_CONST
2487 OL_C_VOLATILE
2488
2489 if test $cross_compiling = yes ; then
2490         AC_MSG_WARN([Crossing compiling... all bets are off!])
2491         AC_DEFINE(CROSS_COMPILING, 1, [define if cross compiling])
2492 else
2493         AC_C_BIGENDIAN
2494 fi
2495
2496 AC_COMPILE_CHECK_SIZEOF(short) 
2497 AC_COMPILE_CHECK_SIZEOF(int) 
2498 AC_COMPILE_CHECK_SIZEOF(long)
2499 AC_COMPILE_CHECK_SIZEOF(wchar_t)
2500
2501 if test "$ac_cv_sizeof_int" -lt 4 ; then
2502         AC_MSG_WARN([OpenLDAP requires 'int' to be 32 bits or greater.])
2503
2504         AC_DEFINE(LBER_INT_T,long)
2505 else
2506         AC_DEFINE(LBER_INT_T,int)
2507 fi
2508
2509 AC_DEFINE(LBER_LEN_T,long)
2510 AC_DEFINE(LBER_SOCKET_T,int)
2511 AC_DEFINE(LBER_TAG_T,long)
2512
2513 dnl ----------------------------------------------------------------
2514 dnl Checks for library functions.
2515 AC_FUNC_MEMCMP
2516
2517 if test $ac_cv_func_memcmp_working = no ; then
2518         AC_DEFINE(NEED_MEMCMP_REPLACEMENT,1,
2519                 [define if memcmp is not 8-bit clean or is otherwise broken])
2520 fi
2521
2522 dnl AC_FUNC_MKTIME([]) dnl checks for sys/time.h and unistd.h
2523 AC_FUNC_STRFTIME
2524 dnl AC_FUNC_STRTOD([])
2525
2526 OL_FUNC_INET_ATON
2527
2528 dnl Check for NT specific routines
2529 AC_CHECK_FUNC(_spawnlp, AC_DEFINE(HAVE_SPAWNLP,1,[if you have spawnlp()]))
2530
2531 AC_CHECK_FUNC(_snprintf, [ac_cv_func_snprintf=yes
2532         AC_DEFINE(snprintf, _snprintf, [define to snprintf routine])
2533 ])
2534
2535 AC_CHECK_FUNC(_vsnprintf, [ac_cv_func_vsnprintf=yes
2536         AC_DEFINE(vsnprintf, _vsnprintf, [define to vsnprintf routine])
2537 ])
2538
2539 AC_FUNC_VPRINTF
2540
2541 if test $ac_cv_func_vprintf = yes ; then
2542         dnl check for vsnprintf
2543         AC_CHECK_FUNCS(snprintf vsnprintf)
2544 fi
2545
2546 AC_CHECK_FUNCS(         \
2547         bcopy                   \
2548         closesocket             \
2549         chroot                  \
2550         endgrent                \
2551         endpwent                \
2552         fcntl                   \
2553         flock                   \
2554         fstat                   \
2555         getdtablesize   \
2556         getgrgid                \
2557         gethostname             \
2558         getpass                 \
2559         getpassphrase   \
2560         getpwuid                \
2561         getpwnam                \
2562         getspnam                \
2563         gettimeofday    \
2564         initgroups              \
2565         lockf                   \
2566         memcpy                  \
2567         memmove                 \
2568         mkstemp                 \
2569         mktemp                  \
2570         pipe                    \
2571         read                    \
2572         recv                    \
2573         recvfrom                \
2574         setpwfile               \
2575         setgid                  \
2576         setegid                 \
2577         setsid                  \
2578         setuid                  \
2579         seteuid                 \
2580         signal                  \
2581         strdup                  \
2582         strpbrk                 \
2583         strrchr                 \
2584         strsep                  \
2585         strstr                  \
2586         strtol                  \
2587         strtoul                 \
2588         strtoq                  \
2589         strtouq                 \
2590         strtoll                 \
2591         strspn                  \
2592         sysconf                 \
2593         usleep                  \
2594         waitpid                 \
2595         wait4                   \
2596         write                   \
2597         send                    \
2598         sendmsg                 \
2599         sendto                  \
2600 )
2601
2602 dnl We actually may need to replace more than this.
2603 AC_REPLACE_FUNCS(getopt getpeereid)
2604
2605 if test "$ac_cv_func_getopt" != yes; then
2606         LIBSRCS="$LIBSRCS getopt.c"
2607 fi
2608 if test "$ac_cv_func_getpeereid" != yes; then
2609         OL_MSGHDR_MSG_ACCRIGHTS
2610         if test "$ac_cv_func_getpeereid" != yes; then
2611                 OL_MSGHDR_MSG_CONTROL
2612         fi
2613         LIBSRCS="$LIBSRCS getpeereid.c"
2614 fi
2615 if test "$ac_cv_func_snprintf" != yes -o "$ac_cv_func_vsnprintf" != yes; then
2616         if test "$ac_cv_func_snprintf" != yes; then
2617                 AC_DEFINE(snprintf, ber_pvt_snprintf, [define to snprintf routine])
2618         fi
2619         if test "$ac_cv_func_vsnprintf" != yes; then
2620                 AC_DEFINE(vsnprintf, ber_pvt_vsnprintf, [define to snprintf routine])
2621         fi
2622 fi
2623
2624 dnl ----------------------------------------------------------------
2625 dnl Sort out defines
2626
2627 if test "$ol_enable_slapi" != no ; then
2628         dnl This check is done also if --enable-modules is used;
2629         dnl it is duplicated here, 'cause it'd be cached anyway
2630         AC_CHECK_HEADERS(ltdl.h)
2631
2632         if test $ac_cv_header_ltdl_h != yes ; then
2633                 AC_MSG_ERROR([could not locate <ltdl.h>])
2634         fi
2635         AC_CHECK_LIB(ltdl, lt_dlinit, [
2636                 SLAPI_LIBS=-lltdl
2637                 LIBSLAPI=libslapi.a
2638                 LIBSLAPITOOLS=../libslapi.a
2639                 AC_DEFINE(HAVE_LIBLTDL,1,[define if you have libtool -ltdl])
2640         ],[AC_MSG_ERROR([could not locate libtool -lltdl])])
2641
2642         AC_DEFINE(LDAP_SLAPI,1, [define this to add SLAPI code])
2643 fi
2644
2645 if test "$ol_enable_debug" != no ; then
2646         AC_DEFINE(LDAP_DEBUG,1,
2647                 [define this to add debugging code])
2648 fi
2649 if test "$ol_enable_syslog" = yes ; then
2650         AC_DEFINE(LDAP_SYSLOG,1,
2651                 [define this to add syslog code])
2652 fi
2653 if test "$ol_link_kbind" != no ; then
2654         AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND,LDAP_VENDOR_VERSION)
2655 fi
2656 if test "$ol_enable_proctitle" != no ; then
2657         AC_DEFINE(LDAP_PROCTITLE,1,
2658                 [define this for LDAP process title support])
2659 fi
2660 if test "$ol_enable_referrals" != no ; then
2661         AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS,LDAP_VENDOR_VERSION)
2662 fi
2663 if test "$ol_enable_local" != no; then
2664         AC_DEFINE(LDAP_PF_LOCAL,1,[define to support PF_LOCAL])
2665 fi
2666 if test "$ol_link_ipv6" != no; then
2667         AC_DEFINE(LDAP_PF_INET6,1,[define to support PF_INET6])
2668 fi
2669 if test "$ol_enable_cleartext" != no ; then
2670         AC_DEFINE(SLAPD_CLEARTEXT,1,[define to support cleartext passwords])
2671 fi
2672 if test "$ol_enable_crypt" != no ; then
2673         AC_DEFINE(SLAPD_CRYPT,1,[define to support crypt(3) passwords])
2674 fi
2675 if test "$ol_link_spasswd" != no ; then
2676         AC_DEFINE(SLAPD_SPASSWD,1,[define to support SASL passwords])
2677 fi
2678 if test "$ol_enable_multimaster" != no ; then
2679         AC_DEFINE(SLAPD_MULTIMASTER,1,[define to support multimaster replication])
2680 fi
2681 if test "$ol_enable_rlookups" != no ; then
2682         AC_DEFINE(SLAPD_RLOOKUPS,1,[define to support reverse lookups])
2683 fi
2684 if test "$ol_enable_aci" != no ; then
2685         AC_DEFINE(SLAPD_ACI_ENABLED,1,[define to support per-object ACIs])
2686 fi
2687
2688 if test "$ol_link_modules" != no ; then
2689         AC_DEFINE(SLAPD_MODULES,1,[define to support modules])
2690         BUILD_SLAPD=yes
2691         SLAPD_MODULES_LDFLAGS="-dlopen self"
2692 fi
2693
2694 AC_DEFINE(SLAPD_MOD_STATIC,1,[statically linked module])
2695 AC_DEFINE(SLAPD_MOD_DYNAMIC,2,[dynamically linked module])
2696
2697 if test "$ol_enable_bdb" != no ; then
2698         BUILD_SLAPD=yes
2699         BUILD_BDB=$ol_enable_bdb
2700         if test "$ol_enable_bdb" = mod ; then
2701                 SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-bdb"
2702                 MFLAG=SLAPD_MOD_DYNAMIC
2703         else
2704                 SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-bdb"
2705                 MFLAG=SLAPD_MOD_STATIC
2706         fi
2707         AC_DEFINE_UNQUOTED(SLAPD_BDB,$MFLAG,[define to support BDB backend])
2708 fi
2709
2710 if test "$ol_enable_dnssrv" != no ; then
2711         BUILD_SLAPD=yes
2712         BUILD_DNSSRV=$ol_enable_dnssrv
2713         if test "$ol_enable_dnssrv" = mod ; then
2714                 SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-dnssrv"
2715                 MFLAG=SLAPD_MOD_DYNAMIC
2716         else
2717                 SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-dnssrv"
2718                 MFLAG=SLAPD_MOD_STATIC
2719         fi
2720         AC_DEFINE_UNQUOTED(SLAPD_DNSSRV,$MFLAG,[define to support DNS SRV backend])
2721 fi
2722
2723 if test "$ol_enable_hdb" != no ; then
2724         BUILD_SLAPD=yes
2725         BUILD_HDB=$ol_enable_hdb
2726         if test "$ol_enable_hdb" = mod ; then
2727                 SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-hdb"
2728                 MFLAG=SLAPD_MOD_DYNAMIC
2729         else
2730                 SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-hdb"
2731                 MFLAG=SLAPD_MOD_STATIC
2732         fi
2733         AC_DEFINE_UNQUOTED(SLAPD_HDB,$MFLAG,[define to support HDB backend])
2734 fi
2735
2736 if test "$ol_enable_ldap" != no ; then
2737         BUILD_SLAPD=yes
2738         BUILD_LDAP=$ol_enable_ldap
2739         if test "$ol_enable_ldap" = mod ; then
2740                 SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-ldap"
2741                 MFLAG=SLAPD_MOD_DYNAMIC
2742         else
2743                 SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-ldap"
2744                 MFLAG=SLAPD_MOD_STATIC
2745         fi
2746         AC_DEFINE_UNQUOTED(SLAPD_LDAP,$MFLAG,[define to support LDAP backend])
2747 fi
2748
2749 if test "$ol_link_ldbm" != no -a $ol_enable_ldbm != no; then
2750         BUILD_SLAPD=yes
2751         BUILD_LDBM=$ol_enable_ldbm
2752         if test "$ol_enable_ldbm" = mod ; then
2753                 SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-ldbm"
2754                 MFLAG=SLAPD_MOD_DYNAMIC
2755         else
2756                 SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-ldbm"
2757                 MFLAG=SLAPD_MOD_STATIC
2758         fi
2759         AC_DEFINE_UNQUOTED(SLAPD_LDBM,$MFLAG,[define to support LDBM backend])
2760 fi
2761
2762 if test "$ol_enable_meta" != no ; then
2763         BUILD_SLAPD=yes
2764         BUILD_META=$ol_enable_meta
2765         BUILD_REWRITE=yes
2766         if test "$ol_enable_meta" = mod ; then
2767                 SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-meta"
2768                 MFLAG=SLAPD_MOD_DYNAMIC
2769         else
2770                 SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-meta"
2771                 MFLAG=SLAPD_MOD_STATIC
2772         fi
2773         AC_DEFINE_UNQUOTED(SLAPD_META,$MFLAG,[define to support LDAP Metadirectory backend])
2774 fi
2775
2776 if test "$ol_enable_monitor" != no ; then
2777         BUILD_SLAPD=yes
2778         BUILD_MONITOR=$ol_enable_monitor
2779         if test "$ol_enable_monitor" = mod ; then
2780                 SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-monitor"
2781                 MFLAG=SLAPD_MOD_DYNAMIC
2782         else
2783                 SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-monitor"
2784                 MFLAG=SLAPD_MOD_STATIC
2785         fi
2786         AC_DEFINE_UNQUOTED(SLAPD_MONITOR,$MFLAG,[define to support cn=Monitor backend])
2787 fi
2788
2789 if test "$ol_enable_null" != no ; then
2790         BUILD_SLAPD=yes
2791         BUILD_NULL=$ol_enable_null
2792         if test "$ol_enable_null" = mod ; then
2793                 SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-null"
2794                 MFLAG=SLAPD_MOD_DYNAMIC
2795         else
2796                 SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-null"
2797                 MFLAG=SLAPD_MOD_STATIC
2798         fi
2799         AC_DEFINE_UNQUOTED(SLAPD_NULL,$MFLAG,[define to support NULL backend])
2800 fi
2801
2802 if test "$ol_enable_passwd" != no ; then
2803         BUILD_SLAPD=yes
2804         BUILD_PASSWD=$ol_enable_passwd
2805         if test "$ol_enable_passwd" = mod ; then
2806                 SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-passwd"
2807                 MFLAG=SLAPD_MOD_DYNAMIC
2808         else
2809                 SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-passwd"
2810                 MFLAG=SLAPD_MOD_STATIC
2811         fi
2812         AC_DEFINE_UNQUOTED(SLAPD_PASSWD,$MFLAG,[define to support PASSWD backend])
2813 fi
2814
2815 if test "$ol_link_perl" != no ; then
2816         BUILD_SLAPD=yes
2817         BUILD_PERL=$ol_enable_perl
2818         if test "$ol_enable_perl" = mod ; then
2819                 SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-perl"
2820                 MFLAG=SLAPD_MOD_DYNAMIC
2821         else
2822                 SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-perl"
2823                 MFLAG=SLAPD_MOD_STATIC
2824         fi
2825         AC_DEFINE_UNQUOTED(SLAPD_PERL,$MFLAG,[define to support PERL backend])
2826 fi
2827
2828 if test "$ol_enable_relay" != no ; then
2829         BUILD_SLAPD=yes
2830         BUILD_RELAY=$ol_enable_relay
2831         if test "$ol_enable_relay" = mod ; then
2832                 SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-relay"
2833                 MFLAG=SLAPD_MOD_DYNAMIC
2834         else
2835                 SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-relay"
2836                 MFLAG=SLAPD_MOD_STATIC
2837         fi
2838         AC_DEFINE_UNQUOTED(SLAPD_RELAY,$MFLAG,[define to support relay backend])
2839 fi
2840
2841 if test "$ol_enable_shell" != no ; then
2842         if test "$ol_link_thread" != no ; then
2843                 AC_MSG_WARN([Use of --without-threads is recommended with back-shell])
2844         fi
2845         BUILD_SLAPD=yes
2846         BUILD_SHELL=$ol_enable_shell
2847         if test "$ol_enable_shell" = mod ; then
2848                 SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-shell"
2849                 MFLAG=SLAPD_MOD_DYNAMIC
2850         else
2851                 SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-shell"
2852                 MFLAG=SLAPD_MOD_STATIC
2853         fi
2854         AC_DEFINE_UNQUOTED(SLAPD_SHELL,$MFLAG,[define to support SHELL backend])
2855 fi
2856
2857 if test "$ol_link_sql" != no ; then
2858         BUILD_SLAPD=yes
2859         BUILD_SQL=$ol_enable_sql
2860         if test "$ol_enable_sql" = mod; then
2861                 SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-sql"
2862                 MFLAG=SLAPD_MOD_DYNAMIC
2863         else
2864                 SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-sql"
2865                 MFLAG=SLAPD_MOD_STATIC
2866         fi
2867         AC_DEFINE_UNQUOTED(SLAPD_SQL,$MFLAG,[define to support SQL backend])
2868 fi
2869
2870 if test "$ol_enable_accesslog" != no ; then
2871         BUILD_ACCESSLOG=$ol_enable_accesslog
2872         if test "$ol_enable_accesslog" = mod ; then
2873                 MFLAG=SLAPD_MOD_DYNAMIC
2874                 SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS accesslog.la"
2875         else
2876                 MFLAG=SLAPD_MOD_STATIC
2877                 SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS accesslog.o"
2878         fi
2879         AC_DEFINE_UNQUOTED(SLAPD_OVER_ACCESSLOG,$MFLAG,[define for In-Directory Access Logging overlay])
2880 fi
2881
2882 if test "$ol_enable_denyop" != no ; then
2883         BUILD_DENYOP=$ol_enable_denyop
2884         if test "$ol_enable_denyop" = mod ; then
2885                 MFLAG=SLAPD_MOD_DYNAMIC
2886                 SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS denyop.la"
2887         else
2888                 MFLAG=SLAPD_MOD_STATIC
2889                 SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS denyop.o"
2890         fi
2891         AC_DEFINE_UNQUOTED(SLAPD_OVER_DENYOP,$MFLAG,[define for Dynamic Group overlay])
2892 fi
2893
2894 if test "$ol_enable_dyngroup" != no ; then
2895         BUILD_DYNGROUP=$ol_enable_dyngroup
2896         if test "$ol_enable_dyngroup" = mod ; then
2897                 MFLAG=SLAPD_MOD_DYNAMIC
2898                 SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS dyngroup.la"
2899         else
2900                 MFLAG=SLAPD_MOD_STATIC
2901                 SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS dyngroup.o"
2902         fi
2903         AC_DEFINE_UNQUOTED(SLAPD_OVER_DYNGROUP,$MFLAG,[define for Dynamic Group overlay])
2904 fi
2905
2906 if test "$ol_enable_dynlist" != no ; then
2907         BUILD_DYNLIST=$ol_enable_dynlist
2908         if test "$ol_enable_dynlist" = mod ; then
2909                 MFLAG=SLAPD_MOD_DYNAMIC
2910                 SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS dynlist.la"
2911         else
2912                 MFLAG=SLAPD_MOD_STATIC
2913                 SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS dynlist.o"
2914         fi
2915         AC_DEFINE_UNQUOTED(SLAPD_OVER_DYNLIST,$MFLAG,[define for Dynamic List overlay])
2916 fi
2917
2918 if test "$ol_enable_glue" != no ; then
2919         BUILD_GLUE=$ol_enable_glue
2920         if test "$ol_enable_glue" = mod ; then
2921                 MFLAG=SLAPD_MOD_DYNAMIC
2922                 SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS glue.la"
2923         else
2924                 MFLAG=SLAPD_MOD_STATIC
2925                 SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS glue.o"
2926         fi
2927         AC_DEFINE_UNQUOTED(SLAPD_OVER_GLUE,$MFLAG,[define for Backend Glue overlay])
2928 fi
2929
2930 if test "$ol_enable_lastmod" != no ; then
2931         BUILD_LASTMOD=$ol_enable_lastmod
2932         if test "$ol_enable_lastmod" = mod ; then
2933                 MFLAG=SLAPD_MOD_DYNAMIC
2934                 SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS lastmod.la"
2935         else
2936                 MFLAG=SLAPD_MOD_STATIC
2937                 SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS lastmod.o"
2938         fi
2939         AC_DEFINE_UNQUOTED(SLAPD_OVER_LASTMOD,$MFLAG,[define for Last Modification overlay])
2940 fi
2941
2942 if test "$ol_enable_ppolicy" != no ; then
2943         BUILD_PPOLICY=$ol_enable_ppolicy
2944         if test "$ol_enable_ppolicy" = mod ; then
2945                 MFLAG=SLAPD_MOD_DYNAMIC
2946                 SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS ppolicy.la"
2947         else
2948                 MFLAG=SLAPD_MOD_STATIC
2949                 SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS ppolicy.o"
2950         fi
2951         AC_DEFINE_UNQUOTED(SLAPD_OVER_PPOLICY,$MFLAG,[define for Password Policy overlay])
2952 fi
2953
2954 if test "$ol_enable_proxycache" != no ; then
2955         BUILD_PROXYCACHE=$ol_enable_proxycache
2956         if test "$ol_enable_proxycache" = mod ; then
2957                 MFLAG=SLAPD_MOD_DYNAMIC
2958                 SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS pcache.la"
2959         else
2960                 MFLAG=SLAPD_MOD_STATIC
2961                 SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS pcache.o"
2962         fi
2963         AC_DEFINE_UNQUOTED(SLAPD_OVER_PROXYCACHE,$MFLAG,[define for Proxy Cache overlay])
2964 fi
2965
2966 if test "$ol_enable_refint" != no ; then
2967         BUILD_REFINT=$ol_enable_refint
2968         if test "$ol_enable_refint" = mod ; then
2969                 MFLAG=SLAPD_MOD_DYNAMIC
2970                 SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS refint.la"
2971         else
2972                 MFLAG=SLAPD_MOD_STATIC
2973                 SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS refint.o"
2974         fi
2975         AC_DEFINE_UNQUOTED(SLAPD_OVER_REFINT,$MFLAG,[define for Referential Integrity overlay])
2976 fi
2977
2978 if test "$ol_enable_retcode" != no ; then
2979         BUILD_RETCODE=$ol_enable_retcode
2980         if test "$ol_enable_retcode" = mod ; then
2981                 MFLAG=SLAPD_MOD_DYNAMIC
2982                 SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS retcode.la"
2983         else
2984                 MFLAG=SLAPD_MOD_STATIC
2985                 SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS retcode.o"
2986         fi
2987         AC_DEFINE_UNQUOTED(SLAPD_OVER_RETCODE,$MFLAG,[define for Referential Integrity overlay])
2988 fi
2989
2990 if test "$ol_enable_rwm" != no ; then
2991         BUILD_REWRITE=yes
2992         BUILD_RWM=$ol_enable_rwm
2993         if test "$ol_enable_rwm" = mod ; then
2994                 MFLAG=SLAPD_MOD_DYNAMIC
2995                 SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS rwm.la"
2996         else
2997                 MFLAG=SLAPD_MOD_STATIC
2998                 SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS rwm_x.o"
2999         fi
3000         AC_DEFINE_UNQUOTED(SLAPD_OVER_RWM,$MFLAG,[define for Rewrite/Remap overlay])
3001 fi
3002
3003 if test "$ol_enable_syncprov" != no ; then
3004         BUILD_SYNCPROV=$ol_enable_syncprov
3005         if test "$ol_enable_syncprov" = mod ; then
3006                 MFLAG=SLAPD_MOD_DYNAMIC
3007                 SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS syncprov.la"
3008         else
3009                 MFLAG=SLAPD_MOD_STATIC
3010                 SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS syncprov.o"
3011         fi
3012         AC_DEFINE_UNQUOTED(SLAPD_OVER_SYNCPROV,$MFLAG,[define for Syncrepl Provider overlay])
3013 fi
3014
3015 if test "$ol_enable_translucent" != no ; then
3016         BUILD_TRANSLUCENT=$ol_enable_translucent
3017         if test "$ol_enable_translucent" = mod ; then
3018                 MFLAG=SLAPD_MOD_DYNAMIC
3019                 SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS translucent.la"
3020         else
3021                 MFLAG=SLAPD_MOD_STATIC
3022                 SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS translucent.o"
3023         fi
3024         AC_DEFINE_UNQUOTED(SLAPD_OVER_TRANSLUCENT,$MFLAG,[define for Translucent Proxy overlay])
3025 fi
3026
3027 if test "$ol_enable_unique" != no ; then
3028         BUILD_UNIQUE=$ol_enable_unique
3029         if test "$ol_enable_unique" = mod ; then
3030                 MFLAG=SLAPD_MOD_DYNAMIC
3031                 SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS unique.la"
3032         else
3033                 MFLAG=SLAPD_MOD_STATIC
3034                 SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS unique.o"
3035         fi
3036         AC_DEFINE_UNQUOTED(SLAPD_OVER_UNIQUE,$MFLAG,[define for Attribute Uniqueness overlay])
3037 fi
3038
3039 if test "$ol_enable_slurpd" != no -a "$ol_link_threads" != no -a \
3040         $BUILD_SLAPD = yes ; then
3041         BUILD_SLURPD=yes
3042 fi
3043
3044 if test "$ol_enable_rewrite" != no ; then
3045         AC_DEFINE(ENABLE_REWRITE,1,[define to enable rewriting in back-ldap and back-meta])
3046         BUILD_REWRITE=yes
3047 fi
3048
3049 if test "$ol_enable_slapi" != no ; then
3050         AC_DEFINE(ENABLE_SLAPI,1,[define to enable slapi library])
3051         BUILD_SLAPI=yes
3052         SLAPD_SLAPI_DEPEND=libslapi.a
3053 fi
3054
3055 dnl ----------------------------------------------------------------
3056
3057 dnl
3058 dnl For Windows build, we don't want to include -dlopen flags.
3059 dnl They hurt more than they help.
3060 dnl
3061
3062 if test "$ac_cv_mingw32" = yes ; then
3063         PLAT=NT
3064         SLAPD_MODULES_LDFLAGS=
3065 else
3066         PLAT=UNIX
3067 fi
3068
3069 AC_SUBST(LIBSRCS)
3070 AC_SUBST(PLAT)
3071 AC_SUBST(WITH_SASL)
3072 AC_SUBST(WITH_TLS)
3073 AC_SUBST(WITH_MODULES_ENABLED)
3074 AC_SUBST(BUILD_LIBS_DYNAMIC)
3075
3076 AC_SUBST(BUILD_SLAPD)
3077 dnl slapi
3078   AC_SUBST(BUILD_SLAPI)
3079   AC_SUBST(SLAPD_SLAPI_DEPEND)
3080 dnl backends
3081   AC_SUBST(BUILD_BDB)
3082   AC_SUBST(BUILD_DNSSRV)
3083   AC_SUBST(BUILD_HDB)
3084   AC_SUBST(BUILD_LDAP)
3085   AC_SUBST(BUILD_LDBM)
3086   AC_SUBST(BUILD_META)
3087   AC_SUBST(BUILD_MONITOR)
3088   AC_SUBST(BUILD_NULL)
3089   AC_SUBST(BUILD_PASSWD)
3090   AC_SUBST(BUILD_RELAY)
3091   AC_SUBST(BUILD_PERL)
3092   AC_SUBST(BUILD_SHELL)
3093   AC_SUBST(BUILD_SQL)
3094 dnl overlays
3095   AC_SUBST(BUILD_ACCESSLOG)
3096   AC_SUBST(BUILD_DENYOP)
3097   AC_SUBST(BUILD_DYNGROUP)
3098   AC_SUBST(BUILD_DYNLIST)
3099   AC_SUBST(BUILD_GLUE)
3100   AC_SUBST(BUILD_LASTMOD)
3101   AC_SUBST(BUILD_PPOLICY)
3102   AC_SUBST(BUILD_PROXYCACHE)
3103   AC_SUBST(BUILD_REFINT)
3104   AC_SUBST(BUILD_RETCODE)
3105   AC_SUBST(BUILD_RWM)
3106   AC_SUBST(BUILD_SYNCPROV)
3107   AC_SUBST(BUILD_TRANSLUCENT)
3108   AC_SUBST(BUILD_UNIQUE)
3109 AC_SUBST(BUILD_SLURPD)
3110
3111 AC_SUBST(LDAP_LIBS)
3112 AC_SUBST(SLAPD_LIBS)
3113 AC_SUBST(SLURPD_LIBS)
3114 AC_SUBST(LDBM_LIBS)
3115 AC_SUBST(LTHREAD_LIBS)
3116 AC_SUBST(LUTIL_LIBS)
3117 AC_SUBST(WRAP_LIBS)
3118
3119 AC_SUBST(SLAPD_MODULES_CPPFLAGS)
3120 AC_SUBST(SLAPD_MODULES_LDFLAGS)
3121
3122 AC_SUBST(SLAPD_NO_STATIC)
3123 AC_SUBST(SLAPD_STATIC_BACKENDS)
3124 AC_SUBST(SLAPD_DYNAMIC_BACKENDS)
3125 AC_SUBST(SLAPD_STATIC_OVERLAYS)
3126 AC_SUBST(SLAPD_DYNAMIC_OVERLAYS)
3127
3128 AC_SUBST(PERL_CPPFLAGS)
3129 AC_SUBST(SLAPD_PERL_LDFLAGS)
3130 AC_SUBST(MOD_PERL_LDFLAGS)
3131
3132 AC_SUBST(KRB4_LIBS)
3133 AC_SUBST(KRB5_LIBS)
3134 AC_SUBST(SASL_LIBS)
3135 AC_SUBST(TLS_LIBS)
3136 AC_SUBST(MODULES_LIBS)
3137 AC_SUBST(SLAPI_LIBS)
3138 AC_SUBST(LIBSLAPI)
3139 AC_SUBST(LIBSLAPITOOLS)
3140 AC_SUBST(AUTH_LIBS)
3141
3142 AC_SUBST(SLAPD_SLP_LIBS)
3143 AC_SUBST(SLAPD_GMP_LIBS)
3144
3145 AC_SUBST(SLAPD_SQL_LDFLAGS)
3146 AC_SUBST(SLAPD_SQL_LIBS)
3147 AC_SUBST(SLAPD_SQL_INCLUDES)
3148
3149 dnl ----------------------------------------------------------------
3150 dnl final help output
3151 AC_ARG_WITH(xxinstall,[
3152 See INSTALL file for further details.])
3153
3154 dnl ----------------------------------------------------------------
3155 dnl final output
3156 dnl
3157
3158 AC_CONFIG_FILES([\
3159 Makefile:build/top.mk:Makefile.in:build/dir.mk \
3160 doc/Makefile:build/top.mk:doc/Makefile.in:build/dir.mk \
3161 doc/man/Makefile:build/top.mk:doc/man/Makefile.in:build/dir.mk \
3162 doc/man/man1/Makefile:build/top.mk:doc/man/man1/Makefile.in:build/man.mk \
3163 doc/man/man3/Makefile:build/top.mk:doc/man/man3/Makefile.in:build/man.mk \
3164 doc/man/man5/Makefile:build/top.mk:doc/man/man5/Makefile.in:build/man.mk \
3165 doc/man/man8/Makefile:build/top.mk:doc/man/man8/Makefile.in:build/man.mk \
3166 clients/Makefile:build/top.mk:clients/Makefile.in:build/dir.mk \
3167 clients/tools/Makefile:build/top.mk:clients/tools/Makefile.in:build/rules.mk \
3168 include/Makefile:build/top.mk:include/Makefile.in \
3169 libraries/Makefile:build/top.mk:libraries/Makefile.in:build/dir.mk      \
3170 libraries/liblber/Makefile:build/top.mk:libraries/liblber/Makefile.in:build/lib.mk:build/lib-shared.mk  \
3171 libraries/libldap/Makefile:build/top.mk:libraries/libldap/Makefile.in:build/lib.mk:build/lib-shared.mk  \
3172 libraries/libldap_r/Makefile:build/top.mk:libraries/libldap_r/Makefile.in:build/lib.mk:build/lib-shared.mk      \
3173 libraries/liblunicode/Makefile:build/top.mk:libraries/liblunicode/Makefile.in:build/lib.mk:build/lib-static.mk  \
3174 libraries/liblutil/Makefile:build/top.mk:libraries/liblutil/Makefile.in:build/lib.mk:build/lib-static.mk        \
3175 libraries/librewrite/Makefile:build/top.mk:libraries/librewrite/Makefile.in:build/lib.mk:build/lib-shared.mk \
3176 servers/Makefile:build/top.mk:servers/Makefile.in:build/dir.mk \
3177 servers/slapd/Makefile:build/top.mk:servers/slapd/Makefile.in:build/srv.mk \
3178 servers/slapd/back-bdb/Makefile:build/top.mk:servers/slapd/back-bdb/Makefile.in:build/mod.mk \
3179 servers/slapd/back-dnssrv/Makefile:build/top.mk:servers/slapd/back-dnssrv/Makefile.in:build/mod.mk \
3180 servers/slapd/back-hdb/Makefile:build/top.mk:servers/slapd/back-hdb/Makefile.in:build/mod.mk \
3181 servers/slapd/back-ldap/Makefile:build/top.mk:servers/slapd/back-ldap/Makefile.in:build/mod.mk \
3182 servers/slapd/back-ldbm/Makefile:build/top.mk:servers/slapd/back-ldbm/Makefile.in:build/mod.mk \
3183 servers/slapd/back-ldif/Makefile:build/top.mk:servers/slapd/back-ldif/Makefile.in:build/mod.mk \
3184 servers/slapd/back-meta/Makefile:build/top.mk:servers/slapd/back-meta/Makefile.in:build/mod.mk \
3185 servers/slapd/back-monitor/Makefile:build/top.mk:servers/slapd/back-monitor/Makefile.in:build/mod.mk \
3186 servers/slapd/back-null/Makefile:build/top.mk:servers/slapd/back-null/Makefile.in:build/mod.mk \
3187 servers/slapd/back-passwd/Makefile:build/top.mk:servers/slapd/back-passwd/Makefile.in:build/mod.mk \
3188 servers/slapd/back-perl/Makefile:build/top.mk:servers/slapd/back-perl/Makefile.in:build/mod.mk \
3189 servers/slapd/back-relay/Makefile:build/top.mk:servers/slapd/back-relay/Makefile.in:build/mod.mk \
3190 servers/slapd/back-shell/Makefile:build/top.mk:servers/slapd/back-shell/Makefile.in:build/mod.mk \
3191 servers/slapd/back-sql/Makefile:build/top.mk:servers/slapd/back-sql/Makefile.in:build/mod.mk \
3192 servers/slapd/shell-backends/Makefile:build/top.mk:servers/slapd/shell-backends/Makefile.in:build/srv.mk \
3193 servers/slapd/slapi/Makefile:build/top.mk:servers/slapd/slapi/Makefile.in:build/lib.mk:build/lib-shared.mk  \
3194 servers/slapd/overlays/Makefile:build/top.mk:servers/slapd/overlays/Makefile.in:build/lib.mk \
3195 servers/slurpd/Makefile:build/top.mk:servers/slurpd/Makefile.in:build/srv.mk \
3196 tests/Makefile:build/top.mk:tests/Makefile.in:build/dir.mk \
3197 tests/run \
3198 tests/progs/Makefile:build/top.mk:tests/progs/Makefile.in:build/rules.mk \
3199 ])
3200 AC_CONFIG_COMMANDS([default],[[
3201 chmod +x tests/run
3202 date > stamp-h
3203 BACKENDSC="servers/slapd/backends.c"
3204 echo "Making $BACKENDSC"
3205 rm -f $BACKENDSC
3206 cat > $BACKENDSC << ENDX
3207 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3208  *
3209  * Copyright 1998-2005 The OpenLDAP Foundation.
3210  * All rights reserved.
3211  *
3212  * Redistribution and use in source and binary forms, with or without
3213  * modification, are permitted only as authorized by the OpenLDAP
3214  * Public License.
3215  *
3216  * A copy of this license is available in the file LICENSE in the
3217  * top-level directory of the distribution or, alternatively, at
3218  * <http://www.OpenLDAP.org/license.html>.
3219  */
3220 /* This file is automatically generated by configure; please do not edit. */
3221
3222 #include "portable.h"
3223 #include "slap.h"
3224
3225 ENDX
3226 if test "${STATIC_BACKENDS}"; then
3227         for b in config ${STATIC_BACKENDS}; do
3228                 bb=`echo "${b}" | sed -e 's/back-//'`
3229                 cat >> $BACKENDSC << ENDX
3230 extern BI_init ${bb}_back_initialize;
3231 ENDX
3232         done
3233
3234         cat >> $BACKENDSC << ENDX
3235
3236 BackendInfo slap_binfo[] = {
3237 ENDX
3238
3239         for b in config ${STATIC_BACKENDS}; do
3240                 bb=`echo "${b}" | sed -e 's/back-//'`
3241                 echo "    Add ${bb} ..."
3242                 cat >> $BACKENDSC << ENDX
3243         { "${bb}", ${bb}_back_initialize },
3244 ENDX
3245         done
3246
3247         cat >> $BACKENDSC << ENDX
3248         { NULL, NULL },
3249 };
3250
3251 /* end of generated file */
3252 ENDX
3253 fi
3254
3255 echo Please run \"make depend\" to build dependencies
3256 ]],[[STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS"]])
3257 AC_OUTPUT