]> git.sur5r.net Git - openldap/blob - configure.in
Update year
[openldap] / configure.in
1 dnl
2 dnl Copyright 1998-2001 The OpenLDAP Foundation.  All Rights Reserved.
3 dnl 
4 dnl Redistribution and use in source and binary forms are permitted only
5 dnl as authorized by the OpenLDAP Public License.  A copy of this
6 dnl license is available at http://www.OpenLDAP.org/license.html or
7 dnl in file LICENSE in the top-level directory of the distribution.
8 dnl
9 dnl ----------------------------------------------------------------
10 dnl Redefine AC_INIT_BINSH to provide RCS IDs and copyright notice
11 dnl at top of generated configure script.  Prints simple copyright.
12 define([AC_INIT_BINSH],
13 [[#! /bin/sh
14 # $]OpenLDAP[$
15 # from] translit([$OpenLDAP$], $")] [
16
17 # Copyright 1998-2001 The OpenLDAP Foundation.  All Rights Reserved.
18 #
19 # Redistribution and use in source and binary forms are permitted only
20 # as authorized by the OpenLDAP Public License.  A copy of this
21 # license is available at http://www.OpenLDAP.org/license.html or
22 # in file LICENSE in the top-level directory of the distribution.
23
24 echo "Copyright 1998-2001 The OpenLDAP Foundation,  All Rights Reserved."
25 echo "Restrictions apply, see COPYRIGHT and LICENSE files."
26 ])dnl
27 dnl ----------------------------------------------------------------
28 dnl Disable config.cache!
29 define([AC_CACHE_LOAD], )dnl
30 define([AC_CACHE_SAVE], )dnl
31 dnl ================================================================
32 dnl Configure.in for OpenLDAP
33 AC_INIT(build/version)dnl
34
35 # set unset (borrowed from autoconf 2.14a)
36 if (unset FOO) >/dev/null 2>&1; then
37   ol_unset=unset
38 else
39   ol_unset=false
40 fi
41 # unset CDPATH
42 $ol_unset CDPATH || test "${CDPATH+set}" != set || CDPATH=: && export CDPATH
43
44 AC_CONFIG_AUX_DIR(build)dnl
45
46 OL_VERSION=`cat $ac_aux_dir/version`
47 if test -z "$OL_VERSION"; then
48     AC_MSG_ERROR([could not determine version])
49 fi
50
51 echo "Configuring OpenLDAP $OL_VERSION ..."
52
53
54 AM_INIT_AUTOMAKE(openldap,[1.2], [no ac_define])dnl
55
56 dnl We use autoconf features new to 2.13.1
57 dnl     aclocal.m4 should be built using aclocal from automake 1.4
58 AC_PREREQ(2.13.1)dnl Required Autoconf version
59
60 AC_CONFIG_HEADER(include/portable.h)dnl
61
62 dnl
63 dnl Start Args
64 AC_MSG_CHECKING(configure arguments)
65 AC_PREFIX_DEFAULT(/usr/local)
66
67 top_builddir=`pwd`
68 AC_SUBST(top_builddir)dnl
69
70 ldap_subdir="openldap"
71
72 AC_ARG_WITH(subdir, [  --with-subdir=DIR change default subdirectory used for installs], [
73         if test "$withval" = "no"; then
74                 ldap_subdir=""
75         elif test "$withval" != "yes"; then
76                 ldap_subdir="$withval"
77         fi
78 ])dnl
79
80 AC_SUBST(ldap_subdir)dnl
81
82 OL_ARG_ENABLE(debug,[  --enable-debug   enable debugging], yes)dnl
83 OL_ARG_ENABLE(proctitle,[  --enable-proctitle   enable proctitle support], yes)dnl
84 OL_ARG_ENABLE(libui,[  --enable-libui   enable library user interface], yes)dnl
85 OL_ARG_ENABLE(cache,[  --enable-cache   enable caching], yes)dnl
86 OL_ARG_ENABLE(dns,[  --enable-dns               enable dns support], no)dnl
87 OL_ARG_ENABLE(referrals,[  --enable-referrals   enable referrals], yes)dnl
88 OL_ARG_ENABLE(cldap,[  --enable-cldap   enable connectionless ldap], no)dnl
89 OL_ARG_ENABLE(x_compile,[  --enable-x-compile   enable cross compiling],
90         no, [yes no])dnl
91
92 dnl General "with" options
93 OL_ARG_ENABLE(dmalloc,[  --enable-dmalloc       enable debug malloc support], no)dnl
94
95 OL_ARG_WITH(kerberos,[  --with-kerberos use Kerberos],
96         auto, [auto k5 k4 afs yes no])
97 OL_ARG_WITH(threads,[  --with-threads   use threads],
98         auto, [auto posix mach pth lwp yes no manual] )
99 OL_ARG_WITH(yielding_select,[  --with-yielding-select   with implicitly yielding select],
100         auto, [auto yes no manual] )
101
102 dnl Server options
103
104 dnl LDAPD OPTIONS
105 AC_ARG_WITH(xxldapdoptions,[LDAPD Options:])
106 OL_ARG_ENABLE(ldapd,[  --enable-ldapd   enable building ldapd], no)dnl
107
108 dnl SLAPD OPTIONS
109 AC_ARG_WITH(xxslapdoptions,[SLAPD Options:])
110 OL_ARG_ENABLE(slapd,[  --enable-slapd   enable building slapd], yes)dnl
111 OL_ARG_ENABLE(aclgroups,[    --enable-aclgroups enable ACL group support], auto)dnl
112 OL_ARG_ENABLE(cleartext,[    --enable-cleartext enable cleartext passwords], yes)dnl
113 OL_ARG_ENABLE(crypt,[    --enable-crypt enable crypt(3) passwords], auto)dnl
114 OL_ARG_ENABLE(wrappers,[    --enable-wrappers   enable tcp wrapper support], no)dnl
115 OL_ARG_ENABLE(phonetic,[    --enable-phonetic   enable phonetic/soundex], no)dnl
116 OL_ARG_ENABLE(rlookups,[    --enable-rlookups   enable reverse lookups], auto)dnl
117
118 dnl SLAPD Backend options
119 OL_ARG_ENABLE(ldbm,[    --enable-ldbm   enable ldbm backend], yes)dnl
120 OL_ARG_WITH(ldbm_api,[      --with-ldbm-api     use LDBM API], auto,
121         [auto db2 db mdbm gdbm manual])
122 OL_ARG_WITH(ldbm_type,[      --with-ldbm-type   use LDBM type], auto,
123         [auto btree hash])
124
125 OL_ARG_ENABLE(passwd,[    --enable-passwd       enable passwd backend], no)dnl
126 OL_ARG_ENABLE(shell,[    --enable-shell enable shell backend], no)dnl
127
128 dnl SLURPD OPTIONS
129 AC_ARG_WITH(xxslurpdoptions,[SLURPD Options:])
130 OL_ARG_ENABLE(slurpd,[  --enable-slurpd enable building slurpd], auto)dnl
131
132 AC_ARG_WITH(xxliboptions,[Library Generation & Linking Options])
133 AM_ENABLE_STATIC
134 AM_DISABLE_SHARED
135 dnl AM_ENABLE_SHARED
136
137 dnl General "enable" options
138 # validate options
139 if test $ol_enable_dns = yes ; then
140         if test $ol_enable_referrals = no ; then
141                 AC_MSG_ERROR([DNS requires --enable-referrals])
142         fi
143         if test $ol_enable_referrals = auto ; then
144                 AC_MSG_WARN([DNS requires referrals, adding --enable-referrals])
145                 ol_enable_referrals=yes
146         fi
147 fi
148
149 if test $ol_enable_slapd = no ; then
150         dnl SLAPD was specificallly disabled
151         if test $ol_enable_ldbm = yes ; then
152                 AC_MSG_WARN([slapd disabled, ignoring --enable_ldbm argument])
153         fi
154         if test $ol_enable_passwd = yes ; then
155                 AC_MSG_WARN([slapd disabled, ignoring --enable_passwd argument])
156         fi
157         if test $ol_enable_shell = yes ; then
158                 AC_MSG_WARN([slapd disabled, ignoring --enable_shell argument])
159         fi
160         if test $ol_enable_aclgroups = yes ; then
161                 AC_MSG_WARN([slapd disabled, ignoring --enable_aclgroups argument])
162         fi
163         if test $ol_enable_wrappers = yes ; then
164                 AC_MSG_WARN([slapd disabled, ignoring --enable_wrappers argument])
165         fi
166         if test $ol_enable_phonetic = yes ; then
167                 AC_MSG_WARN([slapd disabled, ignoring --enable_phonetic argument])
168         fi
169         if test $ol_enable_rlookups = yes ; then
170                 AC_MSG_WARN([slapd disabled, ignoring --enable_rlookups argument])
171         fi
172         if test $ol_with_ldbm_api != auto ; then
173                 AC_MSG_WARN([slapd disabled, ignoring --with_ldbm_api argument])
174         fi
175         if test $ol_with_ldbm_type != auto ; then
176                 AC_MSG_WARN([slapd disabled, ignoring --with_ldbm_type argument])
177         fi
178         if test $ol_enable_slurpd = yes ; then
179                 AC_MSG_ERROR([slurpd requires slapd])
180         fi
181
182         # force settings to no
183         ol_enable_ldbm=no
184         ol_enable_shell=no
185         ol_enable_passwd=no
186         ol_enable_aclgroups=no
187         ol_enable_wrappers=no
188         ol_enable_phonetic=no
189         ol_enable_rlookups=no
190         ol_with_ldbm_api=no
191         ol_with_ldbm_type=no
192         ol_enable_slurpd=no
193
194 elif test $ol_enable_ldbm = no ; then
195         dnl SLAPD without LDBM
196
197         if test $ol_with_ldbm_api != auto ; then
198                 AC_MSG_WARN([LDBM disabled, ignoring --with_ldbm_api argument])
199         fi
200
201         if test $ol_with_ldbm_type != auto ; then
202                 AC_MSG_WARN([LDBM disabled, ignoring --with_ldbm_type argument])
203         fi
204
205         if test $ol_enable_passwd = no -a $ol_enable_shell = no ; then
206                 AC_MSG_ERROR([slapd requires a backend])
207         fi
208
209         ol_with_ldbm_api=no
210         ol_with_ldbm_type=no
211
212 else
213         dnl SLAPD with LDBM
214
215         if test $ol_with_ldbm_api = gdbm -a \
216                 $ol_with_ldbm_type = btree ; then
217                 AC_MSG_ERROR([GDBM only supports LDBM type hash])
218         fi
219         if test $ol_with_ldbm_api = mdbm -a \
220                 $ol_with_ldbm_type = btree ; then
221                 AC_MSG_ERROR([MDBM only supports LDBM type hash])
222         fi
223         if test $ol_with_ldbm_api = ndbm -a \
224                 $ol_with_ldbm_type = btree ; then
225                 AC_MSG_ERROR([NDBM only supports LDBM type hash])
226         fi
227 fi
228
229 if test $ol_enable_slurpd = yes ; then
230         dnl SLURPD was specifically enabled
231         if test $ol_with_threads = no ; then
232                 AC_MSG_ERROR([slurpd requires threads])
233         fi
234 fi
235
236 AC_MSG_RESULT(done)
237
238 AC_CANONICAL_HOST
239
240 ## Initialize vars
241 LDAP_LIBS=
242 LDBM_LIBS=
243 LTHREAD_LIBS=
244 LUTIL_LIBS=
245
246 LDAPD_LIBS=
247 SLAPD_LIBS=
248 SLURPD_LIBS=
249
250 BUILD_LDAPD=no
251 BUILD_SLAPD=no
252 BUILD_SLURPD=no
253
254 BUILD_LDBM=no
255 BUILD_PASSWD=no
256 BUILD_SHELL=no
257 BUILD_THREAD=no
258
259 KRB_LIBS=
260 TERMCAP_LIBS=
261
262 dnl ----------------------------------------------------------------
263 dnl Checks for programs
264
265 AC_PROG_INSTALL
266 AM_PROG_LIBTOOL
267 dnl AC_PROG_MAKE_SET
268
269 AC_PATH_PROG(SENDMAIL, sendmail, /usr/lib/sendmail,
270         $PATH:/usr/libexec:/usr/lib:/usr/sbin:/usr/etc:/etc)
271 AC_PATH_PROG(EDITOR, vi, /usr/ucb/vi, $PATH:/usr/ucb)
272 AC_PATH_PROG(FINGER, finger, /usr/ucb/finger, $PATH:/usr/ucb)
273
274 dnl Checks the compiler and UNIX Variants
275
276 if test $cross_compiling = yes -a $ol_enable_x_compile = yes; then
277         AC_MSG_WARN([cross compiling....  some functionality will be removed.])
278
279 elif test $cross_compiling = no -a $ol_enable_x_compile = yes; then
280         AC_MSG_WARN([programs compiled here do run here...])
281         AC_MSG_ERROR([  if not cross compiling, use --disable-x-compile.])
282
283 elif test $cross_compiling = yes -a $ol_enable_x_compile = no; then
284         AC_MSG_WARN([programs compiled here do not run here...])
285         AC_MSG_ERROR([  if cross compiling,  add --enable-x-compile.])
286 fi
287
288 AC_PROG_CPP
289
290 AC_AIX
291 AC_ISC_POSIX
292 AC_MINIX
293
294 dnl BeOS requires -lbe -lroot -lnet
295 AC_CHECK_LIB(be, be_app,
296         [LIBS="$LIBS -lbe -lroot -lnet"], :,
297         [-lroot -lnet])
298
299 dnl OpenLDAP requires STDC features
300 AM_PROG_CC_STDC
301 if test "X${am_cv_prog_cc_stdc}" = "Xno" ; then
302         AC_MSG_ERROR([OpenLDAP requires compiler to support STDC prototypes.])
303 fi
304
305 dnl AM_C_PROTOTYPES
306
307 dnl Checks for libraries
308
309 dnl Find socket()
310 dnl Likely combinations:
311 dnl             -lsocket [ -lnsl_s | -lnsl ]
312 dnl             -linet
313
314 AC_CHECK_FUNC(socket, [have_socket=yes], [      
315 dnl
316 dnl hopefully we won't include too many libraries
317 dnl
318         AC_CHECK_LIB(socket, main)
319         AC_CHECK_LIB(net, main)
320         AC_CHECK_LIB(nsl_s, main)
321         AC_CHECK_LIB(nsl, main)
322         AC_CHECK_LIB(inet, socket)
323         AC_CHECK_LIB(gen, main)
324 ])
325
326 dnl Check for resolver routines
327 AC_CHECK_FUNCS(res_search)
328 if test $ac_cv_func_res_search = "no" ; then 
329         AC_CHECK_LIB(bind, res_search)
330         ac_cv_func_res_search=$ac_cv_lib_bind_res_search
331 fi
332 if test $ac_cv_func_res_search = "no" ; then 
333         AC_CHECK_LIB(bind, __res_search)
334         ac_cv_func_res_search=$ac_cv_lib_bind___res_search
335 fi
336 if test $ac_cv_func_res_search = "no" ; then 
337         AC_CHECK_LIB(resolv, res_search)
338         ac_cv_func_res_search=$ac_cv_lib_resolv_res_search
339 fi
340 if test $ac_cv_func_res_search = "yes" ; then
341         AC_DEFINE(HAVE_RES_SEARCH,1)
342 fi
343
344 dnl HP-UX requires -lV3
345 AC_CHECK_LIB(V3, sigset)
346
347 # ISODE tests
348 ol_link_isode=no
349 if test $ol_enable_ldapd != no ; then
350         AC_MSG_WARN([ldapd support deprecated.  Manual intervention required.])
351         dnl look for ISODE libraries
352         AC_CHECK_LIB(xtpp, main, [
353                 ol_link_isode=yes
354                 AC_DEFINE(HAVE_XTPP,1, [define if you have -lxttp])
355                 LDAPD_LIBS="$LDAPD_LIBS -lxtpp -lxtdsap -lxtisode -losi"
356                 ],:,[-lxtdsap -lxtisode -losi])
357         AC_CHECK_LIB(dsap, main, [
358                 ol_link_isode=yes
359                 AC_DEFINE(HAVE_DSAP,1, [define if you have -ldsap])
360                 LDAPD_LIBS="$LDAPD_LIBS -ldsap"
361                 ],:,[-lisode])
362         AC_CHECK_LIB(isode, main, [
363                 ol_link_isode=yes
364                 AC_DEFINE(HAVE_ISODE,1, [define if you have -lisode])
365                 LDAPD_LIBS="$LDAPD_LIBS -lisode"
366                 ],:)
367 fi
368
369 if test $ol_link_isode != no; then
370         AC_CHECK_LIB(pp, main, [
371                 AC_DEFINE(HAVE_PP,1, [define if you have -lpp])
372                 LDAPD_LIBS="-lpp $LDAPD_LIBS"
373                 ],:)
374
375         AC_PATH_PROG(PEPSY, pepsy)
376 fi
377
378 dnl
379 dnl check for kerberos
380 dnl
381 ol_link_kerberos=no
382
383 if test $ol_with_kerberos = auto -o $ol_with_kerberos = k5 ; then
384         AC_CHECK_HEADERS(kerberosIV/krb.h kerberosIV/des.h)
385
386         if test $ac_cv_header_kerberosIV_krb_h = yes ; then
387                 AC_CHECK_LIB(krb4, main, [have_k5=yes], [have_k5=no],
388                         [-lkrb5 -ldes425])
389
390                 if test $have_k5 = yes ; then
391                         ol_with_kerberos=found
392                         ol_link_kerberos=yes
393
394                         KRB_LIBS="-lkrb4 -lkrb5 -ldes425"
395
396                         LIBS="$KRB_LIBS $LIBS"
397
398                         AC_CACHE_CHECK([for des_debug in Kerberos libraries],
399                                 [ol_cv_var_des_debug], [
400                                 dnl save the flags
401                                 save_LIBS="$LIBS"
402                                 LIBS="$KRB_LIBS $LIBS"
403                                 AC_TRY_LINK([
404 #include <kerberosIV/krb.h>
405 #include <kerberosIV/des.h>
406 extern int des_debug;
407 ],[
408 des_debug = 1;
409 ],                              ol_cv_var_des_debug=yes, ol_cv_var_des_debug=no)
410                                 dnl restore the LIBS
411                                 LIBS="$save_LIBS"
412                         ])
413
414                         if test $ol_cv_var_des_debug = yes ; then
415                                 AC_DEFINE(HAVE_DES_DEBUG,1,
416                                         [define if you have Kerberos des_debug])
417                         fi
418
419                         LIBS="$save_LIBS"
420                 fi
421         fi
422 fi
423
424 if test $ol_with_kerberos = auto -o $ol_with_kerberos = k4 ; then
425         AC_CHECK_HEADERS(krb.h des.h)
426
427         if test $ac_cv_header_krb_h = yes ; then
428                 AC_CHECK_LIB(krb, main, [have_k4=yes], [have_k4=no], [-ldes])
429
430                 if test $have_k4 = yes ; then
431                         ol_with_kerberos=found
432                         ol_link_kerberos=yes
433
434                         KRB_LIBS="-lkrb -ldes"
435                 fi
436         fi
437 fi
438
439 if test $ol_link_kerberos = yes ; then
440         AC_DEFINE(HAVE_KERBEROS, 1, [define if you have Kerberos])
441 fi
442
443 ol_link_threads=no
444 if test $ol_with_threads = auto -o $ol_with_threads = yes \
445         -o $ol_with_threads = posix ; then
446
447         AC_CHECK_HEADERS(pthread.h sched.h)
448
449         if test $ac_cv_header_pthread_h = yes ; then
450                 OL_POSIX_THREAD_VERSION
451
452                 if test $ol_cv_pthread_version = final ; then
453                         AC_DEFINE(HAVE_PTHREADS_FINAL,1,
454                                 [define if pthreads API compatible with final spec])
455                 elif test $ol_cv_pthread_version = draft4 ; then
456                         AC_DEFINE(HAVE_PTHREADS_D4,1,
457                                 [define if pthreads API compatible with draft4 spec])
458                 else
459                         AC_MSG_ERROR([unknown pthread version])
460                 fi
461
462                 # consider threads found
463                 ol_with_threads=found
464
465                 OL_LINUX_THREADS
466
467                 if test $ol_cv_linux_threads = yes ; then
468                         AC_DEFINE(HAVE_LINUX_THREADS,1,
469                                 [define if you have LinuxThreads])
470                 fi
471
472                 dnl Now the hard part, how to link?
473                 dnl
474                 dnl currently supported checks:
475                 dnl
476                 dnl Check for no flags 
477                 dnl     pthread_create() in $LIBS
478                 dnl
479                 dnl Check special pthread (final) flags
480                 dnl     pthread_create() with -kthread (FreeBSD)
481                 dnl     pthread_create() with -pthread (FreeBSD/Digital Unix)
482                 dnl     pthread_create() with -pthreads (?)
483                 dnl     pthread_create() with -thread (?)
484                 dnl     pthread_create() with -mt (Solaris)
485                 dnl
486                 dnl Check pthread (final) libraries
487                 dnl     pthread_mutex_unlock() in -lpthread -lmach -lexc -lc_r (OSF/1)
488                 dnl     pthread_mutex_lock() in -lpthread -lmach -lexc (OSF/1)
489                 dnl     pthread_mutex_trylock() in -lpthread -lexc (OSF/1)
490                 dnl     pthread_create() in -lpthread (many)
491                 dnl     pthread_create() in -lc_r (FreeBSD)
492                 dnl     pthread_create() in -lpthreads (many)
493                 dnl     pthread_join() -Wl,-woff,85 -lpthreads (IRIX)
494                 dnl     pthread_create() in HP-UX -lpthread (HP-UX 11)
495                 dnl
496                 dnl Check pthread (draft4) flags (to be depreciated)
497                 dnl     pthread_create() with -threads (OSF/1)
498                 dnl
499                 dnl Check pthread (final) libraries (to be depreciated)
500                 dnl     pthread_mutex_unlock() in -lpthreads -lmach -lexc -lc_r (OSF/1)
501                 dnl     pthread_mutex_lock() in -lpthreads -lmach -lexc (OSF/1)
502                 dnl     pthread_mutex_trylock() in -lpthreads -lexc (OSF/1)
503                 dnl
504
505                 dnl pthread_create in $LIBS
506                 AC_CHECK_FUNC(pthread_create,[ol_link_threads=yes])
507
508                 if test $ol_link_threads = no ; then
509                         dnl try -kthread
510                         AC_CACHE_CHECK([for pthread_create with -kthread],
511                                 [ol_cv_kthread_flag], [
512                                 dnl save the flags
513                                 save_LIBS="$LIBS"
514                                 LIBS="-kthread $LIBS"
515                                 AC_TRY_LINK([#include <pthread.h>],
516                                         [pthread_create(NULL,NULL,NULL,NULL);],
517                                         [ol_cv_kthread_flag=yes], [ol_cv_kthread_flag=no])
518                                 dnl restore the LIBS
519                                 LIBS="$save_LIBS"
520                         ])
521
522                         if test $ol_cv_kthread_flag = yes ; then
523                                 LTHREAD_LIBS="$LTHREAD_LIBS -kthread"
524                                 ol_link_threads=posix
525                         fi
526                 fi
527
528                 if test $ol_link_threads = no ; then
529                         dnl try -pthread
530                         AC_CACHE_CHECK([for pthread_create with -pthread],
531                                 [ol_cv_pthread_flag], [
532                                 dnl save the flags
533                                 save_LIBS="$LIBS"
534                                 LIBS="-pthread $LIBS"
535                                 AC_TRY_LINK([#include <pthread.h>],
536                                         [pthread_create(NULL,NULL,NULL,NULL);],
537                                         [ol_cv_pthread_flag=yes], [ol_cv_pthread_flag=no])
538                                 dnl restore the LIBS
539                                 LIBS="$save_LIBS"
540                         ])
541
542                         if test $ol_cv_pthread_flag = yes ; then
543                                 LTHREAD_LIBS="$LTHREAD_LIBS -pthread"
544                                 ol_link_threads=posix
545                         fi
546                 fi
547
548                 if test $ol_link_threads = no ; then
549                         dnl try -pthreads
550                         AC_CACHE_CHECK([for pthread_create with -pthreads],
551                                 [ol_cv_pthreads_flag], [
552                                 dnl save the flags
553                                 save_LIBS="$LIBS"
554                                 LIBS="-pthreads $LIBS"
555                                 AC_TRY_LINK([#include <pthread.h>],
556                                         [pthread_create(NULL,NULL,NULL,NULL);],
557                                         [ol_cv_pthreads_flag=yes], [ol_cv_pthreads_flag=no])
558                                 dnl restore the LIBS
559                                 LIBS="$save_LIBS"
560                         ])
561
562                         if test $ol_cv_pthreads_flag = yes ; then
563                                 LTHREAD_LIBS="$LTHREAD_LIBS -pthreads"
564                                 ol_link_threads=posix
565                         fi
566                 fi
567
568                 if test $ol_link_threads = no ; then
569                         dnl try -thread
570                         AC_CACHE_CHECK([for pthread_create with -thread],
571                                 [ol_cv_thread_flag], [
572                                 dnl save the flags
573                                 save_LIBS="$LIBS"
574                                 LIBS="-thread $LIBS"
575                                 AC_TRY_LINK([char pthread_create();],
576                                         [pthread_create();],
577                                         [ol_cv_thread_flag=yes], [ol_cv_thread_flag=no])
578                                 dnl restore the LIBS
579                                 LIBS="$save_LIBS"
580                         ])
581
582                         if test $ol_cv_thread_flag = yes ; then
583                                 LTHREAD_LIBS="$LTHREAD_LIBS -thread"
584                                 ol_link_threads=posix
585                         fi
586                 fi
587
588                 if test $ol_link_threads = no ; then
589                         dnl try -mt
590                         AC_CACHE_CHECK([for pthread_create with -mt],
591                                 [ol_cv_thread_flag], [
592                                 dnl save the flags
593                                 save_LIBS="$LIBS"
594                                 LIBS="-mt $LIBS"
595                                 AC_TRY_LINK([char pthread_create();],
596                                         [pthread_create();],
597                                         [ol_cv_thread_flag=yes], [ol_cv_thread_flag=no])
598                                 dnl restore the LIBS
599                                 LIBS="$save_LIBS"
600                         ])
601
602                         if test $ol_cv_thread_flag = yes ; then
603                                 LTHREAD_LIBS="$LTHREAD_LIBS -mt"
604                                 ol_link_threads=posix
605                         fi
606                 fi
607
608                 if test $ol_link_threads = no ; then
609                         dnl try DEC Threads -lpthread -lmach -lexc -lc_r
610                         save_LIBS="$LIBS"
611                         AC_CHECK_LIB(pthread, pthread_mutex_unlock, [
612                                 ol_link_threads=posix
613                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lmach -lexc -lc_r"
614                                 if test $ol_with_yielding_select = auto ; then
615                                         ol_with_yielding_select=yes
616                                 fi
617                                 ],:,[-lmach -lexc -lc_r])
618                         LIBS="$save_LIBS"
619                 fi
620
621                 if test $ol_link_threads = no ; then
622                         dnl try DEC Threads -lpthread -lmach -lexc
623                         save_LIBS="$LIBS"
624                         AC_CHECK_LIB(pthread, pthread_mutex_lock, [
625                                 ol_link_threads=posix
626                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lmach -lexc"
627                                 if test $ol_with_yielding_select = auto ; then
628                                         ol_with_yielding_select=yes
629                                 fi
630                                 ],:,[-lmach -lexc])
631                         LIBS="$save_LIBS"
632                 fi
633
634                 if test $ol_link_threads = no ; then
635                         dnl try DEC Threads -lpthread -lexc
636                         save_LIBS="$LIBS"
637                         AC_CHECK_LIB(pthread, pthread_mutex_trylock, [
638                                 ol_link_threads=posix
639                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lexc"
640                                 if test $ol_with_yielding_select = auto ; then
641                                         ol_with_yielding_select=yes
642                                 fi
643                                 ],:,[-lexc])
644                         LIBS="$save_LIBS"
645                 fi
646
647                 if test $ol_link_threads = no ; then
648                         dnl try -lpthread
649                         save_LIBS="$LIBS"
650                         AC_CHECK_LIB(pthread, pthread_create, [
651                                 ol_link_threads=posix
652                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthread"],:)
653                         LIBS="$save_LIBS"
654                 fi
655
656                 if test $ol_link_threads = no ; then
657                         dnl try -lc_r
658                         save_LIBS="$LIBS"
659                         AC_CHECK_LIB(c_r, pthread_create, [
660                                 ol_link_threads=posix
661                                 LTHREAD_LIBS="$LTHREAD_LIBS -lc_r"],:)
662                         LIBS="$save_LIBS"
663                 fi
664
665                 if test $ol_link_threads = no ; then
666                         dnl try -lpthreads
667                         save_LIBS="$LIBS"
668                         AC_CHECK_LIB(pthreads, pthread_create, [
669                                 ol_link_threads=posix
670                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads"],:)
671                         LIBS="$save_LIBS"
672                 fi
673
674                 dnl IRIX Pthread check
675                 if test $ol_link_threads = no ; then
676                         dnl try IRIX Pthreads -Wl,-woff,85 -lpthreads
677                         save_LIBS="$LIBS"
678                         AC_CHECK_LIB(pthreads, pthread_join, [
679                                 ol_link_threads=posix
680                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads"
681                                 ],:,[-Wl,-woff,85])
682                         LIBS="$save_LIBS"
683                 fi
684
685                 dnl HP-UX 11 Pthread check
686                 if test $ol_link_threads = no; then
687                         save_LIBS="$LIBS"
688                         LIBS="$LIBS -lpthread"
689                         AC_MSG_CHECKING([for pthread_create() in HP-UX -lpthread])
690                         ol_try_pthread_hpux_11=no
691                         AC_CACHE_VAL(ol_cv_pthread_hpux_11,[
692                                 AC_TRY_LINK([
693 #include <pthread.h>
694 #include <elf.h>
695 #ifndef ELFABI_HPUX_REL11
696         die horribly
697 #endif
698                                 ], [pthread_create(NULL, NULL, NULL, NULL);],
699                                         ol_try_pthread_hpux_11=yes
700                                         ol_cv_pthread_hpux_11=yes,
701                                         ol_cv_pthread_hpux_11=no)])
702                         AC_MSG_RESULT(yes)
703                         LIBS="$save_LIBS"
704
705                         if test $ol_cv_pthread_hpux_11=yes ; then
706                                 ol_link_threads=posix
707                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthread"
708                                 if test $ol_try_pthread_hpux_11=yes ; then
709                                         dnl Some tests below may fail, cause we aint including
710                                         dnl pthread.h. Force appropriate ones to yes
711                                         ac_cv_func_pthread_attr_init=yes
712                                 fi
713                         fi
714                 fi
715
716                 if test $ol_link_threads = no ; then
717                         dnl try -threads
718                         AC_CACHE_CHECK([for pthread_create with -threads],
719                                 [ol_cv_thread_flag], [
720                                 dnl save the flags
721                                 save_LIBS="$LIBS"
722                                 LIBS="-threads $LIBS"
723                                 AC_TRY_LINK([char pthread_create();],[
724                                         pthread_create();
725                                         ], ol_cv_thread_flag=yes, ol_cv_thread_flag=no)
726                                 dnl restore the LIBS
727                                 LIBS="$save_LIBS"
728                         ])
729
730                         if test $ol_cv_thread_flag = yes ; then
731                                 LTHREAD_LIBS="$LTHREAD_LIBS -threads"
732                                 ol_link_threads=posix
733                         fi
734                 fi
735
736                 if test $ol_link_threads = no ; then
737                         dnl try DEC Threads -lpthreads -lmach -lexc -lc_r
738                         save_LIBS="$LIBS"
739                         AC_CHECK_LIB(pthreads, pthread_mutex_unlock, [
740                                 ol_link_threads=posix
741                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads -lmach -lexc -lc_r"
742                                 if test $ol_with_yielding_select = auto ; then
743                                         ol_with_yielding_select=yes
744                                 fi
745                                 ],:,[-lmach -lexc -lc_r])
746                         LIBS="$save_LIBS"
747                 fi
748
749                 if test $ol_link_threads = no ; then
750                         dnl try DEC Threads -lpthreads -lmach -lexc
751                         save_LIBS="$LIBS"
752                         AC_CHECK_LIB(pthreads, pthread_mutex_lock, [
753                                 ol_link_threads=posix
754                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads -lmach -lexc"
755                                 if test $ol_with_yielding_select = auto ; then
756                                         ol_with_yielding_select=yes
757                                 fi
758                                 ],:,[-lmach -lexc])
759                         LIBS="$save_LIBS"
760                 fi
761
762                 if test $ol_link_threads = no ; then
763                         dnl try DEC Threads -lpthreads -lexc
764                         save_LIBS="$LIBS"
765                         AC_CHECK_LIB(pthreads, pthread_mutex_trylock, [
766                                 ol_link_threads=posix
767                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads -lexc"
768                                 if test $ol_with_yielding_select = auto ; then
769                                         ol_with_yielding_select=yes
770                                 fi
771                                 ],:,[-lexc])
772                         LIBS="$save_LIBS"
773                 fi
774
775                 if test $ol_link_threads != no ; then
776                         AC_DEFINE(HAVE_PTHREADS,1,
777                                 [define if you have POSIX Threads])
778
779                         dnl save flags
780                         save_CPPFLAGS="$CPPFLAGS"
781                         save_LIBS="$LIBS"
782                         LIBS="$LTHREAD_LIBS $LIBS"
783
784                         dnl All POSIX Thread (final) implementations should have
785                         dnl sched_yield instead of pthread yield.
786                         dnl check for both
787                         AC_CHECK_FUNCS(sched_yield pthread_yield)
788
789                         if test $ac_cv_func_sched_yield = no -a \
790                                 $ac_cv_func_pthread_yield = no ; then
791                                 dnl Digital UNIX has sched_yield() in -lrt
792                                 AC_CHECK_LIB(rt, sched_yield,
793                                         [LTHREAD_LIBS="$LTHREAD_LIBS -lrt"
794                                         AC_DEFINE(HAVE_SCHED_YIELD,1)
795                                         ac_cv_func_sched_yield=yes],
796                                         [ac_cv_func_sched_yield=no])
797                         fi
798                         if test $ac_cv_func_sched_yield = no -a \
799                                 $ac_cv_func_pthread_yield = no ; then
800                                 dnl Solaris has sched_yield() in -lposix4
801                                 dnl but we'll use thr_yield instead.
802                                 AC_CHECK_FUNCS(thr_yield)
803                         fi
804                         if test $ac_cv_func_sched_yield = no -a \
805                                 $ac_cv_func_pthread_yield = no -a \
806                                 "$ac_cv_func_thr_yield" = no ; then
807                                 AC_MSG_WARN([could not locate sched_yield() or pthread_yield()])
808                         fi
809
810                         dnl Check functions for compatibility
811                         AC_CHECK_FUNCS(pthread_kill)
812
813                         dnl Check for pthread_detach with <pthread.h> inclusion
814                         dnl as it's symbol may have been mangled.
815                         AC_CACHE_CHECK([for pthread_detach with <pthread.h>],
816                                 [ol_cv_func_pthread_detach], [
817                                 dnl save the flags
818                                 AC_TRY_LINK([#include <pthread.h>],
819                                         [pthread_detach(NULL);],
820                                         [ol_cv_func_pthread_detach=yes],
821                                         [ol_cv_func_pthread_detach=no])
822                         ])
823
824                         if test $ol_cv_func_pthread_detach = no ; then
825                                 AC_MSG_ERROR([could not locate pthread_detach()])
826                         fi
827
828                         AC_DEFINE(HAVE_PTHREAD_DETACH,1,
829                                 [define if you have pthread_detach function])
830
831                         dnl Check for setconcurreny functions
832                         AC_CHECK_FUNCS( \
833                                 pthread_setconcurrency \
834                                 pthread_getconcurrency \
835                                 thr_setconcurrency \
836                                 thr_getconcurrency \
837                         )
838
839                         AC_MSG_CHECKING([if pthread_create() works])
840                         AC_CACHE_VAL(ol_cv_pthread_create_works,[
841                         AC_TRY_RUN([
842 #include <pthread.h>
843 #ifndef NULL
844 #define NULL (void*)0
845 #endif
846
847 static void *task(p)
848         void *p;
849 {
850         return (void *) (p == NULL);
851 }
852
853 int main(argc, argv)
854         int argc;
855         char **argv;
856 {
857         pthread_t t;
858         exit(pthread_create(&t, NULL, task, NULL));
859 }
860 ],
861                                 [ol_cv_pthread_create_works=yes],
862                                 [ol_cv_pthread_create_works=no],
863                                 [dnl assume yes
864                                 ol_cv_pthread_create_works=yes])])
865                         AC_MSG_RESULT($ol_cv_pthread_create_works)
866
867                         if test $ol_cv_pthread_create_works = no ; then
868                                 AC_MSG_ERROR([pthread.h and pthread_create are not compatible])
869                         fi
870
871                         dnl Check if select causes an yield
872                         if test $ol_with_yielding_select = auto ; then
873                                 AC_MSG_CHECKING([if select yields when using pthreads])
874                                 AC_CACHE_VAL(ol_cv_pthread_select_yields,[
875                                 AC_TRY_RUN([
876 #include <sys/types.h>
877 #include <sys/time.h>
878 #include <unistd.h>
879 #include <pthread.h>
880 #ifndef NULL
881 #define NULL (void*) 0
882 #endif
883
884 static int fildes[2];
885
886 static void *task(p)
887         void *p;
888 {
889         int i;
890         struct timeval tv;
891
892         fd_set rfds;
893
894         tv.tv_sec=10;
895         tv.tv_usec=0;
896
897         FD_ZERO(&rfds);
898         FD_SET(fildes[0], &rfds);
899
900         /* we're not interested in any fds */
901         i = select(FD_SETSIZE, &rfds, NULL, NULL, &tv);
902
903         if(i < 0) {
904                 perror("select");
905                 exit(10);
906         }
907
908         exit(0); /* if we exit here, the select blocked the whole process */
909 }
910
911 int main(argc, argv)
912         int argc;
913         char **argv;
914 {
915         pthread_t t;
916
917         /* create a pipe to select */
918         if(pipe(&fildes[0])) {
919                 perror("select");
920                 exit(1);
921         }
922
923 #ifdef HAVE_PTHREAD_SETCONCURRENCY
924         (void) pthread_setconcurrency(2);
925 #else
926 #ifdef HAVE_THR_SETCONCURRENCY
927         /* Set Solaris LWP concurrency to 2 */
928         thr_setconcurrency(2);
929 #endif
930 #endif
931
932         pthread_create(&t, NULL, task, NULL);
933
934 #if HAVE_SCHED_YIELD
935         sched_yield();  /* make sure task runs first */
936 #else
937 #ifdef HAVE_PTHREAD_YIELD
938         pthread_yield();        /* make sure task runs first */
939 #endif
940 #endif
941
942         exit(2);
943 }],
944                                 [ol_cv_pthread_select_yields=no],
945                                 [ol_cv_pthread_select_yields=yes], [
946                                 AC_MSG_ERROR([crossing compiling: use --with-yielding_select=yes|no|manual])])])
947                                 AC_MSG_RESULT($ol_cv_pthread_select_yields)
948
949                                 if test $ol_cv_pthread_select_yields = yes ; then
950                                         ol_with_yielding_select=yes
951                                 fi
952                         fi
953
954                         dnl restore flags
955                         CPPFLAGS="$save_CPPFLAGS"
956                         LIBS="$save_LIBS"
957                 else
958                         AC_MSG_ERROR([could not link with POSIX Threads])
959                 fi
960         fi
961
962         if test $ol_with_threads = posix ; then
963                 AC_MSG_ERROR([could not locate POSIX Threads])
964         fi
965 fi
966
967 if test $ol_with_threads = auto -o $ol_with_threads = yes \
968         -o $ol_with_threads = mach ; then
969
970         dnl check for Mach CThreads
971         AC_CHECK_HEADERS(mach/cthreads.h)
972         if test $ac_cv_header_mach_cthreads_h = yes ; then
973                 ol_with_threads=found
974
975                 dnl check for cthread support in current $LIBS
976                 AC_CHECK_FUNC(cthread_fork,[ol_link_threads=yes])
977
978                 if test $ol_link_threads = no ; then
979                         dnl try -all_load
980                         dnl this test needs work
981                         AC_CACHE_CHECK([for cthread_fork with -all_load],
982                                 [ol_cv_cthread_all_load], [
983                                 dnl save the flags
984                                 save_LIBS="$LIBS"
985                                 LIBS="-all_load $LIBS"
986                                 AC_TRY_LINK([#include <mach/cthreads.h>],[
987                                         cthread_fork((void *)0, (void *)0);
988                                         ], ol_cv_cthread_all_load=yes, ol_cv_cthread_all_load=no)
989                                 dnl restore the LIBS
990                                 LIBS="$save_LIBS"
991                         ])
992
993                         if test $ol_cv_cthread_all_load = yes ; then
994                                 LTHREAD_LIBS="$LTHREAD_LIBS -all_load"
995                                 ol_link_threads=mach
996                         fi
997                 fi
998
999                 if test $ol_link_threads != no ; then
1000                         : check for cthread specific functionality here
1001                         AC_DEFINE(HAVE_MACH_CTHREADS,1,
1002                                 [define if you have Mach Cthreads])
1003                 else
1004                         AC_MSG_ERROR([could not link with Mach CThreads])
1005                 fi
1006         fi
1007
1008         if test $ol_with_threads = mach ; then
1009                 AC_MSG_ERROR([could not locate Mach CThreads])
1010         fi
1011 fi
1012
1013 if test $ol_with_threads = auto -o $ol_with_threads = yes \
1014         -o $ol_with_threads = pth ; then
1015
1016         dnl check for GNU Pth
1017         AC_CHECK_HEADERS(pth.h)
1018         if test $ac_cv_header_pth_h = yes ; then
1019
1020                 dnl check for pth lib
1021                 AC_CHECK_LIB(pth,pth_version,[have_pth=yes],[have_pth=no])
1022
1023                 if test $have_pth = yes ; then
1024                         AC_DEFINE(HAVE_GNU_PTH,1,[if you have GNU Pth])
1025                         LTHREAD_LIBS="$LTHREAD_LIBS -lpth"
1026                         ol_link_threads=pth
1027                 fi
1028
1029                 if test $ol_with_yielding_select = auto ; then
1030                         ol_with_yielding_select=yes
1031                 fi
1032         fi
1033 fi
1034
1035 if test $ol_with_threads = auto -o $ol_with_threads = yes \
1036         -o $ol_with_threads = lwp ; then
1037
1038         dnl check for SunOS5 LWP
1039         AC_CHECK_HEADERS(thread.h synch.h)
1040         if test $ac_cv_header_thread_h = yes -a $ac_cv_header_synch_h = yes ; then
1041                 AC_CHECK_LIB(thread, thr_create, [have_thr=yes], [have_thr=no])
1042
1043                 if test $have_thr = yes ; then
1044                         AC_DEFINE(HAVE_THR,1,
1045                                 [if you have Solaris LWP (thr) package])
1046                         LTHREAD_LIBS="$LTHREAD_LIBS -lthread"
1047                         ol_link_threads=thr
1048
1049                         if test $ol_with_yielding_select = auto ; then
1050                                 ol_with_yielding_select=yes
1051                         fi
1052
1053                         dnl Check for setconcurreny functions
1054                         AC_CHECK_FUNCS( \
1055                                 thr_setconcurrency \
1056                                 thr_getconcurrency \
1057                         )
1058                 fi
1059         fi
1060
1061         dnl check for SunOS4 LWP
1062         AC_CHECK_HEADERS(lwp/lwp.h)
1063         if test $ac_cv_header_lwp_lwp_h = yes ; then
1064                 AC_CHECK_LIB(lwp, lwp_create, [have_lwp=yes], [have_lwp=no])
1065
1066                 if test $have_lwp = yes ; then
1067                         AC_DEFINE(HAVE_LWP,1,
1068                                 [if you have SunOS LWP package])
1069                         LTHREAD_LIBS="$LTHREAD_LIBS -llwp"
1070                         ol_link_threads=lwp
1071
1072                         if test $ol_with_yielding_select = auto ; then
1073                                 ol_with_yielding_select=no
1074                         fi
1075                 fi
1076         fi
1077 fi
1078
1079 if test $ol_with_yielding_select = yes ; then
1080         AC_DEFINE(HAVE_YIELDING_SELECT,1,
1081                 [define if select implicitly yields])
1082 fi
1083
1084 if test $ol_with_threads = manual ; then
1085         dnl User thinks he can manually configure threads.
1086         ol_link_threads=yes
1087
1088         AC_MSG_WARN([thread defines and link options must be set manually])
1089
1090         AC_CHECK_HEADERS(pthread.h sched.h)
1091         AC_CHECK_FUNCS(sched_yield pthread_yield)
1092         OL_LINUX_THREADS
1093
1094         AC_CHECK_HEADERS(mach/cthreads.h)
1095         AC_CHECK_HEADERS(lwp/lwp.h)
1096         AC_CHECK_HEADERS(thread.h synch.h)
1097 fi
1098
1099 if test $ol_link_threads != no ; then  
1100         dnl needed to get reentrant/threadsafe versions
1101         dnl
1102         AC_DEFINE(REENTRANT,1)
1103         AC_DEFINE(_REENTRANT,1)
1104         AC_DEFINE(THREAD_SAFE,1)
1105         AC_DEFINE(_THREAD_SAFE,1)
1106         AC_DEFINE(THREADSAFE,1)
1107         AC_DEFINE(_THREADSAFE,1)
1108         AC_DEFINE(_SGI_MP_SOURCE,1)
1109
1110         dnl this might cause the errno symbol to be
1111         dnl replaced with a function to get a thread specific errno.
1112         dnl check to see if everything needs to be compiled
1113         dnl with the thread libraries
1114         AC_CACHE_CHECK([for thread specific errno],
1115                 [ol_cv_errno_thread_specific], [
1116                 AC_TRY_LINK([#include <errno.h>], [int x = errno;],
1117                         [ol_cv_errno_thread_specific=yes],
1118                         [ol_cv_errno_thread_specific=no])
1119         ])
1120
1121         if test $ol_cv_errno_thread_specific != yes ; then
1122                 LIBS="$LTHREAD_LIBS $LIBS"
1123                 LTHREAD_LIBS=""
1124         fi
1125 fi  
1126
1127 dnl ----------------------------------------------------------------
1128
1129 if test $ol_link_threads = no ; then
1130         if test $ol_with_threads = yes ; then
1131                 AC_MSG_ERROR([no suitable thread support])
1132         fi
1133
1134         if test $ol_with_threads = auto ; then
1135                 AC_MSG_WARN([no suitable thread support, disabling threads])
1136                 ol_with_threads=no
1137         fi
1138
1139         AC_DEFINE(NO_THREADS,1,
1140                 [define if you have (or want) no threads])
1141         LTHREAD_LIBS=""
1142 fi
1143
1144 ol_link_ldbm=no 
1145 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db2 ; then
1146         OL_BERKELEY_DB2
1147
1148         if test $ol_cv_berkeley_db2 = yes ; then
1149                 ol_link_ldbm=db2
1150                 ol_with_ldbm_api=db2
1151
1152                 if test $ol_with_ldbm_type = hash ; then
1153                         AC_DEFINE(LDBM_USE_DBHASH,1)
1154                 else
1155                         AC_DEFINE(LDBM_USE_DBBTREE,1)
1156                 fi
1157
1158                 dnl $ol_cv_lib_db2 should be yes or -ldb
1159                 dnl (it could be no, but that would be an error
1160                 if test $ol_cv_lib_db2 != yes ; then
1161                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_db2"
1162                 fi
1163         fi
1164 fi
1165
1166 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db ; then
1167         OL_BERKELEY_DB
1168
1169         if test $ol_cv_berkeley_db = yes ; then
1170                 ol_link_ldbm=db
1171                 ol_with_ldbm_api=db
1172
1173                 if test $ol_with_ldbm_type = hash ; then
1174                         AC_DEFINE(LDBM_USE_DBHASH,1)
1175                 else
1176                         AC_DEFINE(LDBM_USE_DBBTREE,1)
1177                 fi
1178
1179                 dnl $ol_cv_lib_db should be yes or -ldb
1180                 dnl (it could be no, but that would be an error
1181                 if test $ol_cv_lib_db != yes ; then
1182                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_db"
1183                 fi
1184         fi
1185 fi
1186
1187 if test $ol_with_ldbm_api = manual ; then
1188         dnl User thinks he can manually configure LDBM api.
1189         ol_link_ldbm=yes
1190
1191         AC_MSG_WARN([LDBM defines and link options must be set manually])
1192
1193         AC_CHECK_HEADERS(db.h db_185.h gdbm.h ndbm.h)
1194 fi
1195
1196 if test $ol_link_ldbm = no -a $ol_with_ldbm_type = btree ; then
1197         AC_MSG_WARN(Could not find LDBM with BTREE support)
1198         ol_with_ldbm_api=none
1199 fi
1200
1201 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = gdbm ; then
1202         OL_GDBM
1203
1204         if test $ol_cv_gdbm = yes ; then
1205                 ol_link_ldbm=gdbm
1206                 ol_with_ldbm_api=gdbm
1207
1208                 if test $ol_cv_lib_gdbm != yes ; then
1209                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_gdbm"
1210                 fi
1211         fi
1212 fi
1213
1214 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = mdbm ; then
1215         OL_MDBM
1216
1217         if test $ol_cv_mdbm = yes ; then
1218                 ol_link_ldbm=mdbm
1219                 ol_with_ldbm_api=mdbm
1220                 if test $ol_cv_lib_mdbm != yes ; then
1221                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_mdbm"
1222                 fi
1223         fi
1224 fi
1225
1226 if test $ol_with_ldbm_api = ndbm ; then
1227         OL_NDBM
1228
1229         if test $ol_cv_ndbm = yes ; then
1230                 ol_link_ldbm=ndbm
1231                 ol_with_ldbm_api=ndbm
1232
1233                 if test $ol_cv_lib_ndbm != yes ; then
1234                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_ndbm"
1235                 fi
1236         fi
1237 fi
1238
1239 if test $ol_link_ldbm = no -a $ol_enable_ldbm != no ; then
1240         AC_MSG_WARN(could not find suitable LDBM backend)
1241         if test $ol_enable_ldbm = yes ; then
1242                 AC_MSG_ERROR(select appropriate LDBM options or disable)
1243         fi
1244
1245         AC_MSG_WARN(disabling LDBM)
1246         ol_enable_ldbm=no
1247 fi
1248
1249 if test $ol_enable_wrappers != no ; then
1250         AC_CHECK_HEADERS(tcpd.h)
1251
1252         if test $ac_cv_header_tcpd_h != yes ; then
1253                 have_wrappers=no
1254         else
1255                 AC_TRY_COMPILE([
1256 int allow_severity = 0;
1257 int deny_severity  = 0;
1258                 ],[hosts_access()],[have_wrappers=yes],[have_wrappers=no])
1259         fi
1260
1261         if test $have_wrappers = yes ; then
1262                 AC_DEFINE(HAVE_TCPD,1, [define if you have -lwrap])
1263                 WRAP_LIBS="-lwrap"
1264
1265                 dnl We add another check for -lnsl since some libwrap's
1266                 dnl need it, but it isn't always included from above
1267                 AC_CHECK_LIB(nsl, main)
1268         else
1269                 AC_MSG_WARN(could not find -lwrap)
1270                 if test $ol_enable_wrappers = yes ; then
1271                         AC_MSG_ERROR(could not find wrappers, select appropriate options or disable)
1272                 fi
1273
1274                 AC_MSG_WARN(disabling wrappers support)
1275                 ol_enable_wrappers=no
1276                 WRAP_LIBS=""
1277         fi
1278 fi
1279
1280 if test $ol_enable_dmalloc != no ; then
1281         AC_CHECK_HEADERS(dmalloc.h)
1282         AC_CHECK_LIB(dmalloc, dmalloc_shutdown)
1283 fi
1284
1285 # ud needs termcap (should insert check here)
1286 ol_link_termcap=no
1287 AC_CHECK_HEADERS(termcap.h ncurses.h)
1288
1289 if test $ol_link_termcap = no ; then
1290         AC_CHECK_LIB(termcap, tputs, [have_termcap=yes], [have_termcap=no])
1291         if test $have_termcap = yes ; then
1292                 AC_DEFINE(HAVE_TERMCAP, 1, [define if you have -ltermcap])
1293                 ol_link_termcap=yes
1294                 TERMCAP_LIBS=-ltermcap
1295         fi
1296 fi
1297
1298 if test $ol_link_termcap = no ; then
1299         AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
1300         if test $have_ncurses = yes ; then
1301                 AC_DEFINE(HAVE_NCURSES, 1, [define if you have -lncurses])
1302                 ol_link_termcap=yes
1303                 TERMCAP_LIBS=-lncurses
1304         fi
1305 fi
1306
1307 if test $ol_link_termcap = no ; then
1308         AC_DEFINE(NO_TERMCAP,1, [define if you have no termcap support])
1309         TERMCAP_LIBS=
1310 fi
1311
1312 # FreeBSD (and others) have crypt(3) in -lcrypt
1313 if test $ol_enable_crypt != no ; then
1314         AC_CHECK_FUNC(crypt, [have_crypt=yes], [
1315                 AC_CHECK_LIB(crypt, crypt, [LUTIL_LIBS="$LUTIL_LIBS -lcrypt"
1316                         have_crypt=yes], [have_crypt=no])])
1317
1318         if test $have_crypt = yes ; then
1319                 AC_DEFINE(HAVE_CRYPT,1)
1320         else
1321                 AC_MSG_WARN(could not find crypt)
1322                 if test $ol_enable_crypt = yes ; then
1323                         AC_MSG_ERROR(could not find crypt, select appropriate options or disable)
1324                 fi
1325
1326                 AC_MSG_WARN(disabling crypt support)
1327                 ol_enable_crypt=no
1328         fi
1329 fi
1330
1331 # FreeBSD (and others) have setproctitle(3) in -lutil
1332 if test $ol_enable_proctitle != no ; then
1333         AC_CHECK_FUNC(setproctitle,     [have_setproctitle=yes], [
1334                 AC_CHECK_LIB(util, setproctitle,
1335                         [have_setproctitle=yes
1336                         LUTIL_LIBS="$LUTIL_LIBS -lutil"],
1337                         [have_setproctitle=no
1338                         LIBOBJS="$LIBOBJS setproctitle.o"])])
1339
1340         if test $have_setproctitle = yes ; then
1341                 AC_DEFINE(HAVE_SETPROCTITLE,1)
1342         fi
1343 fi
1344
1345 dnl ----------------------------------------------------------------
1346 dnl Checks for header files.
1347 AC_HEADER_STDC
1348
1349 if test $ac_cv_header_stdc != yes; then
1350         AC_MSG_WARN([could not Standard C compliant headers])
1351 fi
1352
1353 AC_HEADER_DIRENT
1354 AC_HEADER_SYS_WAIT
1355 AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1356 if test $am_cv_sys_posix_termios = yes ; then
1357         AC_DEFINE(HAVE_POSIX_TERMIOS,1,
1358                 [define if you have POSIX termios])
1359 fi
1360
1361 AC_CHECK_HEADERS(       \
1362         arpa/nameser.h  \
1363         crypt.h                 \
1364         errno.h                 \
1365         fcntl.h                 \
1366         filio.h                 \
1367         getopt.h                \
1368         libutil.h               \
1369         limits.h                \
1370         malloc.h                \
1371         memory.h                \
1372         netinet/tcp.h   \
1373         regex.h                 \
1374         psap.h                  \
1375         pwd.h                   \
1376         resolv.h                \
1377         sgtty.h                 \
1378         stdarg.h                \
1379         stddef.h                \
1380         string.h                \
1381         strings.h               \
1382         sys/file.h              \
1383         sys/filio.h             \
1384         sys/errno.h             \
1385         sys/ioctl.h             \
1386         sys/param.h             \
1387         sys/resource.h  \
1388         sys/select.h    \
1389         sys/socket.h    \
1390         sys/syslog.h    \
1391         sys/time.h              \
1392         sys/types.h             \
1393         syslog.h                \
1394         termios.h               \
1395         unistd.h                \
1396 )
1397
1398 dnl ----------------------------------------------------------------
1399 dnl Checks for typedefs, structures, and compiler characteristics.
1400 AC_TYPE_GETGROUPS dnl requires AC_TYPE_UID_T
1401 AC_TYPE_MODE_T
1402 AC_TYPE_OFF_T
1403 AC_TYPE_PID_T
1404 AM_TYPE_PTRDIFF_T
1405 AC_TYPE_SIGNAL
1406 AC_TYPE_SIZE_T
1407 AC_STRUCT_ST_BLKSIZE
1408 AC_HEADER_TIME
1409 AC_STRUCT_TM
1410
1411 OL_C_UPPER_LOWER
1412 AC_C_CONST
1413
1414 if test $cross_compiling = yes ; then
1415         AC_DEFINE(CROSS_COMPILING, 1, [define if cross compiling])
1416 else
1417         AC_C_BIGENDIAN
1418         AC_CHECK_SIZEOF(short) 
1419         AC_CHECK_SIZEOF(int) 
1420         AC_CHECK_SIZEOF(long)
1421 fi
1422
1423 dnl ----------------------------------------------------------------
1424 dnl Checks for library functions.
1425 AC_FUNC_MEMCMP
1426 dnl AM_FUNC_MKTIME dnl checks for sys/time.h and unistd.h
1427 AC_FUNC_STRFTIME
1428 dnl AM_FUNC_STRTOD
1429 AC_FUNC_VPRINTF
1430
1431 if test $ac_cv_func_vprintf = yes ; then
1432         dnl check for vsnprintf
1433         AC_CHECK_FUNCS(vsnprintf vsprintf)
1434 fi
1435
1436 AC_CHECK_FUNCS(         \
1437         bcopy                   \
1438         closesocket             \
1439         flock                   \
1440         getpass                 \
1441         getpassphrase   \
1442         getdtablesize   \
1443         gethostname             \
1444         getpwuid                \
1445         gettimeofday    \
1446         lockf                   \
1447         memcpy                  \
1448         memmove                 \
1449         mkstemp                 \
1450         select                  \
1451         setpwfile               \
1452         setsid                  \
1453         signal                  \
1454         sigset                  \
1455         snprintf                \
1456         socket                  \
1457         strerror                \
1458         strpbrk                 \
1459         strrchr                 \
1460         strsep                  \
1461         strstr                  \
1462         strtok                  \
1463         strtol                  \
1464         strtoul                 \
1465         sysconf                 \
1466         waitpid                 \
1467 )
1468
1469 dnl We actually may need to replace more than this.
1470 AC_REPLACE_FUNCS(getopt strdup tempnam)
1471
1472 dnl ----------------------------------------------------------------
1473 # Check Configuration
1474 OL_SYS_ERRLIST
1475
1476 dnl ----------------------------------------------------------------
1477 dnl Sort out defines
1478
1479 if test "$ol_enable_debug" != no ; then
1480         AC_DEFINE(LDAP_DEBUG,1)
1481 fi
1482 if test "$ol_enable_libui" = yes ; then
1483         AC_DEFINE(LDAP_LIBUI,1)
1484 fi
1485 if test "$ol_enable_cache" = no ; then
1486         AC_DEFINE(LDAP_NOCACHE,1)
1487 fi
1488 if test "$ol_enable_dns" != no ; then
1489         AC_DEFINE(LDAP_DNS,1)
1490 fi
1491 if test "$ol_enable_proctitle" != no ; then
1492         AC_DEFINE(LDAP_PROCTITLE,1)
1493 fi
1494 if test "$ol_enable_referrals" != no ; then
1495         AC_DEFINE(LDAP_REFERRALS,1)
1496 fi
1497 if test "$ol_enable_cldap" != no ; then
1498         AC_DEFINE(LDAP_CONNECTIONLESS,1)
1499 fi
1500
1501 if test "$ol_enable_aclgroups" != no ; then
1502         AC_DEFINE(SLAPD_ACLGROUPS,1)
1503 fi
1504 if test "$ol_enable_crypt" != no ; then
1505         AC_DEFINE(SLAPD_CRYPT,1)
1506 fi
1507 if test "$ol_enable_cleartext" != no ; then
1508         AC_DEFINE(SLAPD_CLEARTEXT,1)
1509 fi
1510 if test "$ol_enable_phonetic" != no ; then
1511         AC_DEFINE(SLAPD_PHONETIC,1)
1512 fi
1513 if test "$ol_enable_rlookups" != no ; then
1514         AC_DEFINE(SLAPD_RLOOKUPS,1)
1515 fi
1516
1517 if test "$ol_link_ldbm" != no ; then
1518         AC_DEFINE(SLAPD_LDBM,1)
1519         BUILD_SLAPD=yes
1520         BUILD_LDBM=yes
1521 fi
1522
1523 if test "$ol_enable_passwd" != no ; then
1524         AC_DEFINE(SLAPD_PASSWD,1)
1525         BUILD_SLAPD=yes
1526         BUILD_PASSWD=yes
1527 fi
1528
1529 if test "$ol_enable_shell" != no ; then
1530         AC_DEFINE(SLAPD_SHELL,1)
1531         BUILD_SLAPD=yes
1532         BUILD_SHELL=yes
1533 fi
1534
1535 if test "$ol_enable_slurpd" != no -a "$ol_link_threads" != no -a \
1536         $BUILD_SLAPD = yes ; then
1537         BUILD_SLURPD=yes
1538 fi
1539
1540 if test "$ol_link_isode" != no ; then
1541         BUILD_LDAPD=yes
1542 fi
1543
1544 dnl ----------------------------------------------------------------
1545
1546 AC_SUBST(BUILD_LDAPD)
1547 AC_SUBST(BUILD_SLAPD)
1548   AC_SUBST(BUILD_LDBM)
1549   AC_SUBST(BUILD_PASSWD)
1550   AC_SUBST(BUILD_SHELL)
1551 AC_SUBST(BUILD_SLURPD)
1552
1553 AC_SUBST(LDAP_LIBS)
1554 AC_SUBST(LDAPD_LIBS)
1555 AC_SUBST(SLAPD_LIBS)
1556 AC_SUBST(SLURPD_LIBS)
1557 AC_SUBST(LDBM_LIBS)
1558 AC_SUBST(LTHREAD_LIBS)
1559 AC_SUBST(LUTIL_LIBS)
1560 AC_SUBST(WRAP_LIBS)
1561 AC_SUBST(KRB_LIBS)
1562 AC_SUBST(TERMCAP_LIBS)
1563
1564 dnl ----------------------------------------------------------------
1565 dnl final output
1566 dnl
1567
1568 AC_OUTPUT( \
1569 Makefile:build/top.mk:Makefile.in:build/dir.mk \
1570 doc/Makefile:build/top.mk:doc/Makefile.in:build/dir.mk \
1571 doc/man/Makefile:build/top.mk:doc/man/Makefile.in:build/dir.mk \
1572 doc/man/man1/Makefile:build/top.mk:doc/man/man1/Makefile.in:build/man.mk \
1573 doc/man/man3/Makefile:build/top.mk:doc/man/man3/Makefile.in:build/man.mk \
1574 doc/man/man5/Makefile:build/top.mk:doc/man/man5/Makefile.in:build/man.mk \
1575 doc/man/man8/Makefile:build/top.mk:doc/man/man8/Makefile.in:build/man.mk \
1576 clients/Makefile:build/top.mk:clients/Makefile.in:build/dir.mk \
1577 clients/finger/Makefile:build/top.mk:clients/finger/Makefile.in:build/rules.mk \
1578 clients/fax500/Makefile:build/top.mk:clients/fax500/Makefile.in:build/rules.mk \
1579 clients/gopher/Makefile:build/top.mk:clients/gopher/Makefile.in:build/rules.mk \
1580 clients/mail500/Makefile:build/top.mk:clients/mail500/Makefile.in:build/rules.mk \
1581 clients/rcpt500/Makefile:build/top.mk:clients/rcpt500/Makefile.in:build/rules.mk \
1582 clients/ud/Makefile:build/top.mk:clients/ud/Makefile.in:build/rules.mk \
1583 clients/tools/Makefile:build/top.mk:clients/tools/Makefile.in:build/rules.mk \
1584 include/Makefile:build/top.mk:include/Makefile.in \
1585 libraries/Makefile:build/top.mk:libraries/Makefile.in:build/dir.mk      \
1586 libraries/libavl/Makefile:build/top.mk:libraries/libavl/Makefile.in:build/lib.mk:build/lib-static.mk    \
1587 libraries/liblber/Makefile:build/top.mk:libraries/liblber/Makefile.in:build/lib.mk:build/lib-shared.mk  \
1588 libraries/libldap/Makefile:build/top.mk:libraries/libldap/Makefile.in:build/lib.mk:build/lib-shared.mk  \
1589 libraries/libldbm/Makefile:build/top.mk:libraries/libldbm/Makefile.in:build/lib.mk:build/lib-static.mk  \
1590 libraries/libldif/Makefile:build/top.mk:libraries/libldif/Makefile.in:build/lib.mk:build/lib-static.mk  \
1591 libraries/liblthread/Makefile:build/top.mk:libraries/liblthread/Makefile.in:build/lib.mk:build/lib-static.mk    \
1592 libraries/liblutil/Makefile:build/top.mk:libraries/liblutil/Makefile.in:build/lib.mk:build/lib-static.mk        \
1593 servers/Makefile:build/top.mk:servers/Makefile.in:build/dir.mk \
1594 servers/ldapd/Makefile:build/top.mk:servers/ldapd/Makefile.in:build/srv.mk \
1595 servers/slapd/Makefile:build/top.mk:servers/slapd/Makefile.in:build/srv.mk \
1596 servers/slapd/back-ldbm/Makefile:build/top.mk:servers/slapd/back-ldbm/Makefile.in:build/srv.mk \
1597 servers/slapd/back-passwd/Makefile:build/top.mk:servers/slapd/back-passwd/Makefile.in:build/srv.mk \
1598 servers/slapd/back-shell/Makefile:build/top.mk:servers/slapd/back-shell/Makefile.in:build/srv.mk \
1599 servers/slapd/shell-backends/Makefile:build/top.mk:servers/slapd/shell-backends/Makefile.in:build/srv.mk \
1600 servers/slapd/tools/Makefile:build/top.mk:servers/slapd/tools/Makefile.in \
1601 servers/slurpd/Makefile:build/top.mk:servers/slurpd/Makefile.in:build/srv.mk \
1602 tests/Makefile:build/top.mk:tests/Makefile.in \
1603 ,[
1604 date > stamp-h
1605 echo Please \"make depend\" to build dependencies
1606 ])