1dnl $OpenLDAP$
2dnl This work is part of OpenLDAP Software <http://www.openldap.org/>.
3dnl
4dnl Copyright 1998-2011 The OpenLDAP Foundation.
5dnl All rights reserved.
6dnl
7dnl Redistribution and use in source and binary forms, with or without
8dnl modification, are permitted only as authorized by the OpenLDAP
9dnl Public License.
10dnl
11dnl A copy of this license is available in the file LICENSE in the
12dnl top-level directory of the distribution or, alternatively, at
13dnl <http://www.OpenLDAP.org/license.html>.
14dnl
15dnl ----------------------------------------------------------------
16dnl Disable config.cache!
17define([AC_CACHE_LOAD], )dnl
18define([AC_CACHE_SAVE], )dnl
19dnl ----------------------------------------------------------------
20dnl Disable libtool 1.5 support for languages we don't use
21define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])dnl
22define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
23define([AC_LIBTOOL_LANG_GCJ_CONFIG], [:])dnl
24dnl ================================================================
25dnl Configure.in for OpenLDAP
26AC_COPYRIGHT([[Copyright 1998-2011 The OpenLDAP Foundation. All rights reserved.
27Restrictions apply, see COPYRIGHT and LICENSE files.]])
28AC_REVISION([$Id: e7e5a7e17ae6655fc0779de0ad978202c3a73699 $])
29AC_INIT([OpenLDAP],,[http://www.openldap.org/its/])
30m4_define([AC_PACKAGE_BUGREPORT],[<http://www.openldap.org/its/>])
31AC_CONFIG_SRCDIR(build/version.sh)dnl
32dnl ----------------------------------------------------------------
33dnl OpenLDAP Autoconf Macros
34builtin(include, build/openldap.m4)dnl
35dnl ================================================================
36
37AC_CONFIG_AUX_DIR(build)dnl
38
39eval `$ac_aux_dir/version.sh`
40if test -z "$OL_STRING"; then
41	AC_MSG_ERROR([could not determine version])
42fi
43
44if test -f "$ac_aux_dir/shtool" && test ! -d $ac_aux_dir/shtool; then
45	ac_cv_shtool="$ac_aux_dir/shtool"
46else
47	AC_MSG_ERROR([no shtool found in $ac_aux_dir])
48fi
49
50SHTOOL="$ac_cv_shtool"
51dnl AC_SUBST(SHTOOL)dnl
52
53TB="" TN=""
54if test -t 1; then
55	TB="`$SHTOOL echo -e '%B' 2>/dev/null`"
56	TN="`$SHTOOL echo -e '%b' 2>/dev/null`"
57fi
58
59OPENLDAP_REPO=""
60if test -d $ac_aux_dir/../.git; then
61	OPENLDAP_REPO="(from Git clone) "
62elif test -d $ac_aux_dir/CVS; then
63	OPENLDAP_REPO="(from CVS checkout) "
64fi
65
66echo "Configuring ${TB}${OL_STRING}${TN} ${OPENLDAP_REPO}..."
67
68dnl Determine host platform
69dnl		we try not to use this for much
70AC_CANONICAL_TARGET([])
71
72AM_INIT_AUTOMAKE([$OL_PACKAGE],[$OL_VERSION], [no defines])dnl
73AC_SUBST(PACKAGE)dnl
74AC_SUBST(VERSION)dnl
75AC_DEFINE_UNQUOTED(OPENLDAP_PACKAGE,"$PACKAGE",Package)
76AC_DEFINE_UNQUOTED(OPENLDAP_VERSION,"$VERSION",Version)
77
78AC_DEFINE_UNQUOTED(LDAP_VENDOR_VERSION,$OL_API_INC,Version)
79AC_DEFINE_UNQUOTED(LDAP_VENDOR_VERSION_MAJOR,$OL_MAJOR,Major)
80AC_DEFINE_UNQUOTED(LDAP_VENDOR_VERSION_MINOR,$OL_MINOR,Minor)
81AC_DEFINE_UNQUOTED(LDAP_VENDOR_VERSION_PATCH,$OL_PATCH,Patch)
82
83OPENLDAP_LIBRELEASE=$OL_API_LIB_RELEASE
84AC_SUBST(OPENLDAP_LIBRELEASE)dnl
85
86OPENLDAP_LIBVERSION=$OL_API_LIB_VERSION
87AC_SUBST(OPENLDAP_LIBVERSION)dnl
88
89OPENLDAP_RELEASE_DATE="$OL_RELEASE_DATE"
90AC_SUBST(OPENLDAP_RELEASE_DATE)dnl
91
92dnl We use autoconf features new to 2.59.  Later versions like won't work.
93dnl aclocal.m4 should be built using aclocal from automake 1.5
94dnl libtool 1.5 should be installed.
95AC_PREREQ(2.59)dnl Required Autoconf version
96
97AH_TOP([
98/* begin of portable.h.pre */
99/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
100 *
101 * Copyright 1998-2011 The OpenLDAP Foundation
102 * All rights reserved.
103 *
104 * Redistribution and use in source and binary forms, with or without
105 * modification, are permitted only as authorized by the OpenLDAP
106 * Public License.
107 *
108 * A copy of this license is available in the file LICENSE in the
109 * top-level directory of the distribution or, alternatively, at
110 * <http://www.OpenLDAP.org/license.html>.
111 */
112
113#ifndef _LDAP_PORTABLE_H
114#define _LDAP_PORTABLE_H
115
116/* define this if needed to get reentrant functions */
117#ifndef REENTRANT
118#undef REENTRANT
119#endif
120#ifndef _REENTRANT
121#undef _REENTRANT
122#endif
123
124/* define this if needed to get threadsafe functions */
125#ifndef THREADSAFE
126#undef THREADSAFE
127#endif
128#ifndef _THREADSAFE
129#undef _THREADSAFE
130#endif
131#ifndef THREAD_SAFE
132#undef THREAD_SAFE
133#endif
134#ifndef _THREAD_SAFE
135#undef _THREAD_SAFE
136#endif
137
138#ifndef _SGI_MP_SOURCE
139#undef _SGI_MP_SOURCE
140#endif
141
142/* end of portable.h.pre */
143])
144AH_BOTTOM([
145/* begin of portable.h.post */
146
147#ifdef _WIN32
148	/* don't suck in all of the win32 api */
149#	define WIN32_LEAN_AND_MEAN 1
150#endif
151
152#ifndef LDAP_NEEDS_PROTOTYPES
153/* force LDAP_P to always include prototypes */
154#define LDAP_NEEDS_PROTOTYPES 1
155#endif
156
157#ifndef LDAP_REL_ENG
158#if (LDAP_VENDOR_VERSION == 000000) && !defined(LDAP_DEVEL)
159#define LDAP_DEVEL
160#endif
161#if defined(LDAP_DEVEL) && !defined(LDAP_TEST)
162#define LDAP_TEST
163#endif
164#endif
165
166#ifdef HAVE_STDDEF_H
167#	include <stddef.h>
168#endif
169
170#ifdef HAVE_EBCDIC 
171/* ASCII/EBCDIC converting replacements for stdio funcs
172 * vsnprintf and snprintf are used too, but they are already
173 * checked by the configure script
174 */
175#define fputs ber_pvt_fputs
176#define fgets ber_pvt_fgets
177#define printf ber_pvt_printf
178#define fprintf ber_pvt_fprintf
179#define vfprintf ber_pvt_vfprintf
180#define vsprintf ber_pvt_vsprintf
181#endif
182
183#include "ac/fdset.h"
184
185#include "ldap_cdefs.h"
186#include "ldap_features.h"
187
188#include "ac/assert.h"
189#include "ac/localize.h"
190
191#endif /* _LDAP_PORTABLE_H */
192/* end of portable.h.post */
193])
194
195AC_CONFIG_HEADERS([include/portable.h:include/portable.hin])
196AC_CONFIG_HEADERS([include/ldap_features.h:include/ldap_features.hin])
197AC_CONFIG_HEADERS([include/lber_types.h:include/lber_types.hin])
198
199dnl ================================================================
200dnl Start Args
201AC_MSG_CHECKING(configure arguments)
202AC_PREFIX_DEFAULT(/usr/local)
203
204top_builddir=`pwd`
205AC_SUBST(top_builddir)dnl
206
207dnl ----------------------------------------------------------------
208dnl --with-subdir
209ldap_subdir="/openldap"
210
211AC_ARG_WITH(subdir,
212[  --with-subdir=DIR       change default subdirectory used for installs],
213[case "$withval" in
214	no) ldap_subdir=""
215		;;
216	yes)
217		;;
218	/*|\\*)
219		ldap_subdir="$withval"
220		;;
221	*)
222		ldap_subdir="/$withval"
223		;;
224esac
225])dnl
226
227AC_SUBST(ldap_subdir)dnl
228
229dnl ----------------------------------------------------------------
230dnl General "enable" options
231dnl set default to traditional to enable the original debug style
232OL_ARG_ENABLE(debug,[  --enable-debug 	  enable debugging], yes, [no yes traditional])dnl
233OL_ARG_ENABLE(dynamic,[  --enable-dynamic	  enable linking built binaries with dynamic libs], no)dnl
234OL_ARG_ENABLE(syslog,[  --enable-syslog	  enable syslog support], auto)dnl
235OL_ARG_ENABLE(proctitle,[  --enable-proctitle	  enable proctitle support], yes)dnl
236dnl OL_ARG_ENABLE(referrals,[  --enable-referrals	  enable LDAPv2+ Referrals (experimental)], no)dnl
237ol_enable_referrals=${ol_enable_referrals-no}
238OL_ARG_ENABLE(ipv6,[  --enable-ipv6 	  enable IPv6 support], auto)dnl
239OL_ARG_ENABLE(local,[  --enable-local	  enable AF_LOCAL (AF_UNIX) socket support], auto)dnl
240
241dnl ----------------------------------------------------------------
242dnl General "with" options
243OL_ARG_WITH(cyrus_sasl,[  --with-cyrus-sasl	  with Cyrus SASL support],
244	auto, [auto yes no] )
245OL_ARG_WITH(fetch,[  --with-fetch		  with fetch(3) URL support],
246	auto, [auto yes no] )
247OL_ARG_WITH(threads,[  --with-threads	  with threads],
248	auto, [auto nt posix mach pth lwp yes no manual] )
249OL_ARG_WITH(tls,[  --with-tls		  with TLS/SSL support auto|secure-transport|openssl|gnutls|moznss],
250	auto, [auto secure-transport openssl gnutls moznss yes no] )
251OL_ARG_WITH(yielding_select,
252	[  --with-yielding-select  with implicitly yielding select],
253	auto, [auto yes no manual] )
254OL_ARG_WITH(mp,
255	[  --with-mp               with multiple precision statistics auto|longlong|long|bignum|gmp],
256	auto, [auto longlong long bignum gmp yes no])
257OL_ARG_WITH(odbc,
258	[  --with-odbc             with specific ODBC support iodbc|unixodbc|odbc32|auto],
259	auto, [auto iodbc unixodbc odbc32] )
260
261dnl ----------------------------------------------------------------
262dnl Server options
263dnl ----------------------------------------------------------------
264
265dnl ----------------------------------------------------------------
266dnl SLAPD OPTIONS
267AC_ARG_ENABLE(xxslapdoptions,[
268SLAPD (Standalone LDAP Daemon) Options:])
269OL_ARG_ENABLE(slapd,[  --enable-slapd	  enable building slapd], yes)dnl
270OL_ARG_ENABLE(dynacl,[    --enable-dynacl	  enable run-time loadable ACL support (experimental)], no)dnl
271OL_ARG_ENABLE(aci,[    --enable-aci	  enable per-object ACIs (experimental)], no, [no yes mod])dnl
272OL_ARG_ENABLE(cleartext,[    --enable-cleartext	  enable cleartext passwords], yes)dnl
273OL_ARG_ENABLE(crypt,[    --enable-crypt	  enable crypt(3) passwords], no)dnl
274OL_ARG_ENABLE(lmpasswd,[    --enable-lmpasswd	  enable LAN Manager passwords], no)dnl
275OL_ARG_ENABLE(spasswd,[    --enable-spasswd	  enable (Cyrus) SASL password verification], no)dnl
276OL_ARG_ENABLE(modules,[    --enable-modules	  enable dynamic module support], no)dnl
277OL_ARG_ENABLE(rlookups,[    --enable-rlookups	  enable reverse lookups of client hostnames], no)dnl
278OL_ARG_ENABLE(slapi,[    --enable-slapi        enable SLAPI support (experimental)], no)dnl
279OL_ARG_ENABLE(slp,[    --enable-slp          enable SLPv2 support], no)dnl     
280OL_ARG_ENABLE(wrappers,[    --enable-wrappers	  enable tcp wrapper support], no)dnl
281
282dnl ----------------------------------------------------------------
283dnl SLAPD Backend Options
284Backends="bdb \
285	dnssrv \
286	hdb \
287	ldap \
288	meta \
289	monitor \
290	null \
291	passwd \
292	perl \
293	relay \
294	shell \
295	sock \
296	sql"
297
298AC_ARG_ENABLE(xxslapbackends,[
299SLAPD Backend Options:])
300
301OL_ARG_ENABLE(backends,[    --enable-backends	  enable all available backends],
302	--, [no yes mod])dnl
303OL_ARG_ENABLE(bdb,[    --enable-bdb	  enable Berkeley DB backend],
304	yes, [no yes mod], ol_enable_backends)dnl
305OL_ARG_ENABLE(dnssrv,[    --enable-dnssrv	  enable dnssrv backend],
306	no, [no yes mod], ol_enable_backends)dnl
307OL_ARG_ENABLE(hdb,[    --enable-hdb	  enable Hierarchical DB backend],
308	yes, [no yes mod], ol_enable_backends)dnl
309OL_ARG_ENABLE(ldap,[    --enable-ldap	  enable ldap backend],
310	no, [no yes mod], ol_enable_backends)dnl
311OL_ARG_ENABLE(meta,[    --enable-meta	  enable metadirectory backend],
312	no, [no yes mod], ol_enable_backends)dnl
313OL_ARG_ENABLE(monitor,[    --enable-monitor	  enable monitor backend],
314	yes, [no yes mod], ol_enable_backends)dnl
315OL_ARG_ENABLE(null,[    --enable-null	  enable null backend],
316	no, [no yes mod], ol_enable_backends)dnl
317OL_ARG_ENABLE(passwd,[    --enable-passwd	  enable passwd backend],
318	no, [no yes mod], ol_enable_backends)dnl
319OL_ARG_ENABLE(perl,[    --enable-perl	  enable perl backend],
320	no, [no yes mod], ol_enable_backends)dnl
321OL_ARG_ENABLE(relay,[    --enable-relay  	  enable relay backend],
322	yes, [no yes mod], ol_enable_backends)dnl
323OL_ARG_ENABLE(shell,[    --enable-shell	  enable shell backend],
324	no, [no yes mod], ol_enable_backends)dnl
325OL_ARG_ENABLE(sock,[    --enable-sock	  enable sock backend],
326	no, [no yes mod], ol_enable_backends)dnl
327OL_ARG_ENABLE(sql,[    --enable-sql	  enable sql backend],
328	no, [no yes mod], ol_enable_backends)dnl
329
330dnl ----------------------------------------------------------------
331dnl SLAPD Overlay Options
332Overlays="accesslog \
333	dynid \
334	odlocales \
335	odusers \
336	auditlog \
337	constraint \
338	dds \
339	deref \
340	dyngroup \
341	nestedgroup \
342	dynlist \
343	memberof \
344	ppolicy \
345	proxycache \
346	refint \
347	retcode \
348	seqmod \
349	syncprov \
350	translucent \
351	unique \
352	valsort"
353
354AC_ARG_ENABLE(xxslapoverlays,[
355SLAPD Overlay Options:])
356
357OL_ARG_ENABLE(overlays,[    --enable-overlays	  enable all available overlays],
358	--, [no yes mod])dnl
359OL_ARG_ENABLE(accesslog,[    --enable-accesslog	  In-Directory Access Logging overlay],
360	no, [no yes mod], ol_enable_overlays)
361OL_ARG_ENABLE(dynid,[    --enable-dynid	  Dynamic ID overlay],
362	no, [no yes mod], ol_enable_overlays)
363OL_ARG_ENABLE(odlocales,[    --enable-odlocales	  enable LDAP ping for Locales],
364	no, [no yes mod], ol_enable_overlays)
365OL_ARG_ENABLE(odusers,[    --enable-odusers	  enable OD User management],
366	no, [no yes mod], ol_enable_overlays)
367OL_ARG_ENABLE(constraint,[    --enable-constraint	  Attribute Constraint overlay],
368	no, [no yes mod], ol_enable_overlays)
369OL_ARG_ENABLE(dds,[    --enable-dds  	  Dynamic Directory Services overlay],
370	no, [no yes mod], ol_enable_overlays)
371OL_ARG_ENABLE(deref,[    --enable-deref	  Dereference overlay],
372	no, [no yes mod], ol_enable_overlays)
373OL_ARG_ENABLE(dyngroup,[    --enable-dyngroup	  Dynamic Group overlay],
374	no, [no yes mod], ol_enable_overlays)
375OL_ARG_ENABLE(nestedgroup,[    --enable-nestedgroup	  Nested Group overlay],
376	no, [no yes mod], ol_enable_overlays)
377OL_ARG_ENABLE(dynlist,[    --enable-dynlist	  Dynamic List overlay],
378	no, [no yes mod], ol_enable_overlays)
379OL_ARG_ENABLE(memberof,[    --enable-memberof	  Reverse Group Membership overlay],
380	no, [no yes mod], ol_enable_overlays)
381OL_ARG_ENABLE(ppolicy,[    --enable-ppolicy	  Password Policy overlay],
382	no, [no yes mod], ol_enable_overlays)
383OL_ARG_ENABLE(proxycache,[    --enable-proxycache	  Proxy Cache overlay],
384	no, [no yes mod], ol_enable_overlays)
385OL_ARG_ENABLE(refint,[    --enable-refint	  Referential Integrity overlay],
386	no, [no yes mod], ol_enable_overlays)
387OL_ARG_ENABLE(retcode,[    --enable-retcode	  Return Code testing overlay],
388	no, [no yes mod], ol_enable_overlays)
389OL_ARG_ENABLE(seqmod,[    --enable-seqmod	  Sequential Modify overlay],
390	yes, [no yes mod], ol_enable_overlays)
391OL_ARG_ENABLE(syncprov,[    --enable-syncprov	  Syncrepl Provider overlay],
392	yes, [no yes mod], ol_enable_overlays)
393OL_ARG_ENABLE(translucent,[    --enable-translucent  Translucent Proxy overlay],
394	no, [no yes mod], ol_enable_overlays)
395OL_ARG_ENABLE(unique,[    --enable-unique       Attribute Uniqueness overlay],
396	no, [no yes mod], ol_enable_overlays)
397OL_ARG_ENABLE(valsort,[    --enable-valsort      Value Sorting overlay],
398	no, [no yes mod], ol_enable_overlays)
399
400dnl ----------------------------------------------------------------
401AC_ARG_ENABLE(xxliboptions,[
402Library Generation & Linking Options])
403AC_ENABLE_STATIC
404AC_ENABLE_SHARED
405
406dnl ----------------------------------------------------------------
407
408# validate options
409if test $ol_enable_slapd = no ; then
410	dnl SLAPD was specificallly disabled
411	if test $ol_enable_slapi = yes ; then
412		AC_MSG_WARN([slapd disabled, ignoring --enable-slapi argument])
413	fi
414	case "$ol_enable_backends" in yes | mod)
415		AC_MSG_WARN([slapd disabled, ignoring --enable-backends argument])
416	esac
417	for i in $Backends; do
418		eval "ol_tmp=\$ol_enable_$i"
419		if test $ol_tmp != no ; then
420			AC_MSG_WARN([slapd disabled, ignoring --enable-$i argument])
421			eval "ol_enable_$i=no"
422		fi
423	done
424	if test $ol_enable_modules = yes ; then
425		AC_MSG_WARN([slapd disabled, ignoring --enable-modules argument])
426	fi
427	if test $ol_enable_wrappers = yes ; then
428		AC_MSG_WARN([slapd disabled, ignoring --enable-wrappers argument])
429	fi
430	if test $ol_enable_rlookups = yes ; then
431		AC_MSG_WARN([slapd disabled, ignoring --enable-rlookups argument])
432	fi
433	if test $ol_enable_dynacl = yes ; then
434		AC_MSG_WARN([slapd disabled, ignoring --enable-dynacl argument])
435	fi
436	if test $ol_enable_aci != no ; then
437		AC_MSG_WARN([slapd disabled, ignoring --enable-aci argument])
438	fi
439	if test $ol_enable_rewrite = yes ; then
440		AC_MSG_WARN([slapd disabled, ignoring --enable-rewrite argument])
441	fi
442	dnl overlays
443	case "$ol_enable_overlays" in yes | mod)
444		AC_MSG_WARN([slapd disabled, ignoring --enable-overlays argument])
445	esac
446	for i in $Overlays; do
447		eval "ol_tmp=\$ol_enable_$i"
448		if test $ol_tmp != no ; then
449			AC_MSG_WARN([slapd disabled, ignoring --enable-$i argument])
450			eval "ol_enable_$i=no"
451		fi
452	done
453
454	# force settings to no
455	ol_enable_slapi=no
456
457	ol_enable_backends=
458	ol_enable_overlays=
459	ol_enable_modules=no
460	ol_enable_rlookups=no
461	ol_enable_dynacl=no
462	ol_enable_aci=no
463	ol_enable_wrappers=no
464
465	ol_enable_rewrite=no
466
467elif test $ol_enable_modules != yes &&
468	test $ol_enable_bdb = no &&
469	test $ol_enable_dnssrv = no &&
470	test $ol_enable_hdb = no &&
471	test $ol_enable_ldap = no &&
472	test $ol_enable_meta = no &&
473	test $ol_enable_monitor = no &&
474	test $ol_enable_null = no &&
475	test $ol_enable_passwd = no &&
476	test $ol_enable_perl = no &&
477	test $ol_enable_relay = no &&
478	test $ol_enable_shell = no &&
479	test $ol_enable_sock = no &&
480	test $ol_enable_sql = no ; then
481	dnl no slapd backend
482
483	if test $ol_enable_slapd = yes ; then
484		AC_MSG_ERROR([slapd requires a backend])
485	else
486		AC_MSG_WARN([skipping slapd, no backend specified])
487		ol_enable_slapd=no
488	fi
489fi
490
491if test $ol_enable_meta/$ol_enable_ldap = yes/no ; then
492	AC_MSG_ERROR([--enable-meta requires --enable-ldap])
493fi
494
495if test $ol_enable_lmpasswd = yes ; then
496	if test $ol_with_tls = no ; then
497		AC_MSG_ERROR([LAN Manager passwords require TLS])
498	fi
499fi
500
501if test $ol_enable_spasswd = yes ; then
502	if test $ol_with_cyrus_sasl = no ; then
503		AC_MSG_ERROR([options require --with-cyrus-sasl])
504	fi
505	ol_with_cyrus_sasl=yes
506fi
507
508AC_MSG_RESULT(done)
509
510dnl ----------------------------------------------------------------
511dnl Initialize vars
512LDAP_LIBS=
513BDB_LIBS=
514LTHREAD_LIBS=
515LUTIL_LIBS=
516
517SLAPD_LIBS=
518
519BUILD_SLAPD=no
520
521BUILD_THREAD=no
522
523BUILD_SLAPI=no
524SLAPD_SLAPI_DEPEND=
525
526BUILD_BDB=no
527BUILD_DNSSRV=no
528BUILD_HDB=no
529BUILD_LDAP=no
530BUILD_META=no
531BUILD_MONITOR=no
532BUILD_NULL=no
533BUILD_PASSWD=no
534BUILD_PERL=no
535BUILD_RELAY=no
536BUILD_SHELL=no
537BUILD_SOCK=no
538BUILD_SQL=no
539
540BUILD_ACCESSLOG=no
541BUILD_DYNID=no
542BUILD_ODLOCALES=no
543BUILD_ODUSERS=no
544BUILD_AUDITLOG=no
545BUILD_CONSTRAINT=no
546BUILD_DDS=no
547BUILD_DENYOP=no
548BUILD_DEREF=no
549BUILD_DYNGROUP=no
550BUILD_DYNLIST=no
551BUILD_LASTMOD=no
552BUILD_MEMBEROF=no
553BUILD_PPOLICY=no
554BUILD_PROXYCACHE=no
555BUILD_REFINT=no
556BUILD_RETCODE=no
557BUILD_SEQMOD=no
558BUILD_SYNCPROV=no
559BUILD_TRANSLUCENT=no
560BUILD_UNIQUE=no
561BUILD_VALSORT=no
562
563SLAPD_STATIC_OVERLAYS=
564SLAPD_DYNAMIC_OVERLAYS=
565
566SLAPD_MODULES_LDFLAGS=
567SLAPD_MODULES_CPPFLAGS=
568
569SLAPD_STATIC_BACKENDS=back-ldif
570SLAPD_DYNAMIC_BACKENDS=
571
572SLAPD_PERL_LDFLAGS=
573MOD_PERL_LDFLAGS=
574PERL_CPPFLAGS=
575
576SLAPD_SQL_LDFLAGS=
577SLAPD_SQL_LIBS=
578SLAPD_SQL_INCLUDES=
579
580KRB4_LIBS=
581KRB5_LIBS=
582SASL_LIBS=
583TLS_LIBS=
584MODULES_LIBS=
585SLAPI_LIBS=
586LIBSLAPI=
587LIBSLAPITOOLS=
588AUTH_LIBS=
589ICU_LIBS=
590
591SLAPD_SLP_LIBS=
592SLAPD_GMP_LIBS=
593
594dnl ================================================================
595dnl Checks for programs
596
597AC_DEFINE(HAVE_MKVERSION, 1, [define this if you have mkversion])
598
599dnl ----------------------------------------------------------------
600dnl
601dnl Determine which C translator to use
602dnl
603
604dnl AIX Thread requires we use cc_r or xlc_r.
605dnl But only do this IF AIX and CC is not set
606dnl and threads are auto|yes|posix.
607dnl
608dnl If we find cc_r|xlc_r, force pthreads and assume
609dnl		pthread_create is in $LIBS (ie: don't bring in
610dnl		any additional thread libraries)
611dnl If we do not find cc_r|xlc_r, disable threads
612
613ol_aix_threads=no
614case "$target" in
615*-*-aix*) dnl all AIX is not a good idea.
616	if test -z "$CC" ; then
617		case "$ol_with_threads" in
618		auto | yes |  posix) ol_aix_threads=yes ;;
619		esac
620	fi
621;;
622esac
623
624if test $ol_aix_threads = yes ; then
625	if test -z "${CC}" ; then
626		AC_CHECK_PROGS(CC,cc_r xlc_r cc)
627
628		if test "$CC" = cc ; then
629			dnl no CC! don't allow --with-threads
630			if test $ol_with_threads != auto ; then
631				AC_MSG_ERROR([--with-threads requires cc_r (or other suitable compiler) on AIX])
632			else
633				AC_MSG_WARN([disabling threads, no cc_r on AIX])
634			fi
635			ol_with_threads=no
636  		fi
637	fi
638
639	case ${CC} in cc_r | xlc_r)
640		ol_with_threads=posix
641		ol_cv_pthread_create=yes
642		;;
643	esac
644fi
645
646if test -z "${CC}"; then
647	AC_CHECK_PROGS(CC,cc gcc,missing)
648
649	if test "${CC}" = "missing" ; then
650		AC_MSG_ERROR([Unable to locate cc(1) or suitable replacement.  Check PATH or set CC.])
651	fi
652fi
653
654if test -z "${AR}"; then
655	AC_CHECK_PROGS(AR,ar gar,missing)
656
657	if test "${AR}" = "missing" ; then
658		AC_MSG_ERROR([Unable to locate ar(1) or suitable replacement.  Check PATH or set AR.])
659	fi
660fi
661
662AC_LIBTOOL_WIN32_DLL
663AC_LIBTOOL_DLOPEN
664AC_PROG_LIBTOOL
665
666dnl ----------------------------------------------------------------
667dnl Perl
668ol_link_perl=no
669if test $ol_enable_perl != no ; then
670	AC_PATH_PROG(PERLBIN, perl, /usr/bin/perl)
671
672	if test "no$PERLBIN" = "no" ; then
673		if test $ol_enable_perl = yes ; then
674			AC_MSG_ERROR([could not locate perl])
675		fi
676
677	else
678		PERL_CPPFLAGS="`$PERLBIN -MExtUtils::Embed -e ccopts`"
679		PERL_LDFLAGS="`$PERLBIN -MExtUtils::Embed -e ldopts|sed -e 's/ -lc / /' -e 's/ -lc$//'`"
680
681		if test x"$ol_enable_perl" = "xyes" ; then
682			SLAPD_PERL_LDFLAGS="$PERL_LDFLAGS"
683		else
684			MOD_PERL_LDFLAGS="$PERL_LDFLAGS"
685		fi
686		dnl should check perl version
687		ol_link_perl=yes
688	fi
689fi
690
691AC_PROG_CPP
692OL_MSVC
693
694dnl ----------------------------------------------------------------
695dnl Checks for Windows NT
696case $host_os in
697  *mingw32* ) ac_cv_mingw32=yes ;;
698  *cygwin* ) ac_cv_cygwin=yes ;;
699  *interix* ) ac_cv_interix=yes ;;
700esac
701
702dnl ----------------------------------------------------------------
703dnl Checks for file extensions
704AC_EXEEXT
705AC_OBJEXT
706AC_DEFINE_UNQUOTED(EXEEXT, "${EXEEXT}", [defined to be the EXE extension])
707
708dnl ----------------------------------------------------------------
709dnl BeOS requires -lbe -lroot -lnet
710AC_CHECK_LIB(be, be_app, [LIBS="$LIBS -lbe -lroot -lnet"], :, [-lroot -lnet])
711
712dnl ----------------------------------------------------------------
713dnl OpenLDAP requires STDC features
714AC_PROG_CC
715if test "X${ac_cv_prog_cc_stdc}" = "Xno" ; then
716	AC_MSG_ERROR([OpenLDAP requires compiler to support STDC constructs.])
717fi
718
719dnl ----------------------------------------------------------------
720dnl Check cc depend flags
721OL_MKDEPEND
722if test "${ol_cv_mkdep}" = no ; then
723	# this will soon become an error
724	AC_MSG_WARN([do not know how to generate dependencies])
725fi
726
727dnl ----------------------------------------------------------------
728dnl Check for AIX security library
729AC_CHECK_LIB(s, afopen, [
730	AUTH_LIBS=-ls
731	AC_DEFINE(HAVE_AIX_SECURITY,1,[define if you have AIX security lib])
732])
733
734dnl ----------------------------------------------------------------
735dnl Check for IBM OS/390
736case "$target" in
737*-ibm-openedition)
738	ac_cv_func_getopt=no
739	AC_DEFINE(BOTH_STRINGS_H,1,[define to use both <string.h> and <strings.h>])
740	;;
741esac
742
743dnl ----------------------------------------------------------------
744dnl Check for module support
745ol_link_modules=no
746WITH_MODULES_ENABLED=no
747if test $ol_enable_modules != no ; then
748	AC_CHECK_HEADERS(ltdl.h)
749
750	if test $ac_cv_header_ltdl_h = no ; then
751		AC_MSG_ERROR([could not locate libtool ltdl.h])
752	fi
753
754	AC_CHECK_LIB(ltdl, lt_dlinit, [
755		MODULES_LIBS=-lltdl
756		AC_DEFINE(HAVE_LIBLTDL,1,[define if you have libtool -ltdl])
757	])
758
759	if test "$ac_cv_lib_ltdl_lt_dlinit" = no ; then
760		AC_MSG_ERROR([could not locate libtool -lltdl])
761	fi
762	ol_link_modules=yes
763	WITH_MODULES_ENABLED=yes
764
765else
766	for i in $Backends; do
767		eval "ol_tmp=\$ol_enable_$i"
768		if test $ol_tmp = mod ; then
769			AC_MSG_WARN([building static $i backend])
770			eval "ol_enable_$i=yes"
771		fi
772	done
773	for i in $Overlays; do
774		eval "ol_tmp=\$ol_enable_$i"
775		if test $ol_tmp = mod ; then
776			AC_MSG_WARN([building static $i overlay])
777			eval "ol_enable_$i=yes"
778		fi
779	done
780fi
781
782dnl ----------------------------------------------------------------
783dnl Checks for header files.
784OL_HEADER_STDC
785
786if test $ol_cv_header_stdc != yes; then
787	AC_MSG_WARN([could not locate Standard C compliant headers])
788fi
789
790AC_HEADER_DIRENT
791AC_HEADER_SYS_WAIT
792AC_HEADER_TIOCGWINSZ
793
794AC_CHECK_HEADERS(	\
795	arpa/inet.h		\
796	arpa/nameser.h	\
797	assert.h		\
798	bits/types.h	\
799	conio.h			\
800	crypt.h			\
801	direct.h		\
802	errno.h			\
803	fcntl.h			\
804	filio.h			\
805	getopt.h		\
806	grp.h			\
807	io.h			\
808	libutil.h		\
809	limits.h		\
810	locale.h		\
811	malloc.h		\
812	memory.h		\
813	psap.h			\
814	pwd.h			\
815	process.h		\
816	sgtty.h			\
817	shadow.h		\
818	stddef.h		\
819	string.h		\
820	strings.h		\
821	sysexits.h		\
822	sys/file.h		\
823	sys/filio.h		\
824	sys/fstyp.h		\
825	sys/errno.h		\
826	sys/ioctl.h		\
827	sys/param.h		\
828	sys/privgrp.h	\
829	sys/resource.h	\
830	sys/select.h	\
831	sys/socket.h	\
832	sys/stat.h		\
833	sys/syslog.h	\
834	sys/time.h		\
835	sys/types.h		\
836	sys/uio.h		\
837	sys/vmount.h	\
838	syslog.h		\
839	termios.h		\
840	unistd.h		\
841	utime.h			\
842)
843
844dnl Only check Winsock on MinGW
845if test "$ac_cv_mingw32" = yes \
846	-o "$ac_cv_interix" = yes \
847	-o "$ol_cv_msvc" = yes
848then
849	AC_CHECK_HEADERS( winsock.h winsock2.h )
850fi
851
852AC_CHECK_HEADERS( resolv.h, [], [],
853[$ac_includes_default
854#include <netinet/in.h>
855])
856
857AC_CHECK_HEADERS( netinet/tcp.h, [], [],
858[$ac_includes_default
859#include <netinet/in.h>
860])
861
862AC_CHECK_HEADERS( sys/ucred.h, [], [],
863[$ac_includes_default
864#ifdef HAVE_SYS_PARAM_H
865#include <sys/param.h>
866#endif
867])
868
869dnl ----------------------------------------------------------------
870dnl Checks for libraries
871
872AC_CHECK_FUNCS( sigaction sigset )
873
874dnl HP-UX requires -lV3
875dnl this is not needed on newer versions of HP-UX
876if test $ac_cv_func_sigaction = no && test $ac_cv_func_sigaction = no ; then
877	AC_CHECK_LIB(V3, sigset)
878fi
879
880if test $ol_cv_msvc = yes ; then
881   ol_cv_winsock=yes
882fi
883
884dnl The following is INTENTIONALLY scripted out because shell does not
885dnl support variable names with the '@' character, which is what
886dnl autoconf would try to generate if one merely used AC_SEARCH_LIBS
887if test "$ac_cv_header_winsock_h" = yes; then
888	AC_CACHE_CHECK([for winsock], [ol_cv_winsock],[
889	save_LIBS="$LIBS"
890	for curlib in none ws2_32 wsock32; do
891		if test $curlib != none ; then
892	    	LIBS="$save_LIBS -l$curlib"
893		fi
894		AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <winsock.h>
895			]], [[
896			socket(0,0,0);
897			select(0,NULL,NULL,NULL,NULL);
898			closesocket(0);
899			gethostname(NULL,0);
900			]])],[ol_cv_winsock=$curlib],[ol_cv_winsock=no])
901
902		test "$ol_cv_winsock" != no && break
903	done
904	LIBS="$save_LIBS"
905	])
906
907	if test $ol_cv_winsock != no ; then
908    	AC_DEFINE(HAVE_WINSOCK, 1, [define if you have winsock])
909    	ac_cv_func_socket=yes
910    	ac_cv_func_select=yes
911    	ac_cv_func_closesocket=yes
912    	ac_cv_func_gethostname=yes
913
914		if test $ol_cv_winsock != none -a $ol_cv_winsock != yes ; then
915        	LIBS="$LIBS -l$ol_cv_winsock"
916		fi
917
918    	if test $ol_cv_winsock = ws2_32 -o $ol_cv_winsock = yes ; then
919			AC_DEFINE(HAVE_WINSOCK2, 1, [define if you have winsock2])
920    	fi
921	fi
922fi
923
924dnl Find socket()
925dnl Likely combinations:
926dnl		-lsocket [ -lnsl_s | -lnsl ]
927dnl		-linet
928
929AC_CHECK_FUNC(socket, :, [	
930dnl hopefully we won't include too many libraries
931	AC_CHECK_LIB(socket, main)
932	AC_CHECK_LIB(net, socket)
933	AC_CHECK_LIB(nsl_s, main)
934	AC_CHECK_LIB(nsl, main)
935	AC_CHECK_LIB(inet, socket)
936	AC_CHECK_LIB(gen, main)
937])
938
939dnl require select
940AC_CHECK_FUNC(select, :, AC_MSG_ERROR([select() required.]))
941
942if test "${ac_cv_header_winsock_h}" != yes; then
943	dnl Select arg types
944	dnl (if this detection becomes permenent, it and the select() detection
945	dnl should be done before the yielding select test) 
946	AC_FUNC_SELECT_ARGTYPES
947fi
948
949dnl check to see if system call automatically restart
950dnl AC_SYS_RESTARTABLE_SYSCALLS
951
952dnl ----------------------------------------------------------------
953AC_CHECK_FUNCS( poll )
954if test $ac_cv_func_poll = yes; then
955AC_CHECK_HEADERS( poll.h sys/poll.h )
956fi
957
958dnl ----------------------------------------------------------------
959AC_CHECK_HEADERS( sys/epoll.h )
960if test "${ac_cv_header_sys_epoll_h}" = yes; then
961	AC_MSG_CHECKING(for epoll system call)
962	AC_RUN_IFELSE([AC_LANG_SOURCE([[int main(int argc, char **argv)
963{
964	int epfd = epoll_create(256);
965	exit (epfd == -1 ? 1 : 0);
966}]])],[AC_MSG_RESULT(yes)
967	AC_DEFINE(HAVE_EPOLL,1, [define if your system supports epoll])],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)])
968fi
969
970dnl ----------------------------------------------------------------
971AC_CHECK_HEADERS( sys/event.h )
972if test "${ac_cv_header_sys_event_h}" = yes; then
973AC_MSG_CHECKING(for kqueue system call)
974AC_RUN_IFELSE([AC_LANG_SOURCE([[int main(int argc, char **argv)
975{
976	int kqfd = kqueue();
977	exit (kqfd == -1 ? 1 : 0);
978}]])],[AC_MSG_RESULT(yes)
979AC_DEFINE(HAVE_KQUEUE,1, [define if your system supports kqueue])],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)])
980fi
981
982dnl ----------------------------------------------------------------
983AC_CHECK_HEADERS( sys/devpoll.h )
984dnl "/dev/poll" needs <sys/poll.h> as well...
985if test "${ac_cv_header_sys_devpoll_h}" = yes \
986		-a "${ac_cv_header_poll_h}" = yes ; \
987then
988	AC_MSG_CHECKING(for /dev/poll)
989	AC_RUN_IFELSE([AC_LANG_SOURCE([[int main(int argc, char **argv)
990{
991	int devpollfd = open("/dev/poll", /* O_RDWR */ 2);
992	exit (devpollfd == -1 ? 1 : 0);
993}]])],[AC_MSG_RESULT(yes)
994	AC_DEFINE(HAVE_DEVPOLL,1, [define if your system supports /dev/poll])],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)])
995fi
996
997dnl ----------------------------------------------------------------
998# strerror checks
999OL_STRERROR
1000
1001dnl ----------------------------------------------------------------
1002dnl require POSIX regex
1003AC_CHECK_HEADERS( regex.h, [], [],
1004[$ac_includes_default
1005#ifdef HAVE_SYS_TYPES_H
1006#include <sys/types.h>
1007#endif
1008])
1009
1010if test "$ac_cv_header_regex_h" != yes ; then
1011	AC_MSG_ERROR([POSIX regex.h required.])
1012fi
1013AC_SEARCH_LIBS(regfree, [regex gnuregex],
1014	:, AC_MSG_ERROR([POSIX regex required.]))
1015
1016OL_POSIX_REGEX
1017if test "$ol_cv_c_posix_regex" = no ; then
1018	AC_MSG_ERROR([broken POSIX regex!])
1019fi
1020
1021dnl ----------------------------------------------------------------
1022dnl UUID Support
1023
1024have_uuid=no
1025AC_CHECK_HEADERS(sys/uuid.h)
1026dnl The HAVE_UUID_TO_STR code path also needs uuid_create
1027if test $ac_cv_header_sys_uuid_h = yes ; then
1028	save_LIBS="$LIBS"
1029	AC_SEARCH_LIBS([uuid_to_str], [uuid], [have_uuid=yes], :)
1030	AC_SEARCH_LIBS([uuid_create], [uuid], :, [have_uuid=no])
1031	LIBS="$save_LIBS"
1032
1033	if test $have_uuid = yes ; then
1034		AC_DEFINE(HAVE_UUID_TO_STR,1,
1035			[define if you have uuid_to_str()])
1036
1037		test "$ac_cv_search_uuid_to_str" = "none required" || \
1038			SLAPD_LIBS="$SLAPD_LIBS $ac_cv_search_uuid_to_str"
1039	fi
1040fi
1041
1042dnl Look for uuid_generate
1043dnl The HAVE_UUID_GENERATE code path also needs uuid_unparse_lower
1044if test $have_uuid = no ; then
1045	AC_CHECK_HEADERS(uuid/uuid.h)
1046	if test $ac_cv_header_uuid_uuid_h = yes ; then
1047		save_LIBS="$LIBS"
1048		AC_SEARCH_LIBS([uuid_generate], [uuid], [have_uuid=yes], :)
1049		AC_SEARCH_LIBS([uuid_unparse_lower], [uuid], :, [have_uuid=no])
1050		LIBS="$save_LIBS"
1051
1052		if test $have_uuid = yes ; then
1053			AC_DEFINE(HAVE_UUID_GENERATE,1,
1054				[define if you have uuid_generate()])
1055
1056			test "$ac_cv_search_uuid_generate" = "none required" || \
1057				SLAPD_LIBS="$SLAPD_LIBS $ac_cv_search_uuid_generate"
1058		fi
1059	fi
1060fi
1061
1062dnl For windows, check for the need of RPCRT for UUID function support
1063if test $have_uuid = no ; then
1064	AC_MSG_CHECKING(to see if -lrpcrt4 is needed for win32 UUID support)
1065	save_LIBS="$LIBS"
1066	LIBS="$LIBS -lrpcrt4"
1067	AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1068		int __stdcall UuidCreate(void *);
1069		int __stdcall UuidToStringA(void *,void **);
1070		]], [[
1071		UuidCreate(0);
1072		UuidToStringA(0,0);
1073		]])],[need_rpcrt=yes],[need_rpcrt=no])
1074	if test $need_rpcrt = yes; then
1075		SLAPD_LIBS="$SLAPD_LIBS -lrpcrt4"
1076	fi
1077	LIBS="$save_LIBS"
1078	AC_MSG_RESULT($need_rpcrt)
1079fi
1080
1081dnl ----------------------------------------------------------------
1082dnl Check for resolver routines
1083OL_RESOLVER_LINK
1084
1085ol_link_dnssrv=no
1086if test "$ol_cv_lib_resolver" != no ; then
1087	AC_DEFINE(HAVE_RES_QUERY,1,
1088		[define if you have res_query()])
1089
1090	if test "$ol_enable_dnssrv" != no ; then
1091		ol_link_dnssrv=yes
1092	fi
1093
1094	if test "$ol_cv_lib_resolver" != yes ; then
1095		LIBS="$ol_cv_lib_resolver $LIBS"
1096	fi
1097fi
1098
1099if test "$ol_enable_dnssrv" = yes || test "$ol_enable_dnssrv" = mod ; then
1100	if test "$ol_link_dnssrv" = no ; then
1101		AC_MSG_ERROR([DNSSRV requires res_query()])
1102	fi
1103else
1104	ol_enable_dnssrv=no
1105fi
1106
1107AC_CHECK_FUNCS( hstrerror )
1108
1109dnl ----------------------------------------------------------------
1110dnl PF_INET6 support requires getaddrinfo and INET6_ADDRSTRLEN
1111dnl PF_LOCAL may use getaddrinfo in available
1112AC_CHECK_FUNCS( getaddrinfo getnameinfo gai_strerror inet_ntop )
1113
1114ol_link_ipv6=no
1115if test $ac_cv_func_getaddrinfo = no || test $ac_cv_func_inet_ntop = no ; then
1116	if test $ol_enable_ipv6 = yes ; then
1117		AC_MSG_ERROR([IPv6 support requires getaddrinfo() and inet_ntop()])
1118	fi
1119elif test $ol_enable_ipv6 != no ; then
1120	AC_CACHE_CHECK([INET6_ADDRSTRLEN],[ol_cv_inet6_addrstrlen],[
1121		AC_EGREP_CPP(__has_inet6_addrstrlen__,[
1122#			include <netinet/in.h>
1123#			ifdef INET6_ADDRSTRLEN
1124				__has_inet6_addrstrlen__;
1125#			endif
1126		], [ol_cv_inet6_addrstrlen=yes], [ol_cv_inet6_addrstrlen=no])])
1127
1128
1129	AC_CACHE_CHECK([struct sockaddr_storage],ol_cv_struct_sockaddr_storage,[
1130		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1131#include <sys/types.h>
1132#include <sys/socket.h>
1133]], [[
1134			struct sockaddr_storage ss;
1135]])],[ol_cv_struct_sockaddr_storage=yes],[ol_cv_struct_sockaddr_storage=no])])
1136
1137	if test $ol_cv_inet6_addrstrlen = yes &&
1138	   test $ol_cv_struct_sockaddr_storage = yes ; then
1139		ol_link_ipv6=yes
1140	elif test $ol_enable_ipv6 = yes &&
1141	     test $ol_cv_inet6_addrstrlen = no ; then
1142		AC_MSG_ERROR([IPv6 support requires INET6_ADDRSTRLEN])
1143	elif test $ol_enable_ipv6 = yes &&
1144	     test $ol_cv_struct_sockaddr_storage = no ; then
1145		AC_MSG_ERROR([IPv6 support requires struct sockaddr_storage])
1146	fi
1147fi
1148
1149if test $ol_enable_local != no ; then
1150	AC_CHECK_HEADERS( sys/un.h )
1151
1152	if test $ol_enable_local = auto ; then
1153		ol_enable_local=$ac_cv_header_sys_un_h
1154	elif test $ac_cv_header_sys_un_h = no ; then
1155		AC_MSG_ERROR([AF_LOCAL domain support requires sys/un.h])
1156	fi
1157fi
1158
1159dnl ----------------------------------------------------------------
1160dnl TLS/SSL
1161	
1162if test $ol_with_tls = yes ; then
1163	ol_with_tls=auto
1164fi
1165
1166ol_link_tls=no
1167if test $ol_with_tls = secure-transport || test $ol_with_tls = auto ; then
1168	save_CPPFLAGS="$CPPFLAGS"
1169	CPPFLAGS="$CPPFLAGS -F/System/Library/PrivateFrameworks"
1170	AC_CHECK_HEADERS(Security/SecureTransport.h CoreDaemon/XSCipher.h)
1171	CPPFLAGS="$save_CPPFLAGS"
1172	if test $ac_cv_header_Security_SecureTransport_h = yes &&
1173	   test $ac_cv_header_CoreDaemon_XSCipher_h = yes ; then
1174		ol_with_tls=secure-transport
1175		ol_link_tls=yes
1176		AC_DEFINE(HAVE_SECURE_TRANSPORT, 1, [define if you have SecureTransport])
1177		TLS_LIBS="-framework Security -framework CoreDaemon"
1178	elif test $ol_with_tls = secure-transport ; then
1179		AC_ERROR([Can't build with SecureTransport: required header not found])
1180	fi
1181fi
1182
1183if test $ol_link_tls = no ; then
1184	if test $ol_with_tls = openssl || test $ol_with_tls = auto ; then
1185		AC_CHECK_HEADERS(openssl/ssl.h)
1186
1187		if test $ac_cv_header_openssl_ssl_h = yes ; then
1188			AC_CHECK_LIB(ssl, SSL_library_init,
1189				[have_openssl=yes
1190				need_rsaref=no], [have_openssl=no],
1191				[-lcrypto])
1192
1193			if test $have_openssl = no ; then
1194				AC_CHECK_LIB(ssl, ssl3_accept, 
1195					[have_openssl=yes
1196					need_rsaref=yes], [have_openssl=no],
1197					[-lcrypto -lRSAglue -lrsaref])
1198			fi
1199
1200			if test $have_openssl = yes ; then
1201				ol_with_tls=openssl
1202				ol_link_tls=yes
1203
1204				AC_DEFINE(HAVE_OPENSSL, 1, 
1205					[define if you have OpenSSL])
1206
1207				if test $need_rsaref = yes; then
1208					AC_DEFINE(HAVE_RSAREF, 1, 
1209						[define if OpenSSL needs RSAref])
1210
1211					TLS_LIBS="-lssl -lcrypto -lRSAglue -lrsaref"
1212				else
1213					TLS_LIBS="-lssl -lcrypto"
1214				fi
1215
1216				OL_SSL_COMPAT
1217				if test $ol_cv_ssl_crl_compat = yes ; then
1218					AC_DEFINE(HAVE_OPENSSL_CRL, 1, 
1219						[define if you have OpenSSL with CRL checking capability])
1220				fi
1221			fi
1222		fi
1223	fi
1224fi
1225
1226if test $ol_link_tls = no ; then
1227	if test $ol_with_tls = gnutls || test $ol_with_tls = auto ; then
1228		AC_CHECK_HEADERS(gnutls/gnutls.h)
1229
1230		if test $ac_cv_header_gnutls_gnutls_h = yes ; then
1231			AC_CHECK_LIB(gnutls, gnutls_init,
1232				[have_gnutls=yes], [have_gnutls=no])
1233
1234			if test $have_gnutls = yes ; then
1235				ol_with_tls=gnutls
1236				ol_link_tls=yes
1237
1238				TLS_LIBS="-lgnutls"
1239
1240				AC_DEFINE(HAVE_GNUTLS, 1, 
1241					[define if you have GNUtls])
1242			fi
1243		fi
1244	fi
1245fi
1246
1247WITH_TLS=no
1248if test $ol_link_tls = yes ; then
1249	AC_DEFINE(HAVE_TLS, 1, [define if you have TLS])
1250	WITH_TLS=yes
1251elif test $ol_with_tls = auto ; then
1252	AC_MSG_WARN([Could not locate TLS/SSL package])
1253	AC_MSG_WARN([TLS data protection not supported!])
1254elif test $ol_with_tls != no ; then
1255	AC_MSG_ERROR([Could not locate TLS/SSL package])
1256else
1257	AC_MSG_WARN([TLS data protection not supported!])
1258fi
1259
1260dnl ----------------------------------------------------------------
1261dnl LAN Manger password checking requires DES from OpenSSL
1262if test $ol_enable_lmpasswd != no; then
1263	if test $ol_link_tls != yes ; then
1264		AC_MSG_ERROR([LAN Manager passwords require TLS])
1265	fi
1266
1267	AC_DEFINE(SLAPD_LMHASH, 1, [define to support LAN Manager passwords])
1268fi
1269
1270dnl ----------------------------------------------------------------
1271dnl Threads?
1272ol_link_threads=no
1273
1274case $ol_with_threads in auto | yes | nt)
1275
1276	OL_NT_THREADS
1277
1278	if test "$ol_cv_nt_threads" = yes ; then
1279		ol_link_threads=nt
1280		ol_with_threads=found
1281		ol_with_yielding_select=yes
1282
1283		AC_DEFINE(HAVE_NT_SERVICE_MANAGER,1,[if you have NT Service Manager])
1284		AC_DEFINE(HAVE_NT_EVENT_LOG,1,[if you have NT Event Log])
1285	fi
1286
1287	if test $ol_with_threads = nt ; then
1288		AC_MSG_ERROR([could not locate NT Threads])
1289	fi
1290	;;
1291esac
1292
1293case $ol_with_threads in auto | yes | posix)
1294
1295	AC_CHECK_HEADERS(pthread.h)
1296
1297	if test $ac_cv_header_pthread_h = yes ; then
1298		OL_POSIX_THREAD_VERSION
1299
1300		if test $ol_cv_pthread_version != 0 ; then
1301			AC_DEFINE_UNQUOTED(HAVE_PTHREADS,$ol_cv_pthread_version,
1302				[define to pthreads API spec revision])
1303		else
1304			AC_MSG_ERROR([unknown pthread version])
1305		fi
1306
1307		# consider threads found
1308		ol_with_threads=found
1309
1310		OL_HEADER_LINUX_THREADS
1311		OL_HEADER_GNU_PTH_PTHREAD_H
1312
1313		if test $ol_cv_header_gnu_pth_pthread_h = no ; then
1314			AC_CHECK_HEADERS(sched.h)
1315		fi
1316
1317		dnl Now the hard part, how to link?
1318		dnl
1319		dnl currently supported checks:
1320		dnl
1321		dnl Check for no flags 
1322		dnl 	pthread_create() in $LIBS
1323		dnl
1324		dnl Check special pthread (final) flags
1325		dnl 	[skipped] pthread_create() with -mt (Solaris) [disabled]
1326		dnl 	pthread_create() with -kthread (FreeBSD)
1327		dnl 	pthread_create() with -pthread (FreeBSD/Digital Unix)
1328		dnl 	pthread_create() with -pthreads (?)
1329		dnl 	pthread_create() with -mthreads (AIX)
1330		dnl 	pthread_create() with -thread (?)
1331		dnl
1332		dnl Check pthread (final) libraries
1333		dnl 	pthread_mutex_unlock() in -lpthread -lmach -lexc -lc_r (OSF/1)
1334		dnl 	pthread_mutex_lock() in -lpthread -lmach -lexc (OSF/1)
1335		dnl 	[skipped] pthread_mutex_trylock() in -lpthread -lexc (OSF/1)
1336		dnl 	pthread_join() -Wl,-woff,85 -lpthread (IRIX)
1337		dnl 	pthread_create() in -lpthread (many)
1338		dnl 	pthread_create() in -lc_r (FreeBSD)
1339		dnl
1340		dnl Check pthread (draft4) flags (depreciated)
1341		dnl 	pthread_create() with -threads (OSF/1)
1342		dnl
1343		dnl Check pthread (draft4) libraries (depreciated)
1344		dnl 	pthread_mutex_unlock() in -lpthreads -lmach -lexc -lc_r (OSF/1)
1345		dnl 	pthread_mutex_lock() in -lpthreads -lmach -lexc (OSF/1)
1346		dnl 	pthread_mutex_trylock() in -lpthreads -lexc (OSF/1)
1347		dnl 	pthread_create() in -lpthreads (many)
1348		dnl
1349
1350		dnl pthread_create in $LIBS
1351		AC_CACHE_CHECK([for pthread_create in default libraries],
1352			ol_cv_pthread_create,[
1353			AC_RUN_IFELSE([OL_PTHREAD_TEST_PROGRAM],
1354				[ol_cv_pthread_create=yes],
1355				[ol_cv_pthread_create=no],
1356				[AC_TRY_LINK(OL_PTHREAD_TEST_INCLUDES,OL_PTHREAD_TEST_FUNCTION,
1357					[ol_cv_pthread_create=yes],
1358					[ol_cv_pthread_create=no])])])
1359
1360		if test $ol_cv_pthread_create != no ; then
1361			ol_link_threads=posix
1362			ol_link_pthreads=""
1363		fi
1364		
1365dnl		OL_PTHREAD_TRY([-mt],		[ol_cv_pthread_mt])
1366		OL_PTHREAD_TRY([-kthread],	[ol_cv_pthread_kthread])
1367		OL_PTHREAD_TRY([-pthread],	[ol_cv_pthread_pthread])
1368		OL_PTHREAD_TRY([-pthreads],	[ol_cv_pthread_pthreads])
1369		OL_PTHREAD_TRY([-mthreads],	[ol_cv_pthread_mthreads])
1370		OL_PTHREAD_TRY([-thread],	[ol_cv_pthread_thread])
1371
1372		OL_PTHREAD_TRY([-lpthread -lmach -lexc -lc_r],
1373			[ol_cv_pthread_lpthread_lmach_lexc_lc_r])
1374		OL_PTHREAD_TRY([-lpthread -lmach -lexc],
1375			[ol_cv_pthread_lpthread_lmach_lexc])
1376dnl		OL_PTHREAD_TRY([-lpthread -lexc],
1377dnl			[ol_cv_pthread_lpthread_lexc])
1378
1379		OL_PTHREAD_TRY([-lpthread -Wl,-woff,85],
1380			[ol_cv_pthread_lib_lpthread_woff])
1381
1382		OL_PTHREAD_TRY([-lpthread],	[ol_cv_pthread_lpthread])
1383		OL_PTHREAD_TRY([-lc_r],		[ol_cv_pthread_lc_r])
1384
1385		OL_PTHREAD_TRY([-threads],	[ol_cv_pthread_threads])
1386
1387		OL_PTHREAD_TRY([-lpthreads -lmach -lexc -lc_r],
1388			[ol_cv_pthread_lpthreads_lmach_lexc_lc_r])
1389		OL_PTHREAD_TRY([-lpthreads -lmach -lexc],
1390			[ol_cv_pthread_lpthreads_lmach_lexc])
1391		OL_PTHREAD_TRY([-lpthreads -lexc],
1392			[ol_cv_pthread_lpthreads_lexc])
1393
1394		OL_PTHREAD_TRY([-lpthreads],[ol_cv_pthread_lib_lpthreads])
1395
1396		if test $ol_link_threads != no ; then
1397			LTHREAD_LIBS="$LTHREAD_LIBS $ol_link_pthreads"
1398
1399			dnl save flags
1400			save_CPPFLAGS="$CPPFLAGS"
1401			save_LIBS="$LIBS"
1402			LIBS="$LTHREAD_LIBS $LIBS"
1403
1404			dnl All POSIX Thread (final) implementations should have
1405			dnl sched_yield instead of pthread yield.
1406			dnl check for both, and thr_yield for Solaris
1407			AC_CHECK_FUNCS(sched_yield pthread_yield thr_yield)
1408
1409			if test $ac_cv_func_sched_yield = no &&
1410			   test $ac_cv_func_pthread_yield = no &&
1411			   test $ac_cv_func_thr_yield = no ; then
1412				dnl Digital UNIX has sched_yield() in -lrt
1413				AC_CHECK_LIB(rt, sched_yield,
1414					[LTHREAD_LIBS="$LTHREAD_LIBS -lrt"
1415					AC_DEFINE(HAVE_SCHED_YIELD,1,
1416						[Define if you have the sched_yield function.])
1417					ac_cv_func_sched_yield=yes],
1418					[ac_cv_func_sched_yield=no])
1419			fi
1420			if test $ac_cv_func_sched_yield = no &&
1421			   test $ac_cv_func_pthread_yield = no &&
1422			   test "$ac_cv_func_thr_yield" = no ; then
1423				AC_MSG_WARN([could not locate sched_yield() or pthread_yield()])
1424			fi
1425
1426			dnl Check functions for compatibility
1427			AC_CHECK_FUNCS(pthread_kill)
1428
1429			dnl Check for pthread_rwlock_destroy with <pthread.h>
1430			dnl as pthread_rwlock_t may not be defined.
1431			AC_CACHE_CHECK([for pthread_rwlock_destroy with <pthread.h>],
1432				[ol_cv_func_pthread_rwlock_destroy], [
1433				dnl save the flags
1434				AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1435#include <pthread.h>
1436pthread_rwlock_t rwlock;
1437]], [[pthread_rwlock_destroy(&rwlock);]])],[ol_cv_func_pthread_rwlock_destroy=yes],[ol_cv_func_pthread_rwlock_destroy=no])
1438			])
1439			if test $ol_cv_func_pthread_rwlock_destroy = yes ; then
1440				AC_DEFINE(HAVE_PTHREAD_RWLOCK_DESTROY,1,
1441					[define if you have pthread_rwlock_destroy function])
1442			fi
1443
1444			dnl Check for pthread_detach with <pthread.h> inclusion
1445			dnl as it's symbol may have been mangled.
1446			AC_CACHE_CHECK([for pthread_detach with <pthread.h>],
1447				[ol_cv_func_pthread_detach], [
1448				dnl save the flags
1449				AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1450#include <pthread.h>
1451#ifndef NULL
1452#define NULL (void*)0
1453#endif
1454]], [[pthread_detach(NULL);]])],[ol_cv_func_pthread_detach=yes],[ol_cv_func_pthread_detach=no])
1455			])
1456
1457			if test $ol_cv_func_pthread_detach = no ; then
1458				AC_MSG_ERROR([could not locate pthread_detach()])
1459			fi
1460
1461			AC_DEFINE(HAVE_PTHREAD_DETACH,1,
1462				[define if you have pthread_detach function])
1463
1464			dnl Check for setconcurreny functions
1465			AC_CHECK_FUNCS(	\
1466				pthread_setconcurrency \
1467				pthread_getconcurrency \
1468				thr_setconcurrency \
1469				thr_getconcurrency \
1470			)
1471
1472			OL_SYS_LINUX_THREADS
1473			OL_LINUX_THREADS
1474
1475			if test $ol_cv_linux_threads = error; then
1476				AC_MSG_ERROR([LinuxThreads header/library mismatch]);
1477			fi
1478
1479			AC_CACHE_CHECK([if pthread_create() works],
1480				ol_cv_pthread_create_works,[
1481			AC_RUN_IFELSE([OL_PTHREAD_TEST_PROGRAM],
1482				[ol_cv_pthread_create_works=yes],
1483				[ol_cv_pthread_create_works=no],
1484				[dnl assume yes
1485				ol_cv_pthread_create_works=yes])])
1486
1487			if test $ol_cv_pthread_create_works = no ; then
1488				AC_MSG_ERROR([pthread_create is not usable, check environment settings])
1489			fi
1490
1491			ol_replace_broken_yield=no
1492dnl			case "$target" in
1493dnl			*-*-linux*) 
1494dnl				AC_CHECK_FUNCS(nanosleep)
1495dnl				ol_replace_broken_yield=yes
1496dnl			;;
1497dnl			esac
1498
1499			if test $ol_replace_broken_yield = yes ; then
1500				AC_DEFINE([REPLACE_BROKEN_YIELD],1,
1501					[define if sched_yield yields the entire process])
1502			fi
1503
1504			dnl Check if select causes an yield
1505			if test $ol_with_yielding_select = auto ; then
1506				AC_CACHE_CHECK([if select yields when using pthreads],
1507					ol_cv_pthread_select_yields,[
1508				AC_RUN_IFELSE([AC_LANG_SOURCE([[
1509#include <sys/types.h>
1510#include <sys/time.h>
1511#include <unistd.h>
1512#include <pthread.h>
1513#ifndef NULL
1514#define NULL (void*) 0
1515#endif
1516
1517static int fildes[2];
1518
1519static void *task(p)
1520	void *p;
1521{
1522	int i;
1523	struct timeval tv;
1524
1525	fd_set rfds;
1526
1527	tv.tv_sec=10;
1528	tv.tv_usec=0;
1529
1530	FD_ZERO(&rfds);
1531	FD_SET(fildes[0], &rfds);
1532
1533	/* we're not interested in any fds */
1534	i = select(FD_SETSIZE, &rfds, NULL, NULL, &tv);
1535
1536	if(i < 0) {
1537		perror("select");
1538		exit(10);
1539	}
1540
1541	exit(0); /* if we exit here, the select blocked the whole process */
1542}
1543
1544int main(argc, argv)
1545	int argc;
1546	char **argv;
1547{
1548	pthread_t t;
1549
1550	/* create a pipe to select */
1551	if(pipe(&fildes[0])) {
1552		perror("select");
1553		exit(1);
1554	}
1555
1556#ifdef HAVE_PTHREAD_SETCONCURRENCY
1557	(void) pthread_setconcurrency(2);
1558#else
1559#ifdef HAVE_THR_SETCONCURRENCY
1560	/* Set Solaris LWP concurrency to 2 */
1561	thr_setconcurrency(2);
1562#endif
1563#endif
1564
1565#if HAVE_PTHREADS < 6
1566	pthread_create(&t, pthread_attr_default, task, NULL);
1567#else
1568	pthread_create(&t, NULL, task, NULL);
1569#endif
1570
1571	/* make sure task runs first */
1572#ifdef HAVE_THR_YIELD
1573	thr_yield();
1574#elif defined( HAVE_SCHED_YIELD )
1575	sched_yield();
1576#elif defined( HAVE_PTHREAD_YIELD )
1577	pthread_yield();
1578#endif
1579
1580	exit(2);
1581}]])],[ol_cv_pthread_select_yields=no],[ol_cv_pthread_select_yields=yes],[ol_cv_pthread_select_yields=cross])])
1582
1583				if test $ol_cv_pthread_select_yields = cross ; then
1584					AC_MSG_ERROR([crossing compiling: use --with-yielding_select=yes|no|manual])
1585				fi
1586
1587				if test $ol_cv_pthread_select_yields = yes ; then
1588					ol_with_yielding_select=yes
1589				fi
1590			fi
1591
1592			dnl restore flags
1593			CPPFLAGS="$save_CPPFLAGS"
1594			LIBS="$save_LIBS"
1595		else
1596			AC_MSG_ERROR([could not locate usable POSIX Threads])
1597		fi
1598	fi
1599
1600	if test $ol_with_threads = posix ; then
1601		AC_MSG_ERROR([could not locate POSIX Threads])
1602	fi
1603	;;
1604esac
1605
1606case $ol_with_threads in auto | yes | mach)
1607
1608	dnl check for Mach CThreads
1609	AC_CHECK_HEADERS(mach/cthreads.h cthreads.h)
1610	if test $ac_cv_header_mach_cthreads_h = yes ; then
1611		ol_with_threads=found
1612
1613		dnl check for cthreads support in current $LIBS
1614		AC_CHECK_FUNC(cthread_fork,[ol_link_threads=yes])
1615
1616		if test $ol_link_threads = no ; then
1617			dnl try -all_load
1618			dnl this test needs work
1619			AC_CACHE_CHECK([for cthread_fork with -all_load],
1620				[ol_cv_cthread_all_load], [
1621				dnl save the flags
1622				save_LIBS="$LIBS"
1623				LIBS="-all_load $LIBS"
1624				AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <mach/cthreads.h>]], [[
1625					cthread_fork((void *)0, (void *)0);
1626					]])],[ol_cv_cthread_all_load=yes],[ol_cv_cthread_all_load=no])
1627				dnl restore the LIBS
1628				LIBS="$save_LIBS"
1629			])
1630
1631			if test $ol_cv_cthread_all_load = yes ; then
1632				LTHREAD_LIBS="$LTHREAD_LIBS -all_load"
1633				ol_link_threads=mach
1634				ol_with_threads=found
1635			fi
1636		fi
1637
1638	elif test $ac_cv_header_cthreads_h = yes ; then
1639		dnl Hurd variant of Mach Cthreads
1640		dnl uses <cthreads.h> and -lthreads
1641
1642		ol_with_threads=found
1643 
1644		dnl save the flags
1645		save_LIBS="$LIBS"
1646		LIBS="$LIBS -lthreads"
1647		AC_CHECK_FUNC(cthread_fork,[ol_link_threads=yes])
1648		LIBS="$save_LIBS"
1649
1650		if test $ol_link_threads = yes ; then
1651			LTHREAD_LIBS="-lthreads"
1652			ol_link_threads=mach
1653			ol_with_threads=found
1654		else
1655			AC_MSG_ERROR([could not link with Mach CThreads])
1656		fi
1657
1658	elif test $ol_with_threads = mach ; then
1659		AC_MSG_ERROR([could not locate Mach CThreads])
1660	fi
1661
1662	if test $ol_link_threads = mach ; then
1663		AC_DEFINE(HAVE_MACH_CTHREADS,1,
1664			[define if you have Mach Cthreads])
1665	elif test $ol_with_threads = found ; then
1666		AC_MSG_ERROR([could not link with Mach CThreads])
1667	fi
1668	;;
1669esac
1670
1671case $ol_with_threads in auto | yes | pth)
1672
1673	AC_CHECK_HEADERS(pth.h)
1674
1675	if test $ac_cv_header_pth_h = yes ; then
1676		AC_CHECK_LIB(pth, pth_version, [have_pth=yes], [have_pth=no])
1677
1678		if test $have_pth = yes ; then
1679			AC_DEFINE(HAVE_GNU_PTH,1,[if you have GNU Pth])
1680			LTHREAD_LIBS="$LTHREAD_LIBS -lpth"
1681			ol_link_threads=pth
1682			ol_with_threads=found
1683
1684			if test $ol_with_yielding_select = auto ; then
1685				ol_with_yielding_select=yes
1686			fi
1687		fi
1688	fi
1689	;;
1690esac
1691
1692case $ol_with_threads in auto | yes | lwp)
1693
1694	dnl check for SunOS5 LWP
1695	AC_CHECK_HEADERS(thread.h synch.h)
1696	if test $ac_cv_header_thread_h = yes &&
1697	   test $ac_cv_header_synch_h = yes ; then
1698		AC_CHECK_LIB(thread, thr_create, [have_thr=yes], [have_thr=no])
1699
1700		if test $have_thr = yes ; then
1701			AC_DEFINE(HAVE_THR,1,
1702				[if you have Solaris LWP (thr) package])
1703			LTHREAD_LIBS="$LTHREAD_LIBS -lthread"
1704			ol_link_threads=thr
1705
1706			if test $ol_with_yielding_select = auto ; then
1707				ol_with_yielding_select=yes
1708			fi
1709
1710			dnl Check for setconcurreny functions
1711			AC_CHECK_FUNCS(	\
1712				thr_setconcurrency \
1713				thr_getconcurrency \
1714			)
1715		fi
1716	fi
1717	;;
1718esac
1719
1720if test $ol_with_yielding_select = yes ; then
1721	AC_DEFINE(HAVE_YIELDING_SELECT,1,
1722		[define if select implicitly yields])
1723fi
1724
1725if test $ol_with_threads = manual ; then
1726	dnl User thinks he can manually configure threads.
1727	ol_link_threads=yes
1728
1729	AC_MSG_WARN([thread defines and link options must be set manually])
1730
1731	AC_CHECK_HEADERS(pthread.h sched.h)
1732	AC_CHECK_FUNCS(sched_yield pthread_yield)
1733	OL_HEADER_LINUX_THREADS
1734
1735	AC_CHECK_HEADERS(mach/cthreads.h)
1736	AC_CHECK_HEADERS(thread.h synch.h)
1737fi
1738
1739if test $ol_link_threads != no && test $ol_link_threads != nt ; then
1740	dnl needed to get reentrant/threadsafe versions
1741	dnl
1742	AC_DEFINE(REENTRANT,1)
1743	AC_DEFINE(_REENTRANT,1)
1744	AC_DEFINE(THREAD_SAFE,1)
1745	AC_DEFINE(_THREAD_SAFE,1)
1746	AC_DEFINE(THREADSAFE,1)
1747	AC_DEFINE(_THREADSAFE,1)
1748	AC_DEFINE(_SGI_MP_SOURCE,1)
1749
1750	dnl The errno declaration may dependent upon _REENTRANT.
1751	dnl If it does, we must link with thread support.
1752	AC_CACHE_CHECK([for thread specific errno],
1753		[ol_cv_errno_thread_specific], [
1754		AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <errno.h>]], [[errno = 0;]])],[ol_cv_errno_thread_specific=yes],[ol_cv_errno_thread_specific=no])
1755	])
1756
1757	dnl The h_errno declaration may dependent upon _REENTRANT.
1758	dnl If it does, we must link with thread support.
1759	AC_CACHE_CHECK([for thread specific h_errno],
1760		[ol_cv_h_errno_thread_specific], [
1761		AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <netdb.h>]], [[h_errno = 0;]])],[ol_cv_h_errno_thread_specific=yes],[ol_cv_h_errno_thread_specific=no])
1762	])
1763
1764	if test $ol_cv_errno_thread_specific != yes ||
1765	   test $ol_cv_h_errno_thread_specific != yes ; then
1766		LIBS="$LTHREAD_LIBS $LIBS"
1767		LTHREAD_LIBS=""
1768	fi
1769
1770dnl When in thread environment, use 
1771dnl		#if defined( HAVE_REENTRANT_FUNCTIONS ) || defined( HAVE_FUNC_R )
1772dnl			func_r(...);
1773dnl		#else
1774dnl		#	if defined( HAVE_THREADS ) 
1775dnl				/* lock */
1776dnl		#	endif
1777dnl				func(...);
1778dnl		#	if defined( HAVE_THREADS ) 
1779dnl				/* unlock */
1780dnl		#	endif
1781dnl		#endif
1782dnl
1783dnl HAVE_REENTRANT_FUNCTIONS is derived from:
1784dnl		_POSIX_REENTRANT_FUNCTIONS
1785dnl		_POSIX_THREAD_SAFE_FUNCTIONS
1786dnl		_POSIX_THREADSAFE_FUNCTIONS
1787dnl
1788dnl		and is currently defined in <ldap_pvt_thread.h>
1789dnl
1790dnl HAVE_THREADS is defined by <ldap_pvt_thread.h> iff -UNO_THREADS
1791dnl 
1792dnl libldap/*.c should only include <ldap_pvt_thread.h> iff
1793dnl LDAP_R_COMPILE is defined.  ie:
1794dnl		#ifdef LDAP_R_COMPILE
1795dnl		#	include <ldap_pvt_thread.h>
1796dnl		#endif
1797dnl
1798dnl LDAP_R_COMPILE is defined by libldap_r/Makefile.in
1799dnl specifically for compiling the threadsafe version of
1800dnl	the ldap library (-lldap_r).
1801dnl		
1802dnl	dnl check for reentrant/threadsafe functions
1803dnl	dnl
1804dnl	dnl note: these should only be used when linking
1805dnl	dnl		with $LTHREAD_LIBS
1806dnl	dnl
1807dnl	save_CPPFLAGS="$CPPFLAGS"
1808dnl	save_LIBS="$LIBS"
1809dnl	LIBS="$LTHREAD_LIBS $LIBS"
1810dnl	AC_CHECK_FUNCS(	\
1811dnl		gmtime_r \
1812dnl		gethostbyaddr_r gethostbyname_r \
1813dnl		feof_unlocked unlocked_feof \
1814dnl		putc_unlocked unlocked_putc \
1815dnl		flockfile ftrylockfile \
1816dnl	)
1817dnl	CPPFLAGS="$save_CPPFLAGS"
1818dnl	LIBS="$save_LIBS"
1819fi  
1820
1821if test $ol_link_threads = no ; then
1822	if test $ol_with_threads = yes ; then
1823		AC_MSG_ERROR([no suitable thread support])
1824	fi
1825
1826	if test $ol_with_threads = auto ; then
1827		AC_MSG_WARN([no suitable thread support, disabling threads])
1828		ol_with_threads=no
1829	fi
1830
1831	AC_DEFINE(NO_THREADS,1,
1832		[define if you have (or want) no threads])
1833	LTHREAD_LIBS=""
1834	BUILD_THREAD=no
1835else
1836	BUILD_THREAD=yes
1837fi
1838
1839if test $ol_link_threads != no ; then
1840	AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE,1,
1841		[define to 1 if library is thread safe])
1842fi
1843
1844dnl ----------------------------------------------------------------
1845dnl Tests for reentrant functions necessary to build -lldap_r
1846AC_CHECK_FUNCS(		\
1847	ctime_r			\
1848	gethostbyname_r	gethostbyaddr_r \
1849)
1850
1851if test "$ac_cv_func_ctime_r" = no ; then
1852	ol_cv_func_ctime_r_nargs=0
1853else
1854	OL_FUNC_CTIME_R_NARGS
1855dnl	OL_FUNC_CTIME_R_TYPE
1856fi
1857
1858if test "$ac_cv_func_gethostbyname_r" = yes ; then
1859 	OL_FUNC_GETHOSTBYNAME_R_NARGS
1860else
1861 	ol_cv_func_gethostbyname_r_nargs=0
1862fi
1863 
1864if test "$ac_cv_func_gethostbyaddr_r" = yes ; then
1865 	OL_FUNC_GETHOSTBYADDR_R_NARGS
1866else
1867 	ol_cv_func_gethostbyaddr_r_nargs=0
1868fi
1869
1870dnl ----------------------------------------------------------------
1871ol_link_bdb=no 
1872
1873if test $ol_enable_bdb/$ol_enable_hdb != no/no; then
1874	OL_BERKELEY_DB
1875
1876	if test $ol_cv_berkeley_db = no ; then
1877		AC_MSG_ERROR(BDB/HDB: BerkeleyDB not available)
1878	fi
1879
1880	AC_DEFINE(HAVE_BERKELEY_DB,1,
1881		[define this if Berkeley DB is available])
1882
1883	dnl $ol_cv_lib_db should be yes or -ldb
1884	dnl (it could be no, but that would be an error
1885	if test $ol_cv_lib_db != yes ; then
1886		BDB_LIBS="$BDB_LIBS $ol_cv_lib_db"
1887	fi
1888
1889	OL_BDB_COMPAT
1890
1891	if test $ol_cv_bdb_compat != yes ; then
1892		AC_MSG_ERROR([BDB/HDB: BerkeleyDB version incompatible])
1893	fi
1894
1895	SLAPD_LIBS="$SLAPD_LIBS \$(BDB_LIBS)"
1896
1897	ol_link_bdb=yes 
1898fi
1899
1900dnl ----------------------------------------------------------------
1901
1902if test $ol_enable_dynamic = yes && test $enable_shared = yes ; then
1903	BUILD_LIBS_DYNAMIC=shared
1904	AC_DEFINE(LDAP_LIBS_DYNAMIC, 1, [define if LDAP libs are dynamic])
1905	LTSTATIC=""
1906else
1907	BUILD_LIBS_DYNAMIC=static
1908	LTSTATIC="-static"
1909fi
1910AC_SUBST(LTSTATIC)dnl
1911
1912dnl ----------------------------------------------------------------
1913if test $ol_enable_wrappers != no ; then
1914	AC_CHECK_HEADERS(tcpd.h,[
1915		AC_MSG_CHECKING([for TCP wrappers library])
1916		save_LIBS="$LIBS"
1917		LIBS="$LIBS -lwrap"
1918		AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1919#include <tcpd.h>
1920int allow_severity = 0;
1921int deny_severity  = 0;
1922
1923struct request_info *req;
1924		]], [[
1925hosts_access(req)
1926		]])],[AC_MSG_RESULT([-lwrap])
1927		have_wrappers=yes
1928		LIBS="$save_LIBS"],[
1929		dnl try with -lnsl
1930		LIBS="$LIBS -lnsl"
1931		AC_TRY_LINK([
1932#include <tcpd.h>
1933int allow_severity = 0;
1934int deny_severity  = 0;
1935
1936struct request_info *req;
1937		],[
1938hosts_access(req)
1939		],[AC_MSG_RESULT([-lwrap -lnsl])
1940		have_wrappers=yes
1941		LIBS="$save_LIBS -lnsl"],[
1942		AC_MSG_RESULT(no)
1943		have_wrappers=no
1944		LIBS=$save_LIBS])])],[have_wrappers=no])
1945
1946	if test $have_wrappers = yes ; then
1947		AC_DEFINE(HAVE_TCPD,1, [define if you have -lwrap])
1948		WRAP_LIBS="-lwrap"
1949	elif test $ol_enable_wrappers = yes ; then
1950		AC_MSG_ERROR([could not find TCP wrappers, select apppropriate options or disable])
1951	else
1952		AC_MSG_WARN([could not find TCP wrappers, support disabled])
1953		WRAP_LIBS=""
1954	fi
1955fi
1956
1957dnl ----------------------------------------------------------------
1958if test $ol_enable_syslog != no ; then
1959	AC_CHECK_FUNC(openlog)
1960	if test $ac_cv_func_openlog = no && test $ol_enable_syslog = yes; then
1961		AC_MSG_ERROR(could not find syslog, select appropriate options or disable)
1962	fi
1963	ol_enable_syslog=$ac_cv_func_openlog
1964fi
1965
1966dnl ----------------------------------------------------------------
1967dnl SQL
1968ol_link_sql=no
1969if test $ol_enable_sql != no ; then
1970	AC_CHECK_HEADERS(sql.h sqlext.h,[],[
1971		AC_MSG_ERROR([could not locate SQL headers])
1972	])
1973
1974	sql_LIBS="$LIBS"
1975	LIBS="$LTHREAD_LIBS"
1976
1977	if test $ol_with_odbc = auto ; then
1978		ol_with_odbc="iodbc unixodbc odbc32"
1979	fi
1980
1981	for odbc in $ol_with_odbc ; do
1982		if test $ol_link_sql = no ; then
1983			case $odbc in
1984			iodbc)
1985				AC_CHECK_LIB(iodbc, SQLDriverConnect, [have_iodbc=yes], [have_iodbc=no])
1986				if test $have_iodbc = yes ; then
1987					ol_link_sql="-liodbc"
1988				fi
1989				;;
1990
1991			unixodbc)
1992				AC_CHECK_LIB(odbc, SQLDriverConnect, [have_odbc=yes], [have_odbc=no])
1993				if test $have_odbc = yes ; then
1994					ol_link_sql="-lodbc"
1995				fi
1996				;;
1997
1998			odbc32)
1999				AC_CHECK_LIB(odbc32, SQLDriverConnect, [have_odbc32=yes], [have_odbc32=no])
2000				if test $have_odbc32 = yes ; then
2001					ol_link_sql="-lodbc32"
2002				fi
2003				;;
2004
2005			*)
2006				AC_MSG_ERROR([unknown ODBC library])
2007				;;
2008			esac
2009		fi
2010	done
2011
2012	LIBS="$sql_LIBS"
2013
2014	if test $ol_link_sql != no ; then
2015		SLAPD_SQL_LIBS="$ol_link_sql"
2016
2017	elif test $ol_enable_sql != auto ; then
2018		AC_MSG_ERROR([could not locate suitable ODBC library])
2019	fi
2020fi
2021
2022dnl ----------------------------------------------------------------
2023dnl International Components for Unicode
2024OL_ICU
2025if test "$ol_icu" = no ; then
2026	AC_MSG_WARN([ICU not available])
2027else
2028	ICU_LIBS="$ol_icu"
2029fi
2030dnl ----------------------------------------------------------------
2031dnl
2032dnl Check for Cyrus SASL
2033dnl
2034WITH_SASL=no
2035ol_link_sasl=no
2036ol_link_spasswd=no
2037if test $ol_with_cyrus_sasl != no ; then
2038	AC_CHECK_HEADERS(sasl/sasl.h sasl.h)
2039
2040	if test $ac_cv_header_sasl_sasl_h = yes ||
2041	   test $ac_cv_header_sasl_h = yes; then
2042		AC_CHECK_LIB(sasl2, sasl_client_init,
2043			[ol_link_sasl="-lsasl2"],
2044			[AC_CHECK_LIB(sasl, sasl_client_init,
2045				[ol_link_sasl="-lsasl"])])
2046	fi
2047
2048	if test $ol_link_sasl = no ; then
2049		if test $ol_with_cyrus_sasl != auto ; then
2050			AC_MSG_ERROR([Could not locate Cyrus SASL])
2051		else
2052			AC_MSG_WARN([Could not locate Cyrus SASL])
2053			AC_MSG_WARN([SASL authentication not supported!])
2054			if test $ol_link_tls = no ; then
2055				AC_MSG_WARN([Strong authentication not supported!])
2056			fi
2057		fi
2058	else
2059		OL_SASL_COMPAT
2060		if test $ol_cv_sasl_compat = no ; then
2061			ol_link_sasl=no
2062			AC_MSG_ERROR([Cyrus SASL library located but is incompatible])
2063		fi
2064
2065		AC_DEFINE(HAVE_CYRUS_SASL,1,[define if you have Cyrus SASL])
2066		SASL_LIBS="$ol_link_sasl"
2067		if test $ol_enable_spasswd != no ; then
2068			ol_link_spasswd=yes
2069		fi
2070
2071		ac_save_LIBS="$LIBS"
2072		LIBS="$LIBS $ol_link_sasl"
2073		AC_CHECK_FUNC(sasl_version, [AC_DEFINE(HAVE_SASL_VERSION,1,
2074			[define if your SASL library has sasl_version()])])
2075		LIBS="$ac_save_LIBS"
2076
2077		WITH_SASL=yes
2078	fi
2079
2080else
2081	AC_MSG_WARN([SASL authentication not supported!])
2082	if test $ol_link_tls = no ; then
2083		AC_MSG_WARN([Strong authentication not supported!])
2084	fi
2085fi
2086
2087dnl ----------------------------------------------------------------
2088dnl Check for entropy sources
2089if test $cross_compiling != yes && test "$ac_cv_mingw32" != yes ; then
2090	dev=no
2091	if test -r /dev/urandom ; then
2092		dev="/dev/urandom";
2093	elif test -r /idev/urandom ; then
2094		dev="/idev/urandom";
2095	elif test -r /dev/srandom ; then
2096		dev="/dev/srandom";
2097	elif test -r /dev/random ; then
2098		dev="/dev/random";
2099	elif test -r /idev/random ; then
2100		dev="/idev/random";
2101	fi
2102
2103	if test $dev != no ; then
2104		AC_DEFINE_UNQUOTED(URANDOM_DEVICE,"$dev",[set to urandom device])
2105	fi
2106fi
2107
2108dnl ----------------------------------------------------------------
2109dnl
2110dnl Check for fetch URL support
2111dnl		should be extended to support other fetch URL APIs
2112dnl
2113ol_link_fetch=no
2114if test $ol_with_fetch != no ; then
2115	OL_LIB_FETCH
2116
2117	if test $ol_cv_lib_fetch != no ; then
2118		LIBS="$LIBS $ol_link_fetch"
2119		ol_link_fetch=freebsd
2120
2121	elif test $ol_with_fetch != auto ; then
2122		AC_MSG_ERROR(no suitable API for --with-fetch=$ol_with_fetch)
2123	fi 
2124fi
2125
2126dnl ----------------------------------------------------------------
2127dnl FreeBSD (and others) have crypt(3) in -lcrypt
2128if test $ol_enable_crypt != no ; then
2129	save_LIBS="$LIBS"
2130	LIBS="$TLS_LIBS $LIBS"
2131
2132	AC_CHECK_FUNC(crypt, [have_crypt=yes], [
2133		LIBS="$save_LIBS"
2134		AC_CHECK_LIB(crypt, crypt, [LUTIL_LIBS="$LUTIL_LIBS -lcrypt"
2135			have_crypt=yes], [have_crypt=no])])
2136
2137	LIBS="$save_LIBS"
2138
2139	if test $have_crypt = yes ; then
2140		AC_DEFINE(HAVE_CRYPT,1, [define if crypt(3) is available])
2141	else
2142		AC_MSG_WARN([could not find crypt])
2143		if test $ol_enable_crypt = yes ; then
2144			AC_MSG_ERROR([could not find crypt, select appropriate options or disable])
2145		fi
2146
2147		AC_MSG_WARN([disabling crypt support])
2148		ol_enable_crypt=no
2149	fi
2150fi
2151
2152dnl ----------------------------------------------------------------
2153dnl FreeBSD (and others) have setproctitle(3) in -lutil
2154if test $ol_enable_proctitle != no ; then
2155	AC_CHECK_FUNC(setproctitle,	[have_setproctitle=yes], [
2156		AC_CHECK_LIB(util, setproctitle,
2157			[have_setproctitle=yes
2158			LUTIL_LIBS="$LUTIL_LIBS -lutil"],
2159			[have_setproctitle=no
2160			AC_LIBOBJ(setproctitle)
2161			LIBSRCS="$LIBSRCS setproctitle.c"])])
2162
2163	if test $have_setproctitle = yes ; then
2164		AC_DEFINE(HAVE_SETPROCTITLE,1,
2165			[define if setproctitle(3) is available])
2166	fi
2167fi
2168
2169dnl ----------------------------------------------------------------
2170if test $ol_enable_slp != no ; then
2171	AC_CHECK_HEADERS( slp.h )
2172
2173	if test $ac_cv_header_slp_h = yes ; then
2174		AC_CHECK_LIB(slp, SLPOpen, [have_slp=yes], [have_slp=no])
2175		if test $have_slp = yes ; then
2176			AC_DEFINE(HAVE_SLP, 1, [define if you have -lslp])
2177			SLAPD_SLP_LIBS=-lslp
2178		fi
2179
2180	elif test $ol_enable_slp = yes ; then
2181		AC_MSG_ERROR([SLP not found])
2182	fi
2183fi
2184
2185dnl ----------------------------------------------------------------
2186dnl Checks for typedefs, structures, and compiler characteristics.
2187
2188AC_CHECK_TYPE(mode_t, int)
2189AC_CHECK_TYPE(off_t, long)
2190AC_CHECK_TYPE(pid_t, int)
2191AC_CHECK_TYPE(ssize_t, [signed int])
2192AC_CHECK_TYPE(caddr_t,	[char *])
2193AC_CHECK_TYPE(size_t, unsigned)
2194
2195AC_CHECK_TYPES([long long])
2196AC_CHECK_TYPES([ptrdiff_t])
2197
2198
2199AC_CHECK_TYPE([socklen_t],,, [$ac_includes_default
2200#ifdef HAVE_SYS_SOCKET_H
2201#include <sys/socket.h>
2202#endif])
2203
2204dnl socklen_t-like type in accept(), default socklen_t or int:
2205dnl - The OS might define socklen_t without using it.  POSIX moved from
2206dnl   int to size_t to socklen_t, hoping to stay at a 32-bit type, and
2207dnl   HP-UX now has selectors for what to use.
2208dnl - On Solaris 2.8 the prototype has void *len, but the default is OK.
2209AC_MSG_CHECKING([the type of arg 3 to accept()])
2210AC_CACHE_VAL(ol_cv_type_ber_socklen_t, [
2211	set socklen_t int unsigned "unsigned long" long size_t
2212	test "$ac_cv_type_socklen_t" = yes || shift
2213	ol_cv_type_ber_socklen_t=$1 guessing="guessing "
2214	for lentype in "$@" ; do for addrtype in "struct sockaddr" void ; do
2215		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_includes_default
2216#ifdef HAVE_SYS_SOCKET_H
2217#include <sys/socket.h>
2218#endif
2219extern int accept(int s, $addrtype *ap, $lentype *lp);
2220], [
2221accept(0, (struct sockaddr *) 0, ($lentype *) 0);
2222])], [ol_cv_type_ber_socklen_t=$lentype guessing= ; break 2])
2223	done ; done])
2224AC_MSG_RESULT([$guessing$ol_cv_type_ber_socklen_t *])
2225AC_DEFINE_UNQUOTED(ber_socklen_t, $ol_cv_type_ber_socklen_t,
2226	[Define to the type of arg 3 for `accept'.])
2227
2228dnl Modules should use ber_socklen_t, not socklen_t.  Define socklen_t
2229dnl for the time being anyway, for backwards compatibility.
2230if test "$ac_cv_type_socklen_t" != yes; then
2231	AC_DEFINE_UNQUOTED([socklen_t], [$ol_cv_type_ber_socklen_t],
2232		[Define like ber_socklen_t if <sys/socket.h> does not define.])
2233fi
2234
2235
2236AC_TYPE_SIGNAL
2237
2238AC_CHECK_TYPE([sig_atomic_t],,
2239	[AC_DEFINE_UNQUOTED([sig_atomic_t], [int],
2240		[Define to `int' if <signal.h> does not define.])],
2241	[$ac_includes_default
2242#include <signal.h>
2243	])
2244
2245AC_TYPE_UID_T
2246
2247AC_HEADER_TIME
2248AC_STRUCT_TM
2249AC_CHECK_MEMBERS([struct stat.st_blksize])
2250AC_CHECK_MEMBERS([struct passwd.pw_gecos],,,[$ac_includes_default
2251#include <pwd.h>])
2252AC_CHECK_MEMBERS([struct passwd.pw_passwd],,,[$ac_includes_default
2253#include <pwd.h>])
2254
2255OL_C_UPPER_LOWER
2256AC_C_CONST
2257OL_C_VOLATILE
2258
2259#if test $cross_compiling = yes ; then
2260#	AC_MSG_WARN([Crossing compiling... all bets are off!])
2261#	AC_DEFINE(CROSS_COMPILING, 1, [define if cross compiling])
2262#else
2263#	AC_C_BIGENDIAN
2264#fi
2265
2266AC_CHECK_SIZEOF(short) 
2267AC_CHECK_SIZEOF(int) 
2268# disable for cross compiling
2269#AC_CHECK_SIZEOF(long)
2270AC_CHECK_SIZEOF(long long)
2271AC_CHECK_SIZEOF(wchar_t)
2272
2273if test "$ac_cv_sizeof_int" -lt 4 ; then
2274	AC_MSG_WARN([OpenLDAP requires 'int' to be 32 bits or greater.])
2275
2276	AC_DEFINE(LBER_INT_T,long,[define to 32-bit or greater integer type])
2277else
2278	AC_DEFINE(LBER_INT_T,int,[define to 32-bit or greater integer type])
2279fi
2280
2281AC_DEFINE(LBER_LEN_T,long,[define to large integer type])
2282AC_DEFINE(LBER_SOCKET_T,int,[define to socket descriptor type])
2283AC_DEFINE(LBER_TAG_T,long,[define to large integer type])
2284
2285dnl ----------------------------------------------------------------
2286dnl Check for multiple precision support
2287if test $ol_with_mp = longlong || test $ol_with_mp = auto ; then
2288	if test $ac_cv_sizeof_long_long -gt 4 ; then
2289		ol_with_mp=longlong
2290		AC_DEFINE(USE_MP_LONG_LONG,1,[define to use 'long long' for MP])
2291	elif test $ol_with_mp = longlong ; then
2292		AC_MSG_ERROR([long long unusable for multiple precision])
2293	fi
2294fi
2295if test $ol_with_mp = long || test $ol_with_mp = auto ; then
2296	if test $ac_cv_sizeof_long -gt 4 ; then
2297		ol_with_mp=long
2298		AC_DEFINE(USE_MP_LONG,1,[define to use 'long' for MP])
2299	elif test $ol_with_mp = long ; then
2300		AC_MSG_ERROR([long unusable for multiple precision])
2301	fi
2302fi
2303if test $ol_with_mp = bignum || test $ol_with_mp = auto ; then
2304	AC_CHECK_HEADERS(openssl/bn.h)
2305	AC_CHECK_HEADERS(openssl/crypto.h)
2306	if test "$ac_cv_header_openssl_bn_h" = "yes" &&
2307		test "$ac_cv_header_openssl_crypto_h" = "yes" &&
2308		test "$ol_with_tls" = "found" ; then
2309		ol_with_mp=bignum
2310		AC_DEFINE(USE_MP_BIGNUM,1,[define to use OpenSSL BIGNUM for MP])
2311	elif test $ol_with_mp = bignum ; then
2312		AC_MSG_ERROR([bignum not available])
2313	fi
2314fi
2315if test $ol_with_mp = gmp || test $ol_with_mp = auto ; then
2316	AC_CHECK_HEADERS(gmp.h)
2317	AC_CHECK_LIB(gmp, __gmpz_add_ui)
2318	if test $ac_cv_header_gmp_h = yes && test $ac_cv_lib_gmp___gmpz_add_ui = yes ; then
2319		AC_DEFINE(USE_MP_GMP,1,[define to use GMP for MP])
2320		ol_with_mp=gmp
2321	elif test $ol_with_mp = gmp ; then
2322		AC_MSG_ERROR([gmp not available])
2323	fi
2324fi
2325if test $ol_with_mp = auto ; then
2326	ol_with_mp=no
2327fi
2328
2329dnl ----------------------------------------------------------------
2330dnl Checks for library functions.
2331AC_FUNC_MEMCMP
2332
2333if test $ac_cv_func_memcmp_working = no ; then
2334	AC_DEFINE(NEED_MEMCMP_REPLACEMENT,1,
2335		[define if memcmp is not 8-bit clean or is otherwise broken])
2336fi
2337
2338AC_FUNC_STRFTIME
2339
2340OL_FUNC_INET_ATON
2341
2342dnl Check for NT specific routines
2343AC_CHECK_FUNC(_spawnlp, AC_DEFINE(HAVE_SPAWNLP,1,[if you have spawnlp()]))
2344
2345AC_CHECK_FUNC(_snprintf, [ac_cv_func_snprintf=yes
2346	AC_DEFINE(snprintf, _snprintf, [define to snprintf routine])
2347])
2348
2349AC_CHECK_FUNCS(vsnprintf _vsnprintf)
2350
2351if test $ac_cv_func_vsnprintf = no -a $ac_cv_func__vsnprintf = yes ; then
2352	ac_cv_func_vsnprintf=yes
2353	AC_DEFINE(vsnprintf, _vsnprintf, [define to vsnprintf routine])
2354fi
2355
2356AC_FUNC_VPRINTF
2357
2358if test $ac_cv_func_vprintf = yes ; then
2359	dnl check for vsnprintf
2360	AC_CHECK_FUNCS(snprintf vsnprintf)
2361fi
2362
2363AC_CHECK_FUNCS(			\
2364	bcopy			\
2365	closesocket		\
2366	chroot			\
2367	endgrent		\
2368	endpwent		\
2369	fcntl			\
2370	flock			\
2371	fstat			\
2372	getdtablesize		\
2373	geteuid			\
2374	getgrgid		\
2375	gethostname		\
2376	getpassphrase		\
2377	getpwuid		\
2378	getpwnam		\
2379	getspnam		\
2380	gettimeofday		\
2381	initgroups		\
2382	inet_ntoa_b		\
2383	ioctl			\
2384	lockf			\
2385	memcpy			\
2386	memmove			\
2387	memrchr			\
2388	mkstemp			\
2389	mktemp			\
2390	pipe			\
2391	read			\
2392	recv			\
2393	recvfrom		\
2394	setpwfile		\
2395	setgid			\
2396	setegid			\
2397	setsid			\
2398	setuid			\
2399	seteuid			\
2400	signal			\
2401	strdup			\
2402	strpbrk			\
2403	strrchr			\
2404	strsep			\
2405	strstr			\
2406	strtol			\
2407	strtoul			\
2408	strtoq			\
2409	strtouq			\
2410	strtoll			\
2411	strtoull		\
2412	strspn			\
2413	sysconf			\
2414	waitpid			\
2415	wait4			\
2416	write			\
2417	send			\
2418	sendmsg			\
2419	sendto			\
2420)
2421
2422dnl We actually may need to replace more than this.
2423AC_REPLACE_FUNCS(getopt getpeereid)
2424
2425if test "$ac_cv_func_getopt" != yes; then
2426	LIBSRCS="$LIBSRCS getopt.c"
2427fi
2428
2429if test "$ac_cv_func_getpeereid" != yes; then
2430	AC_CHECK_FUNCS( getpeerucred )
2431	if test "$ac_cv_func_getpeerucred" != yes ; then
2432		AC_CHECK_MEMBERS([struct msghdr.msg_accrightslen],,,
2433			[$ac_includes_default
2434#ifdef HAVE_SYS_SOCKET_H
2435#include <sys/socket.h>
2436#endif])
2437		if test "$ac_cv_member_struct_msghdr_msg_accrightslen" != yes; then
2438			AC_CHECK_MEMBERS([struct msghdr.msg_control],,,
2439				[$ac_includes_default
2440#ifdef HAVE_SYS_SOCKET_H
2441#include <sys/socket.h>
2442#endif])
2443		fi
2444		AC_CHECK_MEMBERS([struct stat.st_fstype, struct stat.st_vfstype])
2445		if test "$ac_cv_member_struct_stat_st_fstype" = yes; then
2446			AC_COMPILE_IFELSE([struct stat st; char *ptr=st.st_fstype;],
2447				AC_DEFINE([HAVE_STRUCT_STAT_ST_FSTYPE_CHAR],1,[define to 1 if st_fstype is char *]),
2448				AC_DEFINE([HAVE_STRUCT_STAT_ST_FSTYPE_INT],1,[define to 1 if st_fstype is int]))
2449		fi
2450	fi
2451	LIBSRCS="$LIBSRCS getpeereid.c"
2452fi
2453
2454if test "$ac_cv_func_snprintf" != yes ||
2455   test "$ac_cv_func_vsnprintf" != yes; then
2456	if test "$ac_cv_func_snprintf" != yes; then
2457		AC_DEFINE(snprintf, ber_pvt_snprintf, [define to snprintf routine])
2458	fi
2459	if test "$ac_cv_func_vsnprintf" != yes; then
2460		AC_DEFINE(vsnprintf, ber_pvt_vsnprintf, [define to snprintf routine])
2461	fi
2462fi
2463
2464dnl ----------------------------------------------------------------
2465dnl Sort out defines
2466
2467if test "$ol_enable_slapi" != no ; then
2468	dnl This check is done also if --enable-modules is used;
2469	dnl it is duplicated here, 'cause it'd be cached anyway
2470	AC_CHECK_HEADERS(ltdl.h)
2471
2472	if test $ac_cv_header_ltdl_h != yes ; then
2473		AC_MSG_ERROR([could not locate <ltdl.h>])
2474	fi
2475	AC_CHECK_LIB(ltdl, lt_dlinit, [
2476		SLAPI_LIBS=-lltdl
2477		LIBSLAPI=libslapi.a
2478		LIBSLAPITOOLS=../libslapi.a
2479		AC_DEFINE(HAVE_LIBLTDL,1,[define if you have libtool -ltdl])
2480	],[AC_MSG_ERROR([could not locate libtool -lltdl])])
2481
2482	AC_DEFINE(LDAP_SLAPI,1, [define this to add SLAPI code])
2483fi
2484
2485if test "$ol_enable_debug" != no ; then
2486	if test "$ol_enable_debug" = traditional; then
2487		AC_DEFINE(OLD_DEBUG,1,
2488			[define to use the original debug style])
2489	fi
2490	AC_DEFINE(LDAP_DEBUG,1,
2491		[define this to add debugging code])
2492fi
2493if test "$ol_enable_syslog" = yes ; then
2494	AC_DEFINE(LDAP_SYSLOG,1,
2495		[define this to add syslog code])
2496fi
2497if test "$ol_enable_proctitle" != no ; then
2498	AC_DEFINE(LDAP_PROCTITLE,1,
2499		[define this for LDAP process title support])
2500fi
2501if test "$ol_enable_referrals" != no ; then
2502	AC_DEFINE(LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS,LDAP_VENDOR_VERSION,
2503		[define to LDAP VENDOR VERSION])
2504fi
2505if test "$ol_enable_local" != no; then
2506	AC_DEFINE(LDAP_PF_LOCAL,1,[define to support PF_LOCAL])
2507fi
2508if test "$ol_link_ipv6" != no; then
2509	AC_DEFINE(LDAP_PF_INET6,1,[define to support PF_INET6])
2510fi
2511if test "$ol_enable_cleartext" != no ; then
2512	AC_DEFINE(SLAPD_CLEARTEXT,1,[define to support cleartext passwords])
2513fi
2514if test "$ol_enable_crypt" != no ; then
2515	AC_DEFINE(SLAPD_CRYPT,1,[define to support crypt(3) passwords])
2516fi
2517if test "$ol_link_spasswd" != no ; then
2518	AC_DEFINE(SLAPD_SPASSWD,1,[define to support SASL passwords])
2519fi
2520if test "$ol_enable_rlookups" != no ; then
2521	AC_DEFINE(SLAPD_RLOOKUPS,1,[define to support reverse lookups])
2522fi
2523if test "$ol_enable_aci" != no ; then
2524	if test $ol_enable_dynacl = no ; then
2525		ol_enable_dynacl=yes
2526		AC_MSG_WARN([ACIs need dynacl])
2527	fi
2528	if test "$ol_enable_aci" = mod ; then
2529		MFLAG=SLAPD_MOD_DYNAMIC
2530		dnl remove this after moving servers/slapd/aci.c in contrib/slapd-modules/acl
2531		AC_MSG_ERROR([ACI build as dynamic module not supported (yet)])
2532	else 
2533		MFLAG=SLAPD_MOD_STATIC
2534	fi
2535	WITH_ACI_ENABLED=$ol_enable_aci
2536	AC_DEFINE_UNQUOTED(SLAPD_ACI_ENABLED,$MFLAG,[define to support per-object ACIs])
2537else
2538	WITH_ACI_ENABLED=no
2539fi
2540if test "$ol_enable_dynacl" != no ; then
2541	AC_DEFINE(SLAP_DYNACL,1,[define to support run-time loadable ACL])
2542fi
2543
2544if test "$ol_link_modules" != no ; then
2545	AC_DEFINE(SLAPD_MODULES,1,[define to support modules])
2546	BUILD_SLAPD=yes
2547	SLAPD_MODULES_LDFLAGS="-dlopen self"
2548fi
2549
2550AC_DEFINE(SLAPD_MOD_STATIC,1,[statically linked module])
2551AC_DEFINE(SLAPD_MOD_DYNAMIC,2,[dynamically linked module])
2552
2553dnl back-monitor goes first (well, after back-config)
2554if test "$ol_enable_monitor" != no ; then
2555	BUILD_SLAPD=yes
2556	BUILD_MONITOR=$ol_enable_monitor
2557	if test "$ol_enable_monitor" = mod ; then
2558		SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-monitor"
2559		MFLAG=SLAPD_MOD_DYNAMIC
2560	else
2561		SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-monitor"
2562		MFLAG=SLAPD_MOD_STATIC
2563	fi
2564	AC_DEFINE_UNQUOTED(SLAPD_MONITOR,$MFLAG,[define to support cn=Monitor backend])
2565fi
2566
2567if test "$ol_enable_bdb" != no ; then
2568	BUILD_SLAPD=yes
2569	BUILD_BDB=$ol_enable_bdb
2570	if test "$ol_enable_bdb" = mod ; then
2571		SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-bdb"
2572		MFLAG=SLAPD_MOD_DYNAMIC
2573	else
2574		SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-bdb"
2575		MFLAG=SLAPD_MOD_STATIC
2576	fi
2577	AC_DEFINE_UNQUOTED(SLAPD_BDB,$MFLAG,[define to support BDB backend])
2578fi
2579
2580if test "$ol_enable_dnssrv" != no ; then
2581	BUILD_SLAPD=yes
2582	BUILD_DNSSRV=$ol_enable_dnssrv
2583	if test "$ol_enable_dnssrv" = mod ; then
2584		SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-dnssrv"
2585		MFLAG=SLAPD_MOD_DYNAMIC
2586	else
2587		SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-dnssrv"
2588		MFLAG=SLAPD_MOD_STATIC
2589	fi
2590	AC_DEFINE_UNQUOTED(SLAPD_DNSSRV,$MFLAG,[define to support DNS SRV backend])
2591fi
2592
2593if test "$ol_enable_hdb" != no ; then
2594	BUILD_SLAPD=yes
2595	BUILD_HDB=$ol_enable_hdb
2596	if test "$ol_enable_hdb" = mod ; then
2597		SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-hdb"
2598		MFLAG=SLAPD_MOD_DYNAMIC
2599	else
2600		SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-hdb"
2601		MFLAG=SLAPD_MOD_STATIC
2602	fi
2603	AC_DEFINE_UNQUOTED(SLAPD_HDB,$MFLAG,[define to support HDB backend])
2604fi
2605
2606if test "$ol_enable_ldap" != no ; then
2607	BUILD_SLAPD=yes
2608	BUILD_LDAP=$ol_enable_ldap
2609	if test "$ol_enable_ldap" = mod ; then
2610		SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-ldap"
2611		MFLAG=SLAPD_MOD_DYNAMIC
2612	else
2613		SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-ldap"
2614		MFLAG=SLAPD_MOD_STATIC
2615	fi
2616	AC_DEFINE_UNQUOTED(SLAPD_LDAP,$MFLAG,[define to support LDAP backend])
2617fi
2618
2619if test "$ol_enable_meta" != no ; then
2620	BUILD_SLAPD=yes
2621	BUILD_META=$ol_enable_meta
2622	BUILD_REWRITE=yes
2623	if test "$ol_enable_meta" = mod ; then
2624		SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-meta"
2625		MFLAG=SLAPD_MOD_DYNAMIC
2626	else
2627		SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-meta"
2628		MFLAG=SLAPD_MOD_STATIC
2629	fi
2630	AC_DEFINE_UNQUOTED(SLAPD_META,$MFLAG,[define to support LDAP Metadirectory backend])
2631fi
2632
2633if test "$ol_enable_null" != no ; then
2634	BUILD_SLAPD=yes
2635	BUILD_NULL=$ol_enable_null
2636	if test "$ol_enable_null" = mod ; then
2637		SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-null"
2638		MFLAG=SLAPD_MOD_DYNAMIC
2639	else
2640		SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-null"
2641		MFLAG=SLAPD_MOD_STATIC
2642	fi
2643	AC_DEFINE_UNQUOTED(SLAPD_NULL,$MFLAG,[define to support NULL backend])
2644fi
2645
2646if test "$ol_enable_passwd" != no ; then
2647	BUILD_SLAPD=yes
2648	BUILD_PASSWD=$ol_enable_passwd
2649	if test "$ol_enable_passwd" = mod ; then
2650		SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-passwd"
2651		MFLAG=SLAPD_MOD_DYNAMIC
2652	else
2653		SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-passwd"
2654		MFLAG=SLAPD_MOD_STATIC
2655	fi
2656	AC_DEFINE_UNQUOTED(SLAPD_PASSWD,$MFLAG,[define to support PASSWD backend])
2657fi
2658
2659if test "$ol_link_perl" != no ; then
2660	BUILD_SLAPD=yes
2661	BUILD_PERL=$ol_enable_perl
2662	if test "$ol_enable_perl" = mod ; then
2663		SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-perl"
2664		MFLAG=SLAPD_MOD_DYNAMIC
2665	else
2666		SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-perl"
2667		MFLAG=SLAPD_MOD_STATIC
2668	fi
2669	AC_DEFINE_UNQUOTED(SLAPD_PERL,$MFLAG,[define to support PERL backend])
2670fi
2671
2672if test "$ol_enable_relay" != no ; then
2673	BUILD_SLAPD=yes
2674	BUILD_RELAY=$ol_enable_relay
2675	if test "$ol_enable_relay" = mod ; then
2676		SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-relay"
2677		MFLAG=SLAPD_MOD_DYNAMIC
2678	else
2679		SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-relay"
2680		MFLAG=SLAPD_MOD_STATIC
2681	fi
2682	AC_DEFINE_UNQUOTED(SLAPD_RELAY,$MFLAG,[define to support relay backend])
2683fi
2684
2685if test "$ol_enable_shell" != no ; then
2686	if test "$ol_link_threads" != no ; then
2687		AC_MSG_WARN([Use of --without-threads is recommended with back-shell])
2688	fi
2689	BUILD_SLAPD=yes
2690	BUILD_SHELL=$ol_enable_shell
2691	if test "$ol_enable_shell" = mod ; then
2692		SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-shell"
2693		MFLAG=SLAPD_MOD_DYNAMIC
2694	else
2695		SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-shell"
2696		MFLAG=SLAPD_MOD_STATIC
2697	fi
2698	AC_DEFINE_UNQUOTED(SLAPD_SHELL,$MFLAG,[define to support SHELL backend])
2699fi
2700
2701if test "$ol_enable_sock" != no ; then
2702	BUILD_SLAPD=yes
2703	BUILD_SOCK=$ol_enable_sock
2704	if test "$ol_enable_sock" = mod ; then
2705		SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-sock"
2706		MFLAG=SLAPD_MOD_DYNAMIC
2707	else
2708		SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-sock"
2709		MFLAG=SLAPD_MOD_STATIC
2710	fi
2711	AC_DEFINE_UNQUOTED(SLAPD_SOCK,$MFLAG,[define to support SOCK backend])
2712fi
2713
2714if test "$ol_link_sql" != no ; then
2715	BUILD_SLAPD=yes
2716	BUILD_SQL=$ol_enable_sql
2717	if test "$ol_enable_sql" = mod; then
2718		SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-sql"
2719		MFLAG=SLAPD_MOD_DYNAMIC
2720	else
2721		SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-sql"
2722		MFLAG=SLAPD_MOD_STATIC
2723	fi
2724	AC_DEFINE_UNQUOTED(SLAPD_SQL,$MFLAG,[define to support SQL backend])
2725fi
2726
2727if test "$ol_enable_accesslog" != no ; then
2728	BUILD_ACCESSLOG=$ol_enable_accesslog
2729	if test "$ol_enable_accesslog" = mod ; then
2730		MFLAG=SLAPD_MOD_DYNAMIC
2731		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS accesslog.la"
2732	else
2733		MFLAG=SLAPD_MOD_STATIC
2734		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS accesslog.o"
2735	fi
2736	AC_DEFINE_UNQUOTED(SLAPD_OVER_ACCESSLOG,$MFLAG,[define for In-Directory Access Logging overlay])
2737fi
2738
2739if test "$ol_enable_dynid" != no ; then
2740	BUILD_DYNID=$ol_enable_dynid
2741	if test "$ol_enable_dynid" = mod ; then
2742		MFLAG=SLAPD_MOD_DYNAMIC
2743		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS dynid.la"
2744	else
2745		MFLAG=SLAPD_MOD_STATIC
2746		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS dynid.o"
2747	fi
2748	AC_DEFINE_UNQUOTED(SLAPD_OVER_DYNID,$MFLAG,[define for Dynamic ID overlay])
2749fi
2750
2751if test "$ol_enable_odlocales" != no ; then
2752	BUILD_ODLOCALES=$ol_enable_odlocales
2753	if test "$ol_enable_odlocales" = mod ; then
2754		MFLAG=SLAPD_MOD_DYNAMIC
2755		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS odlocales.la"
2756	else
2757		MFLAG=SLAPD_MOD_STATIC
2758		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS odlocales.o"
2759	fi
2760	AC_DEFINE_UNQUOTED(SLAPD_OVER_ODLOCALES,$MFLAG,[define for od locales overlay])
2761fi
2762
2763if test "$ol_enable_odusers" != no ; then
2764	BUILD_ODUSERS=$ol_enable_odusers
2765	if test "$ol_enable_odusers" = mod ; then
2766		MFLAG=SLAPD_MOD_DYNAMIC
2767		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS odusers.la"
2768	else
2769		MFLAG=SLAPD_MOD_STATIC
2770		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS odusers.o"
2771	fi
2772	AC_DEFINE_UNQUOTED(SLAPD_OVER_ODUSERS,$MFLAG,[define for od users overlay])
2773fi
2774
2775if test "$ol_enable_auditlog" != no ; then
2776	BUILD_AUDITLOG=$ol_enable_auditlog
2777	if test "$ol_enable_auditlog" = mod ; then
2778		MFLAG=SLAPD_MOD_DYNAMIC
2779		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS auditlog.la"
2780	else
2781		MFLAG=SLAPD_MOD_STATIC
2782		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS auditlog.o"
2783	fi
2784	AC_DEFINE_UNQUOTED(SLAPD_OVER_AUDITLOG,$MFLAG,[define for Audit Logging overlay])
2785fi
2786
2787if test "$ol_enable_constraint" != no ; then
2788	BUILD_CONSTRAINT=$ol_enable_constraint
2789	if test "$ol_enable_constraint" = mod ; then
2790		MFLAG=SLAPD_MOD_DYNAMIC
2791		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS constraint.la"
2792	else
2793		MFLAG=SLAPD_MOD_STATIC
2794		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS constraint.o"
2795	fi
2796	AC_DEFINE_UNQUOTED(SLAPD_OVER_CONSTRAINT,$MFLAG,[define for Attribute Constraint overlay])
2797fi
2798
2799if test "$ol_enable_dds" != no ; then
2800	BUILD_DDS=$ol_enable_dds
2801	if test "$ol_enable_dds" = mod ; then
2802		MFLAG=SLAPD_MOD_DYNAMIC
2803		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS dds.la"
2804	else
2805		MFLAG=SLAPD_MOD_STATIC
2806		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS dds.o"
2807	fi
2808	AC_DEFINE_UNQUOTED(SLAPD_OVER_DDS,$MFLAG,[define for Dynamic Directory Services overlay])
2809fi
2810
2811if test "$ol_enable_deref" != no ; then
2812	BUILD_DEREF=$ol_enable_deref
2813	if test "$ol_enable_deref" = mod ; then
2814		MFLAG=SLAPD_MOD_DYNAMIC
2815		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS deref.la"
2816	else
2817		MFLAG=SLAPD_MOD_STATIC
2818		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS deref.o"
2819	fi
2820	AC_DEFINE_UNQUOTED(SLAPD_OVER_DEREF,$MFLAG,[define for Dynamic Directory Services overlay])
2821fi
2822
2823if test "$ol_enable_dyngroup" != no ; then
2824	BUILD_DYNGROUP=$ol_enable_dyngroup
2825	if test "$ol_enable_dyngroup" = mod ; then
2826		MFLAG=SLAPD_MOD_DYNAMIC
2827		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS dyngroup.la"
2828	else
2829		MFLAG=SLAPD_MOD_STATIC
2830		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS dyngroup.o"
2831	fi
2832	AC_DEFINE_UNQUOTED(SLAPD_OVER_DYNGROUP,$MFLAG,[define for Dynamic Group overlay])
2833fi
2834if test "$ol_enable_nestedgroup" != no ; then
2835	BUILD_DYNGROUP=$ol_enable_nestedgroup
2836	if test "$ol_enable_nestedgroup" = mod ; then
2837		MFLAG=SLAPD_MOD_DYNAMIC
2838		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS nestedgroup.la"
2839	else
2840		MFLAG=SLAPD_MOD_STATIC
2841		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS nestedgroup.o"
2842	fi
2843	AC_DEFINE_UNQUOTED(SLAPD_OVER_NESTEDGROUP,$MFLAG,[define for Nested Group overlay])
2844fi
2845
2846if test "$ol_enable_dynlist" != no ; then
2847	BUILD_DYNLIST=$ol_enable_dynlist
2848	if test "$ol_enable_dynlist" = mod ; then
2849		MFLAG=SLAPD_MOD_DYNAMIC
2850		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS dynlist.la"
2851	else
2852		MFLAG=SLAPD_MOD_STATIC
2853		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS dynlist.o"
2854	fi
2855	AC_DEFINE_UNQUOTED(SLAPD_OVER_DYNLIST,$MFLAG,[define for Dynamic List overlay])
2856fi
2857
2858if test "$ol_enable_memberof" != no ; then
2859	BUILD_MEMBEROF=$ol_enable_memberof
2860	if test "$ol_enable_memberof" = mod ; then
2861		MFLAG=SLAPD_MOD_DYNAMIC
2862		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS memberof.la"
2863	else
2864		MFLAG=SLAPD_MOD_STATIC
2865		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS memberof.o"
2866	fi
2867	AC_DEFINE_UNQUOTED(SLAPD_OVER_MEMBEROF,$MFLAG,[define for Reverse Group Membership overlay])
2868fi
2869
2870if test "$ol_enable_ppolicy" != no ; then
2871	BUILD_PPOLICY=$ol_enable_ppolicy
2872	if test "$ol_enable_ppolicy" = mod ; then
2873		MFLAG=SLAPD_MOD_DYNAMIC
2874		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS ppolicy.la"
2875	else
2876		MFLAG=SLAPD_MOD_STATIC
2877		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS ppolicy.o"
2878	fi
2879	AC_DEFINE_UNQUOTED(SLAPD_OVER_PPOLICY,$MFLAG,[define for Password Policy overlay])
2880fi
2881
2882if test "$ol_enable_proxycache" != no ; then
2883	BUILD_PROXYCACHE=$ol_enable_proxycache
2884	if test "$ol_enable_proxycache" = mod ; then
2885		MFLAG=SLAPD_MOD_DYNAMIC
2886		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS pcache.la"
2887	else
2888		MFLAG=SLAPD_MOD_STATIC
2889		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS pcache.o"
2890	fi
2891	AC_DEFINE_UNQUOTED(SLAPD_OVER_PROXYCACHE,$MFLAG,[define for Proxy Cache overlay])
2892fi
2893
2894if test "$ol_enable_refint" != no ; then
2895	BUILD_REFINT=$ol_enable_refint
2896	if test "$ol_enable_refint" = mod ; then
2897		MFLAG=SLAPD_MOD_DYNAMIC
2898		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS refint.la"
2899	else
2900		MFLAG=SLAPD_MOD_STATIC
2901		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS refint.o"
2902	fi
2903	AC_DEFINE_UNQUOTED(SLAPD_OVER_REFINT,$MFLAG,[define for Referential Integrity overlay])
2904fi
2905
2906if test "$ol_enable_retcode" != no ; then
2907	BUILD_RETCODE=$ol_enable_retcode
2908	if test "$ol_enable_retcode" = mod ; then
2909		MFLAG=SLAPD_MOD_DYNAMIC
2910		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS retcode.la"
2911	else
2912		MFLAG=SLAPD_MOD_STATIC
2913		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS retcode.o"
2914	fi
2915	AC_DEFINE_UNQUOTED(SLAPD_OVER_RETCODE,$MFLAG,[define for Referential Integrity overlay])
2916fi
2917
2918if test "$ol_enable_seqmod" != no ; then
2919	BUILD_SEQMOD=$ol_enable_seqmod
2920	if test "$ol_enable_seqmod" = mod ; then
2921		MFLAG=SLAPD_MOD_DYNAMIC
2922		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS seqmod.la"
2923	else
2924		MFLAG=SLAPD_MOD_STATIC
2925		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS seqmod.o"
2926	fi
2927	AC_DEFINE_UNQUOTED(SLAPD_OVER_SEQMOD,$MFLAG,[define for Sequential Modify overlay])
2928fi
2929
2930if test "$ol_enable_syncprov" != no ; then
2931	BUILD_SYNCPROV=$ol_enable_syncprov
2932	if test "$ol_enable_syncprov" = mod ; then
2933		MFLAG=SLAPD_MOD_DYNAMIC
2934		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS syncprov.la"
2935	else
2936		MFLAG=SLAPD_MOD_STATIC
2937		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS syncprov.o"
2938	fi
2939	AC_DEFINE_UNQUOTED(SLAPD_OVER_SYNCPROV,$MFLAG,[define for Syncrepl Provider overlay])
2940fi
2941
2942if test "$ol_enable_translucent" != no ; then
2943	BUILD_TRANSLUCENT=$ol_enable_translucent
2944	if test "$ol_enable_translucent" = mod ; then
2945		MFLAG=SLAPD_MOD_DYNAMIC
2946		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS translucent.la"
2947	else
2948		MFLAG=SLAPD_MOD_STATIC
2949		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS translucent.o"
2950	fi
2951	AC_DEFINE_UNQUOTED(SLAPD_OVER_TRANSLUCENT,$MFLAG,[define for Translucent Proxy overlay])
2952fi
2953
2954if test "$ol_enable_unique" != no ; then
2955	BUILD_UNIQUE=$ol_enable_unique
2956	if test "$ol_enable_unique" = mod ; then
2957		MFLAG=SLAPD_MOD_DYNAMIC
2958		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS unique.la"
2959	else
2960		MFLAG=SLAPD_MOD_STATIC
2961		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS unique.o"
2962	fi
2963	AC_DEFINE_UNQUOTED(SLAPD_OVER_UNIQUE,$MFLAG,[define for Attribute Uniqueness overlay])
2964fi
2965
2966if test "$ol_enable_valsort" != no ; then
2967	BUILD_VALSORT=$ol_enable_valsort
2968	if test "$ol_enable_valsort" = mod ; then
2969		MFLAG=SLAPD_MOD_DYNAMIC
2970		SLAPD_DYNAMIC_OVERLAYS="$SLAPD_DYNAMIC_OVERLAYS valsort.la"
2971	else
2972		MFLAG=SLAPD_MOD_STATIC
2973		SLAPD_STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS valsort.o"
2974	fi
2975	AC_DEFINE_UNQUOTED(SLAPD_OVER_VALSORT,$MFLAG,[define for Value Sorting overlay])
2976fi
2977
2978if test "$ol_enable_rewrite" != no ; then
2979	AC_DEFINE(ENABLE_REWRITE,1,[define to enable rewriting in back-ldap and back-meta])
2980	BUILD_REWRITE=yes
2981fi
2982
2983if test "$ol_enable_slapi" != no ; then
2984	AC_DEFINE(ENABLE_SLAPI,1,[define to enable slapi library])
2985	BUILD_SLAPI=yes
2986	SLAPD_SLAPI_DEPEND=libslapi.a
2987fi
2988
2989dnl ----------------------------------------------------------------
2990
2991dnl
2992dnl For Windows build, we don't want to include -dlopen flags.
2993dnl They hurt more than they help.
2994dnl
2995
2996if test "$ac_cv_mingw32" = yes -o $ol_cv_msvc = yes ; then
2997	PLAT=NT
2998	SLAPD_MODULES_LDFLAGS=
2999else
3000	PLAT=UNIX
3001fi
3002
3003AC_SUBST(LIBSRCS)
3004AC_SUBST(PLAT)
3005AC_SUBST(WITH_SASL)
3006AC_SUBST(WITH_TLS)
3007AC_SUBST(WITH_MODULES_ENABLED)
3008AC_SUBST(WITH_ACI_ENABLED)
3009AC_SUBST(BUILD_THREAD)
3010AC_SUBST(BUILD_LIBS_DYNAMIC)
3011
3012AC_SUBST(BUILD_SLAPD)
3013dnl slapi
3014  AC_SUBST(BUILD_SLAPI)
3015  AC_SUBST(SLAPD_SLAPI_DEPEND)
3016dnl backends
3017  AC_SUBST(BUILD_BDB)
3018  AC_SUBST(BUILD_DNSSRV)
3019  AC_SUBST(BUILD_HDB)
3020  AC_SUBST(BUILD_LDAP)
3021  AC_SUBST(BUILD_META)
3022  AC_SUBST(BUILD_MONITOR)
3023  AC_SUBST(BUILD_NULL)
3024  AC_SUBST(BUILD_PASSWD)
3025  AC_SUBST(BUILD_RELAY)
3026  AC_SUBST(BUILD_PERL)
3027  AC_SUBST(BUILD_SHELL)
3028  AC_SUBST(BUILD_SOCK)
3029  AC_SUBST(BUILD_SQL)
3030dnl overlays
3031  AC_SUBST(BUILD_ACCESSLOG)
3032  AC_SUBST(BUILD_DYNID)
3033  AC_SUBST(BUILD_ODLOCALES)
3034  AC_SUBST(BUILD_ODUSERS)
3035  AC_SUBST(BUILD_AUDITLOG)
3036  AC_SUBST(BUILD_CONSTRAINT)
3037  AC_SUBST(BUILD_DDS)
3038  AC_SUBST(BUILD_DENYOP)
3039  AC_SUBST(BUILD_DEREF)
3040  AC_SUBST(BUILD_DYNGROUP)
3041  AC_SUBST(BUILD_DYNLIST)
3042  AC_SUBST(BUILD_LASTMOD)
3043  AC_SUBST(BUILD_MEMBEROF)
3044  AC_SUBST(BUILD_PPOLICY)
3045  AC_SUBST(BUILD_PROXYCACHE)
3046  AC_SUBST(BUILD_REFINT)
3047  AC_SUBST(BUILD_RETCODE)
3048  AC_SUBST(BUILD_SEQMOD)
3049  AC_SUBST(BUILD_SYNCPROV)
3050  AC_SUBST(BUILD_TRANSLUCENT)
3051  AC_SUBST(BUILD_UNIQUE)
3052  AC_SUBST(BUILD_VALSORT)
3053
3054AC_SUBST(LDAP_LIBS)
3055AC_SUBST(SLAPD_LIBS)
3056AC_SUBST(BDB_LIBS)
3057AC_SUBST(LTHREAD_LIBS)
3058AC_SUBST(LUTIL_LIBS)
3059AC_SUBST(WRAP_LIBS)
3060
3061AC_SUBST(SLAPD_MODULES_CPPFLAGS)
3062AC_SUBST(SLAPD_MODULES_LDFLAGS)
3063
3064AC_SUBST(SLAPD_NO_STATIC)
3065AC_SUBST(SLAPD_STATIC_BACKENDS)
3066AC_SUBST(SLAPD_DYNAMIC_BACKENDS)
3067AC_SUBST(SLAPD_STATIC_OVERLAYS)
3068AC_SUBST(SLAPD_DYNAMIC_OVERLAYS)
3069
3070AC_SUBST(PERL_CPPFLAGS)
3071AC_SUBST(SLAPD_PERL_LDFLAGS)
3072AC_SUBST(MOD_PERL_LDFLAGS)
3073
3074AC_SUBST(KRB4_LIBS)
3075AC_SUBST(KRB5_LIBS)
3076AC_SUBST(SASL_LIBS)
3077AC_SUBST(TLS_LIBS)
3078AC_SUBST(MODULES_LIBS)
3079AC_SUBST(SLAPI_LIBS)
3080AC_SUBST(LIBSLAPI)
3081AC_SUBST(LIBSLAPITOOLS)
3082AC_SUBST(AUTH_LIBS)
3083AC_SUBST(ICU_LIBS)
3084
3085AC_SUBST(SLAPD_SLP_LIBS)
3086AC_SUBST(SLAPD_GMP_LIBS)
3087
3088AC_SUBST(SLAPD_SQL_LDFLAGS)
3089AC_SUBST(SLAPD_SQL_LIBS)
3090AC_SUBST(SLAPD_SQL_INCLUDES)
3091
3092dnl ----------------------------------------------------------------
3093dnl final help output
3094AC_ARG_WITH(xxinstall,[
3095See INSTALL file for further details.])
3096
3097dnl ----------------------------------------------------------------
3098dnl final output
3099dnl
3100
3101AC_CONFIG_FILES([Makefile:build/top.mk:Makefile.am:Makefile.in:build/dir.mk]
3102[doc/Makefile:build/top.mk:doc/Makefile.in:build/dir.mk]
3103[doc/man/Makefile:build/top.mk:doc/man/Makefile.in:build/dir.mk]
3104[doc/man/man1/Makefile:build/top.mk:doc/man/man1/Makefile.in:build/man.mk]
3105[doc/man/man3/Makefile:build/top.mk:doc/man/man3/Makefile.in:build/man.mk]
3106[doc/man/man5/Makefile:build/top.mk:doc/man/man5/Makefile.in:build/man.mk]
3107[doc/man/man8/Makefile:build/top.mk:doc/man/man8/Makefile.in:build/man.mk]
3108[clients/Makefile:build/top.mk:clients/Makefile.in:build/dir.mk]
3109[clients/tools/Makefile:build/top.mk:clients/tools/Makefile.in:build/rules.mk]
3110[include/Makefile:build/top.mk:include/Makefile.in]
3111[libraries/Makefile:build/top.mk:libraries/Makefile.in:build/dir.mk]
3112[libraries/liblber/Makefile:build/top.mk:libraries/liblber/Makefile.in:build/lib.mk:build/lib-shared.mk]
3113[libraries/libldap/Makefile:build/top.mk:libraries/libldap/Makefile.in:build/lib.mk:build/lib-shared.mk]
3114[libraries/libldap_r/Makefile:build/top.mk:libraries/libldap_r/Makefile.in:build/lib.mk:build/lib-shared.mk]
3115[libraries/liblunicode/Makefile:build/top.mk:libraries/liblunicode/Makefile.in:build/lib.mk:build/lib-static.mk]
3116[libraries/liblutil/Makefile:build/top.mk:libraries/liblutil/Makefile.in:build/lib.mk:build/lib-static.mk]
3117[libraries/librewrite/Makefile:build/top.mk:libraries/librewrite/Makefile.in:build/lib.mk:build/lib-static.mk]
3118[servers/Makefile:build/top.mk:servers/Makefile.in:build/dir.mk]
3119[servers/slapd/Makefile:build/top.mk:servers/slapd/Makefile.in:build/srv.mk]
3120[servers/slapd/back-bdb/Makefile:build/top.mk:servers/slapd/back-bdb/Makefile.in:build/mod.mk]
3121[servers/slapd/back-dnssrv/Makefile:build/top.mk:servers/slapd/back-dnssrv/Makefile.in:build/mod.mk]
3122[servers/slapd/back-hdb/Makefile:build/top.mk:servers/slapd/back-hdb/Makefile.in:build/mod.mk]
3123[servers/slapd/back-ldap/Makefile:build/top.mk:servers/slapd/back-ldap/Makefile.in:build/mod.mk]
3124[servers/slapd/back-ldif/Makefile:build/top.mk:servers/slapd/back-ldif/Makefile.in:build/mod.mk]
3125[servers/slapd/back-meta/Makefile:build/top.mk:servers/slapd/back-meta/Makefile.in:build/mod.mk]
3126[servers/slapd/back-monitor/Makefile:build/top.mk:servers/slapd/back-monitor/Makefile.in:build/mod.mk]
3127[servers/slapd/back-null/Makefile:build/top.mk:servers/slapd/back-null/Makefile.in:build/mod.mk]
3128[servers/slapd/back-passwd/Makefile:build/top.mk:servers/slapd/back-passwd/Makefile.in:build/mod.mk]
3129[servers/slapd/back-perl/Makefile:build/top.mk:servers/slapd/back-perl/Makefile.in:build/mod.mk]
3130[servers/slapd/back-relay/Makefile:build/top.mk:servers/slapd/back-relay/Makefile.in:build/mod.mk]
3131[servers/slapd/back-shell/Makefile:build/top.mk:servers/slapd/back-shell/Makefile.in:build/mod.mk]
3132[servers/slapd/back-sock/Makefile:build/top.mk:servers/slapd/back-sock/Makefile.in:build/mod.mk]
3133[servers/slapd/back-sql/Makefile:build/top.mk:servers/slapd/back-sql/Makefile.in:build/mod.mk]
3134[servers/slapd/shell-backends/Makefile:build/top.mk:servers/slapd/shell-backends/Makefile.in:build/srv.mk]
3135[servers/slapd/slapi/Makefile:build/top.mk:servers/slapd/slapi/Makefile.in:build/lib.mk:build/lib-shared.mk]
3136[servers/slapd/overlays/Makefile:build/top.mk:servers/slapd/overlays/Makefile.in:build/lib.mk]
3137[tests/Makefile:build/top.mk:tests/Makefile.in:build/dir.mk]
3138[tests/run]
3139[tests/progs/Makefile:build/top.mk:tests/progs/Makefile.in:build/rules.mk])
3140
3141AC_CONFIG_COMMANDS([default],[[
3142chmod +x tests/run
3143date > stamp-h
3144BACKENDSC="servers/slapd/backends.c"
3145echo "Making $BACKENDSC"
3146rm -f $BACKENDSC
3147cat > $BACKENDSC << ENDX
3148/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3149 *
3150 * Copyright 1998-2011 The OpenLDAP Foundation.
3151 * All rights reserved.
3152 *
3153 * Redistribution and use in source and binary forms, with or without
3154 * modification, are permitted only as authorized by the OpenLDAP
3155 * Public License.
3156 *
3157 * A copy of this license is available in the file LICENSE in the
3158 * top-level directory of the distribution or, alternatively, at
3159 * <http://www.OpenLDAP.org/license.html>.
3160 */
3161/* This file is automatically generated by configure; please do not edit. */
3162
3163#include "portable.h"
3164#include "slap.h"
3165
3166ENDX
3167if test "${STATIC_BACKENDS}"; then
3168	for b in config ${STATIC_BACKENDS}; do
3169		bb=`echo "${b}" | sed -e 's/back-//'`
3170		cat >> $BACKENDSC << ENDX
3171extern BI_init ${bb}_back_initialize;
3172ENDX
3173	done
3174
3175	cat >> $BACKENDSC << ENDX
3176
3177BackendInfo slap_binfo[] = {
3178ENDX
3179
3180	for b in config ${STATIC_BACKENDS}; do
3181		bb=`echo "${b}" | sed -e 's/back-//'`
3182		echo "    Add ${bb} ..."
3183		cat >> $BACKENDSC << ENDX
3184	{ "${bb}", ${bb}_back_initialize },
3185ENDX
3186	done
3187
3188	cat >> $BACKENDSC << ENDX
3189	{ NULL, NULL },
3190};
3191
3192/* end of generated file */
3193ENDX
3194fi
3195OVERLAYSC="servers/slapd/overlays/statover.c"
3196echo "Making $OVERLAYSC"
3197rm -f $OVERLAYSC
3198cat > $OVERLAYSC << ENDX
3199/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3200 *
3201 * Copyright 1998-2011 The OpenLDAP Foundation.
3202 * All rights reserved.
3203 *
3204 * Redistribution and use in source and binary forms, with or without
3205 * modification, are permitted only as authorized by the OpenLDAP
3206 * Public License.
3207 *
3208 * A copy of this license is available in the file LICENSE in the
3209 * top-level directory of the distribution or, alternatively, at
3210 * <http://www.OpenLDAP.org/license.html>.
3211 */
3212/* This file is automatically generated by configure; please do not edit. */
3213
3214#include "portable.h"
3215#include "slap.h"
3216
3217ENDX
3218if test "${STATIC_OVERLAYS}"; then
3219	for o in ${STATIC_OVERLAYS}; do
3220		oo=`echo "${o}" | sed -e 's/.o$//' -e 's/_x$//'`
3221		cat >> $OVERLAYSC << ENDX
3222extern OV_init ${oo}_initialize;
3223ENDX
3224	done
3225fi
3226
3227cat >> $OVERLAYSC << ENDX
3228
3229OverlayInit slap_oinfo[] = {
3230ENDX
3231
3232if test "${STATIC_OVERLAYS}"; then
3233	for o in ${STATIC_OVERLAYS}; do
3234		oo=`echo "${o}" | sed -e 's/.o$//' -e 's/_x$//'`
3235		echo "    Add ${oo} ..."
3236		cat >> $OVERLAYSC << ENDX
3237	{ "${oo}", ${oo}_initialize },
3238ENDX
3239	done
3240fi
3241
3242	cat >> $OVERLAYSC << ENDX
3243	{ NULL, NULL },
3244};
3245
3246/* end of generated file */
3247ENDX
3248
3249if test "${ol_cv_mkdep}" = no; then
3250	echo '(Do not "make depend"; we do not know how to build dependencies)'
3251else
3252	echo 'Please run "make depend" to build dependencies'
3253fi
3254]],[[
3255STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS"
3256STATIC_OVERLAYS="$SLAPD_STATIC_OVERLAYS"
3257]])
3258AC_OUTPUT
3259