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