]> git.sur5r.net Git - openldap/blob - configure.in
Update COPYRIGHT/LICENSE from openldap-devel
[openldap] / configure.in
1 dnl $OpenLDAP$
2 dnl
3 dnl Copyright 1998,1999 The OpenLDAP Foundation.  All Rights Reserved.
4 dnl 
5 dnl Redistribution and use in source and binary forms are permitted only
6 dnl as authorized by the OpenLDAP Public License.  A copy of this
7 dnl license is available at http://www.OpenLDAP.org/license.html or
8 dnl in file LICENSE in the top-level directory of the distribution.
9 dnl
10 dnl ----------------------------------------------------------------
11 dnl Redefine AC_INIT_BINSH to provide RCS IDs and copyright notice
12 dnl at top of generated configure script.  Prints simple copyright.
13 define([AC_INIT_BINSH],
14 [[#! /bin/sh
15 # $]OpenLDAP[$
16 # from] translit([$OpenLDAP$], $")] [
17
18 # Copyright 1998,1999 The OpenLDAP Foundation.  All Rights Reserved.
19
20 # Redistribution and use in source and binary forms are permitted only
21 # as authorized by the OpenLDAP Public License.  A copy of this
22 # license is available at http://www.OpenLDAP.org/license.html or
23 # in file LICENSE in the top-level directory of the distribution.
24
25 echo "Copyright 1998-1999 The OpenLDAP Foundation,  All Rights Reserved."
26 echo "Copying restrictions apply, see COPYRIGHT file."
27 ])dnl
28 dnl ----------------------------------------------------------------
29 dnl Disable config.cache!
30 define([AC_CACHE_LOAD], )dnl
31 define([AC_CACHE_SAVE], )dnl
32 dnl ================================================================
33 dnl Configure.in for OpenLDAP
34 AC_INIT(build/version)dnl
35 AC_CONFIG_AUX_DIR(build)dnl
36
37 OL_VERSION=`cat $ac_aux_dir/version`
38 if test -z "$OL_VERSION"; then
39         AC_MSG_ERROR([could not determine version])
40 fi
41
42 echo "Configuring OpenLDAP $OL_VERSION ..."
43
44 dnl Determine host platform
45 dnl             we try not to use this for much
46 AC_CANONICAL_SYSTEM
47
48 AM_INIT_AUTOMAKE(OpenLDAP,[$OL_VERSION], [no defines])dnl
49 AC_SUBST(PACKAGE)
50 AC_SUBST(VERSION)
51 AC_DEFINE_UNQUOTED(OPENLDAP_PACKAGE,"$PACKAGE",Package)
52 AC_DEFINE_UNQUOTED(OPENLDAP_VERSION,"$VERSION",Version)
53
54 dnl We use autoconf features new to 2.13.
55 dnl aclocal.m4 should be built using aclocal from automake 1.4
56 dnl libtool 1.3.3 should be installed.
57 AC_PREREQ(2.13)dnl Required Autoconf version
58
59 AC_CONFIG_HEADER(include/portable.h include/ldap_features.h include/lber_types.h)dnl
60
61 dnl ================================================================
62 dnl Start Args
63 AC_MSG_CHECKING(configure arguments)
64 AC_PREFIX_DEFAULT(/usr/local)
65
66 top_builddir=`pwd`
67 AC_SUBST(top_builddir)dnl
68
69 dnl ----------------------------------------------------------------
70 dnl --with-subdir
71 ldap_subdir="/openldap"
72
73 AC_ARG_WITH(subdir,
74 [  --with-subdir=DIR change default subdirectory used for installs],
75 [case "$withval" in
76         no) ldap_subdir=""
77                 ;;
78         yes)
79                 ;;
80         /*|\\*)
81                 ldap_subdir="$withval"
82                 ;;
83         *)
84                 ldap_subdir="/$withval"
85                 ;;
86 esac
87 ])dnl
88
89 AC_SUBST(ldap_subdir)dnl
90
91 dnl ----------------------------------------------------------------
92 dnl General "enable" options
93 OL_ARG_ENABLE(debug,[  --enable-debug   enable debugging], yes)dnl
94 OL_ARG_ENABLE(syslog,[  --enable-syslog enable syslog support], auto)dnl
95 OL_ARG_ENABLE(proctitle,[  --enable-proctitle   enable proctitle support], yes)dnl
96 OL_ARG_ENABLE(cache,[  --enable-cache   enable caching], yes)dnl
97 OL_ARG_ENABLE(dns,[  --enable-dns               enable V2 DX Referrals extension], no)dnl
98 OL_ARG_ENABLE(referrals,[  --enable-referrals   enable V2 Referrals extension], yes)dnl
99 OL_ARG_ENABLE(cldap,[  --enable-cldap   enable connectionless ldap], no)dnl
100 OL_ARG_ENABLE(x_compile,[  --enable-x-compile   enable cross compiling],
101         no, [yes no])dnl
102
103 dnl ----------------------------------------------------------------
104 dnl General "with" options
105 OL_ARG_ENABLE(dmalloc,[  --enable-dmalloc       enable debug malloc support], no)dnl
106
107 OL_ARG_WITH(cyrus_sasl,[  --with-cyrus-sasl     with Cyrus SASL support],
108         auto, [auto yes no] )
109 OL_ARG_WITH(fetch,[  --with-fetch               with fetch URL support],
110         auto, [auto yes no] )
111 OL_ARG_WITH(kerberos,[  --with-kerberos with Kerberos support],
112         auto, [auto k5 k4 afs yes no])
113 OL_ARG_WITH(readline,[  --with-readline with readline support],
114         auto, [auto yes no] )
115 OL_ARG_WITH(threads,[  --with-threads   use threads],
116         auto, [auto posix mach pth lwp yes no manual] )
117 OL_ARG_WITH(tls,[  --with-tls           with TLS/SSL support],
118         auto, [auto ssleay openssl yes no] )
119 OL_ARG_WITH(yielding_select,[  --with-yielding-select   with implicitly yielding select],
120         auto, [auto yes no manual] )
121
122 dnl ----------------------------------------------------------------
123 dnl Server options
124 dnl ----------------------------------------------------------------
125 dnl LDAPD OPTIONS
126 AC_ARG_WITH(xxldapdoptions,[LDAPD (X.500-to-LDAP Gateway) Options:])
127 OL_ARG_ENABLE(ldapd,[  --enable-ldapd   enable building ldapd], no)dnl
128
129 dnl ----------------------------------------------------------------
130 dnl SLAPD OPTIONS
131 AC_ARG_WITH(xxslapdoptions,[SLAPD (Standalone LDAP Daemon) Options:])
132 OL_ARG_ENABLE(slapd,[  --enable-slapd   enable building slapd], yes)dnl
133 OL_ARG_ENABLE(cleartext,[    --enable-cleartext enable cleartext passwords], yes)dnl
134 OL_ARG_ENABLE(crypt,[    --enable-crypt enable crypt(3) passwords], auto)dnl
135 OL_ARG_ENABLE(modules,[    --enable-modules     enable dynamic module support], no)dnl
136 OL_ARG_ENABLE(multimaster,[    --enable-multimaster     enable multimaster replication], no)dnl
137 OL_ARG_ENABLE(phonetic,[    --enable-phonetic   enable phonetic/soundex], no)dnl
138 OL_ARG_ENABLE(quipu,[    --enable-quipu build quipu migration tools], no)dnl
139 OL_ARG_ENABLE(rlookups,[    --enable-rlookups   enable reverse lookups], auto)dnl
140 OL_ARG_ENABLE(aci,[    --enable-aci     enable per-object ACIs], no)dnl
141 OL_ARG_ENABLE(discreteaci,[    --enable-discreteaci     enable discrete rights in ACIs], no)dnl
142 OL_ARG_ENABLE(wrappers,[    --enable-wrappers   enable tcp wrapper support], no)dnl
143
144 dnl SLAPD Backend options
145 OL_ARG_ENABLE(bdb2,[    --enable-bdb2   enable bdb2 backend], no)dnl
146 OL_ARG_WITH(bdb2_module,[      --with-bdb2-module       module type], static,
147         [static dynamic])
148 OL_ARG_ENABLE(ldap,[    --enable-ldap   enable ldap backend], no)dnl
149 OL_ARG_WITH(ldap_module,[      --with-ldap-module       module type], static,
150         [static dynamic])
151 OL_ARG_ENABLE(ldbm,[    --enable-ldbm   enable ldbm backend], yes)dnl
152 OL_ARG_WITH(ldbm_api,[      --with-ldbm-api     use LDBM API], auto,
153         [auto db2 db mdbm gdbm ndbm manual])
154 OL_ARG_WITH(ldbm_module,[      --with-ldbm-module       module type], static,
155         [static dynamic])
156 OL_ARG_WITH(ldbm_type,[      --with-ldbm-type   use LDBM type], auto,
157         [auto btree hash])
158
159 OL_ARG_ENABLE(passwd,[    --enable-passwd       enable passwd backend], no)dnl
160 OL_ARG_WITH(passwd_module,[      --with-passwd-module   module type], static,
161         [static dynamic])
162 OL_ARG_ENABLE(perl,[    --enable-perl   enable perl backend], no)dnl
163 OL_ARG_WITH(perl_module,[      --with-perl-module       module type], static,
164         [static dynamic])
165 OL_ARG_ENABLE(shell,[    --enable-shell enable shell backend], no)dnl
166 OL_ARG_WITH(shell_module,[      --with-shell-module     module type], static,
167         [static dynamic])
168 OL_ARG_ENABLE(tcl,[    --enable-tcl     enable tcl backend], no)dnl
169 OL_ARG_WITH(tcl_module,[      --with-tcl-module module type], static,
170         [static dynamic])
171
172 dnl ----------------------------------------------------------------
173 dnl SLURPD OPTIONS
174 AC_ARG_WITH(xxslurpdoptions,[SLURPD (Replication Daemon) Options:])
175 OL_ARG_ENABLE(slurpd,[  --enable-slurpd enable building slurpd], auto)dnl
176
177 dnl ----------------------------------------------------------------
178 AC_ARG_WITH(xxliboptions,[Library Generation & Linking Options])
179 AC_ENABLE_STATIC
180 dnl AC_DISABLE_SHARED
181 AC_ENABLE_SHARED
182
183 dnl ----------------------------------------------------------------
184
185 dnl General "enable" options
186 # validate options
187 if test $ol_enable_dns = yes ; then
188         if test $ol_enable_referrals = no ; then
189                 AC_MSG_ERROR([DNS requires --enable-referrals])
190         fi
191         if test $ol_enable_referrals = auto ; then
192                 AC_MSG_WARN([DNS requires referrals, adding --enable-referrals])
193                 ol_enable_referrals=yes
194         fi
195 fi
196
197 if test $ol_enable_slapd = no ; then
198         dnl SLAPD was specificallly disabled
199         if test $ol_enable_bdb2 = yes ; then
200                 AC_MSG_WARN([slapd disabled, ignoring --enable-bdb2 argument])
201         fi
202         if test $ol_enable_ldap = yes ; then
203                 AC_MSG_WARN([slapd disabled, ignoring --enable-ldap argument])
204         fi
205         if test $ol_enable_ldbm = yes ; then
206                 AC_MSG_WARN([slapd disabled, ignoring --enable-ldbm argument])
207         fi
208         if test $ol_enable_passwd = yes ; then
209                 AC_MSG_WARN([slapd disabled, ignoring --enable-passwd argument])
210         fi
211         if test $ol_enable_perl = yes ; then
212                 AC_MSG_WARN([slapd disabled, ignoring --enable-perl argument])
213         fi
214         if test $ol_enable_shell = yes ; then
215                 AC_MSG_WARN([slapd disabled, ignoring --enable-shell argument])
216         fi
217         if test $ol_enable_tcl = yes ; then
218                 AC_MSG_WARN([slapd disabled, ignoring --enable-tcl argument])
219         fi
220         if test $ol_enable_modules = yes ; then
221                 AC_MSG_WARN([slapd disabled, ignoring --enable-modules argument])
222         fi
223         if test $ol_enable_multimaster = yes ; then
224                 AC_MSG_WARN([slapd disabled, ignoring --enable-multimaster argument])
225         fi
226         if test $ol_enable_wrappers = yes ; then
227                 AC_MSG_WARN([slapd disabled, ignoring --enable-wrappers argument])
228         fi
229         if test $ol_enable_phonetic = yes ; then
230                 AC_MSG_WARN([slapd disabled, ignoring --enable-phonetic argument])
231         fi
232         if test $ol_enable_quipu = yes ; then
233                 AC_MSG_WARN([slapd disabled, ignoring --enable-quipu argument])
234         fi
235         if test $ol_enable_rlookups = yes ; then
236                 AC_MSG_WARN([slapd disabled, ignoring --enable-rlookups argument])
237         fi
238         if test $ol_enable_aci = yes ; then
239                 AC_MSG_WARN([slapd disabled, ignoring --enable-aci argument])
240         fi
241         if test $ol_enable_discreteaci = yes ; then
242                 AC_MSG_WARN([slapd disabled, ignoring --enable-discreteaci argument])
243         fi
244         if test $ol_with_ldbm_api != auto ; then
245                 AC_MSG_WARN([slapd disabled, ignoring --with-ldbm-api argument])
246         fi
247         if test $ol_with_ldbm_type != auto ; then
248                 AC_MSG_WARN([slapd disabled, ignoring --with-ldbm-type argument])
249         fi
250         if test $ol_with_bdb2_module != static ; then
251                 AC_MSG_WARN([slapd disabled, ignoring --with-bdb2-module argument])
252         fi
253         if test $ol_with_ldap_module != static ; then
254                 AC_MSG_WARN([slapd disabled, ignoring --with-ldap-module argument])
255         fi
256         if test $ol_with_ldbm_module != static ; then
257                 AC_MSG_WARN([slapd disabled, ignoring --with-ldbm-module argument])
258         fi
259         if test $ol_with_passwd_module != static ; then
260                 AC_MSG_WARN([slapd disabled, ignoring --with-passwd-module argument])
261         fi
262         if test $ol_with_perl_module != static ; then
263                 AC_MSG_WARN([slapd disabled, ignoring --with-perl-module argument])
264         fi
265         if test $ol_with_shell_module != static ; then
266                 AC_MSG_WARN([slapd disabled, ignoring --with-shell-module argument])
267         fi
268         if test $ol_with_tcl_module != static ; then
269                 AC_MSG_WARN([slapd disabled, ignoring --with-tcl-module argument])
270         fi
271         if test $ol_enable_slurpd = yes ; then
272                 AC_MSG_ERROR([slurpd requires slapd])
273         fi
274
275         # force settings to no
276         ol_enable_bdb2=no
277         ol_enable_ldap=no
278         ol_enable_ldbm=no
279         ol_enable_passwd=no
280         ol_enable_perl=no
281         ol_enable_shell=no
282         ol_enable_tcl=no
283
284         ol_enable_modules=no
285         ol_enable_multimaster=no
286         ol_enable_phonetic=no
287         ol_enable_quipu=no
288         ol_enable_rlookups=no
289         ol_enable_aci=no
290         ol_enable_discreteaci=no
291         ol_enable_wrappers=no
292
293         ol_with_ldbm_api=no
294         ol_with_ldbm_type=no
295
296         ol_with_bdb2_module=static
297         ol_with_ldap_module=static
298         ol_with_ldbm_module=static
299         ol_with_passwd_module=static
300         ol_with_perl_module=static
301         ol_with_shell_module=static
302         ol_with_tcl_module=static
303
304         ol_enable_slurpd=no
305
306 elif test $ol_enable_ldbm = no ; then
307         dnl SLAPD without LDBM
308
309         if test $ol_with_ldbm_api != auto ; then
310                 AC_MSG_WARN([LDBM disabled, ignoring --with-ldbm-api argument])
311         fi
312
313         if test $ol_with_ldbm_type != auto ; then
314                 AC_MSG_WARN([LDBM disabled, ignoring --with-ldbm-type argument])
315         fi
316
317         if test $ol_with_ldbm_module != static ; then
318                 AC_MSG_WARN([LDBM disabled, ignoring --with-ldbm-module argument])
319         fi
320
321         if test $ol_enable_bdb2 = yes ; then
322                 AC_MSG_ERROR([BDB2 requires --enable-ldbm])
323         fi
324
325         if test $ol_enable_modules != yes -a \
326                 $ol_enable_ldap = no -a \
327                 $ol_enable_passwd = no -a \
328                 $ol_enable_perl = no -a \
329                 $ol_enable_shell = no -a \
330                 $ol_enable_tcl = no ; then
331                 AC_MSG_ERROR([slapd requires a backend])
332         fi
333
334         ol_with_ldbm_api=no
335         ol_with_ldbm_type=no
336         ol_with_ldbm_module=static
337
338 elif test $ol_enable_bdb2 = yes ; then
339         dnl SLAPD with BDB2
340
341         if test $ol_with_ldbm_api != auto -a \
342                 $ol_with_ldbm_api != db2 ; then
343                 AC_MSG_ERROR([BDB2 requires LDBM API DB2])
344         fi
345
346         ol_with_ldbm_api=db2
347
348 else
349         dnl SLAPD with LDBM
350
351         if test $ol_enable_bdb2 != no ; then
352                 if test $ol_with_ldbm_api != auto -a \
353                         $ol_with_ldbm_api != db2 ; then
354                         AC_MSG_WARN([BDB2 requires LDBM api db2 or auto])
355                         ol_enable_bdb2=no
356                 fi
357         fi
358
359         if test $ol_with_ldbm_api = gdbm -a \
360                 $ol_with_ldbm_type = btree ; then
361                 AC_MSG_ERROR([GDBM only supports LDBM type hash])
362         fi
363         if test $ol_with_ldbm_api = mdbm -a \
364                 $ol_with_ldbm_type = btree ; then
365                 AC_MSG_ERROR([MDBM only supports LDBM type hash])
366         fi
367         if test $ol_with_ldbm_api = ndbm -a \
368                 $ol_with_ldbm_type = btree ; then
369                 AC_MSG_ERROR([NDBM only supports LDBM type hash])
370         fi
371 fi
372
373 if test $ol_enable_slurpd = yes ; then
374         dnl SLURPD was specifically enabled
375         if test $ol_with_threads = no ; then
376                 AC_MSG_ERROR([slurpd requires threads])
377         fi
378 fi
379
380 AC_MSG_RESULT(done)
381
382 dnl ----------------------------------------------------------------
383 dnl Initialize vars
384 LDAP_LIBS=
385 LDIF_LIBS=
386 LDBM_LIBS=
387 LTHREAD_LIBS=
388 LUTIL_LIBS=
389
390 LDAPD_LIBS=
391 SLAPD_LIBS=
392 SLURPD_LIBS=
393
394 BUILD_LDAPD=no
395 BUILD_SLAPD=no
396 BUILD_SLURPD=no
397
398 BUILD_BDB2=no
399 BUILD_LDAP=no
400 BUILD_LDBM=no
401 BUILD_PASSWD=no
402 BUILD_PERL=no
403 BUILD_QUIPU=no
404 BUILD_SHELL=no
405 BUILD_TCL=no
406 BUILD_THREAD=no
407
408 BUILD_BDB2_DYNAMIC=static
409 BUILD_LDAP_DYNAMIC=static
410 BUILD_LDBM_DYNAMIC=static
411 BUILD_PASSWD_DYNAMIC=static
412 BUILD_PERL_DYNAMIC=static
413 BUILD_SHELL_DYNAMIC=static
414 BUILD_TCL_DYNAMIC=static
415
416 SLAPD_MODULES_LDFLAGS=
417 SLAPD_MODULES_CPPFLAGS=
418 SLAPD_MODULES_LIST=
419
420 SLAPD_PERL_LDFLAGS=
421 MOD_PERL_LDFLAGS=
422 PERL_CPPFLAGS=
423
424 MOD_TCL_LIB=
425 KRB_LIBS=
426 READLINE_LIBS=
427 SASL_LIBS=
428 TERMCAP_LIBS=
429 TLS_LIBS=
430 MODULES_LIBS=
431
432 dnl ================================================================
433 dnl Checks for programs
434
435 dnl AC_PROG_INSTALL
436
437 AC_DEFINE(HAVE_MKVERSION, 1, [define this if you have mkversion])
438
439 dnl ----------------------------------------------------------------
440 dnl
441 dnl Determine which C translator to use
442 dnl
443
444 dnl AIX Thread requires we use cc_r or xlc_r.
445 dnl But only do this IF AIX and CC is not set
446 dnl and threads are auto|yes|posix.
447 dnl
448 dnl If we find cc_r|xlc_r, force pthreads and assume
449 dnl             pthread_create is in $LIBS (ie: don't bring in
450 dnl             any additional thread libraries)
451 dnl If we do not find cc_r|xlc_r, disable threads
452
453 ol_aix_threads=no
454 case "$target" in
455 *-*-aix*) dnl all AIX is not a good idea.
456         if test -z "$CC" ; then
457                 case "$ol_with_threads" in
458                 auto | yes |  posix) ol_aix_threads=yes ;;
459                 esac
460         fi
461 ;;
462 esac
463
464 if test $ol_aix_threads = yes ; then
465         if test -z "${CC}" ; then
466                 AC_CHECK_PROGS(CC,cc_r xlc_r cc)
467
468                 if test "$CC" = cc ; then
469                         dnl no CC! don't allow --with-threads
470                         if test $ol_with_threads != auto ; then
471                                 AC_MSG_ERROR([--with-threads requires cc_r (or other suitable compiler) on AIX])
472                         else
473                                 AC_MSG_WARN([disabling threads, no cc_r on AIX])
474                         fi
475                         ol_with_threads=no
476                 fi
477         fi
478
479         if test "${CC}" = "cc_r" -o "${CC}" = "xlc_r" ; then
480                 ol_with_threads=posix
481                 ol_cv_pthread_create=yes
482         fi
483 fi
484
485 if test -z "${CC}"; then
486         AC_CHECK_PROGS(CC,cc)
487 fi
488
489 dnl The default CFLAGS is empty NOT whatever AC_PROG_CC sets.
490 dnl (for now, let autoconf sort this out)
491 dnl CFLAGS=${CFLAGS-""}
492
493 AC_LIBTOOL_DLOPEN
494 AC_PROG_LIBTOOL
495
496 AC_PROG_AWK
497 OL_PROG_LN_H
498 AC_PROG_LN_S
499
500 if test "$LN_H" = "cp" -a "$LN_S" = "ln"; then
501         LN_S="$LN_H"
502 fi
503
504 AC_PATH_PROG(SENDMAIL, sendmail, /usr/lib/sendmail,
505         $PATH:/usr/libexec:/usr/lib:/usr/sbin:/usr/etc:/etc)
506 AC_PATH_PROG(EDITOR, vi, /usr/ucb/vi, $PATH:/usr/ucb)
507 AC_PATH_PROG(FINGER, finger, /usr/ucb/finger, $PATH:/usr/ucb)
508
509 dnl ----------------------------------------------------------------
510 dnl Perl
511 ol_link_perl=no
512 if test $ol_enable_perl != no ; then
513         AC_PATH_PROG(PERLBIN, perl, /usr/bin/perl)
514
515         if test "no$PERLBIN" = "no" ; then
516                 if test $ol_enable_perl = yes ; then
517                         AC_MSG_ERROR([could not locate perl])
518                 fi
519
520         else
521                 PERL_CPPFLAGS="`$PERLBIN -MExtUtils::Embed -e ccopts`"
522                 if test x"$ol_with_perl_module" == "xstatic" ; then
523                         SLAPD_PERL_LDFLAGS="`$PERLBIN -MExtUtils::Embed -e ldopts|sed -e s/-lc//`"
524                 else
525                         MOD_PERL_LDFLAGS="`$PERLBIN -MExtUtils::Embed -e ldopts|sed -e s/-lc//`"
526                 fi
527                 dnl should check perl version
528                 ol_link_perl=yes
529         fi
530 fi
531
532 AC_PROG_CPP
533
534 dnl ----------------------------------------------------------------
535 dnl Cross compiling checks
536 if test $cross_compiling = yes -a $ol_enable_x_compile = yes; then
537         AC_MSG_WARN([cross compiling....  some functionality will be removed.])
538
539 elif test $cross_compiling = no -a $ol_enable_x_compile = yes; then
540         AC_MSG_WARN([programs compiled here do run here...])
541         AC_MSG_ERROR([  if not cross compiling, use --disable-x-compile.])
542
543 elif test $cross_compiling = yes -a $ol_enable_x_compile = no; then
544         AC_MSG_WARN([programs compiled here do not run here...])
545         AC_MSG_ERROR([  if cross compiling,  add --enable-x-compile.])
546 fi
547
548 dnl ----------------------------------------------------------------
549 dnl Checks for UNIX Variants
550 AC_AIX
551 AC_ISC_POSIX
552 AC_MINIX
553
554 dnl ----------------------------------------------------------------
555 dnl Checks for system services
556 AC_CYGWIN
557 AC_MINGW32
558 AC_EXEEXT
559 AC_OBJEXT
560
561 AC_DEFINE_UNQUOTED( EXEEXT, "${EXEEXT}", [defined to be the EXE extension])
562
563 dnl ----------------------------------------------------------------
564 dnl BeOS requires -lbe -lroot -lnet
565 AC_CHECK_LIB(be, be_app, [LIBS="$LIBS -lbe -lroot -lnet"], :, [-lroot -lnet])
566
567 dnl ----------------------------------------------------------------
568 dnl OpenLDAP requires STDC features
569 AM_PROG_CC_STDC
570 if test "X${am_cv_prog_cc_stdc}" = "Xno" ; then
571         AC_MSG_ERROR([OpenLDAP requires compiler to support STDC constructs.])
572 fi
573
574 dnl ----------------------------------------------------------------
575 dnl Check cc depend flags
576 OL_MKDEPEND
577 if test "${ol_cv_mkdep}" = no ; then
578         # this will soon become an error
579         AC_MSG_WARN([do not know how to generate dependencies])
580 fi
581
582 dnl ----------------------------------------------------------------
583 dnl Check for module support
584 ol_link_modules=no
585 if test $ol_enable_modules != no ; then
586         AC_CHECK_HEADERS(ltdl.h)
587
588         if test $ac_cv_header_ltdl_h = no ; then
589                 AC_MSG_ERROR([could not locate libtool ltdl.h])
590         fi
591
592         AC_CHECK_LIB(ltdl, lt_dlinit)
593         if test "$ac_cv_lib_ltdl_lt_dlinit" = no ; then
594                 AC_MSG_ERROR([could not locate libtool -lltdl])
595         fi
596         ol_link_modules=yes
597
598 else
599         ol_with_bdb2_module=static
600         ol_with_ldap_module=static
601         ol_with_ldbm_module=static
602         ol_with_passwd_module=static
603         ol_with_perl_module=static
604         ol_with_shell_module=static
605         ol_with_tcl_module=static
606 fi
607
608 dnl ----------------------------------------------------------------
609 dnl Checks for header files.
610 OL_HEADER_STDC
611
612 if test $ol_cv_header_stdc != yes; then
613         AC_MSG_WARN([could not locate Standard C compliant headers])
614 fi
615
616 AC_HEADER_DIRENT
617 AC_HEADER_SYS_WAIT
618 AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
619 if test $am_cv_sys_posix_termios = yes ; then
620         AC_DEFINE(HAVE_POSIX_TERMIOS,1,
621                 [define if you have POSIX termios])
622 fi
623
624 AC_CHECK_HEADERS(       \
625         arpa/inet.h             \
626         arpa/nameser.h  \
627         assert.h                \
628         crypt.h                 \
629         errno.h                 \
630         fcntl.h                 \
631         filio.h                 \
632         getopt.h                \
633         grp.h                   \
634         libutil.h               \
635         limits.h                \
636         locale.h                \
637         netinet/tcp.h   \
638         malloc.h                \
639         memory.h                \
640         psap.h                  \
641         pwd.h                   \
642         resolv.h                \
643         sgtty.h                 \
644         shadow.h                \
645         stddef.h                \
646         string.h                \
647         strings.h               \
648         sysexits.h              \
649         sys/file.h              \
650         sys/filio.h             \
651         sys/errno.h             \
652         sys/ioctl.h             \
653         sys/param.h             \
654         sys/resource.h  \
655         sys/select.h    \
656         sys/socket.h    \
657         sys/syslog.h    \
658         sys/time.h              \
659         sys/types.h             \
660         syslog.h                \
661         termios.h               \
662         unistd.h                \
663 )
664
665 dnl ----------------------------------------------------------------
666 dnl Checks for libraries
667
668 dnl HP-UX requires -lV3
669 AC_CHECK_LIB(V3, sigset)
670
671 dnl Find socket()
672 dnl Likely combinations:
673 dnl             -lsocket [ -lnsl_s | -lnsl ]
674 dnl             -linet
675
676 AC_CHECK_FUNC(socket, :, [      
677 dnl hopefully we won't include too many libraries
678         AC_CHECK_LIB(socket, main)
679         AC_CHECK_LIB(net, main)
680         AC_CHECK_LIB(net, socket)
681         AC_CHECK_LIB(nsl_s, main)
682         AC_CHECK_LIB(nsl, main)
683         AC_CHECK_LIB(inet, socket)
684         AC_CHECK_LIB(gen, main)
685 ])
686
687 dnl require select
688 AC_CHECK_FUNC(select, :, AC_MSG_ERROR([select() required.]))
689 dnl AC_CHECK_FUNCS(socketpair)
690
691 dnl Select arg types
692 dnl (if this detection becomes permenent, it and the select() detection
693 dnl should be done before the yielding select test) 
694 AC_FUNC_SELECT_ARGTYPES
695
696 dnl check to see if system call automatically restart
697 dnl AC_SYS_RESTARTABLE_SYSCALLS
698
699 dnl ----------------------------------------------------------------
700 dnl require POSIX regex
701 AC_CHECK_HEADERS( regex.h )
702 if test "$ac_cv_header_regex_h" != yes ; then
703         AC_MSG_ERROR([POSIX regex.h required.])
704 fi
705 AC_CHECK_FUNC(regfree, :, AC_MSG_ERROR([POSIX regex required.]))
706
707 OL_POSIX_REGEX
708 if test "$ol_cv_c_posix_regex" = no ; then
709         AC_MSG_ERROR([broken POSIX regex!])
710 fi
711
712 dnl ----------------------------------------------------------------
713 dnl Check for resolver routines
714 AC_CHECK_FUNC(res_search,:)
715 if test $ac_cv_func_res_search = no ; then 
716         AC_CHECK_LIB(bind, res_search)
717         ac_cv_func_res_search=$ac_cv_lib_bind_res_search
718 fi
719
720 if test $ac_cv_func_res_search = no ; then 
721         AC_CHECK_LIB(bind, __res_search)
722         ac_cv_func_res_search=$ac_cv_lib_bind___res_search
723 fi
724
725 if test $ac_cv_func_res_search = no ; then 
726         AC_CHECK_LIB(resolv, res_search)
727         ac_cv_func_res_search=$ac_cv_lib_resolv_res_search
728 fi
729
730 if test "$ac_cv_func_res_search" = yes ; then
731         AC_DEFINE(HAVE_RES_SEARCH,1,
732                 [define if you have res_search()])
733 elif test $ol_enable_dns = yes ; then
734         AC_MSG_ERROR([--enable-dns requires res_search])
735 elif test $ol_enable_dns != no ; then
736         AC_MSG_WARN([no res_search, disabling DNS support])
737 fi
738
739
740 dnl ----------------------------------------------------------------
741 dnl ISODE tests
742 ol_link_isode=no
743 if test $ol_enable_ldapd != no ; then
744         AC_MSG_WARN([ldapd is not supported and may suffer from bit rot.])
745
746         dnl look for ISODE libraries
747         AC_CHECK_LIB(xtpp, main, [
748                 ol_link_isode=yes
749                 AC_DEFINE(HAVE_XTPP,1, [define if you have -lxttp])
750                 LDAPD_LIBS="$LDAPD_LIBS -lxtpp -lxtdsap -lxtisode -losi"
751                 ],:,[-lxtdsap -lxtisode -losi])
752         AC_CHECK_LIB(dsap, main, [
753                 ol_link_isode=yes
754                 AC_DEFINE(HAVE_DSAP,1, [define if you have -ldsap])
755                 LDAPD_LIBS="$LDAPD_LIBS -ldsap"
756                 ],:,[-lisode])
757         AC_CHECK_LIB(isode, main, [
758                 ol_link_isode=yes
759                 AC_DEFINE(HAVE_ISODE,1, [define if you have -lisode])
760                 LDAPD_LIBS="$LDAPD_LIBS -lisode"
761                 ],:)
762 fi
763
764 if test $ol_link_isode != no; then
765         AC_CHECK_LIB(pp, main, [
766                 AC_DEFINE(HAVE_PP,1, [define if you have -lpp])
767                 LDAPD_LIBS="-lpp $LDAPD_LIBS"
768                 ],:)
769
770         AC_PATH_PROG(PEPSY, pepsy)
771 fi
772
773 dnl ----------------------------------------------------------------
774 dnl QUIPU
775 if test $ol_enable_quipu != no ; then
776         AC_CHECK_HEADERS(quipu/commonarg.h)
777
778         if test $ac_cv_header_quipu_commonarg_h = yes ; then
779                 BUILD_QUIPU=yes
780         elif test $ol_enable_quipu = auto ; then
781                 AC_MSG_WARN([no quipu for --enable-quipu=auto, disabling])
782         else
783                 AC_MSG_ERROR(no quipu for --enable-quipu=$ol_enable_quipu)
784         fi
785 fi
786
787 dnl ----------------------------------------------------------------
788 dnl Kerberos
789 ol_link_kerberos=no
790
791 if test $ol_with_kerberos = auto -o $ol_with_kerberos = k5 ; then
792         AC_CHECK_HEADERS(kerberosIV/krb.h kerberosIV/des.h)
793
794         if test $ac_cv_header_kerberosIV_krb_h = yes ; then
795                 AC_CHECK_LIB(krb4, main, [have_k5=yes], [have_k5=no],
796                         [-lkrb5 -ldes425])
797
798                 if test $have_k5 = yes ; then
799                         ol_with_kerberos=found
800                         ol_link_kerberos=yes
801
802                         KRB_LIBS="-lkrb4 -lkrb5 -ldes425"
803
804                         LIBS="$KRB_LIBS $LIBS"
805
806                         AC_CACHE_CHECK([for des_debug in Kerberos libraries],
807                                 [ol_cv_var_des_debug], [
808                                 dnl save the flags
809                                 save_LIBS="$LIBS"
810                                 LIBS="$KRB_LIBS $LIBS"
811                                 AC_TRY_LINK([
812 #include <kerberosIV/krb.h>
813 #include <kerberosIV/des.h>
814 extern int des_debug;
815 ],[
816 des_debug = 1;
817 ],                              ol_cv_var_des_debug=yes, ol_cv_var_des_debug=no)
818                                 dnl restore the LIBS
819                                 LIBS="$save_LIBS"
820                         ])
821
822                         if test $ol_cv_var_des_debug = yes ; then
823                                 AC_DEFINE(HAVE_DES_DEBUG,1,
824                                         [define if you have Kerberos des_debug])
825                         fi
826
827                         LIBS="$save_LIBS"
828                 fi
829         fi
830 fi
831
832 if test $ol_with_kerberos = auto -o $ol_with_kerberos = k4 ; then
833         AC_CHECK_HEADERS(krb.h des.h)
834
835         if test $ac_cv_header_krb_h = yes ; then
836                 AC_CHECK_LIB(krb, main, [have_k4=yes], [have_k4=no], [-ldes])
837
838                 if test $have_k4 = yes ; then
839                         ol_with_kerberos=found
840                         ol_link_kerberos=yes
841
842                         KRB_LIBS="-lkrb -ldes"
843                 fi
844         fi
845 fi
846
847 if test $ol_link_kerberos = yes ; then
848         AC_DEFINE(HAVE_KERBEROS, 1, [define if you have Kerberos])
849 fi
850
851 dnl ----------------------------------------------------------------
852 dnl TLS/SSL
853 ol_link_tls=no
854 if test $ol_with_tls != no ; then
855         
856         AC_CHECK_HEADERS(openssl/ssl.h ssl.h)
857         
858         if test $ac_cv_header_openssl_ssl_h = yes -o $ac_cv_header_ssl_h = yes ; then
859                 AC_CHECK_LIB(ssl, SSLeay_add_ssl_algorithms, 
860                         [have_ssleay=yes
861                         need_rsaref=no],
862                         [have_ssleay=no],
863                         [-lcrypto])
864                         
865                 if test $have_ssleay = no ; then
866                         AC_CHECK_LIB(ssl, SSL_library_init,
867                                 [have_ssleay=yes
868                                 need_rsaref=no], [have_ssleay=no],
869                                 [-lcrypto])
870                 fi
871
872                 if test $have_ssleay = no ; then
873                         AC_CHECK_LIB(ssl, ssl3_accept, 
874                                 [have_ssleay=yes
875                                 need_rsaref=yes], [have_ssleay=no],
876                                 [-lcrypto -lRSAglue -lrsaref])
877                 fi
878
879                 if test $have_ssleay = yes ; then
880                         ol_with_tls=found
881                         ol_link_tls=yes
882
883                         AC_DEFINE(HAVE_SSLEAY, 1, 
884                                 [define if you have SSLeay or OpenSSL])
885
886                         if test $need_rsaref = yes; then
887                                 AC_DEFINE(HAVE_RSAREF, 1, 
888                                         [define if you have RSAref])
889
890                                 TLS_LIBS="-lssl -lcrypto -lRSAglue -lrsaref"
891                         else
892                                 TLS_LIBS="-lssl -lcrypto"
893                         fi
894                 fi
895         fi
896 fi
897
898 if test $ol_link_tls = yes ; then
899         AC_DEFINE(HAVE_TLS, 1, [define if you have TLS])
900 fi      
901
902 dnl ----------------------------------------------------------------
903 dnl Tests for reentrant functions necessary to build a
904 dnl thread_safe -lldap.
905 AC_CHECK_FUNCS(         \
906         ctime_r                 \
907         gethostbyname_r gethostbyaddr_r \
908 )
909
910 if test "$ac_cv_func_ctime_r" = no ; then
911         ol_cv_func_ctime_r_nargs=0
912 else
913         OL_FUNC_CTIME_R_NARGS
914 dnl     OL_FUNC_CTIME_R_TYPE
915 fi
916
917 if test "$ac_cv_func_gethostbyname_r" = yes ; then
918         OL_FUNC_GETHOSTBYNAME_R_NARGS
919 else
920         ol_cv_func_gethostbyname_r_nargs=0
921 fi
922  
923 if test "$ac_cv_func_gethostbyaddr_r" = yes ; then
924         OL_FUNC_GETHOSTBYADDR_R_NARGS
925 else
926         ol_cv_func_gethostbyaddr_r_nargs=0
927 fi
928
929 if test "$ac_cv_func_ctime_r" = yes \
930         -a "$ol_cv_func_ctime_r_nargs" -ge 2 \
931         -a "$ol_cv_func_ctime_r_nargs" -le 3 \
932         -a "$ac_cv_func_gethostbyname_r" = yes \
933         -a "$ol_cv_func_gethostbyname_r_nargs" -ge 5 \
934         -a "$ol_cv_func_gethostbyname_r_nargs" -le 6 \
935         -a "$ac_cv_func_gethostbyaddr_r" = yes \
936         -a "$ol_cv_func_gethostbyaddr_r_nargs" -ge 5 \
937         -a "$ol_cv_func_gethostbyaddr_r_nargs" -le 6 \
938         ; then
939  
940         AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_REENTRANT,1)
941 fi
942
943 dnl ----------------------------------------------------------------
944 dnl Threads?
945 ol_link_threads=no
946 if test $ol_with_threads = auto -o $ol_with_threads = yes \
947         -o $ol_with_threads = posix ; then
948
949         AC_CHECK_HEADERS(pthread.h)
950
951         if test $ac_cv_header_pthread_h = yes ; then
952                 OL_POSIX_THREAD_VERSION
953
954                 if test $ol_cv_pthread_version = final ; then
955                         AC_DEFINE(HAVE_PTHREADS_FINAL,1,
956                                 [define if pthreads API compatible with final spec])
957                 elif test $ol_cv_pthread_version = draft4 ; then
958                         AC_DEFINE(HAVE_PTHREADS_D4,1,
959                                 [define if pthreads API compatible with draft4 spec])
960                 else
961                         AC_MSG_ERROR([unknown pthread version])
962                 fi
963
964                 # consider threads found
965                 ol_with_threads=found
966
967                 OL_HEADER_LINUX_THREADS
968                 OL_HEADER_GNU_PTH_PTHREAD_H
969
970                 if test $ol_cv_header_gnu_pth_pthread_h = no ; then
971                         AC_CHECK_HEADERS(sched.h)
972                 fi
973
974                 dnl Now the hard part, how to link?
975                 dnl
976                 dnl currently supported checks:
977                 dnl
978                 dnl Check for no flags 
979                 dnl     pthread_create() in $LIBS
980                 dnl
981                 dnl Check special pthread (final) flags
982                 dnl     [skipped] pthread_create() with -mt (Solaris) [disabled]
983                 dnl     pthread_create() with -kthread (FreeBSD)
984                 dnl     pthread_create() with -pthread (FreeBSD/Digital Unix)
985                 dnl     pthread_create() with -pthreads (?)
986                 dnl     pthread_create() with -mthreads (AIX)
987                 dnl     pthread_create() with -thread (?)
988                 dnl
989                 dnl Check pthread (final) libraries
990                 dnl     pthread_mutex_unlock() in -lpthread -lmach -lexc -lc_r (OSF/1)
991                 dnl     pthread_mutex_lock() in -lpthread -lmach -lexc (OSF/1)
992                 dnl     [skipped] pthread_mutex_trylock() in -lpthread -lexc (OSF/1)
993                 dnl     pthread_join() -Wl,-woff,85 -lpthread (IRIX)
994                 dnl     pthread_create() in -lpthread (many)
995                 dnl     pthread_create() in -lc_r (FreeBSD)
996                 dnl
997                 dnl Check pthread (draft4) flags (depreciated)
998                 dnl     pthread_create() with -threads (OSF/1)
999                 dnl
1000                 dnl Check pthread (draft4) libraries (depreciated)
1001                 dnl     pthread_mutex_unlock() in -lpthreads -lmach -lexc -lc_r (OSF/1)
1002                 dnl     pthread_mutex_lock() in -lpthreads -lmach -lexc (OSF/1)
1003                 dnl     pthread_mutex_trylock() in -lpthreads -lexc (OSF/1)
1004                 dnl     pthread_create() in -lpthreads (many)
1005                 dnl
1006
1007                 dnl pthread_create in $LIBS
1008                 AC_CACHE_CHECK([for pthread_create in default libraries],
1009                         ol_cv_pthread_create,[
1010                 AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
1011                         [ol_cv_pthread_create=yes],
1012                         [ol_cv_pthread_create=no],
1013                         [AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
1014                                 [ol_cv_pthread_create=yes],
1015                                 [ol_cv_pthread_create=no])])])
1016
1017                 if test $ol_cv_pthread_create != no ; then
1018                         ol_link_threads=posix
1019                         ol_link_pthreads=""
1020                 fi
1021                 
1022 dnl             OL_PTHREAD_TRY([-mt],           [ol_cv_pthread_mt])
1023                 OL_PTHREAD_TRY([-kthread],      [ol_cv_pthread_kthread])
1024                 OL_PTHREAD_TRY([-pthread],      [ol_cv_pthread_pthread])
1025                 OL_PTHREAD_TRY([-pthreads],     [ol_cv_pthread_pthreads])
1026                 OL_PTHREAD_TRY([-mthreads],     [ol_cv_pthread_mthreads])
1027                 OL_PTHREAD_TRY([-thread],       [ol_cv_pthread_thread])
1028
1029                 OL_PTHREAD_TRY([-lpthread -lmach -lexc -lc_r],
1030                         [ol_cv_pthread_lpthread_lmach_lexc_lc_r])
1031                 OL_PTHREAD_TRY([-lpthread -lmach -lexc],
1032                         [ol_cv_pthread_lpthread_lmach_lexc])
1033 dnl             OL_PTHREAD_TRY([-lpthread -lexc],
1034 dnl                     [ol_cv_pthread_lpthread_lexc])
1035
1036                 OL_PTHREAD_TRY([-lpthread -Wl,-woff,85],
1037                         [ol_cv_pthread_lib_lpthread_woff])
1038
1039                 OL_PTHREAD_TRY([-lpthread],     [ol_cv_pthread_lpthread])
1040                 OL_PTHREAD_TRY([-lc_r],         [ol_cv_pthread_lc_r])
1041
1042                 OL_PTHREAD_TRY([-threads],      [ol_cv_pthread_threads])
1043
1044                 OL_PTHREAD_TRY([-lpthreads -lmach -lexc -lc_r],
1045                         [ol_cv_pthread_lpthreads_lmach_lexc_lc_r])
1046                 OL_PTHREAD_TRY([-lpthreads -lmach -lexc],
1047                         [ol_cv_pthread_lpthreads_lmach_lexc])
1048                 OL_PTHREAD_TRY([-lpthreads -lexc],
1049                         [ol_cv_pthread_lpthreads_lexc])
1050
1051                 OL_PTHREAD_TRY([-lpthreads],[ol_cv_pthread_lib_lpthreads])
1052
1053                 if test $ol_link_threads != no ; then
1054                         AC_DEFINE(HAVE_PTHREADS,1,
1055                                 [define if you have POSIX Threads])
1056
1057                         LTHREAD_LIBS="$LTHREAD_LIBS $ol_link_pthreads"
1058
1059                         dnl save flags
1060                         save_CPPFLAGS="$CPPFLAGS"
1061                         save_LIBS="$LIBS"
1062                         LIBS="$LTHREAD_LIBS $LIBS"
1063
1064                         dnl All POSIX Thread (final) implementations should have
1065                         dnl sched_yield instead of pthread yield.
1066                         dnl check for both
1067                         AC_CHECK_FUNCS(sched_yield pthread_yield)
1068
1069                         if test $ac_cv_func_sched_yield = no -a \
1070                                 $ac_cv_func_pthread_yield = no ; then
1071                                 dnl Digital UNIX has sched_yield() in -lrt
1072                                 AC_CHECK_LIB(rt, sched_yield,
1073                                         [LTHREAD_LIBS="$LTHREAD_LIBS -lrt"
1074                                         AC_DEFINE(HAVE_SCHED_YIELD,1,
1075                                                 [Define if you have the sched_yield function.])
1076                                         ac_cv_func_sched_yield=yes],
1077                                         [ac_cv_func_sched_yield=no])
1078                         fi
1079                         if test $ac_cv_func_sched_yield = no -a \
1080                                 $ac_cv_func_pthread_yield = no ; then
1081                                 dnl Solaris has sched_yield() stub in -lposix4
1082                                 dnl but we'll use thr_yield instead.
1083                                 AC_CHECK_FUNCS(thr_yield)
1084                         fi
1085                         if test $ac_cv_func_sched_yield = no -a \
1086                                 $ac_cv_func_pthread_yield = no -a \
1087                                 "$ac_cv_func_thr_yield" = no ; then
1088                                 AC_MSG_WARN([could not locate sched_yield() or pthread_yield()])
1089                         fi
1090
1091                         dnl Check functions for compatibility
1092                         AC_CHECK_FUNCS(pthread_kill)
1093
1094                         dnl Check for pthread_detach with <pthread.h> inclusion
1095                         dnl as it's symbol may have been mangled.
1096                         AC_CACHE_CHECK([for pthread_detach with <pthread.h>],
1097                                 [ol_cv_func_pthread_detach], [
1098                                 dnl save the flags
1099                                 AC_TRY_LINK([
1100 #include <pthread.h>
1101 #ifndef NULL
1102 #define NULL (void*)0
1103 #endif
1104 ],
1105                                         [pthread_detach(NULL);],
1106                                         [ol_cv_func_pthread_detach=yes],
1107                                         [ol_cv_func_pthread_detach=no])
1108                         ])
1109
1110                         if test $ol_cv_func_pthread_detach = no ; then
1111                                 AC_MSG_ERROR([could not locate pthread_detach()])
1112                         fi
1113
1114                         AC_DEFINE(HAVE_PTHREAD_DETACH,1,
1115                                 [define if you have pthread_detach function])
1116
1117                         dnl Check for setconcurreny functions
1118                         AC_CHECK_FUNCS( \
1119                                 pthread_setconcurrency \
1120                                 pthread_getconcurrency \
1121                                 thr_setconcurrency \
1122                                 thr_getconcurrency \
1123                         )
1124
1125                         OL_SYS_LINUX_THREADS
1126                         OL_LINUX_THREADS
1127
1128                         if test $ol_cv_linux_threads = error; then
1129                                 AC_MSG_ERROR([LinuxThreads header/library mismatch]);
1130                         fi
1131
1132                         AC_CACHE_CHECK([if pthread_create() works],
1133                                 ol_cv_pthread_create_works,[
1134                         AC_TRY_RUN(OL_PTHREAD_TEST_PROGRAM,
1135                                 [ol_cv_pthread_create_works=yes],
1136                                 [ol_cv_pthread_create_works=no],
1137                                 [dnl assume yes
1138                                 ol_cv_pthread_create_works=yes])])
1139
1140                         if test $ol_cv_pthread_create_works = no ; then
1141                                 AC_MSG_ERROR([pthread_create is not usable, check environment settings])
1142                         fi
1143
1144                         dnl Check if select causes an yield
1145                         if test $ol_with_yielding_select = auto ; then
1146                                 AC_CACHE_CHECK([if select yields when using pthreads],
1147                                         ol_cv_pthread_select_yields,[
1148                                 AC_TRY_RUN([
1149 #include <sys/types.h>
1150 #include <sys/time.h>
1151 #include <unistd.h>
1152 #include <pthread.h>
1153 #ifndef NULL
1154 #define NULL (void*) 0
1155 #endif
1156
1157 static int fildes[2];
1158
1159 static void *task(p)
1160         void *p;
1161 {
1162         int i;
1163         struct timeval tv;
1164
1165         fd_set rfds;
1166
1167         tv.tv_sec=10;
1168         tv.tv_usec=0;
1169
1170         FD_ZERO(&rfds);
1171         FD_SET(fildes[0], &rfds);
1172
1173         /* we're not interested in any fds */
1174         i = select(FD_SETSIZE, &rfds, NULL, NULL, &tv);
1175
1176         if(i < 0) {
1177                 perror("select");
1178                 exit(10);
1179         }
1180
1181         exit(0); /* if we exit here, the select blocked the whole process */
1182 }
1183
1184 int main(argc, argv)
1185         int argc;
1186         char **argv;
1187 {
1188         pthread_t t;
1189
1190         /* create a pipe to select */
1191         if(pipe(&fildes[0])) {
1192                 perror("select");
1193                 exit(1);
1194         }
1195
1196 #ifdef HAVE_PTHREAD_SETCONCURRENCY
1197         (void) pthread_setconcurrency(2);
1198 #else
1199 #ifdef HAVE_THR_SETCONCURRENCY
1200         /* Set Solaris LWP concurrency to 2 */
1201         thr_setconcurrency(2);
1202 #endif
1203 #endif
1204
1205 #if HAVE_PTHREADS_D4
1206         pthread_create(&t, pthread_attr_default, task, NULL);
1207 #else
1208         pthread_create(&t, NULL, task, NULL);
1209 #endif
1210
1211 #if HAVE_SCHED_YIELD
1212         sched_yield();  /* make sure task runs first */
1213 #else
1214 #ifdef HAVE_PTHREAD_YIELD
1215         pthread_yield();        /* make sure task runs first */
1216 #endif
1217 #endif
1218
1219         exit(2);
1220 }],
1221                                 [ol_cv_pthread_select_yields=no],
1222                                 [ol_cv_pthread_select_yields=yes],
1223                                 [ol_cv_pthread_select_yields=cross])])
1224
1225                                 if test $ol_cv_pthread_select_yields = cross ; then
1226                                         AC_MSG_ERROR([crossing compiling: use --with-yielding_select=yes|no|manual])
1227                                 fi
1228
1229                                 if test $ol_cv_pthread_select_yields = yes ; then
1230                                         ol_with_yielding_select=yes
1231                                 fi
1232                         fi
1233
1234                         dnl restore flags
1235                         CPPFLAGS="$save_CPPFLAGS"
1236                         LIBS="$save_LIBS"
1237                 else
1238                         AC_MSG_ERROR([could not link with POSIX Threads])
1239                 fi
1240         fi
1241
1242         if test $ol_with_threads = posix ; then
1243                 AC_MSG_ERROR([could not locate POSIX Threads])
1244         fi
1245 fi
1246
1247 if test $ol_with_threads = auto -o $ol_with_threads = yes \
1248         -o $ol_with_threads = mach ; then
1249
1250         dnl check for Mach CThreads
1251         AC_CHECK_HEADERS(mach/cthreads.h)
1252         if test $ac_cv_header_mach_cthreads_h = yes ; then
1253                 ol_with_threads=found
1254
1255                 dnl check for cthread support in current $LIBS
1256                 AC_CHECK_FUNC(cthread_fork,[ol_link_threads=yes])
1257
1258                 if test $ol_link_threads = no ; then
1259                         dnl try -all_load
1260                         dnl this test needs work
1261                         AC_CACHE_CHECK([for cthread_fork with -all_load],
1262                                 [ol_cv_cthread_all_load], [
1263                                 dnl save the flags
1264                                 save_LIBS="$LIBS"
1265                                 LIBS="-all_load $LIBS"
1266                                 AC_TRY_LINK([#include <mach/cthreads.h>],[
1267                                         cthread_fork((void *)0, (void *)0);
1268                                         ], ol_cv_cthread_all_load=yes, ol_cv_cthread_all_load=no)
1269                                 dnl restore the LIBS
1270                                 LIBS="$save_LIBS"
1271                         ])
1272
1273                         if test $ol_cv_cthread_all_load = yes ; then
1274                                 LTHREAD_LIBS="$LTHREAD_LIBS -all_load"
1275                                 ol_link_threads=mach
1276                         fi
1277                 fi
1278
1279                 if test $ol_link_threads != no ; then
1280                         : check for cthread specific functionality here
1281                         AC_DEFINE(HAVE_MACH_CTHREADS,1,
1282                                 [define if you have Mach Cthreads])
1283                 else
1284                         AC_MSG_ERROR([could not link with Mach CThreads])
1285                 fi
1286         fi
1287
1288         if test $ol_with_threads = mach ; then
1289                 AC_MSG_ERROR([could not locate Mach CThreads])
1290         fi
1291 fi
1292
1293 if test $ol_with_threads = auto -o $ol_with_threads = yes \
1294         -o $ol_with_threads = pth ; then
1295
1296         AC_CHECK_HEADERS(pth.h)
1297
1298         if test $ac_cv_header_pth_h = yes ; then
1299                 AC_CHECK_LIB(pth, pth_version, [have_pth=yes], [have_pth=no])
1300
1301                 if test $have_pth = yes ; then
1302                         AC_DEFINE(HAVE_GNU_PTH,1,[if you have GNU Pth])
1303                         LTHREAD_LIBS="$LTHREAD_LIBS -lpth"
1304                         ol_link_threads=pth
1305
1306                         if test $ol_with_yielding_select = auto ; then
1307                                 ol_with_yielding_select=yes
1308                         fi
1309                 fi
1310         fi
1311 fi
1312
1313 if test $ol_with_threads = auto -o $ol_with_threads = yes \
1314         -o $ol_with_threads = lwp ; then
1315
1316         dnl check for SunOS5 LWP
1317         AC_CHECK_HEADERS(thread.h synch.h)
1318         if test $ac_cv_header_thread_h = yes -a $ac_cv_header_synch_h = yes ; then
1319                 AC_CHECK_LIB(thread, thr_create, [have_thr=yes], [have_thr=no])
1320
1321                 if test $have_thr = yes ; then
1322                         AC_DEFINE(HAVE_THR,1,
1323                                 [if you have Solaris LWP (thr) package])
1324                         LTHREAD_LIBS="$LTHREAD_LIBS -lthread"
1325                         ol_link_threads=thr
1326
1327                         if test $ol_with_yielding_select = auto ; then
1328                                 ol_with_yielding_select=yes
1329                         fi
1330
1331                         dnl Check for setconcurreny functions
1332                         AC_CHECK_FUNCS( \
1333                                 thr_setconcurrency \
1334                                 thr_getconcurrency \
1335                         )
1336                 fi
1337         fi
1338
1339         dnl check for SunOS4 LWP
1340         AC_CHECK_HEADERS(lwp/lwp.h)
1341         if test $ac_cv_header_lwp_lwp_h = yes ; then
1342                 AC_CHECK_LIB(lwp, lwp_create, [have_lwp=yes], [have_lwp=no])
1343
1344                 if test $have_lwp = yes ; then
1345                         AC_DEFINE(HAVE_LWP,1,
1346                                 [if you have SunOS LWP package])
1347                         LTHREAD_LIBS="$LTHREAD_LIBS -llwp"
1348                         ol_link_threads=lwp
1349
1350                         if test $ol_with_yielding_select = auto ; then
1351                                 ol_with_yielding_select=no
1352                         fi
1353                 fi
1354         fi
1355 fi
1356
1357 if test $ol_with_yielding_select = yes ; then
1358         AC_DEFINE(HAVE_YIELDING_SELECT,1,
1359                 [define if select implicitly yields])
1360 fi
1361
1362 if test $ol_with_threads = manual ; then
1363         dnl User thinks he can manually configure threads.
1364         ol_link_threads=yes
1365
1366         AC_MSG_WARN([thread defines and link options must be set manually])
1367
1368         AC_CHECK_HEADERS(pthread.h sched.h)
1369         AC_CHECK_FUNCS(sched_yield pthread_yield)
1370         OL_HEADER_LINUX_THREADS
1371
1372         AC_CHECK_HEADERS(mach/cthreads.h)
1373         AC_CHECK_HEADERS(lwp/lwp.h)
1374         AC_CHECK_HEADERS(thread.h synch.h)
1375 fi
1376
1377 if test $ol_link_threads != no ; then  
1378         dnl needed to get reentrant/threadsafe versions
1379         dnl
1380         AC_DEFINE(REENTRANT,1)
1381         AC_DEFINE(_REENTRANT,1)
1382         AC_DEFINE(THREAD_SAFE,1)
1383         AC_DEFINE(_THREAD_SAFE,1)
1384         AC_DEFINE(THREADSAFE,1)
1385         AC_DEFINE(_THREADSAFE,1)
1386         AC_DEFINE(_SGI_MP_SOURCE,1)
1387
1388         dnl The errno declaration may dependent upon _REENTRANT.
1389         dnl If it does, we must link with thread support.
1390         AC_CACHE_CHECK([for thread specific errno],
1391                 [ol_cv_errno_thread_specific], [
1392                 AC_TRY_LINK([#include <errno.h>], [errno = 0;],
1393                         [ol_cv_errno_thread_specific=yes],
1394                         [ol_cv_errno_thread_specific=no])
1395         ])
1396
1397         dnl The h_errno declaration may dependent upon _REENTRANT.
1398         dnl If it does, we must link with thread support.
1399         AC_CACHE_CHECK([for thread specific h_errno],
1400                 [ol_cv_h_errno_thread_specific], [
1401                 AC_TRY_LINK([#include <netdb.h>], [h_errno = 0;],
1402                         [ol_cv_h_errno_thread_specific=yes],
1403                         [ol_cv_h_errno_thread_specific=no])
1404         ])
1405
1406         if test $ol_cv_errno_thread_specific != yes \
1407                 -o $ol_cv_h_errno_thread_specific != yes ; then
1408                 LIBS="$LTHREAD_LIBS $LIBS"
1409                 LTHREAD_LIBS=""
1410         fi
1411
1412 dnl When in thread environment, use 
1413 dnl             #if defined( HAVE_REENTRANT_FUNCTIONS ) \ 
1414 dnl                     || defined( HAVE_FUNC_R )
1415 dnl                     func_r(...);
1416 dnl             #else
1417 dnl             #       if defined( HAVE_THREADS ) 
1418 dnl                             /* lock */
1419 dnl             #       endif
1420 dnl                             func(...);
1421 dnl             #       if defined( HAVE_THREADS ) 
1422 dnl                             /* unlock */
1423 dnl             #       endif
1424 dnl             #endif
1425 dnl
1426 dnl HAVE_REENTRANT_FUNCTIONS is derived from:
1427 dnl             _POSIX_REENTRANT_FUNCTIONS
1428 dnl             _POSIX_THREAD_SAFE_FUNCTIONS
1429 dnl             _POSIX_THREADSAFE_FUNCTIONS
1430 dnl
1431 dnl             and is currently defined in lthread.h
1432 dnl
1433 dnl HAVE_THREADS is defined by lthread.h iff -UNO_THREADS
1434 dnl 
1435 dnl libldap/*.c should only include <lthread.h> iff
1436 dnl LDAP_R_COMPILE is defined.  ie:
1437 dnl             #ifdef LDAP_R_COMPILE
1438 dnl             #       include LDAP_R_COMPILE
1439 dnl             #endif
1440 dnl
1441 dnl LDAP_R_COMPILE is defined by libldap_r/Makefile.in
1442 dnl specifically for compiling the threadsafe version of
1443 dnl     the ldap library (-lldap_r).
1444 dnl             
1445 dnl     dnl check for reentrant/threadsafe functions
1446 dnl     dnl
1447 dnl     dnl note: these should only be used when linking
1448 dnl     dnl       with $LTHREAD_LIBS
1449 dnl     dnl
1450 dnl     save_CPPFLAGS="$CPPFLAGS"
1451 dnl     save_LIBS="$LIBS"
1452 dnl     LIBS="$LTHREAD_LIBS $LIBS"
1453 dnl     AC_CHECK_FUNCS( \
1454 dnl             gmtime_r \
1455 dnl             gethostbyaddr_r gethostbyname_r \
1456 dnl             feof_unlocked unlocked_feof \
1457 dnl             putc_unlocked unlocked_putc \
1458 dnl             flockfile ftrylockfile \
1459 dnl     )
1460 dnl     CPPFLAGS="$save_CPPFLAGS"
1461 dnl     LIBS="$save_LIBS"
1462 fi  
1463
1464 if test $ol_link_threads = no ; then
1465         if test $ol_with_threads = yes ; then
1466                 AC_MSG_ERROR([no suitable thread support])
1467         fi
1468
1469         if test $ol_with_threads = auto ; then
1470                 AC_MSG_WARN([no suitable thread support, disabling threads])
1471                 ol_with_threads=no
1472         fi
1473
1474         AC_DEFINE(NO_THREADS,1,
1475                 [define if you have (or want) no threads])
1476         LTHREAD_LIBS=""
1477 fi
1478
1479 if test $ol_link_threads != no ; then
1480         AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE,1)
1481 fi
1482
1483 dnl ----------------------------------------------------------------
1484
1485 ol_link_ldbm=no 
1486 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db2 ; then
1487         OL_BERKELEY_DB2
1488
1489         if test $ol_cv_berkeley_db2 = yes ; then
1490                 ol_link_ldbm=db2
1491                 ol_with_ldbm_api=db2
1492
1493                 if test $ol_with_ldbm_type = hash ; then
1494                         AC_DEFINE(LDBM_USE_DBHASH,1,
1495                                 [define this to use DBHASH w/ LDBM backend])
1496                 else
1497                         AC_DEFINE(LDBM_USE_DBBTREE,1,
1498                                 [define this to use DBBTREE w/ LDBM backend])
1499                 fi
1500
1501                 OL_BERKELEY_DB2_DB_THREAD
1502
1503                 dnl $ol_cv_lib_db2 should be yes or -ldb
1504                 dnl (it could be no, but that would be an error
1505                 if test $ol_cv_lib_db2 != yes ; then
1506                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_db2"
1507                 fi
1508         fi
1509 fi
1510
1511 ol_link_bdb2=no
1512 if test $ol_link_ldbm = db2 -a $ol_enable_bdb2 != no ; then
1513         if test $ol_cv_berkeley_db2_db_thread != no ; then
1514                 ol_link_bdb2=yes
1515         else
1516                 AC_MSG_WARN([Installed BerkeleyDB does not provide DB_THREAD support.])
1517         fi
1518 fi
1519
1520 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db ; then
1521         OL_BERKELEY_DB
1522
1523         if test $ol_cv_berkeley_db = yes ; then
1524                 ol_link_ldbm=db
1525                 ol_with_ldbm_api=db
1526
1527                 if test $ol_with_ldbm_type = hash ; then
1528                         AC_DEFINE(LDBM_USE_DBHASH,1,
1529                                 [define this to use DBHASH w/ LDBM backend])
1530                 else
1531                         AC_DEFINE(LDBM_USE_DBBTREE,1,
1532                                 [define this to use DBBTREE w/ LDBM backend])
1533                 fi
1534
1535                 dnl $ol_cv_lib_db should be yes or -ldb
1536                 dnl (it could be no, but that would be an error
1537                 if test $ol_cv_lib_db != yes ; then
1538                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_db"
1539                 fi
1540         fi
1541 fi
1542
1543 if test $ol_with_ldbm_api = manual ; then
1544         dnl User thinks he can manually configure LDBM api.
1545         ol_link_ldbm=yes
1546
1547         AC_MSG_WARN([LDBM defines and link options must be set manually])
1548
1549         AC_CHECK_HEADERS(db.h db_185.h gdbm.h ndbm.h)
1550 fi
1551
1552 if test $ol_link_ldbm = no -a $ol_with_ldbm_type = btree ; then
1553         AC_MSG_WARN(Could not find LDBM with BTREE support)
1554         ol_with_ldbm_api=none
1555 fi
1556
1557 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = mdbm ; then
1558         OL_MDBM
1559
1560         if test $ol_cv_mdbm = yes ; then
1561                 ol_link_ldbm=mdbm
1562                 ol_with_ldbm_api=mdbm
1563                 if test $ol_cv_lib_mdbm != yes ; then
1564                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_mdbm"
1565                 fi
1566         fi
1567 fi
1568
1569 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = gdbm ; then
1570         OL_GDBM
1571
1572         if test $ol_cv_gdbm = yes ; then
1573                 ol_link_ldbm=gdbm
1574                 ol_with_ldbm_api=gdbm
1575
1576                 if test $ol_cv_lib_gdbm != yes ; then
1577                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_gdbm"
1578                 fi
1579         fi
1580 fi
1581
1582 if test $ol_with_ldbm_api = auto ; then
1583         AC_MSG_WARN([skipping automatic checking for NDBM, must be manually enabled.])
1584 elif test $ol_with_ldbm_api = ndbm ; then
1585         OL_NDBM
1586
1587         if test $ol_cv_ndbm = yes ; then
1588                 ol_link_ldbm=ndbm
1589                 ol_with_ldbm_api=ndbm
1590
1591                 if test $ol_cv_lib_ndbm != yes ; then
1592                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_ndbm"
1593                 fi
1594         fi
1595 fi
1596
1597 if test $ol_link_ldbm = no -a $ol_enable_ldbm != no ; then
1598         AC_MSG_WARN(could not find suitable LDBM backend)
1599         if test $ol_enable_ldbm = yes ; then
1600                 AC_MSG_ERROR(select appropriate LDBM options or disable)
1601         fi
1602
1603         AC_MSG_WARN(disabling LDBM)
1604         ol_enable_ldbm=no
1605 fi
1606
1607 dnl ----------------------------------------------------------------
1608 if test $ol_enable_wrappers != no ; then
1609         AC_CHECK_HEADERS(tcpd.h)
1610
1611         if test $ac_cv_header_tcpd_h != yes ; then
1612                 have_wrappers=no
1613         else
1614                 AC_TRY_COMPILE([
1615 int allow_severity = 0;
1616 int deny_severity  = 0;
1617                 ],[hosts_access()],[have_wrappers=yes],[have_wrappers=no])
1618         fi
1619
1620         if test $have_wrappers = yes ; then
1621                 AC_DEFINE(HAVE_TCPD,1, [define if you have -lwrap])
1622                 WRAP_LIBS="-lwrap"
1623
1624                 dnl We add another check for -lnsl since some libwrap's
1625                 dnl need it, but it isn't always included from above
1626                 AC_CHECK_LIB(nsl, main)
1627         else
1628                 AC_MSG_WARN(could not find -lwrap)
1629                 if test $ol_enable_wrappers = yes ; then
1630                         AC_MSG_ERROR(could not find wrappers, select appropriate options or disable)
1631                 fi
1632
1633                 AC_MSG_WARN(disabling wrappers support)
1634                 ol_enable_wrappers=no
1635                 WRAP_LIBS=""
1636         fi
1637 fi
1638
1639 dnl ----------------------------------------------------------------
1640 if test $ol_enable_syslog != no ; then
1641         AC_CHECK_FUNC(openlog)
1642         if test $ac_cv_func_openlog = no -a $ol_enable_syslog = yes; then
1643                 AC_MSG_ERROR(could not find syslog, select appropriate options or disable)
1644         fi
1645         ol_enable_syslog=$ac_cv_func_openlog
1646 fi
1647
1648 dnl ----------------------------------------------------------------
1649 if test $ol_enable_dmalloc != no ; then
1650         AC_CHECK_HEADERS(dmalloc.h)
1651         AC_CHECK_LIB(dmalloc, dmalloc_shutdown)
1652 fi
1653
1654 dnl ----------------------------------------------------------------
1655 dnl TCL
1656 if test $ol_enable_tcl != no ; then
1657         AC_CHECK_HEADERS(tcl.h)
1658
1659         if test $ac_cv_header_tcl_h != yes ; then
1660                 have_tcl=no
1661         else
1662                 for lib in tcl tcl7.6 tcl8.0 tcl8.2 ; do
1663                         AC_CHECK_LIB($lib,main,
1664                           [have_tcl=yes
1665                            if test x"$ol_with_tcl_module" == "xstatic" ; then
1666                                SLAPD_LIBS="$SLAPD_LIBS -l${lib}"
1667                            else
1668                                MOD_TCL_LIB="-l${lib}"
1669                            fi;break],[have_tcl=no])
1670                 done
1671         fi
1672
1673         if test $have_tcl != yes ; then
1674                 AC_MSG_WARN([could not find -ltcl])
1675                 if test $ol_enable_tcl = yes ; then
1676                         AC_MSG_ERROR([could not find tcl, select appropriate options or disable])
1677                 fi
1678
1679                 ol_enable_tcl=no
1680         fi
1681 fi
1682
1683 dnl ----------------------------------------------------------------
1684 dnl ud needs termcap (should insert check here)
1685 ol_link_termcap=no
1686 AC_CHECK_HEADERS(termcap.h ncurses.h)
1687
1688 if test $ol_link_termcap = no ; then
1689         AC_CHECK_LIB(termcap, tputs, [have_termcap=yes], [have_termcap=no])
1690         if test $have_termcap = yes ; then
1691                 AC_DEFINE(HAVE_TERMCAP, 1, [define if you have -ltermcap])
1692                 ol_link_termcap=yes
1693                 TERMCAP_LIBS=-ltermcap
1694         fi
1695 fi
1696
1697 if test $ol_link_termcap = no ; then
1698         AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
1699         if test $have_ncurses = yes ; then
1700                 AC_DEFINE(HAVE_NCURSES, 1, [define if you have -lncurses])
1701                 ol_link_termcap=yes
1702                 TERMCAP_LIBS=-lncurses
1703         fi
1704 fi
1705
1706 if test $ol_link_termcap = no ; then
1707         AC_DEFINE(NO_TERMCAP,1, [define if you have no termcap support])
1708         TERMCAP_LIBS=
1709 fi
1710
1711 dnl ----------------------------------------------------------------
1712 dnl
1713 dnl Check for fetch URL support
1714 dnl             should be extended to support other fetch URL APIs
1715 dnl
1716 ol_link_sasl=no
1717 if test $ol_with_cyrus_sasl != no ; then
1718         AC_CHECK_HEADER(sasl.h)
1719
1720         if test $ac_cv_header_sasl_h = yes ; then
1721                 AC_CHECK_LIB(sasl, sasl_client_init,
1722                         [have_cyrus_sasl=yes], [have_cyrus_sasl=no])
1723
1724                 if test $have_cyrus_sasl != no ; then
1725                         SASL_LIBS="-lsasl"
1726                         AC_DEFINE(HAVE_CYRUS_SASL,1,[define if you have Cyrus SASL])
1727                         ol_link_sasl=yes
1728                 fi
1729         fi
1730
1731         if test $ol_link_sasl = no -a $ol_with_cyrus_sasl = yes ; then
1732                 AC_MSG_ERROR(no suitable API for --with-cyrus-sasl=$ol_with_cyrus_sasl)
1733         fi
1734 fi
1735
1736 dnl ----------------------------------------------------------------
1737 dnl
1738 dnl Check for fetch URL support
1739 dnl             should be extended to support other fetch URL APIs
1740 dnl
1741 ol_link_fetch=no
1742 if test $ol_with_fetch != no ; then
1743         OL_LIB_FETCH
1744
1745         if test $ol_cv_lib_fetch != no ; then
1746                 LDIF_LIBS="$LDIF_LIBS $ol_link_fetch"
1747                 ol_link_fetch=freebsd
1748
1749         elif test $ol_with_fetch != auto ; then
1750                 AC_MSG_ERROR(no suitable API for --with-fetch=$ol_with_fetch)
1751         fi 
1752 fi
1753
1754 dnl ----------------------------------------------------------------
1755 dnl
1756 dnl Check for GNU readline
1757 dnl
1758 ol_link_readline=no
1759 if test $ol_with_readline != no ; then
1760         AC_CHECK_HEADERS(readline/readline.h readline/history.h)
1761
1762         if test $ac_cv_header_readline_readline_h = yes ; then
1763                 save_LIBS="$LIBS"
1764                 LIBS="$TERMCAP_LIBS $LIBS"
1765                 AC_CHECK_LIB(readline, readline, 
1766                         [have_readline=yes], [have_readline=no])
1767                 LIBS="$save_LIBS"
1768                         
1769                 if test $have_readline = yes ; then
1770                         ol_with_readline=found
1771                         ol_link_readline=yes
1772
1773                         READLINE_LIBS="-lreadline"
1774                 fi
1775         fi
1776 fi
1777
1778 if test $ol_link_readline = yes ; then
1779         AC_DEFINE(HAVE_READLINE, 1, [define if you have -lreadline])
1780 fi
1781
1782
1783 dnl ----------------------------------------------------------------
1784 dnl FreeBSD (and others) have crypt(3) in -lcrypt
1785 if test $ol_enable_crypt != no ; then
1786         AC_CHECK_FUNC(crypt, [have_crypt=yes], [
1787                 AC_CHECK_LIB(crypt, crypt, [LUTIL_LIBS="$LUTIL_LIBS -lcrypt"
1788                         have_crypt=yes], [have_crypt=no])])
1789
1790         if test $have_crypt = yes ; then
1791                 AC_DEFINE(HAVE_CRYPT,1, [define if crypt(3) is available])
1792         else
1793                 AC_MSG_WARN(could not find crypt)
1794                 if test $ol_enable_crypt = yes ; then
1795                         AC_MSG_ERROR(could not find crypt, select appropriate options or disable)
1796                 fi
1797
1798                 AC_MSG_WARN(disabling crypt support)
1799                 ol_enable_crypt=no
1800         fi
1801 fi
1802
1803 dnl ----------------------------------------------------------------
1804 dnl FreeBSD (and others) have setproctitle(3) in -lutil
1805 if test $ol_enable_proctitle != no ; then
1806         AC_CHECK_FUNC(setproctitle,     [have_setproctitle=yes], [
1807                 AC_CHECK_LIB(util, setproctitle,
1808                         [have_setproctitle=yes
1809                         LUTIL_LIBS="$LUTIL_LIBS -lutil"],
1810                         [have_setproctitle=no
1811                         LIBOBJS="$LIBOBJS setproctitle.o"])])
1812
1813         if test $have_setproctitle = yes ; then
1814                 AC_DEFINE(HAVE_SETPROCTITLE,1,
1815                         [define if setproctitle(3) is available])
1816         fi
1817 fi
1818
1819 dnl ----------------------------------------------------------------
1820 dnl Checks for typedefs, structures, and compiler characteristics.
1821 AC_TYPE_GETGROUPS dnl requires AC_TYPE_UID_T
1822 AC_TYPE_MODE_T
1823 AC_TYPE_OFF_T
1824 AC_TYPE_PID_T
1825 AM_TYPE_PTRDIFF_T
1826 AC_TYPE_SIGNAL
1827 OL_TYPE_SIG_ATOMIC_T
1828 AC_TYPE_SIZE_T
1829 OL_TYPE_SOCKLEN_T
1830 AC_STRUCT_ST_BLKSIZE
1831 AC_HEADER_TIME
1832 AC_STRUCT_TM
1833 OL_STRUCT_PASSWD_PW_GECOS
1834 OL_STRUCT_PASSWD_PW_PASSWD
1835
1836 OL_C_UPPER_LOWER
1837 AC_C_CONST
1838 OL_C_VOLATILE
1839
1840 if test $cross_compiling = yes ; then
1841         AC_DEFINE(CROSS_COMPILING, 1, [define if cross compiling])
1842
1843         AC_DEFINE(LBER_INT_T,long)
1844         AC_DEFINE(LBER_TAG_T,long)
1845         AC_DEFINE(LBER_SOCKET_T,int)
1846
1847 else
1848         AC_C_BIGENDIAN
1849         AC_CHECK_SIZEOF(short) 
1850         AC_CHECK_SIZEOF(int) 
1851         AC_CHECK_SIZEOF(long)
1852
1853         if test "$ac_cv_sizeof_int" -lt 4 ; then
1854                 AC_MSG_WARN([OpenLDAP requires 'int' to be 32 bits or greater.])
1855
1856                 AC_DEFINE(LBER_INT_T,long)
1857                 AC_DEFINE(LBER_TAG_T,long)
1858                 AC_DEFINE(LBER_SOCKET_T,int)
1859         else
1860                 AC_DEFINE(LBER_INT_T,int)
1861                 AC_DEFINE(LBER_TAG_T,long)
1862                 AC_DEFINE(LBER_SOCKET_T,int)
1863         fi
1864 fi
1865
1866 AC_DEFINE(LBER_LEN_T,long)
1867
1868 dnl ----------------------------------------------------------------
1869 dnl Checks for library functions.
1870 AC_FUNC_MEMCMP
1871 dnl AM_FUNC_MKTIME dnl checks for sys/time.h and unistd.h
1872 AC_FUNC_STRFTIME
1873 dnl AM_FUNC_STRTOD
1874
1875 OL_FUNC_INET_ATON
1876
1877 dnl we should use vfork instead of fork in a number of places...
1878 dnl AC_FUNC_VFORK
1879 AC_FUNC_VPRINTF
1880
1881 if test $ac_cv_func_vprintf = yes ; then
1882         dnl check for vsnprintf
1883         AC_CHECK_FUNCS(vsnprintf vsprintf)
1884 fi
1885
1886 AC_CHECK_FUNCS(         \
1887         bcopy                   \
1888         closesocket             \
1889         endgrent                \
1890         endpwent                \
1891         flock                   \
1892         getdtablesize   \
1893         getgrgid                \
1894         gethostname             \
1895         getpass                 \
1896         getpwuid                \
1897         getpwnam                \
1898         getspnam                \
1899         gettimeofday    \
1900         initgroups              \
1901         lockf                   \
1902         memcpy                  \
1903         memmove                 \
1904         mkstemp                 \
1905         pipe                    \
1906         read                    \
1907         recv                    \
1908         recvfrom                \
1909         setpwfile               \
1910         setgid                  \
1911         setegid                 \
1912         setsid                  \
1913         setuid                  \
1914         seteuid                 \
1915         sigaction               \
1916         signal                  \
1917         sigset                  \
1918         snprintf                \
1919         strdup                  \
1920         strerror                \
1921         strpbrk                 \
1922         strrchr                 \
1923         strsep                  \
1924         strstr                  \
1925         strtol                  \
1926         strtoul                 \
1927         strspn                  \
1928         sysconf                 \
1929         waitpid                 \
1930         wait4                   \
1931         write                   \
1932         send                    \
1933         sendto                  \
1934 )
1935
1936 dnl We actually may need to replace more than this.
1937 AC_REPLACE_FUNCS(getopt tempnam)
1938
1939 dnl ----------------------------------------------------------------
1940 # Check Configuration
1941 OL_SYS_ERRLIST
1942
1943 dnl ----------------------------------------------------------------
1944 dnl Sort out defines
1945
1946 if test "$ol_enable_debug" != no ; then
1947         AC_DEFINE(LDAP_DEBUG,1,
1948                 [define this to add debugging code])
1949 fi
1950 if test "$ol_enable_syslog" = yes ; then
1951         AC_DEFINE(LDAP_SYSLOG,1,
1952                 [define this to add syslog code])
1953 fi
1954 if test "$ol_enable_libui" = yes ; then
1955         AC_DEFINE(LDAP_LIBUI,1,
1956                 [define this for LDAP User Interface support])
1957 fi
1958 if test "$ol_enable_cache" = no ; then
1959         AC_DEFINE(LDAP_NOCACHE,1,
1960                 [define this to remove -lldap cache support])
1961 fi
1962 if test "$ol_enable_dns" != no ; then
1963         AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_V2_DNS,LDAP_VENDOR_VERSION)
1964 fi
1965 if test "$ol_enable_proctitle" != no ; then
1966         AC_DEFINE(LDAP_PROCTITLE,1,
1967                 [define this for LDAP process title support])
1968 fi
1969 if test "$ol_enable_referrals" != no ; then
1970         AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS,LDAP_VENDOR_VERSION)
1971 fi
1972 if test "$ol_enable_cldap" != no ; then
1973         AC_DEFINE(LDAP_CONNECTIONLESS,1,[define to support CLDAP])
1974 fi
1975
1976 if test "$ol_enable_crypt" != no ; then
1977         AC_DEFINE(SLAPD_CRYPT,1,[define to support crypt(3) passwords])
1978 fi
1979 if test "$ol_enable_cleartext" != no ; then
1980         AC_DEFINE(SLAPD_CLEARTEXT,1,[define to support cleartext passwords])
1981 fi
1982 if test "$ol_enable_multimaster" != no ; then
1983         AC_DEFINE(SLAPD_MULTIMASTER,1,[define to support multimaster replication])
1984 fi
1985 if test "$ol_enable_phonetic" != no ; then
1986         AC_DEFINE(SLAPD_PHONETIC,1,[define to support phonetic])
1987 fi
1988 if test "$ol_enable_rlookups" != no ; then
1989         AC_DEFINE(SLAPD_RLOOKUPS,1,[define to support reverse lookups])
1990 fi
1991 if test "$ol_enable_aci" != no ; then
1992         AC_DEFINE(SLAPD_ACI_ENABLED,1,[define to support per-object ACIs])
1993 fi
1994 if test "$ol_enable_discreteaci" != no ; then
1995         AC_DEFINE(SLAPD_ACI_DISCRETE_RIGHTS,1,[define to support discrete rights in ACIs])
1996 fi
1997
1998 if test "$ol_link_modules" != no ; then
1999         AC_DEFINE(SLAPD_MODULES,1,[define to support modules])
2000         BUILD_SLAPD=yes
2001         MODULES_LIBS=-lltdl
2002         SLAPD_MODULES_LDFLAGS="-dlopen self"
2003 fi
2004
2005 if test "$ol_link_bdb2" != no ; then
2006         AC_DEFINE(SLAPD_BDB2,1,[define to support BDB2 backend])
2007         BUILD_SLAPD=yes
2008         BUILD_BDB2=yes
2009         if test "$ol_with_bdb2_module" != static ; then
2010                 AC_DEFINE(SLAPD_BDB2_DYNAMIC,1,
2011                         [define to support dynamic BDB2 backend])
2012                 BUILD_BDB2=mod
2013                 BUILD_BDB2_DYNAMIC=shared
2014                 SLAPD_MODULES_LIST="$SLAPD_MODULES_LIST -dlopen \$(SLAP_DIR)back-bdb2/back_bdb2.la"
2015         fi
2016 fi
2017
2018 if test "$ol_enable_ldap" != no ; then
2019         AC_DEFINE(SLAPD_LDAP,1,[define to support LDAP backend])
2020         BUILD_SLAPD=yes
2021         BUILD_LDAP=yes
2022         if test "$ol_with_ldap_module" != static ; then
2023                 AC_DEFINE(SLAPD_LDAP_DYNAMIC,1,
2024                         [define to support dynamic LDAP backend])
2025                 BUILD_LDAP=mod
2026                 BUILD_LDAP_DYNAMIC=shared
2027                 SLAPD_MODULES_LIST="$SLAPD_MODULES_LIST -dlopen \$(SLAP_DIR)back-ldap/back_ldap.la"
2028         fi
2029 fi
2030
2031 if test "$ol_link_ldbm" != no ; then
2032         AC_DEFINE(SLAPD_LDBM,1,[define to support LDBM backend])
2033         BUILD_SLAPD=yes
2034         BUILD_LDBM=yes
2035         if test "$ol_with_ldbm_module" != static ; then
2036                 AC_DEFINE(SLAPD_LDBM_DYNAMIC,1,
2037                         [define to support dynamic LDBM backend])
2038                 BUILD_LDBM=mod
2039                 BUILD_LDBM_DYNAMIC=shared
2040                 SLAPD_MODULES_LIST="$SLAPD_MODULES_LIST -dlopen \$(SLAP_DIR)back-ldbm/back_ldbm.la"
2041         fi
2042 fi
2043
2044 if test "$ol_enable_passwd" != no ; then
2045         AC_DEFINE(SLAPD_PASSWD,1,[define to support PASSWD backend])
2046         BUILD_SLAPD=yes
2047         BUILD_PASSWD=yes
2048         if test "$ol_with_passwd_module" != static ; then
2049                 AC_DEFINE(SLAPD_PASSWD_DYNAMIC,1,
2050                         [define to support dynamic PASSWD backend])
2051                 BUILD_PASSWD=mod
2052                 BUILD_PASSWD_DYNAMIC=shared
2053                 SLAPD_MODULES_LIST="$SLAPD_MODULES_LIST -dlopen \$(SLAP_DIR)back-passwd/back_passwd.la"
2054         fi
2055 fi
2056
2057 if test "$ol_link_perl" != no ; then
2058         AC_DEFINE(SLAPD_PERL,1,[define to support PERL backend])
2059         BUILD_SLAPD=yes
2060         BUILD_PERL=yes
2061         if test "$ol_with_perl_module" != static ; then
2062                 AC_DEFINE(SLAPD_PERL_DYNAMIC,1,
2063                         [define to support dynamic PERL backend])
2064                 BUILD_PERL=mod
2065                 BUILD_PERL_DYNAMIC=shared
2066                 SLAPD_MODULES_LIST="$SLAPD_MODULES_LIST -dlopen \$(SLAP_DIR)back-perl/back_perl.la"
2067         fi
2068 fi
2069
2070 if test "$ol_enable_shell" != no ; then
2071         AC_DEFINE(SLAPD_SHELL,1,[define to support SHELL backend])
2072         BUILD_SLAPD=yes
2073         BUILD_SHELL=yes
2074         if test "$ol_with_shell_module" != static ; then
2075                 AC_DEFINE(SLAPD_SHELL_DYNAMIC,1,
2076                         [define to support dynamic SHELL backend])
2077                 BUILD_SHELL=mod
2078                 BUILD_SHELL_DYNAMIC=shared
2079                 SLAPD_MODULES_LIST="$SLAPD_MODULES_LIST -dlopen \$(SLAP_DIR)back-shell/back_shell.la"
2080         fi
2081 fi
2082
2083 if test "$ol_enable_tcl" != no ; then
2084         AC_DEFINE(SLAPD_TCL,1,[define to support TCL backend])
2085         BUILD_SLAPD=yes
2086         BUILD_TCL=yes
2087         if test "$ol_with_tcl_module" != static; then
2088                 AC_DEFINE(SLAPD_TCL_DYNAMIC,1,
2089                         [define to support dynamic TCL backend])
2090                 BUILD_TCL=mod
2091                 BUILD_TCL_DYNAMIC=shared
2092                 SLAPD_MODULES_LIST="$SLAPD_MODULES_LIST -dlopen \$(SLAP_DIR)back-tcl/back_tcl.la"
2093         fi
2094 fi
2095
2096 if test "$ol_enable_slurpd" != no -a "$ol_link_threads" != no -a \
2097         $BUILD_SLAPD = yes ; then
2098         BUILD_SLURPD=yes
2099 fi
2100
2101 if test "$ol_link_isode" != no ; then
2102         BUILD_LDAPD=yes
2103 fi
2104
2105 dnl ----------------------------------------------------------------
2106
2107 AC_SUBST(BUILD_LDAPD)
2108 AC_SUBST(BUILD_SLAPD)
2109   AC_SUBST(BUILD_BDB2)
2110   AC_SUBST(BUILD_LDAP)
2111   AC_SUBST(BUILD_LDBM)
2112   AC_SUBST(BUILD_PASSWD)
2113   AC_SUBST(BUILD_PERL)
2114   AC_SUBST(BUILD_QUIPU)
2115   AC_SUBST(BUILD_SHELL)
2116   AC_SUBST(BUILD_TCL)
2117   AC_SUBST(BUILD_BDB2_DYNAMIC)
2118   AC_SUBST(BUILD_LDAP_DYNAMIC)
2119   AC_SUBST(BUILD_LDBM_DYNAMIC)
2120   AC_SUBST(BUILD_PASSWD_DYNAMIC)
2121   AC_SUBST(BUILD_PERL_DYNAMIC)
2122   AC_SUBST(BUILD_SHELL_DYNAMIC)
2123   AC_SUBST(BUILD_TCL_DYNAMIC)
2124 AC_SUBST(BUILD_SLURPD)
2125
2126 AC_SUBST(LDAP_LIBS)
2127 AC_SUBST(LDAPD_LIBS)
2128 AC_SUBST(LDIF_LIBS)
2129 AC_SUBST(SLAPD_LIBS)
2130 AC_SUBST(SLURPD_LIBS)
2131 AC_SUBST(LDBM_LIBS)
2132 AC_SUBST(LTHREAD_LIBS)
2133 AC_SUBST(LUTIL_LIBS)
2134 AC_SUBST(WRAP_LIBS)
2135 AC_SUBST(MOD_TCL_LIB)
2136
2137 AC_SUBST(SLAPD_MODULES_CPPFLAGS)
2138 AC_SUBST(SLAPD_MODULES_LDFLAGS)
2139 AC_SUBST(SLAPD_MODULES_LIST)
2140
2141 AC_SUBST(PERL_CPPFLAGS)
2142 AC_SUBST(SLAPD_PERL_LDFLAGS)
2143 AC_SUBST(MOD_PERL_LDFLAGS)
2144
2145 AC_SUBST(KRB_LIBS)
2146 AC_SUBST(READLINE_LIBS)
2147 AC_SUBST(SASL_LIBS)
2148 AC_SUBST(TERMCAP_LIBS)
2149 AC_SUBST(TLS_LIBS)
2150 AC_SUBST(MODULES_LIBS)
2151
2152 dnl ----------------------------------------------------------------
2153 dnl final output
2154 dnl
2155
2156 AC_OUTPUT( \
2157 Makefile:build/top.mk:Makefile.in:build/dir.mk \
2158 doc/Makefile:build/top.mk:doc/Makefile.in:build/dir.mk \
2159 doc/man/Makefile:build/top.mk:doc/man/Makefile.in:build/dir.mk \
2160 doc/man/man1/Makefile:build/top.mk:doc/man/man1/Makefile.in:build/man.mk \
2161 doc/man/man3/Makefile:build/top.mk:doc/man/man3/Makefile.in:build/man.mk \
2162 doc/man/man5/Makefile:build/top.mk:doc/man/man5/Makefile.in:build/man.mk \
2163 doc/man/man8/Makefile:build/top.mk:doc/man/man8/Makefile.in:build/man.mk \
2164 clients/Makefile:build/top.mk:clients/Makefile.in:build/dir.mk \
2165 clients/finger/Makefile:build/top.mk:clients/finger/Makefile.in:build/rules.mk \
2166 clients/fax500/Makefile:build/top.mk:clients/fax500/Makefile.in:build/rules.mk \
2167 clients/gopher/Makefile:build/top.mk:clients/gopher/Makefile.in:build/rules.mk \
2168 clients/mail500/Makefile:build/top.mk:clients/mail500/Makefile.in:build/rules.mk \
2169 clients/rcpt500/Makefile:build/top.mk:clients/rcpt500/Makefile.in:build/rules.mk \
2170 clients/ud/Makefile:build/top.mk:clients/ud/Makefile.in:build/rules.mk \
2171 clients/tools/Makefile:build/top.mk:clients/tools/Makefile.in:build/rules.mk \
2172 include/Makefile:build/top.mk:include/Makefile.in \
2173 libraries/Makefile:build/top.mk:libraries/Makefile.in:build/dir.mk      \
2174 libraries/libavl/Makefile:build/top.mk:libraries/libavl/Makefile.in:build/lib.mk:build/lib-static.mk    \
2175 libraries/liblber/Makefile:build/top.mk:libraries/liblber/Makefile.in:build/lib.mk:build/lib-shared.mk  \
2176 libraries/libldap/Makefile:build/top.mk:libraries/libldap/Makefile.in:build/lib.mk:build/lib-shared.mk  \
2177 libraries/libldap_r/Makefile:build/top.mk:libraries/libldap_r/Makefile.in:build/lib.mk:build/lib-shared.mk      \
2178 libraries/libldbm/Makefile:build/top.mk:libraries/libldbm/Makefile.in:build/lib.mk:build/lib-static.mk  \
2179 libraries/libldif/Makefile:build/top.mk:libraries/libldif/Makefile.in:build/lib.mk:build/lib-static.mk  \
2180 libraries/liblutil/Makefile:build/top.mk:libraries/liblutil/Makefile.in:build/lib.mk:build/lib-static.mk        \
2181 servers/Makefile:build/top.mk:servers/Makefile.in:build/dir.mk \
2182 servers/ldapd/Makefile:build/top.mk:servers/ldapd/Makefile.in:build/srv.mk \
2183 servers/slapd/Makefile:build/top.mk:servers/slapd/Makefile.in:build/srv.mk \
2184 servers/slapd/back-bdb2/Makefile:build/top.mk:servers/slapd/back-bdb2/Makefile.in:build/mod.mk \
2185 servers/slapd/back-ldap/Makefile:build/top.mk:servers/slapd/back-ldap/Makefile.in:build/mod.mk \
2186 servers/slapd/back-ldbm/Makefile:build/top.mk:servers/slapd/back-ldbm/Makefile.in:build/mod.mk \
2187 servers/slapd/back-passwd/Makefile:build/top.mk:servers/slapd/back-passwd/Makefile.in:build/mod.mk \
2188 servers/slapd/back-perl/Makefile:build/top.mk:servers/slapd/back-perl/Makefile.in:build/mod.mk \
2189 servers/slapd/back-shell/Makefile:build/top.mk:servers/slapd/back-shell/Makefile.in:build/mod.mk \
2190 servers/slapd/back-tcl/Makefile:build/top.mk:servers/slapd/back-tcl/Makefile.in:build/mod.mk \
2191 servers/slapd/shell-backends/Makefile:build/top.mk:servers/slapd/shell-backends/Makefile.in:build/srv.mk \
2192 servers/slapd/tools/Makefile:build/top.mk:servers/slapd/tools/Makefile.in \
2193 servers/slurpd/Makefile:build/top.mk:servers/slurpd/Makefile.in:build/srv.mk \
2194 tests/Makefile:build/top.mk:tests/Makefile.in:build/dir.mk \
2195 tests/progs/Makefile:build/top.mk:tests/progs/Makefile.in:build/rules.mk \
2196 contrib/Makefile:build/top.mk:contrib/Makefile.in:build/dir.mk \
2197 contrib/saucer/Makefile:build/top.mk:contrib/saucer/Makefile.in:build/rules.mk \
2198 contrib/web_ldap/Makefile:build/top.mk:contrib/web_ldap/Makefile.in:build/rules.mk \
2199 ,[
2200 date > stamp-h
2201 echo Please \"make depend\" to build dependencies
2202 ])