1 dnl Copyright 1998 The OpenLDAP Foundation. All Rights Reserved.
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.
8 dnl Configure.in for OpenLDAP
10 AC_INIT(include/ldap.h)
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
21 AC_MSG_CHECKING(arguments)
22 AC_PREFIX_DEFAULT(/usr/local)
24 dnl General "enable" options
25 CF_ARG_OPTION(debug,[ --enable-debug enable debugging (yes)],[
26 LDAP_DEBUG=no],[LDAP_DEBUG=yes],yes)dnl
27 CF_ARG_OPTION(syslog,[ --enable-syslog enable syslog support (no)],[
28 LDAP_CLDAP=yes],[LDAP_CLDAP=no],no)dnl
29 CF_ARG_OPTION(libui,[ --enable-libui enable library user interface (yes)],[
30 LDAP_LIBUI=no],[LDAP_LIBUI=yes],yes)dnl
31 CF_ARG_OPTION(cache,[ --enable-cache enable caching (yes)],[
32 LDAP_CACHE=no],[LDAP_CACHE=yes],yes)dnl
33 CF_ARG_OPTION(dns,[ --enable-dns enable dns support (no)],[
34 LDAP_DNS=yes],[LDAP_DNS=no],no)dnl
35 CF_ARG_OPTION(referrals,[ --enable-referrals enable referrals (yes)],[
36 LDAP_REFERRALS=no],[LDAP_REFERRALS=yes],yes)dnl
38 CF_ARG_OPTION(cldap,[ --enable-clapd enable connectionless ldap (no)],[
39 LDAP_CLDAP=yes],[LDAP_CLDAP=no],no)dnl
41 dnl General "with" options
42 AC_ARG_WITH(kerberos,[ --with-kerberos use Kerberos (no)],[
43 opt_kerberos=yes],[opt_kerberos=no])
44 AC_ARG_WITH(kerberos-afs,[ --with-kerberos-afs use AFS Kerberos (no)],[
45 opt_kerberos_afs=yes],[opt_kerberos_afs=no])
46 AC_ARG_WITH(threads,[ --with-threads use threads (yes)],[
47 opt_threads=yes],[opt_threads=no])
52 CF_ARG_OPTION(ldapd,[ --enable-ldapd enable building ldapd (no)],[
53 BUILD_LDAPD=yes],[BUILD_LDAPD=no],no)dnl
56 CF_ARG_OPTION(slapd,[ --enable-slapd enable building slapd (yes)],[
57 BUILD_SLAPD=no],[BUILD_SLAPD=yes],yes)dnl
58 CF_ARG_OPTION(aclgroup,[ --enable-aclgroup enable ACL group support (yes)],[
59 SLAPD_ACLGROUP=no],[SLAPD_ALCGROUP=yes],yes)dnl
60 CF_ARG_OPTION(crypt,[ --enable-crypt enable crypt(3) passwords (yes)],[
61 SLAPD_CRYPT=no],[SLAPD_CRYPT=yes],yes)dnl
62 CF_ARG_OPTION(md5,[ --enable-md5 enable MD5 passwords (yes)],[
63 SLAPD_MD5=no],[SLAPD_MD5=yes],yes)dnl
64 CF_ARG_OPTION(sha1,[ --enable-sha1 enable SHA1 passwords (yes)],[
65 SLAPD_SHA1=no],[SLAPD_SHA1=yes],yes)dnl
66 CF_ARG_OPTION(wrappers,[ --enable-wrappers enable tcp wrapper support (no)],[
67 SLAPD_TCP_WRAPPERS=yes],[SLAPD_TCP_WRAPPERS=no],no)dnl
68 CF_ARG_OPTION(phonetic,[ --enable-phonetic enable phonetic/soundex (no)],[
69 SLAPD_PHONETIC=yes],[SLAPD_PHONETIC=no],no)dnl
70 CF_ARG_OPTION(rlookups,[ --enable-rlookups enable reverse lookups (yes)],[
71 SLAPD_RLOOKUP=no],[SLAPD_RLOOKUP=yes],yes)dnl
73 dnl SLAPD Backend options
74 CF_ARG_OPTION(ldbm,[ --enable-ldbm enable ldbm backend (yes)],[
75 SLAPD_LDBM=no],[SLAPD_LDBM=yes],yes)dnl
76 CF_ARG_OPTION(passwd,[ --enable-passwd enable passwd backend (yes)],[
77 SLAPD_PASSWD=no],[SLAPD_PASSWD=yes],yes)dnl
78 CF_ARG_OPTION(shell,[ --enable-shell enable shell backend (yes)],[
79 SLAPD_SHELL=no],[SLAPD_SHELL=yes],yes)dnl
81 AC_ARG_WITH(ndbm,[ --with-ndbm use NDB for LDBM backend (any)],[
82 opt_ndbm=yes],[opt_ndbm=no])
83 AC_ARG_WITH(gdbm,[ --with-gdbm use GDBM for LDBM backend (any)],[
84 opt_gdbm=yes],[opt_gdbm=no])
85 AC_ARG_WITH(dbhash,[ --with-dbhash use Berkeley DB Hash for LDBM backend (any)],[
86 opt_dbhash=yes],[opt_dbhash=no])
87 AC_ARG_WITH(dbbtree,[ --with-dbbtree use Berkeley DB Btrees for LDBM backend (any)],[
88 opt_dbbtree=yes],[opt_dbbtree=no])
89 AC_ARG_WITH(db2,[ --with-db2 use Berkeley DB2 API (any)],[
90 opt_db2=yes],[opt_db2=no])
93 CF_ARG_OPTION(slurpd,[ --enable-slurpd enable building slurpd (yes)],[
94 BUILD_SLURPD=no],[BUILD_SLURPD=yes],yes)dnl
98 AC_MSG_CHECKING(LDBM preferences)
101 if test "$opt_ndbm" = yes ; then
104 if test "$opt_gdbm" = yes ; then
107 if test "$opt_dbhash" = yes ; then
110 if test "$opt_dbbtree" = yes ; then
113 AC_MSG_RESULT($ldbm_prefer)
115 if test "$BUILD_SLAPD" != "yes" ; then
123 ## general LDAP arguments
131 if test "$LDAP_DEBUG" = "yes" ; then
132 LDAP_DEFS="$LDAP_DEFS -DLDAP_DEBUG"
134 if test "$LDAP_SYSLOG" = "yes" ; then
135 LDAP_DEFS="$LDAP_DEFS -DLDAP_SYSLOG"
137 if test "$LDAP_DNS" = "yes" ; then
138 dnl AC_DEFINE(LDAP_DNS,1)
139 LDAP_DEFS="$LDAP_DEFS -DLDAP_DNS"
141 if test "$LDAP_REFERRALS" = "yes" ; then
142 dnl AC_DEFINE(LDAP_REFERRALS,1)
143 LDAP_DEFS="$LDAP_DEFS -DLDAP_REFERRALS"
145 if test "$LDAP_CACHE" = "no" ; then
146 AC_DEFINE(LDAP_NOCACHE,1)
147 LDAP_DEFS="$LDAP_DEFS -DNO_CACHE"
149 if test "$LDAP_CLDAP" = "yes" ; then
150 AC_DEFINE(LDAP_CONNECTIONLESS,1)
151 LDAP_DEFS="$LDAP_DEFS -DCLDAP"
161 if test "$SLAPD_PHONETIC" = "yes" ; then
162 AC_DEFINE(SLAPD_PHONETIC,1)
163 SLAPD_DEFS="$SLAPD_DEFS -DSOUNDEX"
166 if test "$SLAPD_MD5" = "yes" ; then
167 dnl AC_DEFINE(SLAPD_MD5,1)
168 LUTIL_DEFS="$LUTIL_DEFS -DLDAP_MD5"
171 if test "$SLAPD_SHA1" = "yes" ; then
172 dnl AC_DEFINE(SLAPD_SHA1,1)
173 LUTIL_DEFS="$LUTIL_DEFS -DLDAP_SHA1"
177 if test "$SLAPD_LDBM" = "yes" ; then
178 dnl AC_DEFINE(SLAPD_LDBM,1)
180 LDBM_DEFS="$LDBM_DEFS -DLDAP_LDBM"
182 if test "$SLAPD_PASSWD" = "yes" ; then
183 dnl AC_DEFINE(SLAPD_PASSWD,1)
184 SLAPD_DEFS="$SLAPD_DEFS -DLDAP_PASSWD"
186 if test "$SLAPD_SHELL" = "yes" ; then
187 dnl AC_DEFINE(SLAPD_SHELL,1)
188 SLAPD_DEFS="$SLAPD_DEFS -DLDAP_SHELL"
197 dnl ----------------------------------------------------------------
198 dnl Checks for programs
200 AC_PROG_GCC_TRADITIONAL
207 AC_PATH_PROG(SENDMAIL, sendmail, /usr/lib/sendmail,
208 $PATH:/usr/libexec:/usr/lib:/usr/sbin:/usr/etc:/etc)
209 AC_PATH_PROG(EDITOR, vi, /usr/ucb/vi, $PATH:/usr/ucb)
210 AC_PATH_PROG(FINGER, finger, /usr/ucb/finger, $PATH:/usr/ucb)
212 dnl ----------------------------------------------------------------
213 dnl Checks for libraries
216 if test "$opt_thread" = "no" ; then
217 LTHREAD_DEFS="-DNO_THREADS"
220 AC_CHECK_HEADERS(pthread.h sched.h)
222 if test "$ac_cv_header_pthread_h" = yes ; then
223 dnl We have some form of pthreads
224 AC_CACHE_CHECK([POSIX thread version],cf_cv_pthread_version,[
227 /* this check could be improved */
228 #ifdef PTHREAD_ONCE_INIT
231 ], pthread_final=yes, pthread_final=no)
233 AC_EGREP_CPP(draft4,[
235 /* this check could be improved */
236 #ifdef pthread_once_init
239 ], pthread_draft4=yes, pthread_draft4=no)
241 if test $pthread_final = yes -a $pthread_draft4 = no; then
242 cf_cv_pthread_version=final
243 elif test $pthread_final = no -a $pthread_draft4 = yes; then
244 cf_cv_pthread_version=draft4
246 cf_cv_pthread_version=unknown
250 if test $cf_cv_pthread_version = final ; then
251 LTHREAD_DEFS="$LTHREAD_DEFS -DPOSIX_THREADS"
252 elif test $cf_cv_pthread_version = draft4 ; then
253 LTHREAD_DEFS="$LTHREAD_DEFS -DTHREAD_MIT_PTHREADS"
255 AC_MSG_ERROR(unknown pthread version)
258 AC_CACHE_CHECK([for LinuxThreads], cf_cv_linux_threads, [
259 res=`grep Linuxthreads /usr/include/pthread.h 2>/dev/null | wc -l`
260 if test "$res" -gt 0 ; then
261 cf_cv_linux_threads=yes
263 cf_cv_linux_threads=no
267 if test $cf_cv_linux_threads = yes ; then
268 dnl AC_DEFINE(HAVE_LINUX_THREADS,1)
269 LTHREAD_DEFS="$LTHREAD_DEFS -DHAVE_LINUX_THREADS"
272 dnl Now the hard part, how to link
274 dnl A few platforms have pthread support in standard libraries
275 AC_CHECK_FUNC(pthread_create,pthread_link=yes,pthread_link=no)
277 if test $pthread_link = no ; then
279 AC_CACHE_CHECK([for pthread_create with -pthread],
280 cf_cv_pthread_flag, [
281 dnl save the CPPFLAGS
283 LIBS="-pthread $LIBS"
284 AC_TRY_LINK([#include <pthread.h>],[
285 pthread_create((pthread_t*) 0,
286 (pthread_attr_t*) 0, 0, 0);
287 ], cf_cv_pthread_flag=yes, cf_cv_pthread_flag=no)
292 if test $cf_cv_pthread_flag = yes ; then
293 LTHREAD_LIBS="$LTHREAD_LIBS -pthread"
298 if test $pthread_link = no ; then
301 AC_CHECK_LIB(pthread, pthread_create, [
303 LTHREAD_LIBS="$LTHREAD_LIBS -lpthread"])
307 if test $pthread_link = no ; then
310 AC_CHECK_LIB(c_r, pthread_create, [
312 LTHREAD_LIBS="$LTHREAD_LIBS -lc_r"])
316 if test $pthread_link = no ; then
319 AC_CHECK_LIB(pthread, pthread_create, [
321 LTHREAD_DEFS="$LTHREAD_DEFS -DDEC_THREADS"
322 LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lmach -lexc -lc"],,
328 LTHREAD_DEFS="-DNO_THREADS"
332 # check for strtok_r (and presumely other reentrant functions)
334 LIBS="$save_LIBS $LTHREAD_LIBS"
335 AC_CHECK_LIB(pthread,strtok_r)
337 if test $ac_cv_lib_pthread_strtok_r = no ; then
338 LIBS="$save_LIBS $LTHREAD_LIBS"
339 AC_CHECK_LIB(c_r,strtok_r)
340 AC_CHECK_FUNCS(strtok_r sched_yield)
341 if test $ac_cv_lib_c_r_strtok_r = yes ; then
342 LTHREAD_LIBS="$LTHREAD_LIBS -lc_r"
345 AC_CHECK_FUNCS(strtok_r sched_yield)
352 if test "$SLAPD_LDBM" = "yes" ; then
353 if test $ldbm_prefer = any -o $ldbm_prefer = dbbtree \
354 -o $ldbm_prefer = dbhash ; then
355 AC_CHECK_FUNC(dbopen,[
356 ldbm_use=$ldbm_prefer
358 AC_CHECK_LIB(db,dbopen,[
359 ldbm_use=$ldbm_prefer
361 LDBM_LIBS="$LDBM_LIBS -ldb"
365 if test $ldbm_prefer = found ; then
366 if test $ldbm_use = dbhash ; then
367 dnl AC_DEFINE(LDBM_USE_DBHASH,1)
368 LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_DBHASH"
370 dnl AC_DEFINE(LDBM_USE_DBBTREE,1)
371 LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_DBBTREE"
375 AC_CACHE_CHECK(for db2, cf_cv_db2,[
376 AC_EGREP_CPP(__db_version_2,[
378 /* this check could be improved */
379 #ifdef DB_VERSION_MAJOR
380 #if DB_VERSION_MAJOR == 2
384 ], cf_cv_db2=yes, cf_cv_db2=no)])
386 if test $cf_cv_db2 = yes ; then
387 if test $opt_db2 = yes ; then
388 LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_DB2"
390 AC_CHECK_HEADERS(db_185.h)
391 if test $ac_cv_header_db_185_h = no ; then
392 AC_MSG_ERROR([select --with-db2 or install db2 with 1.85 compatibility])
395 LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_DB2_COMPAT185"
398 if test $opt_db2 = yes ; then
399 AC_MSG_ERROR(could not local DB2)
404 if test $ldbm_prefer = any -o $ldbm_prefer = gdbm ; then
405 AC_CHECK_LIB(gdbm, gdbm_open,[
406 ldbm_use=$ldbm_prefer
408 LDBM_LIBS="$LDBM_LIBS -lgdbm"
409 dnl AC_DEFINE(LDBM_USE_GDBM,1)
410 LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_GDBM"
413 if test $ldbm_prefer = any -o $ldbm_prefer = ndbm ; then
414 AC_CHECK_LIB(dbm,dbm_open,[
417 LDBM_LIBS="$LDBM_LIBS -ldbm"
418 dnl AC_DEFINE(LDBM_USE_NDBM,1)
419 LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_NDBM"
423 if test $ldbm_prefer != found ; then
424 AC_MSG_ERROR(could not find suitable db for $ldbm_prefer backend)
427 if test $ldbm_use = ndbm ; then
428 AC_MSG_WARN(LDBM using NDBM, functionality will be limited)
432 if test "$SLAPD_TCP_WRAPPERS" = "yes" ; then
433 AC_CHECK_LIB(wrap, hosts_access, [
435 dnl AC_DEFINE(HAVE_TCPD)
436 SLAPD_DEFS="$SLAPD_DEFS -DTCP_WRAPPERS"
437 SLAPD_LIBS="$SLAPD_LIBS -lwrap"
441 # ud needs termcap (should insert check here)
442 LIBTERMCAP="-ltermcap"
445 # FreeBSD (and others) have crypt(3) in -lcrypt
446 if test "$SLAPD_CRYPT" = "yes" ; then
447 AC_CHECK_FUNC(crypt, have_crypt=yes, [
448 AC_CHECK_LIB(crypt, crypt, [LUTIL_LIBS="$LUTIL_LIBS -lcrypt"
449 have_crypt=yes], [have_crypt=no])])
451 if test $have_crypt = yes ; then
452 dnl AC_DEFINE(SLAPD_CRYPT,1)
453 LUTIL_DEFS="$LUTIL_DEFS -DLDAP_CRYPT"
455 AC_MSG_WARN(could not find crypt, disabling crypt support)
459 dnl ----------------------------------------------------------------
460 dnl Checks for header files.
478 dnl ----------------------------------------------------------------
479 dnl Checks for typedefs, structures, and compiler characteristics.
494 dnl ----------------------------------------------------------------
495 dnl Checks for library functions.
519 AC_REPLACE_FUNCS(strdup)
521 dnl ----------------------------------------------------------------
522 # Check Configuration
525 dnl ----------------------------------------------------------------
526 AC_SUBST(BUILD_LDAPD)
527 AC_SUBST(BUILD_SLAPD)
529 AC_SUBST(BUILD_PASSWD)
530 AC_SUBST(BUILD_SHELL)
531 AC_SUBST(BUILD_SLURPD)
541 AC_SUBST(SLAPD_PASSWD)
542 AC_SUBST(SLAPD_SHELL)
543 AC_SUBST(SLURPD_DEFS)
544 AC_SUBST(SLURPD_LIBS)
547 AC_SUBST(LTHREAD_DEFS)
548 AC_SUBST(LTHREAD_LIBS)
552 dnl ----------------------------------------------------------------
557 dnl contrib/Makefile:build/top.mk:contrib/Makefile.in:build/dir.mk \
558 dnl contrib/saucer/Makefile:build/top.mk:contrib/saucer/Makefile.in:build/rules.mk \
559 dnl contrib/whois++/Makefile:build/top.mk:contrib/whois++/Makefile.in:build/rules.mk \
560 dnl [date > stamp-h])
563 Makefile:build/top.mk:Makefile.in:build/dir.mk \
564 doc/Makefile:build/top.mk:doc/Makefile.in:build/dir.mk \
565 doc/man/Makefile:build/top.mk:doc/man/Makefile.in:build/dir.mk \
566 doc/man/man1/Makefile:build/top.mk:doc/man/man1/Makefile.in:build/man.mk \
567 doc/man/man3/Makefile:build/top.mk:doc/man/man3/Makefile.in:build/man.mk \
568 doc/man/man5/Makefile:build/top.mk:doc/man/man5/Makefile.in:build/man.mk \
569 doc/man/man8/Makefile:build/top.mk:doc/man/man8/Makefile.in:build/man.mk \
570 clients/Makefile:build/top.mk:clients/Makefile.in:build/dir.mk \
571 clients/finger/Makefile:build/top.mk:clients/finger/Makefile.in:build/rules.mk \
572 clients/fax500/Makefile:build/top.mk:clients/fax500/Makefile.in:build/rules.mk \
573 clients/gopher/Makefile:build/top.mk:clients/gopher/Makefile.in:build/rules.mk \
574 clients/mail500/Makefile:build/top.mk:clients/mail500/Makefile.in:build/rules.mk \
575 clients/rcpt500/Makefile:build/top.mk:clients/rcpt500/Makefile.in:build/rules.mk \
576 clients/ud/Makefile:build/top.mk:clients/ud/Makefile.in:build/rules.mk \
577 clients/tools/Makefile:build/top.mk:clients/tools/Makefile.in:build/rules.mk \
578 include/Makefile:build/top.mk:include/Makefile.in \
579 libraries/Makefile:build/top.mk:libraries/Makefile.in:build/dir.mk \
580 libraries/libavl/Makefile:build/top.mk:libraries/libavl/Makefile.in:build/lib.mk \
581 libraries/liblber/Makefile:build/top.mk:libraries/liblber/Makefile.in:build/lib.mk \
582 libraries/libldap/Makefile:build/top.mk:libraries/libldap/Makefile.in:build/lib.mk \
583 libraries/libldbm/Makefile:build/top.mk:libraries/libldbm/Makefile.in:build/lib.mk \
584 libraries/libldif/Makefile:build/top.mk:libraries/libldif/Makefile.in:build/lib.mk \
585 libraries/liblthread/Makefile:build/top.mk:libraries/liblthread/Makefile.in:build/lib.mk \
586 libraries/liblutil/Makefile:build/top.mk:libraries/liblutil/Makefile.in:build/lib.mk \
587 servers/Makefile:build/top.mk:servers/Makefile.in:build/dir.mk \
588 servers/ldapd/Makefile:build/top.mk:servers/ldapd/Makefile.in:build/srv.mk \
589 servers/slapd/Makefile:build/top.mk:servers/slapd/Makefile.in:build/srv.mk \
590 servers/slapd/back-ldbm/Makefile:build/top.mk:servers/slapd/back-ldbm/Makefile.in:build/srv.mk \
591 servers/slapd/back-passwd/Makefile:build/top.mk:servers/slapd/back-passwd/Makefile.in:build/srv.mk \
592 servers/slapd/back-shell/Makefile:build/top.mk:servers/slapd/back-shell/Makefile.in:build/srv.mk \
593 servers/slapd/shell-backends/Makefile:build/top.mk:servers/slapd/shell-backends/Makefile.in:build/srv.mk \
594 servers/slapd/tools/Makefile:build/top.mk:servers/slapd/tools/Makefile.in \
595 servers/slurpd/Makefile:build/top.mk:servers/slurpd/Makefile.in:build/srv.mk \
596 tests/Makefile:build/top.mk:tests/Makefile.in \