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