]> git.sur5r.net Git - openldap/blob - configure.in
d1e012e9c36a50b17e7c5a3804ab512a6416ab30
[openldap] / configure.in
1 dnl Copyright 1998 The OpenLDAP Foundation.  All Rights Reserved.
2 dnl 
3 dnl Redistribution and use in source and binary forms are permitted only
4 dnl as authorized by the OpenLDAP Public License.  A copy of this
5 dnl license is available at http://www.OpenLDAP.org/license.html or
6 dnl in file LICENSE in the top-level directory of the distribution.
7 dnl ----
8 dnl Configure.in for OpenLDAP
9 dnl
10 AC_INIT(include/ldap.h)
11 dnl
12 dnl
13 AC_PREREQ(2.10)dnl Required Autoconf version
14 dnl Do not use AutoConf 2.12; it produces a configuration script
15 dnl that causes an "internal 2K buffer" error on HPUX when run
16 dnl with /bin/sh.  Autoconf 2.10 seems to be okay.
17 AC_CONFIG_AUX_DIR(build)
18 AC_CONFIG_HEADER(include/portable.h)dnl
19 dnl
20 dnl Start Args
21 AC_MSG_CHECKING(configure arguments)
22 AC_PREFIX_DEFAULT(/usr/local)
23
24 dnl General "enable" options
25 OL_ARG_ENABLE(debug,[  --enable-debug   enable debugging], yes)dnl
26 dnl OL_ARG_ENABLE(syslog,[  --enable-syslog     enable syslog support], auto)dnl
27 OL_ARG_ENABLE(libui,[  --enable-libui   enable library user interface], yes)dnl
28 OL_ARG_ENABLE(cache,[  --enable-cache   enable caching], yes)dnl
29 OL_ARG_ENABLE(dns,[  --enable-dns       enable dns support], no)dnl
30 OL_ARG_ENABLE(referrals,[  --enable-referrals   enable referrals], yes)dnl
31 OL_ARG_ENABLE(cldap,[  --enable-cldap   enable connectionless ldap], no)dnl
32
33 dnl General "with" options
34 OL_ARG_WITH(kerberos,[  --with-kerberos use Kerberos],
35         auto, [auto k5 k4 afs yes no])
36 OL_ARG_WITH(threads,[  --with-threads   use threads],
37         auto, [auto posix mach lwp yes no manual] )
38 OL_ARG_WITH(preemptive,[  --with-preemptive     thread implementation is preemptive],
39         auto, [auto yes no manual] )
40
41 dnl Server options
42
43 dnl LDAPD OPTIONS
44 OL_ARG_ENABLE(ldapd,[  --enable-ldapd   enable building ldapd], no)dnl
45
46 dnl SLAPD OPTIONS
47 OL_ARG_ENABLE(slapd,[  --enable-slapd   enable building slapd], yes)dnl
48 OL_ARG_ENABLE(aclgroup,[    --enable-aclgroup   enable ACL group support], auto)dnl
49 OL_ARG_ENABLE(crypt,[    --enable-crypt enable crypt(3) passwords], auto)dnl
50 OL_ARG_ENABLE(md5,[    --enable-md5     enable MD5 passwords], auto)dnl
51 OL_ARG_ENABLE(sha1,[    --enable-sha1   enable SHA1 passwords], auto)dnl
52 OL_ARG_ENABLE(wrappers,[    --enable-wrappers   enable tcp wrapper support], no)dnl
53 OL_ARG_ENABLE(phonetic,[    --enable-phonetic   enable phonetic/soundex], no)dnl
54 OL_ARG_ENABLE(rlookups,[    --enable-rlookups   enable reverse lookups], auto)dnl
55
56 dnl SLAPD Backend options
57 OL_ARG_ENABLE(ldbm,[    --enable-ldbm   enable ldbm backend], yes)dnl
58 OL_ARG_WITH(ldbm_api,[      --with-ldbm-api     use LDBM API], auto,
59         [auto db2 db gdbm ndbm manual])
60 OL_ARG_WITH(ldbm_type,[      --with-ldbm-type   use LDBM type], auto,
61         [auto btree hash])
62
63 OL_ARG_ENABLE(passwd,[    --enable-passwd       enable passwd backend], no)dnl
64 OL_ARG_ENABLE(shell,[    --enable-shell enable shell backend], no)dnl
65
66 dnl SLURPD OPTIONS
67 OL_ARG_ENABLE(slurpd,[  --enable-slurpd enable building slurpd], auto)dnl
68
69 if test $ol_enable_slapd = no ; then
70         dnl SLAPD was specificallly disabled
71         if test $ol_enable_ldbm = yes ; then
72                 AC_MSG_WARN([slapd disabled, ignoring --enable_ldbm argument]);
73         fi
74         if test $ol_enable_passwd = yes ; then
75                 AC_MSG_WARN([slapd disabled, ignoring --enable_passwd argument]);
76         fi
77         if test $ol_enable_shell = yes ; then
78                 AC_MSG_WARN([slapd disabled, ignoring --enable_shell argument]);
79         fi
80         if test $ol_enable_aclgroup = yes ; then
81                 AC_MSG_WARN([slapd disabled, ignoring --enable_aclgroup argument]);
82         fi
83         if test $ol_enable_crypt = yes ; then
84                 AC_MSG_WARN([slapd disabled, ignoring --enable_crypt argument]);
85         fi
86         if test $ol_enable_md5 = yes ; then
87                 AC_MSG_WARN([slapd disabled, ignoring --enable_md5 argument]);
88         fi
89         if test $ol_enable_sha1 = yes ; then
90                 AC_MSG_WARN([slapd disabled, ignoring --enable_sha1 argument]);
91         fi
92         if test $ol_enable_wrappers = yes ; then
93                 AC_MSG_WARN([slapd disabled, ignoring --enable_wrappers argument]);
94         fi
95         if test $ol_enable_phonetic = yes ; then
96                 AC_MSG_WARN([slapd disabled, ignoring --enable_phonetic argument]);
97         fi
98         if test $ol_enable_rlookups = yes ; then
99                 AC_MSG_WARN([slapd disabled, ignoring --enable_rlookups argument]);
100         fi
101         if test $ol_with_ldbm_api != auto ; then
102                 AC_MSG_WARN([slapd disabled, ignoring --with_ldbm_api argument]);
103         fi
104         if test $ol_with_ldbm_type != auto ; then
105                 AC_MSG_WARN([slapd disabled, ignoring --with_ldbm_type argument]);
106         fi
107         if test $ol_enable_slurpd = yes ; then
108                 AC_MSG_ERROR([slurpd requires slapd]);
109         fi
110
111         # force settings to no
112         ol_enable_ldbm=no
113         ol_enable_shell=no
114         ol_enable_passwd=no
115         ol_enable_aclgroup=no
116         ol_enable_crypt=no
117         ol_enable_md5=no
118         ol_enable_sha1=no
119         ol_enable_wrappers=no
120         ol_enable_phonetic=no
121         ol_enable_rlookups=no
122         ol_with_ldbm_api=no
123         ol_with_ldbm_type=no
124         ol_enable_slurpd=no
125
126 elif test $ol_enable_ldbm = no ; then
127         dnl SLAPD without LDBM
128
129         if test $ol_with_ldbm_api != auto ; then
130                 AC_MSG_WARN([LDBM disabled, ignoring --with_ldbm_api argument]);
131         fi
132
133         if test $ol_with_ldbm_type != auto ; then
134                 AC_MSG_WARN([LDBM disabled, ignoring --with_ldbm_type argument]);
135         fi
136
137         if test $ol_enable_passwd = no -a $ol_enable_shell = no ; then
138                 AC_MSG_ERROR([slapd requires a backend]);
139         fi
140
141         ol_with_ldbm_api=no
142         ol_with_ldbm_type=no
143
144 else
145         dnl SLAPD with LDBM
146
147         if test $ol_with_ldbm_api = gdbm -a \
148                 $ol_with_ldbm_type = btree ; then
149                 AC_MSG_ERROR([GDBM only supports LDBM type hash]);
150         fi
151         if test $ol_with_ldbm_api = ndbm -a \
152                 $ol_with_ldbm_type = btree ; then
153                 AC_MSG_ERROR([NDBM only supports LDBM type hash]);
154         fi
155 fi
156
157 if test $ol_enable_slurpd = yes ; then
158         dnl SLURPD was specifically enabled
159         if test $ol_with_threads = no ; then
160                 AC_MSG_ERROR([slurpd requires threads]);
161         fi
162 fi
163
164 AC_MSG_RESULT(done)
165
166 ## Initialize vars
167 LDAP_DEFS=
168 LDAP_LIBS=
169 LDBM_DEFS=
170 LDBM_LIBS=
171 LTHREAD_DEFS=
172 LTHREAD_LIBS=
173 LUTIL_DEFS=
174 LUTIL_LIBS=
175
176 LDAPD_DEFS=
177 LDAPD_LIBS=
178 SLAPD_DEFS=
179 SLAPD_LIBS=
180 SLURPD_DEFS=
181 SLURPD_LIBS=
182
183 BUILD_LDAPD=no
184 BUILD_SLAPD=no
185 BUILD_SLURPD=no
186
187 BUILD_LDBM=no
188 BUILD_PASSWD=no
189 BUILD_SHELL=no
190
191 KRB_DEFS=
192 KRB_LIBS=
193 TERMCAP_DEFS=
194 TERMCAP_LIBS=
195
196 dnl ----------------------------------------------------------------
197 dnl Checks for programs
198
199 AC_PROG_LN_S
200 AC_PROG_INSTALL
201 AC_PROG_RANLIB
202 AC_PROG_MAKE_SET
203
204 AC_PATH_PROG(SENDMAIL, sendmail, /usr/lib/sendmail,
205         $PATH:/usr/libexec:/usr/lib:/usr/sbin:/usr/etc:/etc)
206 AC_PATH_PROG(EDITOR, vi, /usr/ucb/vi, $PATH:/usr/ucb)
207 AC_PATH_PROG(FINGER, finger, /usr/ucb/finger, $PATH:/usr/ucb)
208
209 dnl Checks the compiler and UNIX Variants
210 AC_PROG_CC
211 AC_PROG_GCC_TRADITIONAL
212
213 AC_AIX
214 AC_ISC_POSIX
215 AC_MINIX
216
217 dnl ----------------------------------------------------------------
218 dnl Checks for libraries
219
220 dnl Find socket()
221 dnl Likely combinations:
222 dnl             -lsocket [ -lnsl_s | -lnsl ]
223 dnl             -linet
224
225 AC_CHECK_FUNC(socket, :, [      
226 dnl
227 dnl hopefully we won't include too many libraries
228 dnl
229         AC_CHECK_LIB(socket, main)
230         AC_CHECK_LIB(net, main)
231         AC_CHECK_LIB(nsl_s, main)
232         AC_CHECK_LIB(nsl, main)
233         AC_CHECK_LIB(inet, socket)
234         AC_CHECK_LIB(gen, main)
235 ])
236
237 dnl HP-UX requires -lV3
238 AC_CHECK_LIB(V3, sigset)
239
240 if test $ol_with_kerberos = auto -o $ol_with_kerberos = k5 ; then
241         AC_CHECK_HEADERS(kerberosIV/krb.h kerberosIV/des.h)
242
243         if test $ac_cv_header_kerberosIV_krb_h = yes ; then
244                 AC_CHECK_LIB(krb4, main, [have_k5=yes], [have_k5=no],
245                         [-lkrb5 -ldes425])
246
247                 if test $have_k5 = yes ; then
248                         ol_with_kerberos=found
249                         ol_link_kerberos=yes
250
251                         AC_DEFINE(HAVE_KERBEROS)
252
253                         KRB_DEFS="-DKERBEROS"
254                         KRB_LIBS="-lkrb4 -lkrb5 -ldes425"
255                 fi
256         fi
257 fi
258 if test $ol_with_kerberos = auto -o $ol_with_kerberos = k4 ; then
259         AC_CHECK_HEADERS(krb.h des.h)
260
261         if test $ac_cv_header_krb_h = yes ; then
262                 AC_CHECK_LIB(krb, main, [have_k4=yes], [have_k4=no], [-ldes])
263
264                 if test $have_k4 = yes ; then
265                         ol_with_kerberos=found
266                         ol_link_kerberos=yes
267
268                         AC_DEFINE(HAVE_KERBEROS)
269
270                         KRB_DEFS="-DKERBEROS"
271                         KRB_LIBS="-lkrb -ldes"
272                 fi
273         fi
274 fi
275
276
277 ol_link_threads=no
278 if test $ol_with_threads = auto -o $ol_with_threads = posix ; then
279         AC_CHECK_HEADERS(pthread.h sched.h)
280
281         if test $ac_cv_header_pthread_h = yes ; then
282                 OL_POSIX_THREAD_VERSION
283
284                 if test $ol_cv_pthread_version = final ; then
285                         LTHREAD_DEFS="$LTHREAD_DEFS -DPOSIX_THREADS"
286                 elif test $ol_cv_pthread_version = draft4 ; then
287                         AC_DEFINE(HAVE_PTHREADS_D4)
288                         LTHREAD_DEFS="$LTHREAD_DEFS -DTHREAD_MIT_PTHREADS"
289                 else
290                         AC_MSG_ERROR([unknown pthread version])
291                 fi
292
293                 # consider threads found
294                 ol_with_threads=found
295
296                 OL_LINUX_THREADS
297
298                 if test $ol_cv_linux_threads = yes ; then
299                         AC_DEFINE(HAVE_LINUX_THREADS,1)
300                         LTHREAD_DEFS="$LTHREAD_DEFS -DLINUX_THREADS"
301                 fi
302
303                 dnl Now the hard part, how to link
304
305                 dnl A few platforms have pthread support in standard libraries
306                 AC_CHECK_FUNC(pthread_create,[ol_link_threads=yes])
307
308                 if test $ol_link_threads = no ; then
309                         dnl try -pthread
310                         AC_CACHE_CHECK([for pthread_create with -pthread],
311                                 [ol_cv_pthread_flag], [
312                                 dnl save the CPPFLAGS
313                                 save_LIBS="$LIBS"
314                                 LIBS="-pthread $LIBS"
315                                 AC_TRY_LINK([#include <pthread.h>],[
316                                         pthread_create((pthread_t*) 0,
317                                                 (pthread_attr_t*) 0, 0, 0);
318                                         ], ol_cv_pthread_flag=yes, ol_cv_pthread_flag=no)
319                                 dnl restore the LIBS
320                                 LIBS="$save_LIBS"
321                         ])
322
323                         if test $ol_cv_pthread_flag = yes ; then
324                                 LTHREAD_LIBS="$LTHREAD_LIBS -pthread"
325                                 ol_link_threads=posix
326                         fi
327                 fi
328
329                 if test $ol_link_threads = no ; then
330                         dnl try -lpthread
331                         save_LIBS="$LIBS"
332                         AC_CHECK_LIB(pthread, pthread_create, [
333                                 ol_link_threads=posix
334                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthread"])
335                         LIBS="$save_LIBS"
336                 fi
337
338                 if test $ol_link_threads = no ; then
339                         dnl try -lc_r
340                         save_LIBS="$LIBS"
341                         AC_CHECK_LIB(c_r, pthread_create, [
342                                 ol_link_threads=posix
343                                 LTHREAD_LIBS="$LTHREAD_LIBS -lc_r"])
344                         LIBS="$save_LIBS"
345                 fi
346
347                 if test $ol_link_threads = no ; then
348                         dnl try DEC Threads
349                         save_LIBS="$LIBS"
350                         AC_CHECK_LIB(pthread, pthread_create, [
351                                 AC_DEFINE(HAVE_DCE)
352                                 ol_link_threads=posix
353                                 LTHREAD_DEFS="$LTHREAD_DEFS -DTHREAD_DCE_THREADS"
354                                 LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lmach -lexc -lc"],,
355                                 if test $with_preemptive = auto ; then
356                                         ol_with_preemptive=yes
357                                 fi
358                                 [-lmach -lexc -lc])
359                         LIBS="$save_LIBS"
360                 fi
361
362                 if test $ol_link_threads != no ; then
363                         AC_DEFINE(HAVE_PTHREADS)
364
365                         dnl save DEFS/LIBS
366                         save_CPPFLAGS="$CPPFLAGS"
367                         save_LIBS="$LIBS"
368                         CPPFLAGS="$LTHREAD_DEFS $CPPFLAGS"
369                         LIBS="$LTHREAD_LIBS $LIBS"
370
371                         dnl All POSIX Thread (final) implementations should have
372                         dnl sched_yield instead of pthread yield.
373                         dnl check for both
374                         AC_CHECK_FUNCS(sched_yield pthread_yield)
375
376                         if test $ac_cv_func_sched_yield = no -a \
377                                 $ac_cv_func_pthread_yield = no ; then
378
379                                 AC_MSG_WARN([could not locate sched_yield() or pthread_yield()])
380                                 AC_MSG_ERROR([POSIX Threads are not usable])
381                         fi
382
383                         dnl Check functions for compatibility
384                         AC_CHECK_FUNCS(pthread_kill)
385 dnl                     AC_CHECK_FUNCS(
386 dnl                             pthread_attr_create pthread_attr_init \
387 dnl                             pthread_attr_destroy pthread_attr_delete \
388 dnl                             pthread_attr_setdetachstate pthread_attr_setdetach_np \
389 dnl                     )
390
391                         dnl Check PREEMPTIVE Implementation 
392                         if test $ol_with_preemptive = auto ; then
393                                 AC_MSG_CHECKING([for preemptive Pthread implementation])
394                                 AC_TRY_RUN([
395 #include <sys/types.h>
396 #include <sys/time.h>
397 #include <unistd.h>
398 #include <pthread.h>
399 #ifndef NULL
400 #define NULL 0
401 #endif
402
403 int task(arg)
404         int *arg;
405 {
406         struct timeval tv;
407
408         tv.tv_sec=4;
409         tv.tv_usec=0;
410         select(0, NULL, NULL, NULL, &tv);
411
412         tv.tv_sec=6;
413         tv.tv_usec=0;
414         select(0, NULL, NULL, NULL, &tv);
415
416         exit(1); /* if we exit here, the select blocked the whole process */
417 }
418
419 main(argc, argv)
420 int argc; char **argv;
421 {
422         pthread_t t;
423         pthread_create(&t, NULL, (void *) task, NULL);
424
425 #if HAVE_SCHED_YIELD
426         sched_yield();  /* make sure task runs first */
427 #else
428 #if defined(HAVE_PTHREAD_YIELD)
429         pthread_yield();        /* make sure task runs first */
430 #endif
431 #endif
432         exit(0);
433 }
434                                 ], [ol_pthread_preemptive=yes], [ol_pthread_preemptive=no], [
435                                 AC_MSG_ERROR([crossing compiling: use --with-preemptive=yes|no|manual])])
436                                 AC_MSG_RESULT($ol_pthread_preemptive)
437
438                                 if test $ol_pthread_preemptive = yes ; then
439                                         AC_DEFINE(HAVE_PREEMPTIVE_PTHREADS)
440                                         ol_with_preemptive=yes
441                                 fi
442                         fi
443
444                         dnl restore DEFS/LIBS
445                         CPPFLAGS="$save_CPPFLAGS"
446                         LIBS="$save_LIBS"
447                 else
448                         AC_MSG_ERROR([could not link with POSIX Threads])
449                 fi
450         fi
451
452         if test $ol_with_threads = posix ; then
453                 AC_MSG_ERROR([could not locate POSIX Threads])
454         fi
455 fi
456
457 if test $ol_with_threads = auto -o $ol_with_threads = cthreads ; then
458         dnl check for Mach CThreads
459         AC_CHECK_HEADERS(mach/cthreads.h)
460         if test $ac_cv_header_lwp_lwp_h = yes ; then
461                 AC_CHECK_LIB(lwp, cthread_fork, [have_cthreads=yes], [have_cthreads=no])
462
463                 if test $have_cthreads = yes ; then
464                         AC_DEFINE(HAVE_CTHREADS)
465                         LTHREAD_DEFS="$LTHREAD_DEFS -DTHREAD_NEXT_CTHREADS"
466                         LTHREAD_LIBS="$LTHREAD_LIBS -llwp"
467                 fi
468         fi
469 fi
470
471 if test $ol_with_threads = auto -o $ol_with_threads = lwp ; then
472         dnl check for SunOS5 LWP
473         AC_CHECK_HEADERS(thread.h synch.h)
474         if test $ac_cv_header_lwp_lwp_h = yes ; then
475                 AC_CHECK_LIB(thread, thr_create, [have_lwp=yes], [have_lwp=no])
476
477                 if test $have_lwp = yes ; then
478                         AC_DEFINE(HAVE_LWP)
479                         AC_DEFINE(HAVE_LWP_THR)
480                         LTHREAD_DEFS="$LTHREAD_DEFS -DTHREAD_SUNOS5_LWP"
481                         LTHREAD_LIBS="$LTHREAD_LIBS -llwp"
482                 fi
483         fi
484
485         dnl check for SunOS4 LWP
486         AC_CHECK_HEADERS(lwp/lwp.h)
487         if test $ac_cv_header_thread_h = yes -a $ac_cv_header_synch_h = yes ; then
488                 AC_CHECK_LIB(lwp, lwp_create, [have_lwp=yes], [have_lwp=no])
489
490                 if test $have_lwp = yes ; then
491                         AC_DEFINE(HAVE_LWP)
492                         LTHREAD_DEFS="$LTHREAD_DEFS -DTHREAD_SUNOS4_LWP"
493                         LTHREAD_LIBS="$LTHREAD_LIBS -llwp"
494
495                         if test $with_preemptive = auto ; then
496                                 with_preemptive=yes
497                         fi
498                 fi
499         fi
500 fi
501
502 if test $ol_with_preemptive = yes ; then
503         LTHREAD_DEFS="$LTHREAD_DEFS -DTHREAD_PREEMPTIVE"
504 fi
505
506 if test $ol_with_threads = manual ; then
507         dnl User thinks he can manually configure threads.
508         $ol_link_threads=yes
509
510         AC_MSG_WARN([thread defines and link options must be set manually])
511
512         AC_CHECK_HEADERS(pthread.h sched.h)
513         AC_CHECK_FUNCS(sched_yield pthread_yield)
514         OL_LINUX_THREADS
515
516         AC_CHECK_HEADERS(mach/cthreads.h)
517         AC_CHECK_HEADERS(lwp/lwp.h)
518         AC_CHECK_HEADERS(thread.h synch.h)
519 fi
520
521 if test $ol_link_threads = no ; then
522         if test $ol_with_threads = yes ; then
523                 AC_MSG_ERROR([no suitable thread support])
524         fi
525
526         if test $ol_with_threads = auto ; then
527                 AC_MSG_WARN([no suitable thread support, disabling threads])
528                 $ol_with_threads = no
529         fi
530
531         LTHREAD_DEFS="-DNO_THREADS"
532         LTHREAD_LIBS=""
533 fi
534
535 ol_link_ldbm=no 
536 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db2 ; then
537         OL_BERKELEY_DB2
538
539         if test $ol_cv_berkeley_db2 = yes ; then
540                 ol_link_ldbm=db2
541                 ol_with_ldbm_api=db2
542
543                 LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_DB2"
544
545                 if test $ol_with_ldbm_type = hash ; then
546                         LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_DBHASH"
547                 else
548                         LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_DBBTREE"
549                 fi
550
551                 dnl $ol_cv_lib_db2 should be yes or -ldb
552                 dnl (it could be no, but that would be an error
553                 if test $ol_cv_lib_db2 != yes ; then
554                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_db2"
555                 fi
556         fi
557 fi
558
559 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db ; then
560         OL_BERKELEY_DB
561
562         if test $ol_cv_berkeley_db = yes ; then
563                 ol_link_ldbm=db
564                 ol_with_ldbm_api=db
565
566                 if test $ac_cv_header_db_185_h = yes ; then
567                         LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_DB2_COMPAT185"
568                 fi
569
570                 if test $ol_with_ldbm_type = hash ; then
571                         LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_DBHASH"
572                 else
573                         LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_DBBTREE"
574                 fi
575
576                 dnl $ol_cv_lib_db should be yes or -ldb
577                 dnl (it could be no, but that would be an error
578                 if test $ol_cv_lib_db != yes ; then
579                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_db"
580                 fi
581         fi
582 fi
583
584 if test $ol_with_ldbm_api = manual ; then
585         dnl User thinks he can manually configure LDBM api.
586         $ol_link_ldbm=yes
587
588         AC_MSG_WARN([LDBM defines and link options must be set manually])
589
590         AC_CHECK_HEADERS(db.h db_185.h gdbm.h ndbm.h)
591 fi
592
593 if test $ol_link_ldbm = no -a $ol_with_ldbm_type = btree ; then
594         AC_MSG_WARN(Could not find LDBM with BTREE support);
595         $ol_with_ldbm_api=none
596 fi
597
598 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = gdbm ; then
599         OL_GDBM
600
601         if test $ol_cv_gdbm = yes ; then
602                 ol_link_ldbm=gdbm
603                 ol_with_ldbm_api=gdbm
604
605                 LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_GDBM"
606
607                 if test $ol_cv_lib_gdbm != yes ; then
608                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_gdbm"
609                 fi
610         fi
611 fi
612
613 if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = ndbm ; then
614         OL_NDBM
615
616         if test $ol_cv_ndbm = yes ; then
617                 ol_link_ldbm=ndbm
618                 ol_with_ldbm_api=ndbm
619
620                 if test $ol_with_ldbm_api = ndbm ; then
621                         AC_WARN([Attempting to use NDBM.  Functionality will be limited.])
622                 fi
623
624                 LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_NDBM"
625
626                 if test $ol_cv_lib_ndbm != yes ; then
627                         LDBM_LIBS="$LDBM_LIBS $ol_cv_lib_ndbm"
628                 fi
629         fi
630 fi
631
632 if test $ol_link_ldbm = no -a $ol_enable_ldbm != no ; then
633         AC_MSG_WARN(could not find suitable LDBM backend)
634         if test $ol_enable_ldbm = yes ; then
635                 AC_MSG_ERROR(select appropriate LDBM options or disable)
636         fi
637
638         AC_MSG_WARN(disabling LDBM)
639         $ol_enable_ldbm=no
640 fi
641
642 if test $ol_enable_wrappers = yes ; then
643         AC_CHECK_LIB(wrap, hosts_access,
644                 [have_wrappers=yes], [have_wrappers=no])
645
646         if test $have_wrappers = yes ; then
647 dnl             AC_DEFINE(HAVE_TCPD)
648                 SLAPD_DEFS="$SLAPD_DEFS -DTCP_WRAPPERS"
649                 SLAPD_LIBS="$SLAPD_LIBS -lwrap"
650         else
651                 AC_MSG_WARN(could not find -lwrap)
652                 if test $ol_enable_wrappers = yes ; then
653                         AC_MSG_ERROR(could not find wrappers, select appropriate options or disable)
654                 fi
655
656                 AC_MSG_WARN(disabling wrappers support)
657                 ol_enable_wrappers=no
658         fi
659
660 fi
661
662 # ud needs termcap (should insert check here)
663 ol_link_termcap=no
664
665 AC_CHECK_HEADERS(termcap.h ncurses.h)
666
667 if test $ol_link_termcap = no ; then
668         AC_CHECK_LIB(termcap, tputs, [have_termcap=yes], [have_termcap=no])
669         if test $have_termcap = yes ; then
670 dnl             AC_DEFINE(HAVE_TERMCAP)
671                 ol_link_termcap=yes
672                 TERMCAP_LIBS=-ltermcap
673         fi
674 fi
675
676 if test $ol_link_termcap = no ; then
677         AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
678         if test $have_ncurses = yes ; then
679 dnl             AC_DEFINE(HAVE_NCURSES)
680                 ol_link_termcap=yes
681                 TERMCAP_LIBS=-lncurses
682         fi
683 fi
684
685 if test $ol_link_termcap = no ; then
686         TERMCAP_DEFS="-DNOTERMCAP"
687         TERMCAP_LIBS=
688 fi
689
690 # FreeBSD (and others) have crypt(3) in -lcrypt
691 if test $ol_enable_crypt != no ; then
692         AC_CHECK_FUNC(crypt, [have_crypt=yes], [
693                 AC_CHECK_LIB(crypt, crypt, [LUTIL_LIBS="$LUTIL_LIBS -lcrypt"
694                         have_crypt=yes], [have_crypt=no])])
695
696         if test $have_crypt = yes ; then
697 dnl             AC_DEFINE(HAVE_CRYPT)
698                 LUTIL_DEFS="$LUTIL_DEFS -DLDAP_CRYPT"
699         else
700                 AC_MSG_WARN(could not find crypt)
701                 if test $ol_enable_crypt = yes ; then
702                         AC_MSG_ERROR(could not find crypt, select appropriate options or disable)
703                 fi
704
705                 AC_MSG_WARN(disabling crypt support)
706                 ol_enable_crypt=no
707         fi
708 fi
709
710 dnl ----------------------------------------------------------------
711 dnl Checks for header files.
712 AC_HEADER_STDC
713 AC_HEADER_DIRENT
714 AC_HEADER_SYS_WAIT
715 AC_CHECK_HEADERS( \
716         stddef.h        \
717         fcntl.h         \
718         filio.h         \
719         limits.h        \
720         malloc.h        \
721         sgtty.h         \
722         sys/file.h      \
723         sys/ioctl.h     \
724         sys/time.h      \
725         syslog.h        \
726         termio.h        \
727         unistd.h        \
728 )
729
730 dnl ----------------------------------------------------------------
731 dnl Checks for typedefs, structures, and compiler characteristics.
732 AC_TYPE_GETGROUPS
733 AC_TYPE_MODE_T
734 AC_TYPE_OFF_T
735 AC_TYPE_PID_T
736 AC_TYPE_SIGNAL
737 AC_TYPE_SIZE_T
738 AC_TYPE_UID_T
739 AC_STRUCT_ST_BLKSIZE
740 AC_HEADER_TIME
741 AC_STRUCT_TM
742
743 dnl AC_C_BIGENDIAN
744 AC_C_CONST
745
746 dnl AC_CHECK_SIZEOF(short) 
747 dnl AC_CHECK_SIZEOF(int) 
748 dnl AC_CHECK_SIZEOF(long)
749
750 dnl ----------------------------------------------------------------
751 dnl Checks for library functions.
752 AC_FUNC_MEMCMP
753 AC_FUNC_STRFTIME
754 AC_FUNC_VPRINTF
755 AC_FUNC_WAIT3
756
757 AC_CHECK_FUNCS(         \
758         bcopy                   \
759         flock                   \
760         gethostname             \
761         gettimeofday    \
762         getdtablesize   \
763         lockf                   \
764         memcpy                  \
765         memmove                 \
766         mktime                  \
767         select                  \
768         setpwfile               \
769         setsid                  \
770         signal                  \
771         sigset                  \
772         socket                  \
773         strerror                \
774         strstr                  \
775         strrchr                 \
776         strsep                  \
777         strtod                  \
778         strtol                  \
779         strtoul                 \
780         sysconf                 \
781 )
782
783 AC_REPLACE_FUNCS(strdup)
784
785 dnl ----------------------------------------------------------------
786 # Check Configuration
787 OL_SYS_ERRLIST
788
789 dnl ----------------------------------------------------------------
790 dnl Sort out defines
791
792 if test $ol_enable_debug != no ; then
793         LDAP_DEFS="$LDAP_DEFS -DLDAP_DEBUG"
794 fi
795 dnl     if test $ol_enable_syslog != no ; then
796 dnl             LDAP_DEFS="$LDAP_DEFS -DLDAP_SYSLOG"
797 dnl     fi
798 if test $ol_enable_libui = yes ; then
799         LDAP_DEFS="$LDAP_DEFS -DLDAP_LIBUI"
800 fi
801 if test $ol_enable_cache = no ; then
802         LDAP_DEFS="$LDAP_DEFS -DNO_CACHE"
803 fi
804 if test $ol_enable_dns != no ; then
805         LDAP_DEFS="$LDAP_DEFS -DLDAP_DNS"
806 fi
807 if test $ol_enable_referrals != no ; then
808         LDAP_DEFS="$LDAP_DEFS -DLDAP_REFERRALS"
809 fi
810 if test $ol_enable_cldap != no ; then
811         LDAP_DEFS="$LDAP_DEFS -DCLDAP"
812 fi
813
814 if test $ol_enable_aclgroup != no ; then
815         AC_DEFINE(SLAPD_ACLGROUP,1)
816         SLAPD_DEFS="$SLAPD_DEFS -DACLGROUP"
817 fi
818
819 if test $ol_enable_md5 != no ; then
820 dnl     AC_DEFINE(SLAPD_MD5,1)
821         LUTIL_DEFS="$LUTIL_DEFS -DLDAP_MD5"
822 fi
823
824 if test $ol_enable_sha1 != no ; then
825 dnl     AC_DEFINE(SLAPD_SHA1,1)
826         LUTIL_DEFS="$LUTIL_DEFS -DLDAP_SHA1"
827 fi
828
829 if test $ol_enable_phonetic != no ; then
830         AC_DEFINE(SLAPD_PHONETIC,1)
831         SLAPD_DEFS="$SLAPD_DEFS -DSOUNDEX"
832 fi
833
834 if test $ol_enable_rlookups != no ; then
835         AC_DEFINE(SLAPD_RLOOKUPS,1)
836         SLAPD_DEFS="$SLAPD_DEFS -DREVERSE_LOOKUPS"
837 fi
838
839 if test $ol_link_ldbm != no ; then
840 dnl     AC_DEFINE(SLAPD_LDBM,1)
841         BUILD_SLAPD=yes
842         BUILD_LDBM=yes
843         LDBM_DEFS="-DLDAP_LDBM $LDBM_DEFS"
844 fi
845
846 if test $ol_enable_passwd != no ; then
847 dnl     AC_DEFINE(SLAPD_PASSWD,1)
848         BUILD_SLAPD=yes
849         BUILD_PASSWD=yes
850         SLAPD_DEFS="-DLDAP_PASSWD $SLAPD_DEFS"
851 fi
852
853 if test $ol_enable_shell != no ; then
854 dnl     AC_DEFINE(SLAPD_SHELL,1)
855         BUILD_SLAPD=yes
856         BUILD_SHELL=yes
857         SLAPD_DEFS="-DLDAP_SHELL $SLAPD_DEFS"
858 fi
859
860 if test $ol_enable_slurpd != no -a $ol_link_threads != no -a \
861         $BUILD_SLAPD = yes ; then
862         BUILD_SLURPD=yes
863 fi
864
865 dnl ----------------------------------------------------------------
866
867 AC_SUBST(BUILD_LDAPD)
868 AC_SUBST(BUILD_SLAPD)
869   AC_SUBST(BUILD_LDBM)
870   AC_SUBST(BUILD_PASSWD)
871   AC_SUBST(BUILD_SHELL)
872 AC_SUBST(BUILD_SLURPD)
873
874
875 AC_SUBST(LDAP_DEFS)
876 AC_SUBST(LDAP_LIBS)
877 AC_SUBST(LDAPD_DEFS)
878 AC_SUBST(LDAPD_LIBS)
879 AC_SUBST(SLAPD_DEFS)
880 AC_SUBST(SLAPD_LIBS)
881 AC_SUBST(SLURPD_DEFS)
882 AC_SUBST(SLURPD_LIBS)
883 AC_SUBST(LDBM_DEFS)
884 AC_SUBST(LDBM_LIBS)
885 AC_SUBST(LTHREAD_DEFS)
886 AC_SUBST(LTHREAD_LIBS)
887 AC_SUBST(LUTIL_DEFS)
888 AC_SUBST(LUTIL_LIBS)
889
890 AC_SUBST(KRB_DEFS)
891 AC_SUBST(KRB_LIBS)
892 AC_SUBST(TERMCAP_DEFS)
893 AC_SUBST(TERMCAP_LIBS)
894
895 dnl ----------------------------------------------------------------
896 dnl final output
897 dnl
898
899 dnl AC_OUTPUT( \
900 dnl contrib/Makefile:build/top.mk:contrib/Makefile.in:build/dir.mk \
901 dnl contrib/saucer/Makefile:build/top.mk:contrib/saucer/Makefile.in:build/rules.mk \
902 dnl contrib/whois++/Makefile:build/top.mk:contrib/whois++/Makefile.in:build/rules.mk \
903 dnl [date > stamp-h])
904
905 AC_OUTPUT( \
906 Makefile:build/top.mk:Makefile.in:build/dir.mk \
907 doc/Makefile:build/top.mk:doc/Makefile.in:build/dir.mk \
908 doc/man/Makefile:build/top.mk:doc/man/Makefile.in:build/dir.mk \
909 doc/man/man1/Makefile:build/top.mk:doc/man/man1/Makefile.in:build/man.mk \
910 doc/man/man3/Makefile:build/top.mk:doc/man/man3/Makefile.in:build/man.mk \
911 doc/man/man5/Makefile:build/top.mk:doc/man/man5/Makefile.in:build/man.mk \
912 doc/man/man8/Makefile:build/top.mk:doc/man/man8/Makefile.in:build/man.mk \
913 clients/Makefile:build/top.mk:clients/Makefile.in:build/dir.mk \
914 clients/finger/Makefile:build/top.mk:clients/finger/Makefile.in:build/rules.mk \
915 clients/fax500/Makefile:build/top.mk:clients/fax500/Makefile.in:build/rules.mk \
916 clients/gopher/Makefile:build/top.mk:clients/gopher/Makefile.in:build/rules.mk \
917 clients/mail500/Makefile:build/top.mk:clients/mail500/Makefile.in:build/rules.mk \
918 clients/rcpt500/Makefile:build/top.mk:clients/rcpt500/Makefile.in:build/rules.mk \
919 clients/ud/Makefile:build/top.mk:clients/ud/Makefile.in:build/rules.mk \
920 clients/tools/Makefile:build/top.mk:clients/tools/Makefile.in:build/rules.mk \
921 include/Makefile:build/top.mk:include/Makefile.in \
922 libraries/Makefile:build/top.mk:libraries/Makefile.in:build/dir.mk      \
923 libraries/libavl/Makefile:build/top.mk:libraries/libavl/Makefile.in:build/lib.mk \
924 libraries/liblber/Makefile:build/top.mk:libraries/liblber/Makefile.in:build/lib.mk \
925 libraries/libldap/Makefile:build/top.mk:libraries/libldap/Makefile.in:build/lib.mk \
926 libraries/libldbm/Makefile:build/top.mk:libraries/libldbm/Makefile.in:build/lib.mk \
927 libraries/libldif/Makefile:build/top.mk:libraries/libldif/Makefile.in:build/lib.mk \
928 libraries/liblthread/Makefile:build/top.mk:libraries/liblthread/Makefile.in:build/lib.mk \
929 libraries/liblutil/Makefile:build/top.mk:libraries/liblutil/Makefile.in:build/lib.mk \
930 servers/Makefile:build/top.mk:servers/Makefile.in:build/dir.mk \
931 servers/ldapd/Makefile:build/top.mk:servers/ldapd/Makefile.in:build/srv.mk \
932 servers/slapd/Makefile:build/top.mk:servers/slapd/Makefile.in:build/srv.mk \
933 servers/slapd/back-ldbm/Makefile:build/top.mk:servers/slapd/back-ldbm/Makefile.in:build/srv.mk \
934 servers/slapd/back-passwd/Makefile:build/top.mk:servers/slapd/back-passwd/Makefile.in:build/srv.mk \
935 servers/slapd/back-shell/Makefile:build/top.mk:servers/slapd/back-shell/Makefile.in:build/srv.mk \
936 servers/slapd/shell-backends/Makefile:build/top.mk:servers/slapd/shell-backends/Makefile.in:build/srv.mk \
937 servers/slapd/tools/Makefile:build/top.mk:servers/slapd/tools/Makefile.in \
938 servers/slurpd/Makefile:build/top.mk:servers/slurpd/Makefile.in:build/srv.mk \
939 tests/Makefile:build/top.mk:tests/Makefile.in \
940 ,[date > stamp-h])