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