]> git.sur5r.net Git - openldap/blob - configure.in
Update pthread detection.
[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 0)  pthread_create() in $LIBS
400                 dnl
401                 dnl Check special pthread (final) flags
402                 dnl 1)  pthread_create() with -kthread (FreeBSD)
403                 dnl 2)  pthread_create() with -pthread (FreeBSD)
404                 dnl 3)  pthread_create() with -pthreads (OSF/1)
405                 dnl 4)  pthread_create() with -thread (?)
406                 dnl
407                 dnl Check pthread (final) libraries
408                 dnl 5)  pthread_mutex_lock() in -lpthread -lexc (OSF/1)
409                 dnl 6)  pthread_mutex_unlock() in -lpthread -lmach -lexc -lc_r (OSF/1)
410                 dnl 7)  pthread_create() in -lpthread (many)
411                 dnl 8)  pthread_create() in -lc_r (FreeBSD)
412                 dnl 9)  pthread_create() in -lpthreads (many)
413                 dnl 10) pthread_join() -Wl,-woff,85 -lpthreads (IRIX)
414                 dnl 11) pthread_create() in HP-UX -lpthread (HP-UX 11)
415                 dnl
416                 dnl Check pthread (draft4) flags (to be depreciated)
417                 dnl 12) pthread_create() with -threads (OSF/1)
418                 dnl
419                 dnl Check pthread (final) libraries (to be depreciated)
420                 dnl 13) pthread_mutex_lock() in -lpthreads -lexc (OSF/1)
421                 dnl 14) pthread_mutex_unlock() in -lpthreads -lmach -lexc -lc_r (OSF/1)
422                 dnl
423
424                 dnl pthread_create in $LIBS
425                 AC_CHECK_FUNC(pthread_create,[ol_link_threads=yes])
426
427                 if test $ol_link_threads = no ; then
428                         dnl try -kthread
429                         AC_CACHE_CHECK([for pthread_create with -kthread],
430                                 [ol_cv_kthread_flag], [
431                                 dnl save the flags
432                                 save_LIBS="$LIBS"
433                                 LIBS="-kthread $LIBS"
434                                 AC_TRY_LINK([char pthread();],[
435                                         pthread_create();
436                                         ], ol_cv_kthread_flag=yes, ol_cv_kthread_flag=no)
437                                 dnl restore the LIBS
438                                 LIBS="$save_LIBS"
439                         ])
440
441                         if test $ol_cv_kthread_flag = yes ; then
442                                 LTHREAD_LIBS="$LTHREAD_LIBS -kthread"
443                                 ol_link_threads=posix
444                         fi
445                 fi
446
447                 if test $ol_link_threads = no ; then
448                         dnl try -pthread
449                         AC_CACHE_CHECK([for pthread_create with -pthread],
450                                 [ol_cv_pthread_flag], [
451                                 dnl save the flags
452                                 save_LIBS="$LIBS"
453                                 LIBS="-pthread $LIBS"
454                                 AC_TRY_LINK([char pthread();],[
455                                         pthread_create();
456                                         ], ol_cv_pthread_flag=yes, ol_cv_pthread_flag=no)
457                                 dnl restore the LIBS
458                                 LIBS="$save_LIBS"
459                         ])
460
461                         if test $ol_cv_pthread_flag = yes ; then
462                                 LTHREAD_LIBS="$LTHREAD_LIBS -pthread"
463                                 ol_link_threads=posix
464                         fi
465                 fi
466
467                 if test $ol_link_threads = no ; then
468                         dnl try -pthreads
469                         AC_CACHE_CHECK([for pthread_create with -pthreads],
470                                 [ol_cv_pthreads_flag], [
471                                 dnl save the flags
472                                 save_LIBS="$LIBS"
473                                 LIBS="-pthreads $LIBS"
474                                 AC_TRY_LINK([char pthread();],[
475                                         pthread_create();
476                                         ], ol_cv_pthreads_flag=yes, ol_cv_pthreads_flag=no)
477                                 dnl restore the LIBS
478                                 LIBS="$save_LIBS"
479                         ])
480
481                         if test $ol_cv_pthreads_flag = yes ; then
482                                 LTHREAD_LIBS="$LTHREAD_LIBS -pthreads"
483                                 ol_link_threads=posix
484                         fi
485                 fi
486
487                 if test $ol_link_threads = no ; then
488                         dnl try -thread
489                         AC_CACHE_CHECK([for pthread_create with -thread],
490                                 [ol_cv_thread_flag], [
491                                 dnl save the flags
492                                 save_LIBS="$LIBS"
493                                 LIBS="-thread $LIBS"
494                                 AC_TRY_LINK([char pthread();],[
495                                         pthread_create();
496                                         ], ol_cv_thread_flag=yes, ol_cv_thread_flag=no)
497                                 dnl restore the LIBS
498                                 LIBS="$save_LIBS"
499                         ])
500
501                         if test $ol_cv_thread_flag = yes ; then
502                                 LTHREAD_LIBS="$LTHREAD_LIBS -thread"
503                                 ol_link_threads=posix
504                         fi
505                 fi
506
507                 if test $ol_link_threads = no ; then
508                         dnl try DEC Threads -lpthread -lexc
509                         save_LIBS="$LIBS"
510                         AC_CHECK_LIB(pthread, pthread_mutex_lock, [
511                                 ol_link_threads=posix
512                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lexc"
513                                 if test $ol_with_yielding_select = auto ; then
514                                         ol_with_yielding_select=yes
515                                 fi
516                                 ],:,[-lexc])
517                         LIBS="$save_LIBS"
518                 fi
519
520                 if test $ol_link_threads = no ; then
521                         dnl try DEC Threads -lpthread -lmach -lexc -lc_r
522                         save_LIBS="$LIBS"
523                         AC_CHECK_LIB(pthread, pthread_mutex_unlock, [
524                                 ol_link_threads=posix
525                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lmach -lexc -lc_r"
526                                 if test $ol_with_yielding_select = auto ; then
527                                         ol_with_yielding_select=yes
528                                 fi
529                                 ],:,[-lmach -lexc -lc_r])
530                         LIBS="$save_LIBS"
531                 fi
532
533                 if test $ol_link_threads = no ; then
534                         dnl try -lpthread
535                         save_LIBS="$LIBS"
536                         AC_CHECK_LIB(pthread, pthread_create, [
537                                 ol_link_threads=posix
538                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthread"],:)
539                         LIBS="$save_LIBS"
540                 fi
541
542                 if test $ol_link_threads = no ; then
543                         dnl try -lc_r
544                         save_LIBS="$LIBS"
545                         AC_CHECK_LIB(c_r, pthread_create, [
546                                 ol_link_threads=posix
547                                 LTHREAD_LIBS="$LTHREAD_LIBS -lc_r"],:)
548                         LIBS="$save_LIBS"
549                 fi
550
551                 if test $ol_link_threads = no ; then
552                         dnl try -lpthreads
553                         save_LIBS="$LIBS"
554                         AC_CHECK_LIB(pthreads, pthread_create, [
555                                 ol_link_threads=posix
556                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads"],:)
557                         LIBS="$save_LIBS"
558                 fi
559
560                 dnl IRIX Pthread check
561                 if test $ol_link_threads = no ; then
562                         dnl try IRIX Pthreads -Wl,-woff,85 -lpthreads
563                         save_LIBS="$LIBS"
564                         AC_CHECK_LIB(pthreads, pthread_join, [
565                                 ol_link_threads=posix
566                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads"
567                                 ],:,[-Wl,-woff,85])
568                         LIBS="$save_LIBS"
569                 fi
570
571                 dnl HP-UX 11 Pthread check
572                 if test $ol_link_threads = no; then
573                         save_LIBS="$LIBS"
574                         LIBS="$LIBS -lpthread"
575                         AC_MSG_CHECKING([for pthread_create() in HP-UX -lpthread])
576                         ol_try_pthread_hpux_11=no
577                         AC_CACHE_VAL(ol_cv_pthread_hpux_11,[
578                                 AC_TRY_LINK([
579 #include <pthread.h>
580 #include <elf.h>
581 #ifndef ELFABI_HPUX_REL11
582         die horribly
583 #endif
584                                 ], [pthread_create(NULL, NULL, NULL, NULL);],
585                                         ol_try_pthread_hpux_11=yes
586                                         ol_cv_pthread_hpux_11=yes,
587                                         ol_cv_pthread_hpux_11=no)])
588                         AC_MSG_RESULT(yes)
589                         LIBS="$save_LIBS"
590
591                         if test $ol_cv_pthread_hpux_11=yes ; then
592                                 ol_link_threads=posix
593                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthread"
594                                 if test $ol_try_pthread_hpux_11=yes ; then
595                                         dnl Some tests below may fail, cause we aint including
596                                         dnl pthread.h. Force appropriate ones to yes
597                                         ac_cv_func_pthread_attr_init=yes
598                                 fi
599                         fi
600                 fi
601
602                 if test $ol_link_threads = no ; then
603                         dnl try -threads
604                         AC_CACHE_CHECK([for pthread_create with -threads],
605                                 [ol_cv_thread_flag], [
606                                 dnl save the flags
607                                 save_LIBS="$LIBS"
608                                 LIBS="-threads $LIBS"
609                                 AC_TRY_LINK([char pthread();],[
610                                         pthread_create();
611                                         ], ol_cv_thread_flag=yes, ol_cv_thread_flag=no)
612                                 dnl restore the LIBS
613                                 LIBS="$save_LIBS"
614                         ])
615
616                         if test $ol_cv_thread_flag = yes ; then
617                                 LTHREAD_LIBS="$LTHREAD_LIBS -threads"
618                                 ol_link_threads=posix
619                         fi
620                 fi
621
622                 if test $ol_link_threads = no ; then
623                         dnl try DEC Threads -lpthreads -lexc
624                         save_LIBS="$LIBS"
625                         AC_CHECK_LIB(pthreads, pthread_mutex_lock, [
626                                 ol_link_threads=posix
627                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads -lexc"
628                                 if test $ol_with_yielding_select = auto ; then
629                                         ol_with_yielding_select=yes
630                                 fi
631                                 ],:,[-lexc])
632                         LIBS="$save_LIBS"
633                 fi
634
635                 if test $ol_link_threads = no ; then
636                         dnl try DEC Threads -lpthreads -lmach -lexc -lc_r
637                         save_LIBS="$LIBS"
638                         AC_CHECK_LIB(pthreads, pthread_mutex_unlock, [
639                                 ol_link_threads=posix
640                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthreads -lmach -lexc -lc_r"
641                                 if test $ol_with_yielding_select = auto ; then
642                                         ol_with_yielding_select=yes
643                                 fi
644                                 ],:,[-lmach -lexc -lc_r])
645                         LIBS="$save_LIBS"
646                 fi
647
648                 if test $ol_link_threads != no ; then
649                         AC_DEFINE(HAVE_PTHREADS)
650
651                         dnl save flags
652                         save_CPPFLAGS="$CPPFLAGS"
653                         save_LIBS="$LIBS"
654                         LIBS="$LTHREAD_LIBS $LIBS"
655
656                         dnl All POSIX Thread (final) implementations should have
657                         dnl sched_yield instead of pthread yield.
658                         dnl check for both
659                         AC_CHECK_FUNCS(sched_yield pthread_yield)
660
661                         if test $ac_cv_func_sched_yield = no -a \
662                                 $ac_cv_func_pthread_yield = no ; then
663                                 dnl Digital UNIX has sched_yield() in -lrt
664                                 AC_CHECK_LIB(rt, sched_yield,
665                                         [LTHREAD_LIBS="$LTHREAD_LIBS -lrt"
666                                         AC_DEFINE(HAVE_SCHED_YIELD,1)
667                                         ac_cv_func_sched_yield=yes],
668                                         [ac_cv_func_sched_yield=no])
669                         fi
670                         if test $ac_cv_func_sched_yield = no -a \
671                                 $ac_cv_func_pthread_yield = no ; then
672                                 dnl Solaris has sched_yield() in -lposix4
673                                 dnl but we'll use thr_yield instead.
674                                 AC_CHECK_FUNCS(thr_yield)
675                         fi
676                         if test $ac_cv_func_sched_yield = no -a \
677                                 $ac_cv_func_pthread_yield = no -a \
678                                 "$ac_cv_func_thr_yield" = no ; then
679                                 AC_MSG_WARN([could not locate sched_yield() or pthread_yield()])
680                         fi
681
682                         dnl Check functions for compatibility
683                         AC_CHECK_FUNCS(pthread_kill pthread_detach)
684
685                         if test $ac_cv_func_pthread_detach = no ; then
686                                 AC_MSG_ERROR([could not locate pthread_detach()])
687                         fi
688
689                         dnl Check for setconcurreny functions
690                         AC_CHECK_FUNCS( \
691                                 pthread_setconcurrency \
692                                 pthread_getconcurrency \
693                                 thr_setconcurrency \
694                                 thr_getconcurrency \
695                         )
696
697                         AC_MSG_CHECKING([if pthread_create() works])
698                         AC_CACHE_VAL(ol_cv_pthread_create_works,[
699                         AC_TRY_RUN([
700 #include <pthread.h>
701 #ifndef NULL
702 #define NULL (void*)0
703 #endif
704
705 static void *task(p)
706         void *p;
707 {
708         return (void *) (p == NULL);
709 }
710
711 int main(argc, argv)
712         int argc;
713         char **argv;
714 {
715         pthread_t t;
716         exit(pthread_create(&t, NULL, task, NULL));
717 }
718 ],
719                                 [ol_cv_pthread_create_works=yes],
720                                 [ol_cv_pthread_create_works=no],
721                                 [dnl assume yes
722                                 ol_cv_pthread_create_works=yes])])
723                         AC_MSG_RESULT($ol_cv_pthread_create_works)
724
725                         if test $ol_cv_pthread_create_works = no ; then
726                                 AC_MSG_ERROR([pthread.h and pthread_create are not compatible])
727                         fi
728
729                         dnl Check if select causes an yield
730                         if test $ol_with_yielding_select = auto ; then
731                                 AC_MSG_CHECKING([if select yields when using pthreads])
732                                 AC_CACHE_VAL(ol_cv_pthread_select_yields,[
733                                 AC_TRY_RUN([
734 #include <sys/types.h>
735 #include <sys/time.h>
736 #include <unistd.h>
737 #include <pthread.h>
738 #ifndef NULL
739 #define NULL (void*) 0
740 #endif
741
742 static int fildes[2];
743
744 static void *task(p)
745         void *p;
746 {
747         int i;
748         struct timeval tv;
749
750         fd_set rfds;
751
752         tv.tv_sec=10;
753         tv.tv_usec=0;
754
755         FD_ZERO(&rfds);
756         FD_SET(fildes[0], &rfds);
757
758         /* we're not interested in any fds */
759         i = select(FD_SETSIZE, &rfds, NULL, NULL, &tv);
760
761         if(i < 0) {
762                 perror("select");
763                 exit(10);
764         }
765
766         exit(0); /* if we exit here, the select blocked the whole process */
767 }
768
769 int main(argc, argv)
770         int argc;
771         char **argv;
772 {
773         pthread_t t;
774
775         /* create a pipe to select */
776         if(pipe(&fildes[0])) {
777                 perror("select");
778                 exit(1);
779         }
780
781 #ifdef HAVE_PTHREAD_SETCONCURRENCY
782         (void) pthread_setconcurrency(2);
783 #else
784 #ifdef HAVE_THR_SETCONCURRENCY
785         /* Set Solaris LWP concurrency to 2 */
786         thr_setconcurrency(2);
787 #endif
788 #endif
789
790         pthread_create(&t, NULL, task, NULL);
791
792 #if HAVE_SCHED_YIELD
793         sched_yield();  /* make sure task runs first */
794 #else
795 #ifdef HAVE_PTHREAD_YIELD
796         pthread_yield();        /* make sure task runs first */
797 #endif
798 #endif
799
800         exit(2);
801 }],
802                                 [ol_cv_pthread_select_yields=no],
803                                 [ol_cv_pthread_select_yields=yes], [
804                                 AC_MSG_ERROR([crossing compiling: use --with-yielding_select=yes|no|manual])])])
805                                 AC_MSG_RESULT($ol_cv_pthread_select_yields)
806
807                                 if test $ol_cv_pthread_select_yields = yes ; then
808                                         ol_with_yielding_select=yes
809                                 fi
810                         fi
811
812                         dnl restore flags
813                         CPPFLAGS="$save_CPPFLAGS"
814                         LIBS="$save_LIBS"
815                 else
816                         AC_MSG_ERROR([could not link with POSIX Threads])
817                 fi
818         fi
819
820         if test $ol_with_threads = posix ; then
821                 AC_MSG_ERROR([could not locate POSIX Threads])
822         fi
823 fi
824
825 if test $ol_with_threads = auto -o $ol_with_threads = yes \
826         -o $ol_with_threads = mach ; then
827
828         dnl check for Mach CThreads
829         AC_CHECK_HEADERS(mach/cthreads.h)
830         if test $ac_cv_header_mach_cthreads_h = yes ; then
831                 ol_with_threads=found
832
833                 dnl check for cthread support in current $LIBS
834                 AC_CHECK_FUNC(cthread_fork,[ol_link_threads=yes])
835
836                 if test $ol_link_threads = no ; then
837                         dnl try -all_load
838                         dnl this test needs work
839                         AC_CACHE_CHECK([for cthread_fork with -all_load],
840                                 [ol_cv_cthread_all_load], [
841                                 dnl save the flags
842                                 save_LIBS="$LIBS"
843                                 LIBS="-all_load $LIBS"
844                                 AC_TRY_LINK([#include <mach/cthreads.h>],[
845                                         cthread_fork((void *)0, (void *)0);
846                                         ], ol_cv_cthread_all_load=yes, ol_cv_cthread_all_load=no)
847                                 dnl restore the LIBS
848                                 LIBS="$save_LIBS"
849                         ])
850
851                         if test $ol_cv_cthread_all_load = yes ; then
852                                 LTHREAD_LIBS="$LTHREAD_LIBS -all_load"
853                                 ol_link_threads=mach
854                         fi
855                 fi
856
857                 if test $ol_link_threads != no ; then
858                         : check for cthread specific functionality here
859                         AC_DEFINE(HAVE_MACH_CTHREADS,1)
860                 else
861                         AC_MSG_ERROR([could not link with Mach CThreads])
862                 fi
863         fi
864
865         if test $ol_with_threads = mach ; then
866                 AC_MSG_ERROR([could not locate Mach CThreads])
867         fi
868 fi
869
870 if test $ol_with_threads = auto -o $ol_with_threads = yes \
871         -o $ol_with_threads = lwp ; then
872
873         dnl check for SunOS5 LWP
874         AC_CHECK_HEADERS(thread.h synch.h)
875         if test $ac_cv_header_thread_h = yes -a $ac_cv_header_synch_h = yes ; then
876                 AC_CHECK_LIB(thread, thr_create, [have_thr=yes], [have_thr=no])
877
878                 if test $have_thr = yes ; then
879                         AC_DEFINE(HAVE_THR)
880                         LTHREAD_LIBS="$LTHREAD_LIBS -lthread"
881                         ol_link_threads=thr
882
883                         if test $ol_with_yielding_select = auto ; then
884                                 ol_with_yielding_select=yes
885                         fi
886
887                         dnl Check for setconcurreny functions
888                         AC_CHECK_FUNCS( \
889                                 thr_setconcurrency \
890                                 thr_getconcurrency \
891                         )
892                 fi
893         fi
894
895         dnl check for SunOS4 LWP
896         AC_CHECK_HEADERS(lwp/lwp.h)
897         if test $ac_cv_header_lwp_lwp_h = yes ; then
898                 AC_CHECK_LIB(lwp, lwp_create, [have_lwp=yes], [have_lwp=no])
899
900                 if test $have_lwp = yes ; then
901                         AC_DEFINE(HAVE_LWP)
902                         LTHREAD_LIBS="$LTHREAD_LIBS -llwp"
903                         ol_link_threads=lwp
904
905                         if test $ol_with_yielding_select = auto ; then
906                                 ol_with_yielding_select=no
907                         fi
908                 fi
909         fi
910 fi
911
912 if test $ol_with_yielding_select = yes ; then
913         AC_DEFINE(HAVE_YIELDING_SELECT,1)
914 fi
915
916 if test $ol_with_threads = manual ; then
917         dnl User thinks he can manually configure threads.
918         ol_link_threads=yes
919
920         AC_MSG_WARN([thread defines and link options must be set manually])
921
922         AC_CHECK_HEADERS(pthread.h sched.h)
923         AC_CHECK_FUNCS(sched_yield pthread_yield)
924         OL_LINUX_THREADS
925
926         AC_CHECK_HEADERS(mach/cthreads.h)
927         AC_CHECK_HEADERS(lwp/lwp.h)
928         AC_CHECK_HEADERS(thread.h synch.h)
929 fi
930
931 if test $ol_link_threads != no ; then  
932         dnl needed to get reentrant/threadsafe versions
933         dnl
934         AC_DEFINE(REENTRANT,1)
935         AC_DEFINE(_REENTRANT,1)
936         AC_DEFINE(THREAD_SAFE,1)
937         AC_DEFINE(_THREAD_SAFE,1)
938         AC_DEFINE(THREADSAFE,1)
939         AC_DEFINE(_THREADSAFE,1)
940
941         dnl this might cause the errno symbol to be
942         dnl replaced with a function to get a thread specific errno.
943         dnl check to see if everything needs to be compiled
944         dnl with the thread libraries
945         AC_CACHE_CHECK([for thread specific errno],
946                 [ol_cv_errno_thread_specific], [
947                 AC_TRY_LINK([
948 #include <errno.h>
949                         ], [
950 int x = errno;
951                         ],
952                         [ol_cv_errno_thread_specific=yes],
953                         [ol_cv_errno_thread_specific=no])
954         ])
955
956         if test $ol_cv_errno_thread_specific != yes ; then
957                 LIBS="$LTHREAD_LIBS $LIBS"
958                 LTHREAD_LIBS=""
959         fi
960 fi  
961
962 dnl ----------------------------------------------------------------
963
964 if test $ol_link_threads = no ; then
965         if test $ol_with_threads = yes ; then
966                 AC_MSG_ERROR([no suitable thread support])
967         fi
968
969         if test $ol_with_threads = auto ; then
970                 AC_MSG_WARN([no suitable thread support, disabling threads])
971                 ol_with_threads=no
972         fi
973
974         AC_DEFINE(NO_THREADS,1)
975         LTHREAD_LIBS=""
976 fi
977
978 ol_link_ldbm=no 
979 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db2 ; then
980         OL_BERKELEY_DB2
981
982         if test $ol_cv_berkeley_db2 = yes ; then
983                 ol_link_ldbm=db2
984                 ol_with_ldbm_api=db2
985
986                 if test $ol_with_ldbm_type = hash ; then
987                         AC_DEFINE(LDBM_USE_DBHASH,1)
988                 else
989                         AC_DEFINE(LDBM_USE_DBBTREE,1)
990                 fi
991
992                 dnl $ol_cv_lib_db2 should be yes or -ldb
993                 dnl (it could be no, but that would be an error
994                 if test $ol_cv_lib_db2 != yes ; then
995                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_db2"
996                 fi
997         fi
998 fi
999
1000 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db ; then
1001         OL_BERKELEY_DB
1002
1003         if test $ol_cv_berkeley_db = yes ; then
1004                 ol_link_ldbm=db
1005                 ol_with_ldbm_api=db
1006
1007                 if test $ol_with_ldbm_type = hash ; then
1008                         AC_DEFINE(LDBM_USE_DBHASH,1)
1009                 else
1010                         AC_DEFINE(LDBM_USE_DBBTREE,1)
1011                 fi
1012
1013                 dnl $ol_cv_lib_db should be yes or -ldb
1014                 dnl (it could be no, but that would be an error
1015                 if test $ol_cv_lib_db != yes ; then
1016                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_db"
1017                 fi
1018         fi
1019 fi
1020
1021 if test $ol_with_ldbm_api = manual ; then
1022         dnl User thinks he can manually configure LDBM api.
1023         ol_link_ldbm=yes
1024
1025         AC_MSG_WARN([LDBM defines and link options must be set manually])
1026
1027         AC_CHECK_HEADERS(db.h db_185.h gdbm.h ndbm.h)
1028 fi
1029
1030 if test $ol_link_ldbm = no -a $ol_with_ldbm_type = btree ; then
1031         AC_MSG_WARN(Could not find LDBM with BTREE support)
1032         ol_with_ldbm_api=none
1033 fi
1034
1035 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = gdbm ; then
1036         OL_GDBM
1037
1038         if test $ol_cv_gdbm = yes ; then
1039                 ol_link_ldbm=gdbm
1040                 ol_with_ldbm_api=gdbm
1041
1042                 if test $ol_cv_lib_gdbm != yes ; then
1043                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_gdbm"
1044                 fi
1045         fi
1046 fi
1047
1048 if test $ol_with_ldbm_api = auto ; then
1049         AC_MSG_WARN([skipping automatic checking for NDBM, must be manually enabled.])
1050 elif test $ol_with_ldbm_api = ndbm ; then
1051         OL_NDBM
1052
1053         if test $ol_cv_ndbm = yes ; then
1054                 ol_link_ldbm=ndbm
1055                 ol_with_ldbm_api=ndbm
1056
1057                 if test $ol_cv_lib_ndbm != yes ; then
1058                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_ndbm"
1059                 fi
1060         fi
1061 fi
1062
1063 if test $ol_link_ldbm = no -a $ol_enable_ldbm != no ; then
1064         AC_MSG_WARN(could not find suitable LDBM backend)
1065         if test $ol_enable_ldbm = yes ; then
1066                 AC_MSG_ERROR(select appropriate LDBM options or disable)
1067         fi
1068
1069         AC_MSG_WARN(disabling LDBM)
1070         ol_enable_ldbm=no
1071 fi
1072
1073 if test $ol_enable_wrappers != no ; then
1074         AC_CHECK_HEADERS(tcpd.h)
1075
1076         if test $ac_cv_header_tcpd_h != yes ; then
1077                 have_wrappers=no
1078         else
1079                 AC_CHECK_LIB(wrap, main,
1080                         [have_wrappers=yes], [have_wrappers=no])
1081         fi
1082
1083         if test $have_wrappers = yes ; then
1084                 AC_DEFINE(HAVE_TCPD)
1085                 SLAPD_LIBS="$SLAPD_LIBS -lwrap"
1086         else
1087                 AC_MSG_WARN(could not find -lwrap)
1088                 if test $ol_enable_wrappers = yes ; then
1089                         AC_MSG_ERROR(could not find wrappers, select appropriate options or disable)
1090                 fi
1091
1092                 AC_MSG_WARN(disabling wrappers support)
1093                 ol_enable_wrappers=no
1094         fi
1095 fi
1096
1097 if test $ol_enable_dmalloc != no ; then
1098         AC_CHECK_HEADERS(dmalloc.h)
1099         AC_CHECK_LIB(dmalloc, dmalloc_shutdown)
1100 fi
1101
1102 # ud needs termcap (should insert check here)
1103 ol_link_termcap=no
1104 AC_CHECK_HEADERS(termcap.h ncurses.h)
1105
1106 if test $ol_link_termcap = no ; then
1107         AC_CHECK_LIB(termcap, tputs, [have_termcap=yes], [have_termcap=no])
1108         if test $have_termcap = yes ; then
1109                 AC_DEFINE(HAVE_TERMCAP)
1110                 ol_link_termcap=yes
1111                 TERMCAP_LIBS=-ltermcap
1112         fi
1113 fi
1114
1115 if test $ol_link_termcap = no ; then
1116         AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
1117         if test $have_ncurses = yes ; then
1118                 AC_DEFINE(HAVE_NCURSES)
1119                 ol_link_termcap=yes
1120                 TERMCAP_LIBS=-lncurses
1121         fi
1122 fi
1123
1124 if test $ol_link_termcap = no ; then
1125         AC_DEFINE(NO_TERMCAP,1)
1126         TERMCAP_LIBS=
1127 fi
1128
1129 # FreeBSD (and others) have crypt(3) in -lcrypt
1130 if test $ol_enable_crypt != no ; then
1131         AC_CHECK_FUNC(crypt, [have_crypt=yes], [
1132                 AC_CHECK_LIB(crypt, crypt, [LUTIL_LIBS="$LUTIL_LIBS -lcrypt"
1133                         have_crypt=yes], [have_crypt=no])])
1134
1135         if test $have_crypt = yes ; then
1136                 AC_DEFINE(HAVE_CRYPT,1)
1137         else
1138                 AC_MSG_WARN(could not find crypt)
1139                 if test $ol_enable_crypt = yes ; then
1140                         AC_MSG_ERROR(could not find crypt, select appropriate options or disable)
1141                 fi
1142
1143                 AC_MSG_WARN(disabling crypt support)
1144                 ol_enable_crypt=no
1145         fi
1146 fi
1147
1148 # FreeBSD (and others) have setproctitle(3) in -lutil
1149 if test $ol_enable_proctitle != no ; then
1150         AC_CHECK_FUNC(setproctitle,     [have_setproctitle=yes], [
1151                 AC_CHECK_LIB(util, setproctitle,
1152                         [have_setproctitle=yes
1153                         LUTIL_LIBS="$LUTIL_LIBS -lutil"],
1154                         [have_setproctitle=no
1155                         LIBOBJS="$LIBOBJS setproctitle.o"])])
1156
1157         if test $have_setproctitle = yes ; then
1158                 AC_DEFINE(HAVE_SETPROCTITLE,1)
1159         fi
1160 fi
1161
1162 dnl ----------------------------------------------------------------
1163 dnl Checks for header files.
1164 AC_HEADER_STDC
1165
1166 if test $ac_cv_header_stdc != yes; then
1167         AC_MSG_WARN([could not Standard C compliant headers])
1168 fi
1169
1170 AC_HEADER_DIRENT
1171 AC_HEADER_SYS_WAIT
1172 AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1173 if test $am_cv_sys_posix_termios = yes ; then
1174         AC_DEFINE(HAVE_POSIX_TERMIOS,1)
1175 fi
1176
1177 AC_CHECK_HEADERS(       \
1178         crypt.h                 \
1179         errno.h                 \
1180         fcntl.h                 \
1181         filio.h                 \
1182         getopt.h                \
1183         libutil.h               \
1184         limits.h                \
1185         malloc.h                \
1186         memory.h                \
1187         regex.h                 \
1188         psap.h                  \
1189         pwd.h                   \
1190         sgtty.h                 \
1191         stdarg.h                \
1192         stddef.h                \
1193         string.h                \
1194         strings.h               \
1195         sys/file.h              \
1196         sys/filio.h             \
1197         sys/errno.h             \
1198         sys/ioctl.h             \
1199         sys/param.h             \
1200         sys/resource.h  \
1201         sys/socket.h    \
1202         sys/syslog.h    \
1203         sys/time.h              \
1204         sys/types.h             \
1205         syslog.h                \
1206         termios.h               \
1207         unistd.h                \
1208 )
1209
1210 dnl ----------------------------------------------------------------
1211 dnl Checks for typedefs, structures, and compiler characteristics.
1212 AC_TYPE_GETGROUPS dnl requires AC_TYPE_UID_T
1213 AC_TYPE_MODE_T
1214 AC_TYPE_OFF_T
1215 AC_TYPE_PID_T
1216 AM_TYPE_PTRDIFF_T
1217 AC_TYPE_SIGNAL
1218 AC_TYPE_SIZE_T
1219 AC_STRUCT_ST_BLKSIZE
1220 AC_HEADER_TIME
1221 AC_STRUCT_TM
1222
1223 OL_C_UPPER_LOWER
1224 AC_C_CONST
1225
1226 if test $cross_compiling = yes ; then
1227         AC_DEFINE(CROSS_COMPILING, 1)
1228 else
1229         AC_C_BIGENDIAN
1230         AC_CHECK_SIZEOF(short) 
1231         AC_CHECK_SIZEOF(int) 
1232         AC_CHECK_SIZEOF(long)
1233 fi
1234
1235 dnl ----------------------------------------------------------------
1236 dnl Checks for library functions.
1237 AC_FUNC_MEMCMP
1238 dnl AM_FUNC_MKTIME dnl checks for sys/time.h and unistd.h
1239 AC_FUNC_STRFTIME
1240 dnl AM_FUNC_STRTOD
1241 AC_FUNC_VPRINTF
1242
1243 if test $ac_cv_func_vprintf = yes ; then
1244         dnl check for vsnprintf
1245         AC_CHECK_FUNCS(vsnprintf vsprintf)
1246 fi
1247
1248 AC_CHECK_FUNCS(         \
1249         bcopy                   \
1250         flock                   \
1251         getdtablesize   \
1252         gethostname             \
1253         getpwuid                \
1254         gettimeofday    \
1255         lockf                   \
1256         memcpy                  \
1257         memmove                 \
1258         mkstemp                 \
1259         select                  \
1260         setpwfile               \
1261         setsid                  \
1262         signal                  \
1263         sigset                  \
1264         snprintf                \
1265         socket                  \
1266         strerror                \
1267         strpbrk                 \
1268         strrchr                 \
1269         strsep                  \
1270         strstr                  \
1271         strtok                  \
1272         strtol                  \
1273         strtoul                 \
1274         sysconf                 \
1275         waitpid                 \
1276 )
1277
1278 dnl We actually may need to replace more than this.
1279 AC_REPLACE_FUNCS(getopt strdup tempnam)
1280
1281 dnl ----------------------------------------------------------------
1282 # Check Configuration
1283 OL_SYS_ERRLIST
1284
1285 dnl ----------------------------------------------------------------
1286 dnl Sort out defines
1287
1288 if test "$ol_enable_debug" != no ; then
1289         AC_DEFINE(LDAP_DEBUG,1)
1290 fi
1291 if test "$ol_enable_libui" = yes ; then
1292         AC_DEFINE(LDAP_LIBUI,1)
1293 fi
1294 if test "$ol_enable_cache" = no ; then
1295         AC_DEFINE(LDAP_NOCACHE,1)
1296 fi
1297 if test "$ol_enable_dns" != no ; then
1298         AC_DEFINE(LDAP_DNS,1)
1299 fi
1300 if test "$ol_enable_proctitle" != no ; then
1301         AC_DEFINE(LDAP_PROCTITLE,1)
1302 fi
1303 if test "$ol_enable_referrals" != no ; then
1304         AC_DEFINE(LDAP_REFERRALS,1)
1305 fi
1306 if test "$ol_enable_cldap" != no ; then
1307         AC_DEFINE(LDAP_CONNECTIONLESS,1)
1308 fi
1309
1310 if test "$ol_enable_aclgroups" != no ; then
1311         AC_DEFINE(SLAPD_ACLGROUPS,1)
1312 fi
1313 if test "$ol_enable_crypt" != no ; then
1314         AC_DEFINE(SLAPD_CRYPT,1)
1315 fi
1316 if test "$ol_enable_cleartext" != no ; then
1317         AC_DEFINE(SLAPD_CLEARTEXT,1)
1318 fi
1319 if test "$ol_enable_phonetic" != no ; then
1320         AC_DEFINE(SLAPD_PHONETIC,1)
1321 fi
1322 if test "$ol_enable_rlookups" != no ; then
1323         AC_DEFINE(SLAPD_RLOOKUPS,1)
1324 fi
1325
1326 if test "$ol_link_ldbm" != no ; then
1327         AC_DEFINE(SLAPD_LDBM,1)
1328         BUILD_SLAPD=yes
1329         BUILD_LDBM=yes
1330 fi
1331
1332 if test "$ol_enable_passwd" != no ; then
1333         AC_DEFINE(SLAPD_PASSWD,1)
1334         BUILD_SLAPD=yes
1335         BUILD_PASSWD=yes
1336 fi
1337
1338 if test "$ol_enable_shell" != no ; then
1339         AC_DEFINE(SLAPD_SHELL,1)
1340         BUILD_SLAPD=yes
1341         BUILD_SHELL=yes
1342 fi
1343
1344 if test "$ol_enable_slurpd" != no -a "$ol_link_threads" != no -a \
1345         $BUILD_SLAPD = yes ; then
1346         BUILD_SLURPD=yes
1347 fi
1348
1349 if test "$ol_link_isode" != no ; then
1350         BUILD_LDAPD=yes
1351 fi
1352
1353 dnl ----------------------------------------------------------------
1354
1355 AC_SUBST(BUILD_LDAPD)
1356 AC_SUBST(BUILD_SLAPD)
1357   AC_SUBST(BUILD_LDBM)
1358   AC_SUBST(BUILD_PASSWD)
1359   AC_SUBST(BUILD_SHELL)
1360 AC_SUBST(BUILD_SLURPD)
1361
1362 AC_SUBST(LDAP_LIBS)
1363 AC_SUBST(LDAPD_LIBS)
1364 AC_SUBST(SLAPD_LIBS)
1365 AC_SUBST(SLURPD_LIBS)
1366 AC_SUBST(LDBM_LIBS)
1367 AC_SUBST(LTHREAD_LIBS)
1368 AC_SUBST(LUTIL_LIBS)
1369
1370 AC_SUBST(KRB_LIBS)
1371 AC_SUBST(TERMCAP_LIBS)
1372
1373 dnl ----------------------------------------------------------------
1374 dnl final output
1375 dnl
1376
1377 AC_OUTPUT( \
1378 Makefile:build/top.mk:Makefile.in:build/dir.mk \
1379 doc/Makefile:build/top.mk:doc/Makefile.in:build/dir.mk \
1380 doc/man/Makefile:build/top.mk:doc/man/Makefile.in:build/dir.mk \
1381 doc/man/man1/Makefile:build/top.mk:doc/man/man1/Makefile.in:build/man.mk \
1382 doc/man/man3/Makefile:build/top.mk:doc/man/man3/Makefile.in:build/man.mk \
1383 doc/man/man5/Makefile:build/top.mk:doc/man/man5/Makefile.in:build/man.mk \
1384 doc/man/man8/Makefile:build/top.mk:doc/man/man8/Makefile.in:build/man.mk \
1385 clients/Makefile:build/top.mk:clients/Makefile.in:build/dir.mk \
1386 clients/finger/Makefile:build/top.mk:clients/finger/Makefile.in:build/rules.mk \
1387 clients/fax500/Makefile:build/top.mk:clients/fax500/Makefile.in:build/rules.mk \
1388 clients/gopher/Makefile:build/top.mk:clients/gopher/Makefile.in:build/rules.mk \
1389 clients/mail500/Makefile:build/top.mk:clients/mail500/Makefile.in:build/rules.mk \
1390 clients/rcpt500/Makefile:build/top.mk:clients/rcpt500/Makefile.in:build/rules.mk \
1391 clients/ud/Makefile:build/top.mk:clients/ud/Makefile.in:build/rules.mk \
1392 clients/tools/Makefile:build/top.mk:clients/tools/Makefile.in:build/rules.mk \
1393 include/Makefile:build/top.mk:include/Makefile.in \
1394 libraries/Makefile:build/top.mk:libraries/Makefile.in:build/dir.mk      \
1395 libraries/libavl/Makefile:build/top.mk:libraries/libavl/Makefile.in:build/lib.mk:build/lib-static.mk    \
1396 libraries/liblber/Makefile:build/top.mk:libraries/liblber/Makefile.in:build/lib.mk:build/lib-shared.mk  \
1397 libraries/libldap/Makefile:build/top.mk:libraries/libldap/Makefile.in:build/lib.mk:build/lib-shared.mk  \
1398 libraries/libldbm/Makefile:build/top.mk:libraries/libldbm/Makefile.in:build/lib.mk:build/lib-static.mk  \
1399 libraries/libldif/Makefile:build/top.mk:libraries/libldif/Makefile.in:build/lib.mk:build/lib-static.mk  \
1400 libraries/liblthread/Makefile:build/top.mk:libraries/liblthread/Makefile.in:build/lib.mk:build/lib-static.mk    \
1401 libraries/liblutil/Makefile:build/top.mk:libraries/liblutil/Makefile.in:build/lib.mk:build/lib-static.mk        \
1402 servers/Makefile:build/top.mk:servers/Makefile.in:build/dir.mk \
1403 servers/ldapd/Makefile:build/top.mk:servers/ldapd/Makefile.in:build/srv.mk \
1404 servers/slapd/Makefile:build/top.mk:servers/slapd/Makefile.in:build/srv.mk \
1405 servers/slapd/back-ldbm/Makefile:build/top.mk:servers/slapd/back-ldbm/Makefile.in:build/srv.mk \
1406 servers/slapd/back-passwd/Makefile:build/top.mk:servers/slapd/back-passwd/Makefile.in:build/srv.mk \
1407 servers/slapd/back-shell/Makefile:build/top.mk:servers/slapd/back-shell/Makefile.in:build/srv.mk \
1408 servers/slapd/shell-backends/Makefile:build/top.mk:servers/slapd/shell-backends/Makefile.in:build/srv.mk \
1409 servers/slapd/tools/Makefile:build/top.mk:servers/slapd/tools/Makefile.in \
1410 servers/slurpd/Makefile:build/top.mk:servers/slurpd/Makefile.in:build/srv.mk \
1411 tests/Makefile:build/top.mk:tests/Makefile.in \
1412 ,[
1413 date > stamp-h
1414 echo Please \"make depend\" to build dependencies
1415 ])