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