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(libui,[ --enable-libui enable library user interface (yes)],[
28 LDAP_LIBUI=no],[LDAP_LIBUI=yes],yes)dnl
29 CF_ARG_OPTION(cache,[ --enable-cache enable caching (yes)],[
30 LDAP_CACHE=no],[LDAP_CACHE=yes],yes)dnl
31 CF_ARG_OPTION(referrals,[ --enable-referrals enable referrals (yes)],[
32 LDAP_REFERRALS=no],[LDAP_REFERRALS=yes],yes)dnl
34 CF_ARG_OPTION(cldap,[ --enable-clapd enable connectionless ldap (no)],[
35 LDAP_CLDAP=yes],[LDAP_CLDAP=no],no)dnl
37 dnl General "with" options
38 AC_ARG_WITH(kerberos,[ --with-kerberos use Kerberos (no)],[
39 opt_kerberos=yes],[opt_kerberos=no])
40 AC_ARG_WITH(kerberos-afs,[ --with-kerberos-afs use AFS Kerberos (no)],[
41 opt_kerberos_afs=yes],[opt_kerberos_afs=no])
42 AC_ARG_WITH(threads,[ --with-threads use threads (yes)],[
43 opt_threads=yes],[opt_threads=no])
48 CF_ARG_OPTION(ldapd,[ --enable-ldapd enable building ldapd (no)],[
49 BUILD_LDAPD=yes],[BUILD_LDAPD=no],no)dnl
52 CF_ARG_OPTION(slapd,[ --enable-slapd enable building slapd (yes)],[
53 BUILD_SLAPD=no],[BUILD_SLAPD=yes],yes)dnl
54 CF_ARG_OPTION(aclgroup,[ --enable-aclgroup enable ACL group support (yes)],[
55 SLAPD_ACLGROUP=no],[SLAPD_ALCGROUP=yes],yes)dnl
56 CF_ARG_OPTION(crypt,[ --enable-crypt enable crypt(3) passwords (yes)],[
57 SLAPD_CRYPT=no],[SLAPD_CRYPT=yes],yes)dnl
58 CF_ARG_OPTION(md5,[ --enable-md5 enable MD5 passwords (yes)],[
59 SLAPD_MD5=no],[SLAPD_MD5=yes],yes)dnl
60 CF_ARG_OPTION(sha1,[ --enable-sha1 enable SHA1 passwords (yes)],[
61 SLAPD_SHA1=no],[SLAPD_SHA1=yes],yes)dnl
62 CF_ARG_OPTION(wrappers,[ --enable-wrappers enable tcp wrapper support (no)],[
63 SLAPD_TCP_WRAPPERS=yes],[SLAPD_TCP_WRAPPERS=no],no)dnl
64 CF_ARG_OPTION(phonetic,[ --enable-phonetic enable phonetic/soundex (no)],[
65 SLAPD_PHONETIC=yes],[SLAPD_PHONETIC=no],no)dnl
66 CF_ARG_OPTION(rlookups,[ --enable-rlookups enable reverse lookups (yes)],[
67 SLAPD_RLOOKUP=no],[SLAPD_RLOOKUP=yes],yes)dnl
69 dnl SLAPD Backend options
70 CF_ARG_OPTION(ldbm,[ --enable-ldbm enable ldbm backend (yes)],[
71 SLAPD_LDBM=no],[SLAPD_LDBM=yes],yes)dnl
72 CF_ARG_OPTION(passwd,[ --enable-passwd enable passwd backend (yes)],[
73 SLAPD_PASSWD=no],[SLAPD_PASSWD=yes],yes)dnl
74 CF_ARG_OPTION(shell,[ --enable-shell enable shell backend (yes)],[
75 SLAPD_SHELL=no],[SLAPD_SHELL=yes],yes)dnl
77 AC_ARG_WITH(ndbm,[ --with-ndbm use NDB for LDBM backend (any)],[
78 opt_ndbm=yes],[opt_ndbm=no])
79 AC_ARG_WITH(gdbm,[ --with-gdbm use GDBM for LDBM backend (any)],[
80 opt_gdbm=yes],[opt_gdbm=no])
81 AC_ARG_WITH(dbhash,[ --with-dbhash use Berkeley DB Hash for LDBM backend (any)],[
82 opt_dbhash=yes],[opt_dbhash=no])
83 AC_ARG_WITH(dbbtree,[ --with-dbbtree use Berkeley DB Btrees for LDBM backend (any)],[
84 opt_dbbtree=yes],[opt_dbbtree=no])
85 AC_ARG_WITH(db2,[ --with-db2 use Berkeley DB2 API (any)],[
86 opt_db2=yes],[opt_db2=no])
89 CF_ARG_OPTION(slurpd,[ --enable-slurpd enable building slurpd (yes)],[
90 BUILD_SLURPD=no],[BUILD_SLURPD=yes],yes)dnl
94 AC_MSG_CHECKING(LDBM preferences)
97 if test "$opt_ndbm" = yes ; then
100 if test "$opt_gdbm" = yes ; then
103 if test "$opt_dbhash" = yes ; then
106 if test "$opt_dbbtree" = yes ; then
109 AC_MSG_RESULT($ldbm_prefer)
111 if test "$BUILD_SLAPD" != "yes" ; then
119 ## general LDAP arguments
123 if test "$LDAP_DEBUG" = "yes" ; then
124 LDAP_DEFS="$LDAP_DEFS -DLDAP_DEBUG"
126 if test "$LDAP_REFERRALS" = "yes" ; then
127 AC_DEFINE(LDAP_REFERRALS,1)
128 LDAP_DEFS="$LDAP_DEFS -DLDAP_REFERRALS"
130 if test "$LDAP_CACHE" = "no" ; then
131 AC_DEFINE(LDAP_NOCACHE,1)
132 LDAP_DEFS="$LDAP_DEFS -DNO_CACHE"
134 if test "$LDAP_CLDAP" = "yes" ; then
135 AC_DEFINE(LDAP_CONNECTIONLESS,1)
136 LDAP_DEFS="$LDAP_DEFS -DCLDAP"
147 if test "$SLAPD_PHONETIC" = "yes" ; then
148 AC_DEFINE(SLAPD_PHONETIC,1)
149 SLAPD_DEFS="$SLAPD_DEFS -DSOUNDEX"
152 if test "$SLAPD_MD5" = "yes" ; then
153 dnl AC_DEFINE(SLAPD_MD5,1)
154 LUTIL_DEFS="$LUTIL_DEFS -DLDAP_MD5"
157 if test "$SLAPD_SHA1" = "yes" ; then
158 dnl AC_DEFINE(SLAPD_SHA1,1)
159 LUTIL_DEFS="$LUTIL_DEFS -DLDAP_SHA1"
162 if test "$SLAPD_LDBM" = "yes" ; then
163 dnl AC_DEFINE(SLAPD_LDBM,1)
164 SLAPD_DEFS="$SLAPD_DEFS -DLDAP_LDBM"
166 if test "$SLAPD_PASSWD" = "yes" ; then
167 dnl AC_DEFINE(SLAPD_PASSWD,1)
168 SLAPD_DEFS="$SLAPD_DEFS -DLDAP_PASSWD"
170 if test "$SLAPD_SHELL" = "yes" ; then
171 dnl AC_DEFINE(SLAPD_SHELL,1)
172 SLAPD_DEFS="$SLAPD_DEFS -DLDAP_SHELL"
181 dnl ----------------------------------------------------------------
182 dnl Checks for programs
184 AC_PROG_GCC_TRADITIONAL
191 AC_PATH_PROG(SENDMAIL, sendmail, /usr/lib/sendmail,
192 $PATH:/usr/libexec:/usr/lib:/usr/sbin:/usr/etc:/etc)
193 AC_PATH_PROG(EDITOR, vi, /usr/ucb/vi, $PATH:/usr/ucb)
194 AC_PATH_PROG(FINGER, finger, /usr/ucb/finger, $PATH:/usr/ucb)
196 dnl ----------------------------------------------------------------
197 dnl Checks for libraries
200 if test "$opt_thread" = "no" ; then
201 LTHREAD_DEFS="-DNO_THREADS"
204 AC_CHECK_HEADERS(pthread.h sched.h)
206 if test "$ac_cv_header_pthread_h" = yes ; then
207 dnl We have some form of pthreads
208 AC_CACHE_CHECK([POSIX thread version],cf_cv_pthread_version,[
211 /* this check could be improved */
212 #ifdef PTHREAD_ONCE_INIT
215 ], pthread_final=yes, pthread_final=no)
217 AC_EGREP_CPP(draft4,[
219 /* this check could be improved */
220 #ifdef pthread_once_init
223 ], pthread_draft4=yes, pthread_draft4=no)
225 if test $pthread_final = yes -a $pthread_draft4 = no; then
226 cf_cv_pthread_version=final
227 elif test $pthread_final = no -a $pthread_draft4 = yes; then
228 cf_cv_pthread_version=draft4
230 cf_cv_pthread_version=unknown
234 if test $cf_cv_pthread_version = final ; then
235 LTHREAD_DEFS="$LTHREAD_DEFS -DPOSIX_THREADS"
236 elif test $cf_cv_pthread_version = draft4 ; then
237 LTHREAD_DEFS="$LTHREAD_DEFS -DTHREAD_MIT_PTHREADS"
239 AC_MSG_ERROR(unknown pthread version)
242 AC_CACHE_CHECK([for LinuxThreads], cf_cv_linux_threads, [
243 res=`grep Linuxthreads /usr/include/pthread.h 2>/dev/null | wc -l`
244 if test "$res" -gt 0 ; then
245 cf_cv_linux_threads=yes
247 cf_cv_linux_threads=no
251 if test $cf_cv_linux_threads = yes ; then
252 dnl AC_DEFINE(HAVE_LINUX_THREADS,1)
253 LTHREAD_DEFS="$LTHREAD_DEFS -DHAVE_LINUX_THREADS"
256 dnl Now the hard part, how to link
258 dnl A few platforms have pthread support in standard libraries
259 AC_CHECK_FUNC(pthread_create,pthread_link=yes,pthread_link=no)
261 if test $pthread_link = no ; then
263 AC_CACHE_CHECK([for pthread_create with -pthread],
264 cf_cv_pthread_flag, [
265 dnl save the CPPFLAGS
267 LIBS="-pthread $LIBS"
268 AC_TRY_LINK([#include <pthread.h>],[
269 pthread_create((pthread_t*) 0,
270 (pthread_attr_t*) 0, 0, 0);
271 ], cf_cv_pthread_flag=yes, cf_cv_pthread_flag=no)
276 if test $cf_cv_pthread_flag = yes ; then
277 LTHREAD_LIBS="$LTHREAD_LIBS -pthread"
282 if test $pthread_link = no ; then
285 AC_CHECK_LIB(pthread, pthread_create, [
287 LTHREAD_LIBS="$LTHREAD_LIBS -lpthread"])
291 if test $pthread_link = no ; then
294 AC_CHECK_LIB(c_r, pthread_create, [
296 LTHREAD_LIBS="$LTHREAD_LIBS -lc_r"])
300 if test $pthread_link = no ; then
303 AC_CHECK_LIB(pthread, pthread_create, [
305 LTHREAD_DEFS="$LTHREAD_DEFS -DDEC_THREADS"
306 LTHREAD_LIBS="$LTHREAD_LIBS -lpthread -lmach -lexc -lc"],,
312 LTHREAD_DEFS="-DNO_THREADS"
318 LIBS="$save_LIBS $LTHREAD_LIBS"
319 AC_CHECK_LIB(pthread,strtok_r)
321 if test $ac_cv_lib_pthread_strtok_r = no ; then
322 AC_CHECK_LIB(c_r,strtok_r)
323 AC_CHECK_FUNCS(strtok_r sched_yield)
324 if test $ac_cv_lib_c_r_strtok_r = yes ; then
325 LTHREAD_LIBS="$LTHREAD_LIBS -lc_r"
328 AC_CHECK_FUNCS(strtok_r sched_yield)
338 if test "$SLAPD_LDBM" = "yes" ; then
339 if test $ldbm_prefer = any -o $ldbm_prefer = dbbtree \
340 -o $ldbm_prefer = dbhash ; then
341 AC_CHECK_FUNC(dbopen,[
342 ldbm_use=$ldbm_prefer
344 AC_CHECK_LIB(db,dbopen,[
345 ldbm_use=$ldbm_prefer
347 LDBM_LIBS="$LDBM_LIBS -ldb"
351 if test $ldbm_prefer = found ; then
352 if test $ldbm_use = dbhash ; then
353 dnl AC_DEFINE(LDBM_USE_DBHASH,1)
354 LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_DBHASH"
356 dnl AC_DEFINE(LDBM_USE_DBBTREE,1)
357 LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_DBBTREE"
361 AC_CACHE_CHECK(for db2, cf_cv_db2,[
362 AC_EGREP_CPP(__db_version_2,[
364 /* this check could be improved */
365 #ifdef DB_VERSION_MAJOR
366 #if DB_VERSION_MAJOR == 2
370 ], cf_cv_db2=yes, cf_cv_db2=no)])
372 if test $cf_cv_db2 = yes ; then
373 if test $opt_db2 = yes ; then
374 LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_DB2"
376 AC_CHECK_HEADERS(db_185.h)
377 if test $ac_cv_header_db_185_h = no ; then
378 AC_MSG_ERROR([select --with-db2 or install db2 with 1.85 compatibility])
381 LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_DB2_COMPAT185"
384 if test $opt_db2 = yes ; then
385 AC_MSG_ERROR(could not local DB2)
390 if test $ldbm_prefer = any -o $ldbm_prefer = gdbm ; then
391 AC_CHECK_LIB(gdbm, gdbm_open,[
392 ldbm_use=$ldbm_prefer
394 LDBM_LIBS="$LDBM_LIBS -lgdbm"
395 dnl AC_DEFINE(LDBM_USE_GDBM,1)
396 LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_GDBM"
399 if test $ldbm_prefer = any -o $ldbm_prefer = ndbm ; then
400 AC_CHECK_LIB(dbm,dbm_open,[
403 LDBM_LIBS="$LDBM_LIBS -ldbm"
404 dnl AC_DEFINE(LDBM_USE_NDBM,1)
405 LDBM_DEFS="$LDBM_DEFS -DLDBM_USE_NDBM"
409 if test $ldbm_prefer != found ; then
410 AC_MSG_ERROR(could not find suitable db for $ldbm_prefer backend)
413 if test $ldbm_use = ndbm ; then
414 AC_MSG_WARN(LDBM using NDBM, functionality will be limited)
418 if test "$SLAPD_TCP_WRAPPERS" = "yes" ; then
419 AC_CHECK_LIB(wrap, hosts_access, [
421 dnl AC_DEFINE(HAVE_TCPD)
422 SLAPD_DEFS="$SLAPD_DEFS -DTCP_WRAPPERS"
423 SLAPD_LIBS="$SLAPD_LIBS -lwrap"
427 # ud needs termcap (should insert check here)
428 LIBTERMCAP="-ltermcap"
431 # FreeBSD (and others) have crypt(3) in -lcrypt
432 if test "$SLAPD_CRYPT" = "yes" ; then
433 AC_CHECK_FUNC(crypt, have_crypt=yes, [
434 AC_CHECK_LIB(crypt, crypt, [LUTIL_LIBS="$LUTIL_LIBS -lcrypt"
435 have_crypt=yes], [have_crypt=no])])
437 if test $have_crypt = yes ; then
438 dnl AC_DEFINE(SLAPD_CRYPT,1)
439 LUTIL_DEFS="$LUTIL_DEFS -DLDAP_CRYPT"
441 AC_MSG_WARN(could not find crypt, disabling crypt support)
445 dnl ----------------------------------------------------------------
446 dnl Checks for header files.
464 dnl ----------------------------------------------------------------
465 dnl Checks for typedefs, structures, and compiler characteristics.
480 dnl ----------------------------------------------------------------
481 dnl Checks for library functions.
505 AC_REPLACE_FUNCS(strsep strdup)
507 dnl ----------------------------------------------------------------
508 # Check Configuration
511 AC_SUBST(BUILD_LDAPD)
513 AC_SUBST(BUILD_SLAPD)
515 AC_SUBST(SLAPD_PASSWD)
516 AC_SUBST(SLAPD_SHELL)
518 AC_SUBST(BUILD_SLURPD)
526 AC_SUBST(SLURPD_DEFS)
527 AC_SUBST(SLURPD_LIBS)
530 AC_SUBST(LTHREAD_DEFS)
531 AC_SUBST(LTHREAD_LIBS)
536 dnl contrib/Makefile:build/top.mk:contrib/Makefile.in:build/dir.mk \
537 dnl contrib/saucer/Makefile:build/top.mk:contrib/saucer/Makefile.in:build/rules.mk \
538 dnl contrib/whois++/Makefile:build/top.mk:contrib/whois++/Makefile.in:build/rules.mk \
539 dnl [date > stamp-h])
542 Makefile:build/top.mk:Makefile.in:build/dir.mk \
543 doc/Makefile:build/top.mk:doc/Makefile.in:build/dir.mk \
544 doc/man/Makefile:build/top.mk:doc/man/Makefile.in:build/dir.mk \
545 doc/man/man1/Makefile:build/top.mk:doc/man/man1/Makefile.in:build/man.mk \
546 doc/man/man3/Makefile:build/top.mk:doc/man/man3/Makefile.in:build/man.mk \
547 doc/man/man5/Makefile:build/top.mk:doc/man/man5/Makefile.in:build/man.mk \
548 doc/man/man8/Makefile:build/top.mk:doc/man/man8/Makefile.in:build/man.mk \
549 clients/Makefile:build/top.mk:clients/Makefile.in:build/dir.mk \
550 clients/finger/Makefile:build/top.mk:clients/finger/Makefile.in:build/rules.mk \
551 clients/fax500/Makefile:build/top.mk:clients/fax500/Makefile.in:build/rules.mk \
552 clients/gopher/Makefile:build/top.mk:clients/gopher/Makefile.in:build/rules.mk \
553 clients/mail500/Makefile:build/top.mk:clients/mail500/Makefile.in:build/rules.mk \
554 clients/rcpt500/Makefile:build/top.mk:clients/rcpt500/Makefile.in:build/rules.mk \
555 clients/ud/Makefile:build/top.mk:clients/ud/Makefile.in:build/rules.mk \
556 clients/tools/Makefile:build/top.mk:clients/tools/Makefile.in:build/rules.mk \
557 include/Makefile:build/top.mk:include/Makefile.in \
558 libraries/Makefile:build/top.mk:libraries/Makefile.in:build/dir.mk \
559 libraries/libavl/Makefile:build/top.mk:libraries/libavl/Makefile.in:build/lib.mk \
560 libraries/liblber/Makefile:build/top.mk:libraries/liblber/Makefile.in:build/lib.mk \
561 libraries/libldap/Makefile:build/top.mk:libraries/libldap/Makefile.in:build/lib.mk \
562 libraries/libldbm/Makefile:build/top.mk:libraries/libldbm/Makefile.in:build/lib.mk \
563 libraries/libldif/Makefile:build/top.mk:libraries/libldif/Makefile.in:build/lib.mk \
564 libraries/liblthread/Makefile:build/top.mk:libraries/liblthread/Makefile.in:build/lib.mk \
565 libraries/liblutil/Makefile:build/top.mk:libraries/liblutil/Makefile.in:build/lib.mk \
566 servers/Makefile:build/top.mk:servers/Makefile.in:build/dir.mk \
567 servers/ldapd/Makefile:build/top.mk:servers/ldapd/Makefile.in:build/srv.mk \
568 servers/slapd/Makefile:build/top.mk:servers/slapd/Makefile.in:build/srv.mk \
569 servers/slapd/back-ldbm/Makefile:build/top.mk:servers/slapd/back-ldbm/Makefile.in:build/srv.mk \
570 servers/slapd/back-passwd/Makefile:build/top.mk:servers/slapd/back-passwd/Makefile.in:build/srv.mk \
571 servers/slapd/back-shell/Makefile:build/top.mk:servers/slapd/back-shell/Makefile.in:build/srv.mk \
572 servers/slapd/shell-backends/Makefile:build/top.mk:servers/slapd/shell-backends/Makefile.in:build/srv.mk \
573 servers/slapd/tools/Makefile:build/top.mk:servers/slapd/tools/Makefile.in \
574 servers/slurpd/Makefile:build/top.mk:servers/slurpd/Makefile.in:build/srv.mk \
575 tests/Makefile:build/top.mk:tests/Makefile.in \