configure.in revision 254897
1# Copyright (C) 2004-2013  Internet Systems Consortium, Inc. ("ISC")
2# Copyright (C) 1998-2003  Internet Software Consortium.
3#
4# Permission to use, copy, modify, and/or distribute this software for any
5# purpose with or without fee is hereby granted, provided that the above
6# copyright notice and this permission notice appear in all copies.
7#
8# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14# PERFORMANCE OF THIS SOFTWARE.
15
16dnl
17AC_DIVERT_PUSH(1)dnl
18esyscmd([sed "s/^/# /" COPYRIGHT])dnl
19AC_DIVERT_POP()dnl
20
21AC_REVISION($Revision: 1.533 $)
22
23AC_INIT(lib/dns/name.c)
24AC_PREREQ(2.59)
25
26AC_CONFIG_HEADER(config.h)
27AC_CONFIG_MACRO_DIR([libtool.m4])
28
29AC_CANONICAL_HOST
30
31AC_PROG_MAKE_SET
32
33#
34# GNU libtool support
35#
36case $build_os in
37sunos*)
38    # Just set the maximum command line length for sunos as it otherwise
39    # takes a exceptionally long time to work it out. Required for libtool.
40
41    lt_cv_sys_max_cmd_len=4096;
42    ;;
43esac
44
45AC_PROG_LIBTOOL
46AC_PROG_INSTALL
47AC_PROG_LN_S
48
49AC_SUBST(STD_CINCLUDES)
50AC_SUBST(STD_CDEFINES)
51AC_SUBST(STD_CWARNINGS)
52AC_SUBST(CCOPT)
53
54# Warn if the user specified libbind, which is now deprecated
55AC_ARG_ENABLE(libbind, [  --enable-libbind	  deprecated])
56
57case "$enable_libbind" in
58	yes)
59		AC_MSG_ERROR(['libbind' is no longer part of the BIND 9 distribution.
60It is available from http://www.isc.org as a separate download.])
61		;;
62	no|'')
63		;;
64esac
65
66AC_ARG_ENABLE(developer, [  --enable-developer      enable developer build settings])
67case "$enable_developer" in
68yes)
69	STD_CDEFINES="$STD_CDEFINES -DISC_LIST_CHECKINIT=1"
70	test "${enable_fixed_rrset+set}" = set || enable_fixed_rrset=yes
71	test "${with_atf+set}" = set || with_atf=yes
72	test "${enable_filter_aaaa+set}" = set || enable_filter_aaaa=yes
73	test "${with_dlz_filesystem+set}" = set || with_dlz_filesystem=yes
74	case "$host" in
75	*-darwin*)
76		test "${enable_exportlib+set}" = set || enable_exportlib=yes
77		;;
78	*-linux*)
79		test "${enable_exportlib+set}" = set || enable_exportlib=yes
80		;;
81	esac
82	;;
83esac
84#
85# Make very sure that these are the first files processed by
86# config.status, since we use the processed output as the input for
87# AC_SUBST_FILE() substitutions in other files.
88#
89AC_CONFIG_FILES([make/rules make/includes])
90
91AC_PATH_PROG(AR, ar)
92ARFLAGS="cruv"
93AC_SUBST(AR)
94AC_SUBST(ARFLAGS)
95
96# The POSIX ln(1) program.  Non-POSIX systems may substitute
97# "copy" or something.
98LN=ln
99AC_SUBST(LN)
100
101case "$AR" in
102	"")
103		AC_MSG_ERROR([
104ar program not found.  Please fix your PATH to include the directory in
105which ar resides, or set AR in the environment with the full path to ar.
106])
107
108		;;
109esac
110
111#
112# Etags.
113#
114AC_PATH_PROGS(ETAGS, etags emacs-etags)
115
116#
117# Some systems, e.g. RH7, have the Exuberant Ctags etags instead of
118# GNU emacs etags, and it requires the -L flag.
119#
120if test "X$ETAGS" != "X"; then
121	AC_MSG_CHECKING(for Exuberant Ctags etags)
122	if $ETAGS --version 2>&1 | grep 'Exuberant Ctags' >/dev/null 2>&1; then
123		AC_MSG_RESULT(yes)
124		ETAGS="$ETAGS -L"
125	else
126		AC_MSG_RESULT(no)
127	fi
128fi
129AC_SUBST(ETAGS)
130
131#
132# Perl is optional; it is used only by some of the system test scripts.
133# Note: the backtrace feature (see below) uses perl to build the symbol table,
134# but it still compiles without perl, in which case an empty table will be used.
135#
136AC_PATH_PROGS(PERL, perl5 perl)
137AC_SUBST(PERL)
138
139#
140# Python is also optional; it is used by the tools in bin/python.
141# If python is unavailable, we simply don't build those.
142#
143AC_ARG_WITH(python,
144[  --with-python=PATH      Specify path to python interpreter],
145    use_python="$withval", use_python="unspec")
146
147case "$use_python" in
148	no)
149		AC_MSG_RESULT(disabled)
150		;;
151	unspec|yes|*)
152		case "$use_python" in
153		unspec|yes|'')
154			AC_PATH_PROGS(PYTHON, python)
155			;;
156		*)
157			AC_PATH_PROGS(PYTHON, $use_python)
158			;;
159		esac
160		if test "X$PYTHON" == "X"
161		then
162			case "$use_python" in
163			unspec)
164				AC_MSG_RESULT(disabled)
165				;;
166			yes|*)
167				AC_MSG_ERROR([missing python])
168				;;
169			esac
170			break
171		fi
172                testscript='try: import argparse
173except: exit(1)'
174		AC_MSG_CHECKING([python module 'argparse'])
175                if $PYTHON -c "$testscript"; then
176                        AC_MSG_RESULT([found, using $PYTHON])
177                else
178			case "$use_python" in
179			unspec)
180				PYTHON=""
181				AC_SUBST(CHECKDS)
182				AC_SUBST(COVERAGE)
183				AC_MSG_RESULT([not found, python disabled])
184				;;
185			yes)
186                        AC_MSG_RESULT([no found])
187                        AC_MSG_ERROR([python 'argparse' module not supported])
188				;;
189			esac
190                fi
191		;;
192esac
193
194PYTHON_TOOLS=''
195CHECKDS=''
196COVERAGE=''
197if test "X$PYTHON" != "X"; then
198        PYTHON_TOOLS=python
199	CHECKDS=checkds
200	COVERAGE=coverage
201fi
202AC_SUBST(CHECKDS)
203AC_SUBST(COVERAGE)
204AC_SUBST(PYTHON_TOOLS)
205
206#
207# Special processing of paths depending on whether --prefix,
208# --sysconfdir or --localstatedir arguments were given.  What's
209# desired is some compatibility with the way previous versions
210# of BIND built; they defaulted to /usr/local for most parts of
211# the installation, but named.boot/named.conf was in /etc
212# and named.pid was in /var/run.
213#
214# So ... if none of --prefix, --sysconfdir or --localstatedir are
215# specified, set things up that way.  If --prefix is given, use
216# it for sysconfdir and localstatedir the way configure normally
217# would.  To change the prefix for everything but leave named.conf
218# in /etc or named.pid in /var/run, then do this the usual configure way:
219# ./configure --prefix=/somewhere --sysconfdir=/etc
220# ./configure --prefix=/somewhere --localstatedir=/var
221#
222# To put named.conf and named.pid in /usr/local with everything else,
223# set the prefix explicitly to /usr/local even though that's the default:
224# ./configure --prefix=/usr/local
225#
226case "$prefix" in
227	NONE)
228		case "$sysconfdir" in
229			'${prefix}/etc')
230				sysconfdir=/etc
231				;;
232		esac
233		case "$localstatedir" in
234			'${prefix}/var')
235				localstatedir=/var
236				;;
237		esac
238		;;
239esac
240
241#
242# Make sure INSTALL uses an absolute path, else it will be wrong in all
243# Makefiles, since they use make/rules.in and INSTALL will be adjusted by
244# configure based on the location of the file where it is substituted.
245# Since in BIND9 INSTALL is only substituted into make/rules.in, an immediate
246# subdirectory of install-sh, This relative path will be wrong for all
247# directories more than one level down from install-sh.
248#
249case "$INSTALL" in
250	/*)
251		;;
252	*)
253		#
254		# Not all systems have dirname.
255		#
256		changequote({, })
257		ac_dir="`echo $INSTALL | sed 's%/[^/]*$%%'`"
258		changequote([, ])
259
260		ac_prog="`echo $INSTALL | sed 's%.*/%%'`"
261		test "$ac_dir" = "$ac_prog" && ac_dir=.
262		test -d "$ac_dir" && ac_dir="`(cd \"$ac_dir\" && pwd)`"
263		INSTALL="$ac_dir/$ac_prog"
264		;;
265esac
266
267#
268# On these hosts, we really want to use cc, not gcc, even if it is
269# found.  The gcc that these systems have will not correctly handle
270# pthreads.
271#
272# However, if the user sets $CC to be something, let that override
273# our change.
274#
275if test "X$CC" = "X" ; then
276	case "$host" in
277		*-dec-osf*)
278			CC="cc"
279			;;
280		*-solaris*)
281			# Use Sun's cc if it is available, but watch
282			# out for /usr/ucb/cc; it will never be the right
283			# compiler to use.
284			#
285			# If setting CC here fails, the AC_PROG_CC done
286			# below might still find gcc.
287			IFS="${IFS=	}"; ac_save_ifs="$IFS"; IFS=":"
288			for ac_dir in $PATH; do
289				test -z "$ac_dir" && ac_dir=.
290				case "$ac_dir" in
291				/usr/ucb)
292					# exclude
293					;;
294				*)
295					if test -f "$ac_dir/cc"; then
296						CC="$ac_dir/cc"
297						break
298					fi
299					;;
300				esac
301			done
302			IFS="$ac_save_ifs"
303			;;
304		*-hp-hpux*)
305			CC="cc"
306			;;
307		mips-sgi-irix*)
308			CC="cc"
309			;;
310	esac
311fi
312
313AC_PROG_CC
314
315#
316# gcc's optimiser is broken at -02 for ultrasparc
317#
318if test "$ac_env_CFLAGS_set" != set -a "X$GCC" = "Xyes"; then
319	case "$host" in
320	sparc-*)
321		CCFLAGS="-g -O1"
322		;;
323	esac
324fi
325
326#
327# OS dependent CC flags
328#
329case "$host" in
330	# OSF 5.0: recv/send are only available with -D_POSIX_PII_SOCKET or
331	# -D_XOPEN_SOURCE_EXTENDED.
332	*-dec-osf*)
333		STD_CDEFINES="$STD_CDEFINES -D_POSIX_PII_SOCKET"
334		CPPFLAGS="$CPPFLAGS -D_POSIX_PII_SOCKET"
335		;;
336	#HP-UX: need -D_XOPEN_SOURCE_EXTENDED and -lxnet for CMSG macros
337	*-hp-hpux*)
338		STD_CDEFINES="$STD_CDEFINES -D_XOPEN_SOURCE_EXTENDED"
339		CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
340		LIBS="-lxnet $LIBS"
341		;;
342	# Solaris: need -D_XPG4_2 and -D__EXTENSIONS__ for CMSG macros
343	*-solaris*)
344		STD_CDEFINES="$STD_CDEFINES -D_XPG4_2 -D__EXTENSIONS__"
345		CPPFLAGS="$CPPFLAGS -D_XPG4_2 -D__EXTENSIONS__"
346		;;
347	# POSIX doesn't include the IPv6 Advanced Socket API and glibc hides
348	# parts of the IPv6 Advanced Socket API as a result.  This is stupid
349	# as it breaks how the two halves (Basic and Advanced) of the IPv6
350	# Socket API were designed to be used but we have to live with it.
351	# Define _GNU_SOURCE to pull in the IPv6 Advanced Socket API.
352	*-linux* | *-kfreebsd*-gnu)
353		STD_CDEFINES="$STD_CDEFINES -D_GNU_SOURCE"
354		CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
355		;;
356	#
357	# Starting with OSX 10.7 (Lion) we must choose which IPv6 API to use.
358	# Setting this is sufficient to select the correct behavior for BIND 9.
359	#
360	*-darwin*)
361	  STD_CDEFINES="$STD_CDEFINES -D__APPLE_USE_RFC_3542"
362	  CPPFLAGS="$CPPFLAGS -D__APPLE_USE_RFC_3542"
363	  ;;
364esac
365
366AC_HEADER_STDC
367
368AC_CHECK_HEADERS(fcntl.h regex.h sys/time.h unistd.h sys/sockio.h sys/select.h sys/param.h sys/sysctl.h net/if6.h,,,
369[$ac_includes_default
370#ifdef HAVE_SYS_PARAM_H
371# include <sys/param.h>
372#endif
373])
374
375AC_C_CONST
376AC_C_INLINE
377AC_C_VOLATILE
378AC_CHECK_FUNC(sysctlbyname, AC_DEFINE(HAVE_SYSCTLBYNAME))
379AC_C_FLEXIBLE_ARRAY_MEMBER
380
381#
382# Older versions of HP/UX don't define seteuid() and setegid()
383#
384AC_CHECK_FUNCS(seteuid setresuid)
385AC_CHECK_FUNCS(setegid setresgid)
386
387#
388# UnixWare 7.1.1 with the feature supplement to the UDK compiler
389# is reported to not support "static inline" (RT #1212).
390#
391AC_MSG_CHECKING(for static inline breakage)
392AC_TRY_COMPILE([
393	static inline int foo1() {
394		return 0;
395	}
396
397	static inline int foo2() {
398		return foo1();
399	}
400	], [foo1();],
401	[AC_MSG_RESULT(no)],
402	[AC_MSG_RESULT(yes)
403	 AC_DEFINE(inline, ,[Define to empty if your compiler does not support "static inline".])])
404
405AC_TYPE_SIZE_T
406AC_CHECK_TYPE(ssize_t, int)
407AC_CHECK_TYPE(uintptr_t,unsigned long)
408AC_CHECK_TYPE(socklen_t,
409[AC_DEFINE(ISC_SOCKADDR_LEN_T, socklen_t)],
410[
411AC_TRY_COMPILE(
412[
413#include <sys/types.h>
414#include <sys/socket.h>
415int getsockname(int, struct sockaddr *, size_t *);
416],[],
417[AC_DEFINE(ISC_SOCKADDR_LEN_T, size_t)],
418[AC_DEFINE(ISC_SOCKADDR_LEN_T, int)])
419],
420[
421#include <sys/types.h>
422#include <sys/socket.h>
423])
424AC_SUBST(ISC_SOCKADDR_LEN_T)
425AC_HEADER_TIME
426AC_MSG_CHECKING(for long long)
427AC_TRY_COMPILE([],[long long i = 0; return (0);],
428	[AC_MSG_RESULT(yes)
429		ISC_PLATFORM_HAVELONGLONG="#define ISC_PLATFORM_HAVELONGLONG 1"],
430	[AC_MSG_RESULT(no)
431		ISC_PLATFORM_HAVELONGLONG="#undef ISC_PLATFORM_HAVELONGLONG"])
432AC_SUBST(ISC_PLATFORM_HAVELONGLONG)
433
434#
435# check for GCC noreturn attribute
436#
437AC_MSG_CHECKING(for GCC noreturn attribute)
438AC_TRY_COMPILE([],[void foo() __attribute__((noreturn));],
439	[AC_MSG_RESULT(yes)
440		ISC_PLATFORM_NORETURN_PRE="#define ISC_PLATFORM_NORETURN_PRE"
441		ISC_PLATFORM_NORETURN_POST="#define ISC_PLATFORM_NORETURN_POST __attribute__((noreturn))"],
442	[AC_MSG_RESULT(no)
443		ISC_PLATFORM_NORETURN_PRE="#define ISC_PLATFORM_NORETURN_PRE"
444		ISC_PLATFORM_NORETURN_POST="#define ISC_PLATFORM_NORETURN_POST"])
445AC_SUBST(ISC_PLATFORM_NORETURN_PRE)
446AC_SUBST(ISC_PLATFORM_NORETURN_POST)
447
448#
449# check if we have lifconf
450#
451AC_MSG_CHECKING(for struct lifconf)
452AC_TRY_COMPILE([
453#include <sys/types.h>
454#include <sys/socket.h>
455#include <net/if.h>
456],
457[
458struct lifconf lifconf;
459lifconf.lifc_len = 0;
460]
461,
462	[AC_MSG_RESULT(yes)
463		ISC_PLATFORM_HAVELIFCONF="#define ISC_PLATFORM_HAVELIFCONF 1"],
464	[AC_MSG_RESULT(no)
465		ISC_PLATFORM_HAVELIFCONF="#undef ISC_PLATFORM_HAVELIFCONF"])
466AC_SUBST(ISC_PLATFORM_HAVELIFCONF)
467
468#
469# check if we want the new statistics
470#
471AC_ARG_ENABLE(newstats,
472	[  --enable-newstats         use the new statistics])
473case "$enable_newstats" in
474yes)
475        AC_DEFINE(NEWSTATS, 1, [Use the new XML schema for statistics])
476	;;
477*)
478	;;
479esac
480
481#
482# check if we have kqueue
483#
484AC_ARG_ENABLE(kqueue,
485	[  --enable-kqueue         use BSD kqueue when available [[default=yes]]],
486	      want_kqueue="$enableval",  want_kqueue="yes")
487case $want_kqueue in
488yes)
489	AC_CHECK_FUNC(kqueue, ac_cv_have_kqueue=yes, ac_cv_have_kqueue=no)
490	case $ac_cv_have_kqueue in
491	yes)
492		ISC_PLATFORM_HAVEKQUEUE="#define ISC_PLATFORM_HAVEKQUEUE 1"
493		;;
494	*)
495		ISC_PLATFORM_HAVEKQUEUE="#undef ISC_PLATFORM_HAVEKQUEUE"
496		;;
497	esac
498	;;
499*)
500	ISC_PLATFORM_HAVEKQUEUE="#undef ISC_PLATFORM_HAVEKQUEUE"
501	;;
502esac
503AC_SUBST(ISC_PLATFORM_HAVEKQUEUE)
504
505#
506# check if we have epoll.  Linux kernel 2.4 has epoll_create() which fails,
507# so we need to try running the code, not just test its existence.
508#
509AC_ARG_ENABLE(epoll,
510[  --enable-epoll          use Linux epoll when available [[default=auto]]],
511	      want_epoll="$enableval",  want_epoll="auto")
512case $want_epoll in
513auto)
514	AC_MSG_CHECKING(epoll support)
515	AC_TRY_RUN([
516#include <sys/epoll.h>
517int main() {
518	if (epoll_create(1) < 0)
519		return (1);
520	return (0);
521}
522],
523	[AC_MSG_RESULT(yes)
524	ISC_PLATFORM_HAVEEPOLL="#define ISC_PLATFORM_HAVEEPOLL 1"],
525	[AC_MSG_RESULT(no)
526	ISC_PLATFORM_HAVEEPOLL="#undef ISC_PLATFORM_HAVEEPOLL"],
527	[AC_MSG_RESULT(no)
528	ISC_PLATFORM_HAVEEPOLL="#undef ISC_PLATFORM_HAVEEPOLL"])
529	;;
530yes)
531	ISC_PLATFORM_HAVEEPOLL="#define ISC_PLATFORM_HAVEEPOLL 1"
532	;;
533*)
534	ISC_PLATFORM_HAVEEPOLL="#undef ISC_PLATFORM_HAVEEPOLL"
535	;;
536esac
537AC_SUBST(ISC_PLATFORM_HAVEEPOLL)
538
539#
540# check if we support /dev/poll
541#
542AC_ARG_ENABLE(devpoll,
543	[  --enable-devpoll        use /dev/poll when available [[default=yes]]],
544	      want_devpoll="$enableval",  want_devpoll="yes")
545case $want_devpoll in
546yes)
547	AC_CHECK_HEADERS(sys/devpoll.h devpoll.h,
548	ISC_PLATFORM_HAVEDEVPOLL="#define ISC_PLATFORM_HAVEDEVPOLL 1"
549	,
550	ISC_PLATFORM_HAVEDEVPOLL="#undef ISC_PLATFORM_HAVEDEVPOLL"
551	)
552	;;
553*)
554	ISC_PLATFORM_HAVEDEVPOLL="#undef ISC_PLATFORM_HAVEDEVPOLL"
555	;;
556esac
557AC_SUBST(ISC_PLATFORM_HAVEDEVPOLL)
558
559#
560# check if we need to #include sys/select.h explicitly
561#
562case $ac_cv_header_unistd_h in
563yes)
564AC_MSG_CHECKING(if unistd.h or sys/types.h defines fd_set)
565AC_TRY_COMPILE([
566#include <sys/types.h> /* Ultrix */
567#include <unistd.h>],
568[fd_set read_set; return (0);],
569	[AC_MSG_RESULT(yes)
570	 ISC_PLATFORM_NEEDSYSSELECTH="#undef ISC_PLATFORM_NEEDSYSSELECTH"
571	 LWRES_PLATFORM_NEEDSYSSELECTH="#undef LWRES_PLATFORM_NEEDSYSSELECTH"],
572	[AC_MSG_RESULT(no)
573	case $ac_cv_header_sys_select_h in
574	yes)
575	 ISC_PLATFORM_NEEDSYSSELECTH="#define ISC_PLATFORM_NEEDSYSSELECTH 1"
576	 LWRES_PLATFORM_NEEDSYSSELECTH="#define LWRES_PLATFORM_NEEDSYSSELECTH 1"
577		;;
578	no)
579		AC_MSG_ERROR([need either working unistd.h or sys/select.h])
580		;;
581	esac
582	])
583	;;
584no)
585	case $ac_cv_header_sys_select_h in
586	yes)
587	     ISC_PLATFORM_NEEDSYSSELECTH="#define ISC_PLATFORM_NEEDSYSSELECTH 1"
588	     LWRES_PLATFORM_NEEDSYSSELECTH="#define LWRES_PLATFORM_NEEDSYSSELECTH 1"
589		;;
590	no)
591		AC_MSG_ERROR([need either unistd.h or sys/select.h])
592		;;
593	esac
594	;;
595esac
596AC_SUBST(ISC_PLATFORM_NEEDSYSSELECTH)
597AC_SUBST(LWRES_PLATFORM_NEEDSYSSELECTH)
598
599#
600# Find the machine's endian flavor.
601#
602AC_C_BIGENDIAN
603
604#
605# was --with-openssl specified?
606#
607OPENSSL_WARNING=
608AC_MSG_CHECKING(for OpenSSL library)
609AC_ARG_WITH(openssl,
610[  --with-openssl[=PATH]     Build with OpenSSL [yes|no|path].
611			  (Required for DNSSEC)],
612    use_openssl="$withval", use_openssl="auto")
613
614openssldirs="/usr /usr/local /usr/local/ssl /usr/pkg /usr/sfw"
615if test "$use_openssl" = "auto"
616then
617	for d in $openssldirs
618	do
619		if test -f $d/include/openssl/opensslv.h
620		then
621			use_openssl=$d
622			break
623		fi
624	done
625fi
626OPENSSL_ECDSA=""
627OPENSSL_GOST=""
628case "$use_openssl" in
629	no)
630		AC_MSG_RESULT(no)
631		DST_OPENSSL_INC=""
632		USE_OPENSSL=""
633		OPENSSLGOSTLINKOBJS=""
634		OPENSSLGOSTLINKSRS=""
635		OPENSSLLINKOBJS=""
636		OPENSSLLINKSRCS=""
637		;;
638	auto)
639		DST_OPENSSL_INC=""
640		USE_OPENSSL=""
641		OPENSSLGOSTLINKOBJS=""
642		OPENSSLGOSTLINKSRS=""
643		OPENSSLLINKOBJS=""
644		OPENSSLLINKSRCS=""
645		AC_MSG_ERROR(
646[OpenSSL was not found in any of $openssldirs; use --with-openssl=/path
647If you don't want OpenSSL, use --without-openssl])
648		;;
649	*)
650		if test "$use_openssl" = "yes"
651		then
652			# User did not specify a path - guess it
653			for d in $openssldirs
654			do
655				if test -f $d/include/openssl/opensslv.h
656				then
657					use_openssl=$d
658					break
659				fi
660			done
661			if test "$use_openssl" = "yes"
662			then
663				AC_MSG_RESULT(not found)
664				AC_MSG_ERROR(
665[OpenSSL was not found in any of $openssldirs; use --with-openssl=/path])
666			fi
667		elif ! test -f "$use_openssl"/include/openssl/opensslv.h
668		then
669			AC_MSG_ERROR(["$use_openssl/include/openssl/opensslv.h" not found])
670		fi
671		USE_OPENSSL='-DOPENSSL'
672		if test "$use_openssl" = "/usr"
673		then
674			DST_OPENSSL_INC=""
675			DNS_OPENSSL_LIBS="-lcrypto"
676		else
677			DST_OPENSSL_INC="-I$use_openssl/include"
678			case $host in
679			*-solaris*)
680				DNS_OPENSSL_LIBS="-L$use_openssl/lib -R$use_openssl/lib -lcrypto"
681				;;
682			*-hp-hpux*)
683				DNS_OPENSSL_LIBS="-L$use_openssl/lib -Wl,+b: -lcrypto"
684				;;
685			*-apple-darwin*)
686				#
687				# Apple's ld seaches for serially for dynamic
688				# then static libraries.  This means you can't
689				# use -L to override dynamic system libraries
690				# with static ones when linking.  Instead
691				# we specify a absolute path.
692				#
693				if test -f "$use_openssl/lib/libcrypto.dylib"
694				then
695					DNS_OPENSSL_LIBS="-L$use_openssl/lib -lcrypto"
696				else
697					DNS_OPENSSL_LIBS="$use_openssl/lib/libcrypto.a"
698				fi
699				;;
700			*)
701				DNS_OPENSSL_LIBS="-L$use_openssl/lib -lcrypto"
702				;;
703			esac
704		fi
705		AC_MSG_RESULT(using OpenSSL from $use_openssl/lib and $use_openssl/include)
706
707		saved_cflags="$CFLAGS"
708		saved_libs="$LIBS"
709		CFLAGS="$CFLAGS $DST_OPENSSL_INC"
710		LIBS="$LIBS $DNS_OPENSSL_LIBS"
711		AC_MSG_CHECKING(whether linking with OpenSSL works)
712		AC_TRY_RUN([
713#include <openssl/err.h>
714int main() {
715	ERR_clear_error();
716	return (0);
717}
718],
719		[AC_MSG_RESULT(yes)],
720		[AC_MSG_RESULT(no)
721		 AC_MSG_ERROR(Could not run test program using OpenSSL from
722$use_openssl/lib and $use_openssl/include.
723Please check the argument to --with-openssl and your
724shared library configuration (e.g., LD_LIBRARY_PATH).)],
725		[AC_MSG_RESULT(assuming it does work on target platform)])
726
727		AC_MSG_CHECKING(whether linking with OpenSSL requires -ldl)
728		AC_TRY_LINK([
729#include <openssl/err.h>],
730[ DSO_METHOD_dlfcn(); ],
731		[AC_MSG_RESULT(no)],
732		[LIBS="$LIBS -ldl"
733		AC_TRY_LINK([
734#include <openssl/err.h>
735],[ DSO_METHOD_dlfcn(); ],
736		[AC_MSG_RESULT(yes)
737		DNS_OPENSSL_LIBS="$DNS_OPENSSL_LIBS -ldl"
738		],
739		 [AC_MSG_RESULT(unknown)
740		 AC_MSG_ERROR(OpenSSL has unsupported dynamic loading)],
741		[AC_MSG_RESULT(assuming it does work on target platform)])
742		],
743		[AC_MSG_RESULT(assuming it does work on target platform)]
744		)
745		
746AC_ARG_ENABLE(openssl-version-check,
747[AC_HELP_STRING([--enable-openssl-version-check],
748	[Check OpenSSL Version @<:@default=yes@:>@])])
749case "$enable_openssl_version_check" in
750yes|'')
751		AC_MSG_CHECKING(OpenSSL library version)
752		AC_TRY_RUN([
753#include <stdio.h>
754#include <openssl/opensslv.h>
755int main() {
756	if ((OPENSSL_VERSION_NUMBER >= 0x009070cfL &&
757	     OPENSSL_VERSION_NUMBER < 0x00908000L) ||
758	     OPENSSL_VERSION_NUMBER >= 0x0090804fL)
759		return (0);
760	printf("\n\nFound   OPENSSL_VERSION_NUMBER %#010x\n",
761		OPENSSL_VERSION_NUMBER);
762	printf("Require OPENSSL_VERSION_NUMBER 0x009070cf or greater (0.9.7l)\n"
763	       "Require OPENSSL_VERSION_NUMBER 0x0090804f or greater (0.9.8d)\n\n");
764	return (1);
765}
766		],
767		[AC_MSG_RESULT(ok)],
768		[AC_MSG_RESULT(not compatible)
769		 OPENSSL_WARNING=yes
770		],
771		[AC_MSG_RESULT(assuming target platform has compatible version)])
772;;
773no)
774	AC_MSG_RESULT(Skipped OpenSSL version check)
775;;
776esac
777
778        AC_MSG_CHECKING(for OpenSSL DSA support)
779        if test -f $use_openssl/include/openssl/dsa.h
780        then
781                AC_DEFINE(HAVE_OPENSSL_DSA)
782                AC_MSG_RESULT(yes)
783        else
784                AC_MSG_RESULT(no)
785        fi
786
787        AC_CHECK_FUNCS(EVP_sha256 EVP_sha384 EVP_sha512)
788
789        AC_MSG_CHECKING(for OpenSSL ECDSA support)
790        have_ecdsa=""
791        AC_TRY_RUN([
792#include <stdio.h>
793#include <openssl/ecdsa.h>
794#include <openssl/objects.h>
795int main() {
796	EC_KEY *ec256, *ec384;
797
798#if !defined(HAVE_EVP_SHA256) || !defined(HAVE_EVP_SHA384)
799	return (1);
800#endif
801	ec256 = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
802	ec384 = EC_KEY_new_by_curve_name(NID_secp384r1);
803	if (ec256 == NULL || ec384 == NULL)
804		return (2);
805	return (0);
806}
807],
808        [AC_MSG_RESULT(yes)
809        have_ecdsa="yes"],
810        [AC_MSG_RESULT(no)
811        have_ecdsa="no"],
812        [AC_MSG_RESULT(using --with-ecdsa)])
813        AC_ARG_WITH(ecdsa, [  --with-ecdsa            OpenSSL ECDSA],
814	            with_ecdsa="$withval", with_ecdsa="auto")
815        case "$with_ecdsa" in
816        yes)
817            case "$have_ecdsa" in
818            no)  AC_MSG_ERROR([ecdsa not supported]) ;;
819            *)  have_ecdsa=yes ;;
820            esac
821            ;;
822        no)
823            have_ecdsa=no ;;
824        *)
825            case "$have_ecdsa" in
826            yes|no) ;;
827            *) AC_MSG_ERROR([need --with-ecdsa=[[yes or no]]]) ;;
828            esac
829            ;;
830        esac
831        case $have_ecdsa in
832        yes)
833                OPENSSL_ECDSA="yes"
834                AC_DEFINE(HAVE_OPENSSL_ECDSA, 1,
835                          [Define if your OpenSSL version supports ECDSA.])
836                ;;
837        *)
838                ;;
839        esac
840
841        AC_MSG_CHECKING(for OpenSSL GOST support)
842        have_gost=""
843        AC_TRY_RUN([
844#include <openssl/conf.h>
845#include <openssl/engine.h>
846int main() {
847#if (OPENSSL_VERSION_NUMBER >= 0x10000000L)
848	ENGINE *e;
849	EC_KEY *ek;
850
851	ek = NULL;
852	OPENSSL_config(NULL);
853
854	e = ENGINE_by_id("gost");
855	if (e == NULL)
856		return (1);
857	if (ENGINE_init(e) <= 0)
858		return (1);
859	return (0);
860#else
861	return (1);
862#endif
863}
864],
865        [AC_MSG_RESULT(yes)
866        have_gost="yes"],
867        [AC_MSG_RESULT(no)
868        have_gost="no"],
869        [AC_MSG_RESULT(using --with-gost)])
870        AC_ARG_WITH(gost, [  --with-gost             OpenSSL GOST],
871                    with_gost="$withval", with_gost="auto")
872        case "$with_gost" in
873        yes)
874            case "$have_gost" in
875            no)  AC_MSG_ERROR([gost not supported]) ;;
876            *)  have_gost=yes ;;
877            esac
878            ;;
879        no)
880            have_gost=no ;;
881        *)
882            case "$have_gost" in
883            yes|no) ;;
884            *) AC_MSG_ERROR([need --with-gost=[[yes or no]]]) ;;
885            esac
886            ;;
887        esac
888        case $have_gost in
889        yes)
890		OPENSSL_GOST="yes"
891		OPENSSLGOSTLINKOBJS='${OPENSSLGOSTLINKOBJS}'
892		OPENSSLGOSTLINKSRCS='${OPENSSLGOSTLINKSRCS}'
893		AC_DEFINE(HAVE_OPENSSL_GOST, 1,
894			  [Define if your OpenSSL version supports GOST.])
895		;;
896        *)
897                ;;
898        esac
899        CFLAGS="$saved_cflags"
900        LIBS="$saved_libs"
901        OPENSSLLINKOBJS='${OPENSSLLINKOBJS}'
902        OPENSSLLINKSRCS='${OPENSSLLINKSRCS}'
903
904        ;;
905esac
906
907#
908# This would include the system openssl path (and linker options to use
909# it as needed) if it is found.
910#
911
912AC_SUBST(USE_OPENSSL)
913AC_SUBST(DST_OPENSSL_INC)
914AC_SUBST(OPENSSLGOSTLINKOBJS)
915AC_SUBST(OPENSSLGOSTLINKSRCS)
916AC_SUBST(OPENSSLLINKOBJS)
917AC_SUBST(OPENSSLLINKSRCS)
918AC_SUBST(OPENSSL_ECDSA)
919AC_SUBST(OPENSSL_GOST)
920
921DNS_CRYPTO_LIBS="$DNS_CRYPTO_LIBS $DNS_OPENSSL_LIBS"
922
923#
924# Use OpenSSL for hash functions
925#
926
927AC_ARG_ENABLE(openssl-hash,
928	[  --enable-openssl-hash   use OpenSSL for hash functions [[default=no]]],
929	want_openssl_hash="$enableval", want_openssl_hash="no")
930case $want_openssl_hash in
931	yes)
932		if test "$USE_OPENSSL" = ""
933		then
934			AC_MSG_ERROR([No OpenSSL for hash functions])
935		fi
936		ISC_PLATFORM_OPENSSLHASH="#define ISC_PLATFORM_OPENSSLHASH 1"
937		ISC_OPENSSL_INC="$DST_OPENSSL_INC"
938		;;
939	no)
940		ISC_PLATFORM_OPENSSLHASH="#undef ISC_PLATFORM_OPENSSLHASH"
941		ISC_OPENSSL_INC=""
942		;;
943esac
944AC_SUBST(ISC_PLATFORM_OPENSSLHASH)
945AC_SUBST(ISC_OPENSSL_INC)
946
947#
948# PKCS11 (aka crypto hardware) support
949#
950# This works only with the right OpenSSL with PKCS11 engine!
951#
952
953AC_MSG_CHECKING(for PKCS11 support)
954AC_ARG_WITH(pkcs11,
955[  --with-pkcs11[=PATH]      Build with PKCS11 support [yes|no|path]
956                          (PATH is for the PKCS11 provider)],
957   use_pkcs11="$withval", use_pkcs11="no")
958
959case "$use_pkcs11" in
960	no|'')
961		AC_MSG_RESULT(disabled)
962		USE_PKCS11=''
963		PKCS11_TOOLS=''
964		;;
965	yes|*)
966		AC_MSG_RESULT(using OpenSSL with PKCS11 support)
967		USE_PKCS11='-DUSE_PKCS11'
968		PKCS11_TOOLS=pkcs11
969		;;
970esac
971AC_SUBST(USE_PKCS11)
972AC_SUBST(PKCS11_TOOLS)
973
974AC_MSG_CHECKING(for PKCS11 tools)
975case "$use_pkcs11" in
976	no|yes|'')
977		AC_MSG_RESULT(disabled)
978		PKCS11_PROVIDER="undefined"
979		;;
980       *)
981		AC_MSG_RESULT(PKCS11 provider is "$use_pkcs11")
982		PKCS11_PROVIDER="$use_pkcs11"
983		;;
984esac
985AC_SUBST(PKCS11_PROVIDER)
986
987AC_MSG_CHECKING(for GSSAPI library)
988AC_ARG_WITH(gssapi,
989[  --with-gssapi=PATH      Specify path for system-supplied GSSAPI [[default=yes]]],
990    use_gssapi="$withval", use_gssapi="yes")
991
992# gssapi is just the framework, we really require kerberos v5, so
993# look for those headers (the gssapi headers must be there, too)
994# The problem with this implementation is that it doesn't allow
995# for the specification of gssapi and krb5 headers in different locations,
996# which probably ought to be fixed although fixing might raise the issue of
997# trying to build with incompatible versions of gssapi and krb5.
998if test "$use_gssapi" = "yes"
999then
1000	# first, deal with the obvious
1001	if test \( -f /usr/include/kerberosv5/krb5.h -o \
1002		   -f /usr/include/krb5/krb5.h -o \
1003		   -f /usr/include/krb5.h \)   -a \
1004		\( -f /usr/include/gssapi.h -o \
1005		   -f /usr/include/gssapi/gssapi.h \)
1006	then
1007		use_gssapi=/usr
1008	else
1009	    krb5dirs="/usr/local /usr/local/krb5 /usr/local/kerberosv5 /usr/local/kerberos /usr/pkg /usr/krb5 /usr/kerberosv5 /usr/kerberos /usr"
1010	    for d in $krb5dirs
1011	    do
1012		if test -f $d/include/gssapi/gssapi_krb5.h -o \
1013		        -f $d/include/krb5.h
1014		then
1015			if test -f $d/include/gssapi/gssapi.h -o \
1016			        -f $d/include/gssapi.h
1017			then
1018				use_gssapi=$d
1019				break
1020			fi
1021		fi
1022		use_gssapi="no"
1023	    done
1024	fi
1025fi
1026
1027case "$use_gssapi" in
1028	no)
1029		AC_MSG_RESULT(disabled)
1030		USE_GSSAPI=''
1031		;;
1032	yes)
1033		AC_MSG_ERROR([--with-gssapi must specify a path])
1034		;;
1035	*)
1036		AC_MSG_RESULT(looking in $use_gssapi/lib)
1037		USE_GSSAPI='-DGSSAPI'
1038		saved_cppflags="$CPPFLAGS"
1039		CPPFLAGS="-I$use_gssapi/include $CPPFLAGS"
1040		AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h,
1041		    [ISC_PLATFORM_GSSAPIHEADER="#define ISC_PLATFORM_GSSAPIHEADER <$ac_header>"])
1042
1043		if test "$ISC_PLATFORM_GSSAPIHEADER" = ""; then
1044		    AC_MSG_ERROR([gssapi.h not found])
1045		fi
1046
1047		AC_CHECK_HEADERS(gssapi_krb5.h gssapi/gssapi_krb5.h,
1048		    [ISC_PLATFORM_GSSAPI_KRB5_HEADER="#define ISC_PLATFORM_GSSAPI_KRB5_HEADER <$ac_header>"])
1049
1050		AC_CHECK_HEADERS(krb5.h krb5/krb5.h kerberosv5/krb5.h,
1051		    [ISC_PLATFORM_KRB5HEADER="#define ISC_PLATFORM_KRB5HEADER <$ac_header>"])
1052
1053		if test "$ISC_PLATFORM_KRB5HEADER" = ""; then
1054		    AC_MSG_ERROR([krb5.h not found])
1055		fi
1056
1057		CPPFLAGS="$saved_cppflags"
1058
1059		#
1060		# XXXDCL This probably doesn't work right on all systems.
1061		# It will need to be worked on as problems become evident.
1062		#
1063		# Essentially the problems here relate to two different
1064		# areas.  The first area is building with either KTH
1065		# or MIT Kerberos, particularly when both are present on
1066		# the machine.  The other is static versus dynamic linking.
1067		#
1068		# On the KTH vs MIT issue, Both have libkrb5 that can mess
1069		# up the works if one implementation ends up trying to
1070		# use the other's krb.  This is unfortunately a situation
1071		# that very easily arises.
1072		#
1073		# Dynamic linking when the dependency information is built
1074		# into MIT's libgssapi_krb5 or KTH's libgssapi magically makes
1075		# all such problems go away, but when that setup is not
1076		# present, because either the dynamic libraries lack
1077		# dependencies or static linking is being done, then the
1078		# problems start to show up.
1079		saved_libs="$LIBS"
1080		for TRY_LIBS in \
1081		    "-lgssapi_krb5" \
1082		    "-lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err" \
1083		    "-lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lresolv" \
1084		    "-lgssapi" \
1085		    "-lgssapi -lkrb5 -ldes -lcrypt -lasn1 -lroken -lcom_err" \
1086		    "-lgssapi -lkrb5 -lcrypto -lcrypt -lasn1 -lroken -lcom_err" \
1087		    "-lgss -lkrb5"
1088		do
1089		    # Note that this does not include $saved_libs, because
1090		    # on FreeBSD machines this configure script has added
1091		    # -L/usr/local/lib to LIBS, which can make the
1092		    # -lgssapi_krb5 test succeed with shared libraries even
1093		    # when you are trying to build with KTH in /usr/lib.
1094		    if test "$use_gssapi" = "/usr"
1095		    then
1096			    LIBS="$TRY_LIBS"
1097		    else
1098			    LIBS="-L$use_gssapi/lib $TRY_LIBS"
1099		    fi
1100		    AC_MSG_CHECKING(linking as $TRY_LIBS)
1101		    AC_TRY_LINK( , [gss_acquire_cred();krb5_init_context()],
1102				gssapi_linked=yes, gssapi_linked=no)
1103		    case $gssapi_linked in
1104		    yes) AC_MSG_RESULT(yes); break ;;
1105		    no)  AC_MSG_RESULT(no) ;;
1106		    esac
1107		done
1108
1109		case $gssapi_linked in
1110		no) AC_MSG_ERROR(could not determine proper GSSAPI linkage) ;;
1111		esac
1112
1113		#
1114		# XXXDCL Major kludge.  Tries to cope with KTH in /usr/lib
1115		# but MIT in /usr/local/lib and trying to build with KTH.
1116		# /usr/local/lib can end up earlier on the link lines.
1117		# Like most kludges, this one is not only inelegant it
1118		# is also likely to be the wrong thing to do at least as
1119		# many times as it is the right thing.  Something better
1120		# needs to be done.
1121		#
1122		if test "$use_gssapi" = "/usr" -a \
1123			-f /usr/local/lib/libkrb5.a; then
1124		    FIX_KTH_VS_MIT=yes
1125		fi
1126
1127		case "$FIX_KTH_VS_MIT" in
1128		yes)
1129		    case "$enable_static_linking" in
1130		    yes) gssapi_lib_suffix=".a"  ;;
1131		    *)   gssapi_lib_suffix=".so" ;;
1132		    esac
1133
1134		    for lib in $LIBS; do
1135			case $lib in
1136			-L*)
1137			    ;;
1138			-l*)
1139			    new_lib=`echo $lib |
1140				     sed -e s%^-l%$use_gssapi/lib/lib% \
1141					 -e s%$%$gssapi_lib_suffix%`
1142			    NEW_LIBS="$NEW_LIBS $new_lib"
1143			    ;;
1144			*)
1145			   AC_MSG_ERROR([KTH vs MIT Kerberos confusion!])
1146			    ;;
1147			esac
1148		    done
1149		    LIBS="$NEW_LIBS"
1150		    ;;
1151		esac
1152
1153		DST_GSSAPI_INC="-I$use_gssapi/include"
1154		DNS_GSSAPI_LIBS="$LIBS"
1155
1156		AC_MSG_RESULT(using GSSAPI from $use_gssapi/lib and $use_gssapi/include)
1157		LIBS="$saved_libs"
1158		;;
1159esac
1160
1161AC_SUBST(ISC_PLATFORM_HAVEGSSAPI)
1162AC_SUBST(ISC_PLATFORM_GSSAPIHEADER)
1163AC_SUBST(ISC_PLATFORM_GSSAPI_KRB5_HEADER)
1164AC_SUBST(ISC_PLATFORM_KRB5HEADER)
1165
1166AC_SUBST(USE_GSSAPI)
1167AC_SUBST(DST_GSSAPI_INC)
1168AC_SUBST(DNS_GSSAPI_LIBS)
1169DNS_CRYPTO_LIBS="$DNS_GSSAPI_LIBS $DNS_CRYPTO_LIBS"
1170
1171#
1172# Applications linking with libdns also need to link with these libraries.
1173#
1174
1175AC_SUBST(DNS_CRYPTO_LIBS)
1176
1177#
1178# was --with-randomdev specified?
1179#
1180AC_MSG_CHECKING(for random device)
1181AC_ARG_WITH(randomdev,
1182[  --with-randomdev=PATH   Specify path for random device],
1183    use_randomdev="$withval", use_randomdev="unspec")
1184
1185case "$use_randomdev" in
1186	unspec)
1187		case "$cross_compiling" in
1188		yes)
1189			AC_MSG_RESULT(unspecified)
1190			AC_MSG_ERROR([ need --with-randomdev=PATH or --with-randomdev=no])
1191		esac
1192		case "$host" in
1193			*-openbsd*)
1194				devrandom=/dev/arandom
1195				;;
1196			*)
1197				devrandom=/dev/random
1198				;;
1199		esac
1200		AC_MSG_RESULT($devrandom)
1201		AC_CHECK_FILE($devrandom,
1202			      AC_DEFINE_UNQUOTED(PATH_RANDOMDEV,
1203						 "$devrandom"),)
1204			      
1205		;;
1206	yes)
1207		AC_MSG_ERROR([--with-randomdev must specify a path])
1208		;;
1209	no)
1210		AC_MSG_RESULT(disabled)
1211		;;
1212	*)
1213		AC_DEFINE_UNQUOTED(PATH_RANDOMDEV, "$use_randomdev")
1214		AC_MSG_RESULT(using "$use_randomdev")
1215		;;
1216esac
1217
1218#
1219# Do we have arc4random() ?
1220#
1221AC_CHECK_FUNC(arc4random, AC_DEFINE(HAVE_ARC4RANDOM))
1222
1223sinclude(config.threads.in)dnl
1224
1225if $use_threads
1226then
1227	if test "X$GCC" = "Xyes"; then
1228		case "$host" in
1229		*-freebsd*)
1230			CC="$CC -pthread"
1231			CCOPT="$CCOPT -pthread"
1232			STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
1233			;;
1234		*-openbsd*)
1235			CC="$CC -pthread"
1236			CCOPT="$CCOPT -pthread"
1237			;;
1238		*-solaris*)
1239			LIBS="$LIBS -lthread"
1240			;;
1241		*-ibm-aix*)
1242			STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
1243			;;
1244		esac
1245	else
1246		case $host in
1247		*-dec-osf*)
1248			CC="$CC -pthread"
1249			CCOPT="$CCOPT -pthread"
1250			;;
1251		*-solaris*)
1252			CC="$CC -mt"
1253			CCOPT="$CCOPT -mt"
1254			;;
1255		*-ibm-aix*)
1256			STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
1257			;;
1258		*-sco-sysv*uw*|*-*-sysv*UnixWare*)
1259			CC="$CC -Kthread"
1260			CCOPT="$CCOPT -Kthread"
1261			;;
1262		*-*-sysv*OpenUNIX*)
1263			CC="$CC -Kpthread"
1264			CCOPT="$CCOPT -Kpthread"
1265			;;
1266		esac
1267	fi
1268	ALWAYS_DEFINES="-D_REENTRANT"
1269	ISC_PLATFORM_USETHREADS="#define ISC_PLATFORM_USETHREADS 1"
1270	THREADOPTOBJS='${THREADOPTOBJS}'
1271	THREADOPTSRCS='${THREADOPTSRCS}'
1272	thread_dir=pthreads
1273	#
1274	# We'd like to use sigwait() too
1275	#
1276	AC_CHECK_FUNC(sigwait,
1277		      AC_DEFINE(HAVE_SIGWAIT),
1278		      AC_CHECK_LIB(c, sigwait,
1279		      AC_DEFINE(HAVE_SIGWAIT),
1280		      AC_CHECK_LIB(pthread, sigwait,
1281				   AC_DEFINE(HAVE_SIGWAIT),
1282				   AC_CHECK_LIB(pthread, _Psigwait,
1283						AC_DEFINE(HAVE_SIGWAIT),))))
1284
1285	AC_CHECK_FUNC(pthread_attr_getstacksize,
1286		      AC_DEFINE(HAVE_PTHREAD_ATTR_GETSTACKSIZE),)
1287
1288	AC_CHECK_FUNC(pthread_attr_setstacksize,
1289		      AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACKSIZE),)
1290
1291	#
1292	# Additional OS-specific issues related to pthreads and sigwait.
1293	#
1294	case "$host" in
1295		#
1296		# One more place to look for sigwait.
1297		#
1298		*-freebsd*)
1299			AC_CHECK_LIB(c_r, sigwait, AC_DEFINE(HAVE_SIGWAIT),)
1300			case $host in
1301			*-freebsd5.[[012]]|*-freebsd5.[[012]].*);;
1302			*-freebsd5.[[3456789]]|*-freebsd5.[[3456789]].*)
1303				AC_DEFINE(NEED_PTHREAD_SCOPE_SYSTEM)
1304				;;
1305			*-freebsd6.*)
1306				AC_DEFINE(NEED_PTHREAD_SCOPE_SYSTEM)
1307				;;
1308			esac
1309			;;
1310		#
1311		# BSDI 3.0 through 4.0.1 needs pthread_init() to be
1312		# called before certain pthreads calls.	 This is deprecated
1313		# in BSD/OS 4.1.
1314		#
1315		*-bsdi3.*|*-bsdi4.0*)
1316			AC_DEFINE(NEED_PTHREAD_INIT)
1317			;;
1318		#
1319		# LinuxThreads requires some changes to the way we
1320		# deal with signals.
1321		#
1322		*-linux*)
1323			AC_DEFINE(HAVE_LINUXTHREADS)
1324			;;
1325		#
1326		# Ensure the right sigwait() semantics on Solaris and make
1327		# sure we call pthread_setconcurrency.
1328		#
1329		*-solaris*)
1330			AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
1331			AC_CHECK_FUNC(pthread_setconcurrency,
1332				      AC_DEFINE(CALL_PTHREAD_SETCONCURRENCY))
1333			;;
1334		#
1335		# UnixWare does things its own way.
1336		#
1337		*-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
1338			AC_DEFINE(HAVE_UNIXWARE_SIGWAIT)
1339			;;
1340	esac
1341
1342	#
1343	# Look for sysconf to allow detection of the number of processors.
1344	#
1345	AC_CHECK_FUNC(sysconf, AC_DEFINE(HAVE_SYSCONF),)
1346
1347else
1348	ISC_PLATFORM_USETHREADS="#undef ISC_PLATFORM_USETHREADS"
1349	thread_dir=nothreads
1350	THREADOPTOBJS=""
1351	THREADOPTSRCS=""
1352	ALWAYS_DEFINES=""
1353fi
1354
1355AC_SUBST(ALWAYS_DEFINES)
1356AC_SUBST(ISC_PLATFORM_USETHREADS)
1357AC_SUBST(THREADOPTOBJS)
1358AC_SUBST(THREADOPTSRCS)
1359ISC_THREAD_DIR=$thread_dir
1360AC_SUBST(ISC_THREAD_DIR)
1361
1362#
1363# was --with-libxml2 specified?
1364#
1365AC_MSG_CHECKING(for libxml2 library)
1366AC_ARG_WITH(libxml2,
1367[  --with-libxml2[=PATH]     Build with libxml2 library [yes|no|path]],
1368    use_libxml2="$withval", use_libxml2="auto")
1369
1370case "$use_libxml2" in
1371	no)
1372		DST_LIBXML2_INC=""
1373		;;
1374	auto|yes)
1375		case X`(xml2-config --version) 2>/dev/null` in
1376		X2.[[6789]].*)
1377			libxml2_libs=`xml2-config --libs`
1378			libxml2_cflags=`xml2-config --cflags`
1379			;;
1380		*)
1381			libxml2_libs=
1382			libxml2_cflags=
1383			;;
1384		esac
1385		;;
1386	*)
1387		if test -f "$use_libxml2/bin/xml2-config" ; then
1388			libxml2_libs=`$use_libxml2/bin/xml2-config --libs`
1389			libxml2_cflags=`$use_libxml2/bin/xml2-config --cflags`
1390		fi
1391		;;
1392esac
1393
1394if test "X$libxml2_libs" != "X"
1395then
1396	AC_MSG_RESULT(yes)
1397	CFLAGS="$CFLAGS $libxml2_cflags"
1398	LIBS="$LIBS $libxml2_libs"
1399	AC_DEFINE(HAVE_LIBXML2, 1, [Define if libxml2 was found])
1400else
1401	AC_MSG_RESULT(no)
1402fi
1403
1404#
1405# In solaris 10, SMF can manage named service
1406#
1407AC_CHECK_LIB(scf, smf_enable_instance)
1408
1409#
1410# flockfile is usually provided by pthreads, but we may want to use it
1411# even if compiled with --disable-threads.  getc_unlocked might also not
1412# be defined.
1413#
1414AC_CHECK_FUNC(flockfile, AC_DEFINE(HAVE_FLOCKFILE),)
1415AC_CHECK_FUNC(getc_unlocked, AC_DEFINE(HAVE_GETCUNLOCKED),)
1416
1417#
1418# Indicate what the final decision was regarding threads.
1419#
1420AC_MSG_CHECKING(whether to build with threads)
1421if $use_threads; then
1422	AC_MSG_RESULT(yes)
1423else
1424	AC_MSG_RESULT(no)
1425fi
1426
1427#
1428# End of pthreads stuff.
1429#
1430
1431#
1432# Large File
1433#
1434AC_ARG_ENABLE(largefile, [  --enable-largefile	  64-bit file support],
1435	      want_largefile="yes", want_largefile="no")
1436case $want_largefile in
1437	yes)
1438		ALWAYS_DEFINES="$ALWAYS_DEFINES -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
1439		;;
1440	*)
1441		;;
1442esac
1443
1444#
1445# Additional compiler settings.
1446#
1447MKDEPCC="$CC"
1448MKDEPCFLAGS="-M"
1449IRIX_DNSSEC_WARNINGS_HACK=""
1450
1451if test "X$GCC" = "Xyes"; then
1452	AC_MSG_CHECKING(if "$CC" supports -fno-strict-aliasing)
1453	SAVE_CFLAGS=$CFLAGS
1454	CFLAGS="$CFLAGS -fno-strict-aliasing"
1455	AC_TRY_COMPILE(,, [FNOSTRICTALIASING=yes],[FNOSTRICTALIASING=no])
1456	CFLAGS=$SAVE_CFLAGS
1457	if test "$FNOSTRICTALIASING" = "yes"; then
1458		AC_MSG_RESULT(yes)
1459	STD_CWARNINGS="$STD_CWARNINGS -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -Wpointer-arith -fno-strict-aliasing"
1460	else
1461		AC_MSG_RESULT(no)
1462	STD_CWARNINGS="$STD_CWARNINGS -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -Wpointer-arith"
1463	fi
1464	case "$host" in
1465	*-hp-hpux*)
1466		LDFLAGS="-Wl,+vnocompatwarnings $LDFLAGS"
1467		;;
1468	esac
1469else
1470	case $host in
1471	*-dec-osf*)
1472		CC="$CC -std"
1473		CCOPT="$CCOPT -std"
1474		MKDEPCC="$CC"
1475		;;
1476	*-hp-hpux*)
1477		CC="$CC -Ae -z"
1478		# The version of the C compiler that constantly warns about
1479		# 'const' as well as alignment issues is unfortunately not
1480		# able to be discerned via the version of the operating
1481		# system, nor does cc have a version flag.
1482		case "`$CC +W 123 2>&1`" in
1483		*Unknown?option*)
1484			STD_CWARNINGS="+w1"
1485			;;
1486		*)
1487			# Turn off the pointlessly noisy warnings.
1488			STD_CWARNINGS="+w1 +W 474,530,2193,2236"
1489			;;
1490		esac
1491		CCOPT="$CCOPT -Ae -z"
1492		LDFLAGS="-Wl,+vnocompatwarnings $LDFLAGS"
1493		MKDEPPROG='cc -Ae -E -Wp,-M >/dev/null 2>>$TMP'
1494		;;
1495	*-sgi-irix*)
1496		STD_CWARNINGS="-fullwarn -woff 1209"
1497		#
1498		# Silence more than 250 instances of
1499		#   "prototyped function redeclared without prototype"
1500		# and 11 instances of
1501		#   "variable ... was set but never used"
1502		# from lib/dns/sec/openssl.
1503		#
1504		IRIX_DNSSEC_WARNINGS_HACK="-woff 1692,1552"
1505		;;
1506	*-solaris*)
1507		MKDEPCFLAGS="-xM"
1508		;;
1509	*-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
1510		# UnixWare
1511		CC="$CC -w"
1512		;;
1513	esac
1514fi
1515
1516AC_SUBST(MKDEPCC)
1517AC_SUBST(MKDEPCFLAGS)
1518AC_SUBST(MKDEPPROG)
1519AC_SUBST(IRIX_DNSSEC_WARNINGS_HACK)
1520
1521#
1522# NLS
1523#
1524AC_CHECK_FUNC(catgets, AC_DEFINE(HAVE_CATGETS),)
1525
1526#
1527# -lxnet buys us one big porting headache...  standards, gotta love 'em.
1528#
1529# AC_CHECK_LIB(xnet, socket, ,
1530#    AC_CHECK_LIB(socket, socket)
1531# )
1532#
1533# Use this for now, instead:
1534#
1535case "$host" in
1536	mips-sgi-irix*)
1537		;;
1538	*-linux*)
1539		;;
1540	*)
1541		AC_CHECK_LIB(socket, socket)
1542		AC_CHECK_LIB(nsl, inet_addr)
1543		;;
1544esac
1545
1546#
1547# Work around Solaris's select() limitations.
1548#
1549case "$host" in
1550	*-solaris2.[[89]]|*-solaris2.1?)
1551	AC_DEFINE(FD_SETSIZE, 65536,
1552		  [Solaris hack to get select_large_fdset.])
1553	;;
1554esac
1555
1556#
1557# Purify support
1558#
1559AC_MSG_CHECKING(whether to use purify)
1560AC_ARG_WITH(purify,
1561	[  --with-purify[=PATH]      use Rational purify],
1562	use_purify="$withval", use_purify="no")
1563
1564case "$use_purify" in
1565	no)
1566		;;
1567	yes)
1568		AC_PATH_PROG(purify_path, purify, purify)
1569		;;
1570	*)
1571		purify_path="$use_purify"
1572		;;
1573esac
1574
1575case "$use_purify" in
1576	no)
1577		AC_MSG_RESULT(no)
1578		PURIFY=""
1579		;;
1580	*)
1581		if test -f $purify_path || test $purify_path = purify; then
1582			AC_MSG_RESULT($purify_path)
1583			PURIFYFLAGS="`echo $PURIFYOPTIONS`"
1584			PURIFY="$purify_path $PURIFYFLAGS"
1585		else
1586			AC_MSG_ERROR([$purify_path not found.
1587
1588Please choose the proper path with the following command:
1589
1590    configure --with-purify=PATH
1591])
1592		fi
1593		;;
1594esac
1595
1596AC_SUBST(PURIFY)
1597
1598
1599AC_ARG_WITH(libtool,
1600	    [  --with-libtool          use GNU libtool],
1601	    use_libtool="$withval", use_libtool="no")
1602
1603case $use_libtool in
1604	yes)
1605		AM_PROG_LIBTOOL
1606		O=lo
1607		A=la
1608		LIBTOOL_MKDEP_SED='s;\.o;\.lo;'
1609		LIBTOOL_MODE_COMPILE='--mode=compile --tag=CC'
1610		LIBTOOL_MODE_INSTALL='--mode=install --tag=CC'
1611		LIBTOOL_MODE_LINK='--mode=link --tag=CC'
1612		case "$host" in
1613		*) LIBTOOL_ALLOW_UNDEFINED= ;;
1614		esac
1615		case "$host" in
1616		*-ibm-aix*) LIBTOOL_IN_MAIN="-Wl,-bI:T_testlist.imp" ;;
1617		*) LIBTOOL_IN_MAIN= ;;
1618		esac;
1619		;;
1620	*)
1621		O=o
1622		A=a
1623		LIBTOOL=
1624		AC_SUBST(LIBTOOL)
1625		LIBTOOL_MKDEP_SED=
1626		LIBTOOL_MODE_COMPILE=
1627		LIBTOOL_MODE_INSTALL=
1628		LIBTOOL_MODE_LINK=
1629		LIBTOOL_ALLOW_UNDEFINED=
1630		LIBTOOL_IN_MAIN=
1631		;;
1632esac
1633
1634#
1635# enable/disable dumping stack backtrace.  Also check if the system supports
1636# glibc-compatible backtrace() function.
1637#
1638AC_ARG_ENABLE(backtrace,
1639[  --enable-backtrace      log stack backtrace on abort [[default=yes]]],
1640	      want_backtrace="$enableval",  want_backtrace="yes")
1641case $want_backtrace in
1642yes)
1643	ISC_PLATFORM_USEBACKTRACE="#define ISC_PLATFORM_USEBACKTRACE 1"
1644	AC_TRY_LINK([#include <execinfo.h>],
1645	[return (backtrace((void **)0, 0));],
1646	[AC_DEFINE([HAVE_LIBCTRACE], [], [if system have backtrace function])],)
1647	;;
1648*)
1649	ISC_PLATFORM_USEBACKTRACE="#undef ISC_PLATFORM_USEBACKTRACE"
1650	;;
1651esac
1652AC_SUBST(ISC_PLATFORM_USEBACKTRACE)
1653
1654AC_ARG_ENABLE(symtable,
1655[  --enable-symtable       use internal symbol table for backtrace
1656                          [[all|minimal(default)|none]]],
1657		want_symtable="$enableval",  want_symtable="minimal")
1658case $want_symtable in
1659yes|all|minimal)     # "yes" is a hidden value equivalent to "minimal"
1660	if test "$PERL" = ""
1661	then
1662		AC_MSG_ERROR([Internal symbol table requires perl but no perl is found.
1663Install perl or explicitly disable the feature by --disable-symtable.])
1664	fi
1665	if test "$use_libtool" = "yes"; then
1666		AC_MSG_WARN([Internal symbol table does not work with libtool.  Disabling symbol table.])
1667	else
1668		# we generate the internal symbol table only for those systems
1669		# known to work to avoid unexpected build failure.  Also, warn
1670		# about unsupported systems when the feature is enabled
1671		#  manually.
1672		case $host_os in
1673		freebsd*|netbsd*|openbsd*|linux*|solaris*|darwin*)
1674			MKSYMTBL_PROGRAM="$PERL"
1675			if test $want_symtable = all; then
1676				ALWAYS_MAKE_SYMTABLE="yes"
1677			fi
1678			;;
1679		*)
1680			if test $want_symtable = yes -o $want_symtable = all
1681			then
1682				AC_MSG_WARN([this system is not known to generate internal symbol table safely; disabling it])
1683			fi
1684		esac
1685	fi
1686	;;
1687*)
1688	;;
1689esac
1690AC_SUBST(MKSYMTBL_PROGRAM)
1691AC_SUBST(ALWAYS_MAKE_SYMTABLE)
1692
1693#
1694# File name extension for static archive files, for those few places
1695# where they are treated differently from dynamic ones.
1696#
1697SA=a
1698
1699AC_SUBST(O)
1700AC_SUBST(A)
1701AC_SUBST(SA)
1702AC_SUBST(LIBTOOL_MKDEP_SED)
1703AC_SUBST(LIBTOOL_MODE_COMPILE)
1704AC_SUBST(LIBTOOL_MODE_INSTALL)
1705AC_SUBST(LIBTOOL_MODE_LINK)
1706AC_SUBST(LIBTOOL_ALLOW_UNDEFINED)
1707AC_SUBST(LIBTOOL_IN_MAIN)
1708
1709#
1710# build exportable DNS library?
1711#
1712AC_ARG_ENABLE(exportlib,
1713	[  --enable-exportlib	  build exportable library (GNU make required)
1714                          [[default=no]]])
1715case "$enable_exportlib" in
1716	yes)
1717		gmake=
1718		for x in gmake gnumake make; do
1719			if $x --version 2>/dev/null | grep GNU > /dev/null; then
1720				gmake=$x
1721				break;
1722			fi
1723		done
1724		if test -z "$gmake"; then
1725			AC_MSG_ERROR([exportlib requires GNU make.  Install it or disable the feature.])
1726		fi
1727		LIBEXPORT=lib/export
1728		AC_SUBST(LIBEXPORT)
1729		BIND9_CO_RULE="%.$O:  \${srcdir}/%.c"
1730		;;
1731	no|*)
1732		BIND9_CO_RULE=".c.$O:"
1733		;;
1734esac
1735AC_SUBST(BIND9_CO_RULE)
1736
1737AC_ARG_WITH(export-libdir,
1738	[  --with-export-libdir[=PATH]
1739                          installation directory for the export library
1740                          [[EPREFIX/lib/bind9]]],
1741	export_libdir="$withval",)
1742if test -z "$export_libdir"; then
1743	export_libdir="\${exec_prefix}/lib/bind9/"
1744fi
1745AC_SUBST(export_libdir)
1746
1747AC_ARG_WITH(export-includedir,
1748	[  --with-export-includedir[=PATH]
1749                          installation directory for the header files of the
1750                          export library [[PREFIX/include/bind9]]],
1751	export_includedir="$withval",)
1752if test -z "$export_includedir"; then
1753	export_includedir="\${prefix}/include/bind9/"
1754fi
1755AC_SUBST(export_includedir)
1756
1757#
1758# Here begins a very long section to determine the system's networking
1759# capabilities.  The order of the tests is significant.
1760#
1761
1762#
1763# IPv6
1764#
1765AC_ARG_ENABLE(ipv6,
1766	[  --enable-ipv6           use IPv6 [default=autodetect]])
1767
1768case "$enable_ipv6" in
1769	yes|''|autodetect)
1770		AC_DEFINE(WANT_IPV6)
1771		;;
1772	no)
1773		;;
1774esac
1775
1776#
1777# We do the IPv6 compilation checking after libtool so that we can put
1778# the right suffix on the files.
1779#
1780AC_MSG_CHECKING(for IPv6 structures)
1781AC_TRY_COMPILE([
1782#include <sys/types.h>
1783#include <sys/socket.h>
1784#include <netinet/in.h>],
1785[struct sockaddr_in6 sin6; return (0);],
1786	[AC_MSG_RESULT(yes)
1787	 found_ipv6=yes],
1788	[AC_MSG_RESULT(no)
1789	 found_ipv6=no])
1790
1791#
1792# See whether IPv6 support is provided via a Kame add-on.
1793# This is done before other IPv6 linking tests to LIBS is properly set.
1794#
1795AC_MSG_CHECKING(for Kame IPv6 support)
1796AC_ARG_WITH(kame,
1797	[  --with-kame[=PATH]	  use Kame IPv6 [default path /usr/local/v6]],
1798	use_kame="$withval", use_kame="no")
1799
1800case "$use_kame" in
1801	no)
1802		;;
1803	yes)
1804		kame_path=/usr/local/v6
1805		;;
1806	*)
1807		kame_path="$use_kame"
1808		;;
1809esac
1810
1811case "$use_kame" in
1812	no)
1813		AC_MSG_RESULT(no)
1814		;;
1815	*)
1816		if test -f $kame_path/lib/libinet6.a; then
1817			AC_MSG_RESULT($kame_path/lib/libinet6.a)
1818			LIBS="-L$kame_path/lib -linet6 $LIBS"
1819		else
1820			AC_MSG_ERROR([$kame_path/lib/libinet6.a not found.
1821
1822Please choose the proper path with the following command:
1823
1824    configure --with-kame=PATH
1825])
1826		fi
1827		;;
1828esac
1829
1830#
1831# Whether netinet6/in6.h is needed has to be defined in isc/platform.h.
1832# Including it on Kame-using platforms is very bad, though, because
1833# Kame uses #error against direct inclusion.   So include it on only
1834# the platform that is otherwise broken without it -- BSD/OS 4.0 through 4.1.
1835# This is done before the in6_pktinfo check because that's what
1836# netinet6/in6.h is needed for.
1837#
1838changequote({, })
1839case "$host" in
1840*-bsdi4.[01]*)
1841	ISC_PLATFORM_NEEDNETINET6IN6H="#define ISC_PLATFORM_NEEDNETINET6IN6H 1"
1842	LWRES_PLATFORM_NEEDNETINET6IN6H="#define LWRES_PLATFORM_NEEDNETINET6IN6H 1"
1843	isc_netinet6in6_hack="#include <netinet6/in6.h>"
1844	;;
1845*)
1846	ISC_PLATFORM_NEEDNETINET6IN6H="#undef ISC_PLATFORM_NEEDNETINET6IN6H"
1847	LWRES_PLATFORM_NEEDNETINET6IN6H="#undef LWRES_PLATFORM_NEEDNETINET6IN6H"
1848	isc_netinet6in6_hack=""
1849	;;
1850esac
1851changequote([, ])
1852
1853#
1854# This is similar to the netinet6/in6.h issue.
1855#
1856case "$host" in
1857*-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
1858	# UnixWare
1859	ISC_PLATFORM_NEEDNETINETIN6H="#define ISC_PLATFORM_NEEDNETINETIN6H 1"
1860	LWRES_PLATFORM_NEEDNETINETIN6H="#define LWRES_PLATFORM_NEEDNETINETIN6H 1"
1861	ISC_PLATFORM_FIXIN6ISADDR="#define ISC_PLATFORM_FIXIN6ISADDR 1"
1862	isc_netinetin6_hack="#include <netinet/in6.h>"
1863	;;
1864*)
1865	ISC_PLATFORM_NEEDNETINETIN6H="#undef ISC_PLATFORM_NEEDNETINETIN6H"
1866	LWRES_PLATFORM_NEEDNETINETIN6H="#undef LWRES_PLATFORM_NEEDNETINETIN6H"
1867	ISC_PLATFORM_FIXIN6ISADDR="#undef ISC_PLATFORM_FIXIN6ISADDR"
1868	isc_netinetin6_hack=""
1869	;;
1870esac
1871
1872#
1873# Now delve deeper into the suitability of the IPv6 support.
1874#
1875case "$found_ipv6" in
1876	yes)
1877		ISC_PLATFORM_HAVEIPV6="#define ISC_PLATFORM_HAVEIPV6 1"
1878		LWRES_PLATFORM_HAVEIPV6="#define LWRES_PLATFORM_HAVEIPV6 1"
1879
1880		AC_MSG_CHECKING(for in6_addr)
1881		AC_TRY_COMPILE([
1882#include <sys/types.h>
1883#include <sys/socket.h>
1884#include <netinet/in.h>
1885$isc_netinetin6_hack
1886$isc_netinet6in6_hack
1887],
1888[struct in6_addr in6; return (0);],
1889		[AC_MSG_RESULT(yes)
1890		 ISC_PLATFORM_HAVEINADDR6="#undef ISC_PLATFORM_HAVEINADDR6"
1891		 LWRES_PLATFORM_HAVEINADDR6="#undef LWRES_PLATFORM_HAVEINADDR6"
1892		 isc_in_addr6_hack=""],
1893		[AC_MSG_RESULT(no)
1894		 ISC_PLATFORM_HAVEINADDR6="#define ISC_PLATFORM_HAVEINADDR6 1"
1895		 LWRES_PLATFORM_HAVEINADDR6="#define LWRES_PLATFORM_HAVEINADDR6 1"
1896		 isc_in_addr6_hack="#define in6_addr in_addr6"])
1897
1898		AC_MSG_CHECKING(for in6addr_any)
1899		AC_TRY_LINK([
1900#include <sys/types.h>
1901#include <sys/socket.h>
1902#include <netinet/in.h>
1903$isc_netinetin6_hack
1904$isc_netinet6in6_hack
1905$isc_in_addr6_hack
1906],
1907		[struct in6_addr in6; in6 = in6addr_any; return (in6.s6_addr[0]);],
1908			[AC_MSG_RESULT(yes)
1909			 ISC_PLATFORM_NEEDIN6ADDRANY="#undef ISC_PLATFORM_NEEDIN6ADDRANY"
1910			 LWRES_PLATFORM_NEEDIN6ADDRANY="#undef LWRES_PLATFORM_NEEDIN6ADDRANY"],
1911			[AC_MSG_RESULT(no)
1912			 ISC_PLATFORM_NEEDIN6ADDRANY="#define ISC_PLATFORM_NEEDIN6ADDRANY 1"
1913			 LWRES_PLATFORM_NEEDIN6ADDRANY="#define LWRES_PLATFORM_NEEDIN6ADDRANY 1"])
1914
1915		AC_MSG_CHECKING(for in6addr_loopback)
1916		AC_TRY_LINK([
1917#include <sys/types.h>
1918#include <sys/socket.h>
1919#include <netinet/in.h>
1920$isc_netinetin6_hack
1921$isc_netinet6in6_hack
1922$isc_in_addr6_hack
1923],
1924		[struct in6_addr in6; in6 = in6addr_loopback; return (in6.s6_addr[0]);],
1925			[AC_MSG_RESULT(yes)
1926			 ISC_PLATFORM_NEEDIN6ADDRLOOPBACK="#undef ISC_PLATFORM_NEEDIN6ADDRLOOPBACK"
1927			 LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK="#undef LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK"],
1928			[AC_MSG_RESULT(no)
1929			 ISC_PLATFORM_NEEDIN6ADDRLOOPBACK="#define ISC_PLATFORM_NEEDIN6ADDRLOOPBACK 1"
1930			 LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK="#define LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK 1"])
1931
1932		AC_MSG_CHECKING(for sin6_scope_id in struct sockaddr_in6)
1933		AC_TRY_COMPILE([
1934#include <sys/types.h>
1935#include <sys/socket.h>
1936#include <netinet/in.h>
1937$isc_netinetin6_hack
1938$isc_netinet6in6_hack
1939],
1940		[struct sockaddr_in6 xyzzy; xyzzy.sin6_scope_id = 0; return (0);],
1941			[AC_MSG_RESULT(yes)
1942			 ISC_PLATFORM_HAVESCOPEID="#define ISC_PLATFORM_HAVESCOPEID 1"
1943			 result="#define LWRES_HAVE_SIN6_SCOPE_ID 1"],
1944			[AC_MSG_RESULT(no)
1945			 ISC_PLATFORM_HAVESCOPEID="#undef ISC_PLATFORM_HAVESCOPEID"
1946			 result="#undef LWRES_HAVE_SIN6_SCOPE_ID"])
1947		LWRES_HAVE_SIN6_SCOPE_ID="$result"
1948
1949		AC_MSG_CHECKING(for in6_pktinfo)
1950		AC_TRY_COMPILE([
1951#include <sys/types.h>
1952#include <sys/socket.h>
1953#include <netinet/in.h>
1954$isc_netinetin6_hack
1955$isc_netinet6in6_hack
1956],
1957		[struct in6_pktinfo xyzzy; return (0);],
1958			[AC_MSG_RESULT(yes)
1959			 ISC_PLATFORM_HAVEIN6PKTINFO="#define ISC_PLATFORM_HAVEIN6PKTINFO 1"],
1960			[AC_MSG_RESULT(no -- disabling runtime ipv6 support)
1961			 ISC_PLATFORM_HAVEIN6PKTINFO="#undef ISC_PLATFORM_HAVEIN6PKTINFO"])
1962		;;
1963	no)
1964		ISC_PLATFORM_HAVEIPV6="#undef ISC_PLATFORM_HAVEIPV6"
1965		LWRES_PLATFORM_HAVEIPV6="#undef LWRES_PLATFORM_HAVEIPV6"
1966		ISC_PLATFORM_NEEDIN6ADDRANY="#undef ISC_PLATFORM_NEEDIN6ADDRANY"
1967		LWRES_PLATFORM_NEEDIN6ADDRANY="#undef LWRES_PLATFORM_NEEDIN6ADDRANY"
1968		ISC_PLATFORM_HAVEIN6PKTINFO="#undef ISC_PLATFORM_HAVEIN6PKTINFO"
1969		LWRES_HAVE_SIN6_SCOPE_ID="#define LWRES_HAVE_SIN6_SCOPE_ID 1"
1970		ISC_PLATFORM_HAVESCOPEID="#define ISC_PLATFORM_HAVESCOPEID 1"
1971		ISC_IPV6_H="ipv6.h"
1972		ISC_IPV6_O="ipv6.$O"
1973		ISC_ISCIPV6_O="unix/ipv6.$O"
1974		ISC_IPV6_C="ipv6.c"
1975		;;
1976esac
1977
1978AC_SUBST(ISC_PLATFORM_HAVEIPV6)
1979AC_SUBST(LWRES_PLATFORM_HAVEIPV6)
1980AC_SUBST(ISC_PLATFORM_NEEDNETINETIN6H)
1981AC_SUBST(LWRES_PLATFORM_NEEDNETINETIN6H)
1982AC_SUBST(ISC_PLATFORM_NEEDNETINET6IN6H)
1983AC_SUBST(LWRES_PLATFORM_NEEDNETINET6IN6H)
1984AC_SUBST(ISC_PLATFORM_HAVEINADDR6)
1985AC_SUBST(LWRES_PLATFORM_HAVEINADDR6)
1986AC_SUBST(ISC_PLATFORM_NEEDIN6ADDRANY)
1987AC_SUBST(LWRES_PLATFORM_NEEDIN6ADDRANY)
1988AC_SUBST(ISC_PLATFORM_NEEDIN6ADDRLOOPBACK)
1989AC_SUBST(LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK)
1990AC_SUBST(ISC_PLATFORM_HAVEIN6PKTINFO)
1991AC_SUBST(ISC_PLATFORM_FIXIN6ISADDR)
1992AC_SUBST(ISC_IPV6_H)
1993AC_SUBST(ISC_IPV6_O)
1994AC_SUBST(ISC_ISCIPV6_O)
1995AC_SUBST(ISC_IPV6_C)
1996AC_SUBST(LWRES_HAVE_SIN6_SCOPE_ID)
1997AC_SUBST(ISC_PLATFORM_HAVESCOPEID)
1998
1999AC_MSG_CHECKING([for struct if_laddrreq])
2000AC_TRY_LINK([
2001#include <sys/types.h>
2002#include <net/if6.h>
2003],[ struct if_laddrreq a; ],
2004	[AC_MSG_RESULT(yes)
2005	ISC_PLATFORM_HAVEIF_LADDRREQ="#define ISC_PLATFORM_HAVEIF_LADDRREQ 1"],
2006	[AC_MSG_RESULT(no)
2007	ISC_PLATFORM_HAVEIF_LADDRREQ="#undef ISC_PLATFORM_HAVEIF_LADDRREQ"])
2008AC_SUBST(ISC_PLATFORM_HAVEIF_LADDRREQ)
2009
2010AC_MSG_CHECKING([for struct if_laddrconf])
2011AC_TRY_LINK([
2012#include <sys/types.h>
2013#include <net/if6.h>
2014],[ struct if_laddrconf a; ],
2015	[AC_MSG_RESULT(yes)
2016	ISC_PLATFORM_HAVEIF_LADDRCONF="#define ISC_PLATFORM_HAVEIF_LADDRCONF 1"],
2017	[AC_MSG_RESULT(no)
2018	ISC_PLATFORM_HAVEIF_LADDRCONF="#undef ISC_PLATFORM_HAVEIF_LADDRCONF"])
2019AC_SUBST(ISC_PLATFORM_HAVEIF_LADDRCONF)
2020
2021#
2022# Check for network functions that are often missing.  We do this
2023# after the libtool checking, so we can put the right suffix on
2024# the files.  It also needs to come after checking for a Kame add-on,
2025# which provides some (all?) of the desired functions.
2026#
2027
2028AC_MSG_CHECKING([for inet_ntop with IPv6 support])
2029AC_TRY_RUN([
2030#include <sys/types.h>
2031#include <sys/socket.h>
2032#include <netinet/in.h>
2033#include <arpa/inet.h>
2034main() {
2035char a[16],b[64]; return(inet_ntop(AF_INET6, a, b, sizeof(b)) == (char*)0);}],
2036	[AC_MSG_RESULT(yes)
2037	ISC_PLATFORM_NEEDNTOP="#undef ISC_PLATFORM_NEEDNTOP"],
2038
2039	[AC_MSG_RESULT(no)
2040	ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_ntop.$O"
2041	ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_ntop.c"
2042	ISC_PLATFORM_NEEDNTOP="#define ISC_PLATFORM_NEEDNTOP 1"],
2043	[AC_MSG_RESULT(assuming inet_ntop not needed)
2044	ISC_PLATFORM_NEEDNTOP="#undef ISC_PLATFORM_NEEDNTOP"])
2045
2046
2047# On NetBSD 1.4.2 and maybe others, inet_pton() incorrectly accepts
2048# addresses with less than four octets, like "1.2.3".  Also leading
2049# zeros should also be rejected.
2050
2051AC_MSG_CHECKING([for working inet_pton with IPv6 support])
2052AC_TRY_RUN([
2053#include <sys/types.h>
2054#include <sys/socket.h>
2055#include <netinet/in.h>
2056#include <arpa/inet.h>
2057main() { char a[16]; return (inet_pton(AF_INET, "1.2.3", a) == 1 ? 1 :
2058			     inet_pton(AF_INET, "1.2.3.04", a) == 1 ? 1 :
2059			     (inet_pton(AF_INET6, "::1.2.3.4", a) != 1)); }],
2060	[AC_MSG_RESULT(yes)
2061	ISC_PLATFORM_NEEDPTON="#undef ISC_PLATFORM_NEEDPTON"],
2062	[AC_MSG_RESULT(no)
2063	ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_pton.$O"
2064	ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_pton.c"
2065	ISC_PLATFORM_NEEDPTON="#define ISC_PLATFORM_NEEDPTON 1"],
2066	[AC_MSG_RESULT(assuming inet_pton needed)
2067	ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_pton.$O"
2068	ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_pton.c"
2069	ISC_PLATFORM_NEEDPTON="#define ISC_PLATFORM_NEEDPTON 1"])
2070
2071AC_SUBST(ISC_PLATFORM_NEEDNTOP)
2072AC_SUBST(ISC_PLATFORM_NEEDPTON)
2073
2074#
2075# Look for a 4.4BSD-style sa_len member in struct sockaddr.
2076#
2077case "$host" in
2078	*-dec-osf*)
2079		# Turn on 4.4BSD style sa_len support.
2080		AC_DEFINE(_SOCKADDR_LEN)
2081		;;
2082esac
2083
2084AC_MSG_CHECKING(for sa_len in struct sockaddr)
2085AC_TRY_COMPILE([
2086#include <sys/types.h>
2087#include <sys/socket.h>],
2088[struct sockaddr sa; sa.sa_len = 0; return (0);],
2089	[AC_MSG_RESULT(yes)
2090	ISC_PLATFORM_HAVESALEN="#define ISC_PLATFORM_HAVESALEN 1"
2091	LWRES_PLATFORM_HAVESALEN="#define LWRES_PLATFORM_HAVESALEN 1"],
2092	[AC_MSG_RESULT(no)
2093	ISC_PLATFORM_HAVESALEN="#undef ISC_PLATFORM_HAVESALEN"
2094	LWRES_PLATFORM_HAVESALEN="#undef LWRES_PLATFORM_HAVESALEN"])
2095AC_SUBST(ISC_PLATFORM_HAVESALEN)
2096AC_SUBST(LWRES_PLATFORM_HAVESALEN)
2097
2098#
2099# Look for a 4.4BSD or 4.3BSD struct msghdr
2100#
2101AC_MSG_CHECKING(for struct msghdr flavor)
2102AC_TRY_COMPILE([
2103#include <sys/types.h>
2104#include <sys/socket.h>],
2105[struct msghdr msg; msg.msg_flags = 0; return (0);],
2106	[AC_MSG_RESULT(4.4BSD)
2107	ISC_PLATFORM_MSGHDRFLAVOR="#define ISC_NET_BSD44MSGHDR 1"],
2108	[AC_MSG_RESULT(4.3BSD)
2109	ISC_PLATFORM_MSGHDRFLAVOR="#define ISC_NET_BSD43MSGHDR 1"])
2110AC_SUBST(ISC_PLATFORM_MSGHDRFLAVOR)
2111
2112#
2113# Look for in_port_t.
2114#
2115AC_MSG_CHECKING(for type in_port_t)
2116AC_TRY_COMPILE([
2117#include <sys/types.h>
2118#include <netinet/in.h>],
2119[in_port_t port = 25; return (0);],
2120	[AC_MSG_RESULT(yes)
2121	ISC_PLATFORM_NEEDPORTT="#undef ISC_PLATFORM_NEEDPORTT"],
2122	[AC_MSG_RESULT(no)
2123	ISC_PLATFORM_NEEDPORTT="#define ISC_PLATFORM_NEEDPORTT 1"])
2124AC_SUBST(ISC_PLATFORM_NEEDPORTT)
2125
2126#
2127# Check for addrinfo
2128#
2129AC_MSG_CHECKING(for struct addrinfo)
2130AC_TRY_COMPILE([
2131#include <netdb.h>],
2132[struct addrinfo a; return (0);],
2133	[AC_MSG_RESULT(yes)
2134	ISC_LWRES_NEEDADDRINFO="#undef ISC_LWRES_NEEDADDRINFO"
2135	ISC_IRS_NEEDADDRINFO="#undef ISC_IRS_NEEDADDRINFO"
2136	AC_DEFINE(HAVE_ADDRINFO)],
2137	[AC_MSG_RESULT(no)
2138	ISC_LWRES_NEEDADDRINFO="#define ISC_LWRES_NEEDADDRINFO 1"
2139	ISC_IRS_NEEDADDRINFO="#define ISC_IRS_NEEDADDRINFO 1"])
2140AC_SUBST(ISC_LWRES_NEEDADDRINFO)
2141AC_SUBST(ISC_IRS_NEEDADDRINFO)
2142
2143#
2144# Check for rrsetinfo
2145#
2146AC_MSG_CHECKING(for struct rrsetinfo)
2147AC_TRY_COMPILE([
2148#include <netdb.h>],
2149[struct rrsetinfo r; return (0);],
2150	[AC_MSG_RESULT(yes)
2151	ISC_LWRES_NEEDRRSETINFO="#undef ISC_LWRES_NEEDRRSETINFO"],
2152	[AC_MSG_RESULT(no)
2153	ISC_LWRES_NEEDRRSETINFO="#define ISC_LWRES_NEEDRRSETINFO 1"])
2154AC_SUBST(ISC_LWRES_NEEDRRSETINFO)
2155
2156AC_MSG_CHECKING(for int sethostent)
2157AC_TRY_COMPILE([
2158#include <netdb.h>],
2159[int i = sethostent(0); return(0);],
2160	[AC_MSG_RESULT(yes)
2161	ISC_LWRES_SETHOSTENTINT="#define ISC_LWRES_SETHOSTENTINT 1"],
2162	[AC_MSG_RESULT(no)
2163	ISC_LWRES_SETHOSTENTINT="#undef ISC_LWRES_SETHOSTENTINT"])
2164AC_SUBST(ISC_LWRES_SETHOSTENTINT)
2165
2166AC_MSG_CHECKING(for int endhostent)
2167AC_TRY_COMPILE([
2168#include <netdb.h>],
2169[int i = endhostent(); return(0);],
2170	[AC_MSG_RESULT(yes)
2171	ISC_LWRES_ENDHOSTENTINT="#define ISC_LWRES_ENDHOSTENTINT 1"],
2172	[AC_MSG_RESULT(no)
2173	ISC_LWRES_ENDHOSTENTINT="#undef ISC_LWRES_ENDHOSTENTINT"])
2174AC_SUBST(ISC_LWRES_ENDHOSTENTINT)
2175
2176AC_MSG_CHECKING(for getnetbyaddr(in_addr_t, ...))
2177AC_TRY_COMPILE([
2178#include <netdb.h>
2179struct netent *getnetbyaddr(in_addr_t, int);],
2180[],
2181	[AC_MSG_RESULT(yes)
2182	ISC_LWRES_GETNETBYADDRINADDR="#define ISC_LWRES_GETNETBYADDRINADDR 1"],
2183	[AC_MSG_RESULT(no)
2184	ISC_LWRES_GETNETBYADDRINADDR="#undef ISC_LWRES_GETNETBYADDRINADDR"])
2185AC_SUBST(ISC_LWRES_GETNETBYADDRINADDR)
2186
2187AC_MSG_CHECKING(for int setnetent)
2188AC_TRY_COMPILE([
2189#include <netdb.h>],
2190[int i = setnetent(0); return(0);],
2191	[AC_MSG_RESULT(yes)
2192	ISC_LWRES_SETNETENTINT="#define ISC_LWRES_SETNETENTINT 1"],
2193	[AC_MSG_RESULT(no)
2194	ISC_LWRES_SETNETENTINT="#undef ISC_LWRES_SETNETENTINT"])
2195AC_SUBST(ISC_LWRES_SETNETENTINT)
2196
2197AC_MSG_CHECKING(for int endnetent)
2198AC_TRY_COMPILE([
2199#include <netdb.h>],
2200[int i = endnetent(); return(0);],
2201	[AC_MSG_RESULT(yes)
2202	ISC_LWRES_ENDNETENTINT="#define ISC_LWRES_ENDNETENTINT 1"],
2203	[AC_MSG_RESULT(no)
2204	ISC_LWRES_ENDNETENTINT="#undef ISC_LWRES_ENDNETENTINT"])
2205AC_SUBST(ISC_LWRES_ENDNETENTINT)
2206
2207AC_MSG_CHECKING(for gethostbyaddr(const void *, size_t, ...))
2208AC_TRY_COMPILE([
2209#include <netdb.h>
2210struct hostent *gethostbyaddr(const void *, size_t, int);],
2211[return(0);],
2212	[AC_MSG_RESULT(yes)
2213	ISC_LWRES_GETHOSTBYADDRVOID="#define ISC_LWRES_GETHOSTBYADDRVOID 1"],
2214	[AC_MSG_RESULT(no)
2215	ISC_LWRES_GETHOSTBYADDRVOID="#undef ISC_LWRES_GETHOSTBYADDRVOID"])
2216AC_SUBST(ISC_LWRES_GETHOSTBYADDRVOID)
2217
2218AC_MSG_CHECKING(for h_errno in netdb.h)
2219AC_TRY_COMPILE([
2220#include <netdb.h>],
2221[h_errno = 1; return(0);],
2222	[AC_MSG_RESULT(yes)
2223	ISC_LWRES_NEEDHERRNO="#undef ISC_LWRES_NEEDHERRNO"],
2224	[AC_MSG_RESULT(no)
2225	ISC_LWRES_NEEDHERRNO="#define ISC_LWRES_NEEDHERRNO 1"])
2226AC_SUBST(ISC_LWRES_NEEDHERRNO)
2227
2228#
2229# Sadly, the definitions of system-supplied getnameinfo(3) vary.  Try to catch
2230# known variations here:
2231#
2232AC_MSG_CHECKING(for getnameinfo prototype definitions)
2233AC_TRY_COMPILE([
2234#include <sys/types.h>
2235#include <sys/socket.h>
2236#include <netdb.h>
2237int getnameinfo(const struct sockaddr *, socklen_t, char *,
2238                socklen_t, char *, socklen_t, unsigned int);],
2239[ return (0);],
2240	[AC_MSG_RESULT(socklen_t for buflen; u_int for flags)
2241	 AC_DEFINE(IRS_GETNAMEINFO_BUFLEN_T, socklen_t,
2242		   [Define to the buffer length type used by getnameinfo(3).])
2243	 AC_DEFINE(IRS_GETNAMEINFO_FLAGS_T, unsigned int,
2244		   [Define to the flags type used by getnameinfo(3).])],
2245[AC_TRY_COMPILE([
2246#include <sys/types.h>
2247#include <sys/socket.h>
2248#include <netdb.h>
2249int getnameinfo(const struct sockaddr *, socklen_t, char *,
2250                size_t, char *, size_t, int);],
2251[ return (0);],
2252	[AC_MSG_RESULT(size_t for buflen; int for flags)
2253	 AC_DEFINE(IRS_GETNAMEINFO_BUFLEN_T, size_t)
2254	 AC_DEFINE(IRS_GETNAMEINFO_FLAGS_T, int)],
2255[AC_MSG_RESULT(not match any subspecies; assume standard definition)
2256AC_DEFINE(IRS_GETNAMEINFO_BUFLEN_T, socklen_t)
2257AC_DEFINE(IRS_GETNAMEINFO_FLAGS_T, int)])])
2258
2259#
2260# ...and same for gai_strerror().
2261#
2262AC_MSG_CHECKING(for gai_strerror prototype definitions)
2263AC_TRY_COMPILE([
2264#include <sys/types.h>
2265#include <sys/socket.h>
2266#include <netdb.h>
2267char *gai_strerror(int ecode);],
2268[ return (0); ],
2269	[AC_MSG_RESULT(returning char *)
2270	 AC_DEFINE([IRS_GAISTRERROR_RETURN_T], [char *],
2271	 [return type of gai_strerror])],
2272[AC_MSG_RESULT(not match any subspecies; assume standard definition)
2273AC_DEFINE([IRS_GAISTRERROR_RETURN_T], [const char *])])
2274
2275AC_CHECK_FUNC(getipnodebyname,
2276	[ISC_LWRES_GETIPNODEPROTO="#undef ISC_LWRES_GETIPNODEPROTO"],
2277	[ISC_LWRES_GETIPNODEPROTO="#define ISC_LWRES_GETIPNODEPROTO 1"])
2278AC_CHECK_FUNC(getnameinfo,
2279	[ISC_LWRES_GETNAMEINFOPROTO="#undef ISC_LWRES_GETNAMEINFOPROTO"],
2280	[ISC_LWRES_GETNAMEINFOPROTO="#define ISC_LWRES_GETNAMEINFOPROTO 1"])
2281AC_CHECK_FUNC(getaddrinfo,
2282	[ISC_LWRES_GETADDRINFOPROTO="#undef ISC_LWRES_GETADDRINFOPROTO"
2283	AC_DEFINE(HAVE_GETADDRINFO)],
2284	[ISC_LWRES_GETADDRINFOPROTO="#define ISC_LWRES_GETADDRINFOPROTO 1"])
2285AC_CHECK_FUNC(gai_strerror, AC_DEFINE(HAVE_GAISTRERROR))
2286AC_SUBST(ISC_LWRES_GETIPNODEPROTO)
2287AC_SUBST(ISC_LWRES_GETADDRINFOPROTO)
2288AC_SUBST(ISC_LWRES_GETNAMEINFOPROTO)
2289AC_SUBST(ISC_IRS_GETNAMEINFOSOCKLEN)
2290
2291AC_ARG_ENABLE(getifaddrs,
2292[  --enable-getifaddrs     Enable the use of getifaddrs() [[yes|no]].],
2293    want_getifaddrs="$enableval",  want_getifaddrs="yes")
2294
2295#
2296# This interface iteration code for getifaddrs() will fall back to using
2297# /proc/net/if_inet6 if getifaddrs() in glibc doesn't return any IPv6
2298# addresses.
2299#
2300case $want_getifaddrs in
2301glibc)
2302AC_MSG_WARN("--enable-getifaddrs=glibc is no longer required")
2303AC_CHECK_FUNC(getifaddrs, AC_DEFINE(HAVE_GETIFADDRS))
2304;;
2305yes)
2306AC_CHECK_FUNC(getifaddrs, AC_DEFINE(HAVE_GETIFADDRS))
2307;;
2308no)
2309;;
2310esac
2311
2312#
2313# Look for a sysctl call to get the list of network interfaces.
2314#
2315case $ac_cv_header_sys_sysctl_h in
2316yes)
2317AC_MSG_CHECKING(for interface list sysctl)
2318AC_EGREP_CPP(found_rt_iflist, [
2319#include <sys/param.h>
2320#include <sys/sysctl.h>
2321#include <sys/socket.h>
2322#ifdef NET_RT_IFLIST
2323found_rt_iflist
2324#endif
2325],
2326	[AC_MSG_RESULT(yes)
2327	 AC_DEFINE(HAVE_IFLIST_SYSCTL)],
2328	[AC_MSG_RESULT(no)])
2329;;
2330esac
2331
2332#
2333# Check for some other useful functions that are not ever-present.
2334#
2335
2336# We test for strsep() using AC_TRY_LINK instead of AC_CHECK_FUNC
2337# because AIX 4.3.3 with patches for bos.adt.include to version 4.3.3.77
2338# reportedly defines strsep() without declaring it in <string.h> when
2339# -D_LINUX_SOURCE_COMPAT is not defined [RT #2190], and
2340# AC_CHECK_FUNC() incorrectly succeeds because it declares
2341# the function itself.
2342AC_MSG_CHECKING(for correctly declared strsep())
2343AC_TRY_LINK([#include <string.h>], [char *sp; char *foo = strsep(&sp, ".");],
2344	[AC_MSG_RESULT(yes); ISC_PLATFORM_NEEDSTRSEP="#undef ISC_PLATFORM_NEEDSTRSEP"],
2345	[AC_MSG_RESULT(no); ISC_PLATFORM_NEEDSTRSEP="#define ISC_PLATFORM_NEEDSTRSEP 1"])
2346AC_SUBST(ISC_PLATFORM_NEEDSTRSEP)
2347
2348AC_CHECK_FUNC(memmove,
2349	[ISC_PLATFORM_NEEDMEMMOVE="#undef ISC_PLATFORM_NEEDMEMMOVE"],
2350	[ISC_PLATFORM_NEEDMEMMOVE="#define ISC_PLATFORM_NEEDMEMMOVE 1"])
2351AC_SUBST(ISC_PLATFORM_NEEDMEMMOVE)
2352
2353AC_CHECK_FUNC(strtoul,
2354	[ISC_PLATFORM_NEEDSTRTOUL="#undef ISC_PLATFORM_NEEDSTRTOUL"
2355	 LWRES_PLATFORM_NEEDSTRTOUL="#undef LWRES_PLATFORM_NEEDSTRTOUL"
2356	 GENRANDOMLIB=""],
2357	[ISC_PLATFORM_NEEDSTRTOUL="#define ISC_PLATFORM_NEEDSTRTOUL 1"
2358	 LWRES_PLATFORM_NEEDSTRTOUL="#define LWRES_PLATFORM_NEEDSTRTOUL 1"
2359	 GENRANDOMLIB='${ISCLIBS}'])
2360AC_SUBST(ISC_PLATFORM_NEEDSTRTOUL)
2361AC_SUBST(LWRES_PLATFORM_NEEDSTRTOUL)
2362AC_SUBST(GENRANDOMLIB)
2363
2364AC_CHECK_FUNC(strlcpy,
2365	[ISC_PLATFORM_NEEDSTRLCPY="#undef ISC_PLATFORM_NEEDSTRLCPY"],
2366	[ISC_PLATFORM_NEEDSTRLCPY="#define ISC_PLATFORM_NEEDSTRLCPY 1"])
2367AC_SUBST(ISC_PLATFORM_NEEDSTRLCPY)
2368
2369AC_CHECK_FUNC(strlcat,
2370	[ISC_PLATFORM_NEEDSTRLCAT="#undef ISC_PLATFORM_NEEDSTRLCAT"],
2371	[ISC_PLATFORM_NEEDSTRLCAT="#define ISC_PLATFORM_NEEDSTRLCAT 1"])
2372AC_SUBST(ISC_PLATFORM_NEEDSTRLCAT)
2373
2374
2375AC_SUBST(READLINE_LIB)
2376AC_ARG_WITH(readline,
2377        [  --with-readline[=LIBSPEC]    specify readline library [default -lreadline]],
2378        readline="$withval", readline="-lreadline")
2379case "$readline" in
2380no)	;;
2381*)
2382	if test "x$readline" = "xyes"
2383	then
2384		readline=-lreadline
2385	fi
2386	saved_LIBS="$LIBS"
2387	LIBS="$readline"
2388	AC_CHECK_FUNCS(readline)
2389	if test "$ac_cv_func_readline" = "yes"
2390	then
2391		READLINE_LIB="$readline"
2392	fi
2393	LIBS="$saved_LIBS"
2394        ;;
2395esac
2396
2397ISC_PRINT_OBJS=
2398ISC_PRINT_SRCS=
2399AC_MSG_CHECKING(sprintf)
2400AC_TRY_COMPILE([
2401#include <stdio.h>
2402],
2403[ char buf[2]; return(*sprintf(buf,"x"));],
2404[
2405ISC_PRINT_OBJS="print.$O"
2406ISC_PRINT_SRCS="print.c"
2407ISC_PLATFORM_NEEDSPRINTF="#define ISC_PLATFORM_NEEDSPRINTF"
2408LWRES_PLATFORM_NEEDSPRINTF="#define LWRES_PLATFORM_NEEDSPRINTF"
2409],
2410[ISC_PLATFORM_NEEDSPRINTF="#undef ISC_PLATFORM_NEEDSPRINTF"
2411 LWRES_PLATFORM_NEEDSPRINTF="#undef LWRES_PLATFORM_NEEDSPRINTF"]
2412)
2413AC_SUBST(ISC_PLATFORM_NEEDSPRINTF)
2414AC_SUBST(LWRES_PLATFORM_NEEDSPRINTF)
2415
2416AC_CHECK_FUNC(vsnprintf,
2417	[ISC_PLATFORM_NEEDVSNPRINTF="#undef ISC_PLATFORM_NEEDVSNPRINTF"
2418	 LWRES_PLATFORM_NEEDVSNPRINTF="#undef LWRES_PLATFORM_NEEDVSNPRINTF"],
2419	[ISC_PRINT_OBJS="print.$O"
2420	 ISC_PRINT_SRCS="print.c"
2421	 ISC_PLATFORM_NEEDVSNPRINTF="#define ISC_PLATFORM_NEEDVSNPRINTF 1"
2422	 LWRES_PLATFORM_NEEDVSNPRINTF="#define LWRES_PLATFORM_NEEDVSNPRINTF 1"])
2423AC_SUBST(ISC_PLATFORM_NEEDVSNPRINTF)
2424AC_SUBST(LWRES_PLATFORM_NEEDVSNPRINTF)
2425ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS $ISC_PRINT_OBJS"
2426ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS $ISC_PRINT_SRCS"
2427
2428AC_CHECK_FUNC(strerror, AC_DEFINE(HAVE_STRERROR))
2429
2430AC_SUBST(ISC_EXTRA_OBJS)
2431AC_SUBST(ISC_EXTRA_SRCS)
2432
2433#
2434# Use our own SPNEGO implementation?
2435#
2436AC_ARG_ENABLE(isc-spnego,
2437	[  --disable-isc-spnego    use SPNEGO from GSSAPI library])
2438
2439if test -n "$USE_GSSAPI"
2440then
2441	case "$enable_isc_spnego" in
2442		yes|'')
2443			USE_ISC_SPNEGO='-DUSE_ISC_SPNEGO'
2444			DST_EXTRA_OBJS="$DST_EXTRA_OBJS spnego.$O"
2445			DST_EXTRA_SRCS="$DST_EXTRA_SRCS spnego.c"
2446			AC_MSG_RESULT(using SPNEGO from lib/dns)
2447			;;
2448		no)
2449			AC_MSG_RESULT(using SPNEGO from GSSAPI library)
2450			;;
2451	esac
2452fi
2453
2454AC_SUBST(USE_ISC_SPNEGO)
2455
2456AC_SUBST(DST_EXTRA_OBJS)
2457AC_SUBST(DST_EXTRA_SRCS)
2458
2459# Determine the printf format characters to use when printing
2460# values of type isc_int64_t. This will normally be "ll", but where
2461# the compiler treats "long long" as a alias for "long" and printf
2462# doesn't know about "long long" use "l".  Hopefully the sprintf
2463# will produce a inconsistent result in the later case.  If the compiler
2464# fails due to seeing "%lld" we fall back to "l".
2465#
2466# Digital Unix 4.0 (gcc?) (long long) is 64 bits as is its long. It uses
2467# %ld even for (long long)/
2468#
2469# Win32 uses "%I64d", but that's defined elsewhere since we don't use
2470# configure on Win32.
2471#
2472AC_MSG_CHECKING(printf format modifier for 64-bit integers)
2473AC_TRY_RUN([
2474#include <stdio.h>
2475main() {
2476	long long int j = 0;
2477	char buf[100];
2478	buf[0] = 0;
2479	sprintf(buf, "%lld", j);
2480	exit((sizeof(long long int) != sizeof(long int))? 0 :
2481	     (strcmp(buf, "0") != 0));
2482}
2483],
2484	[AC_MSG_RESULT(ll)
2485	ISC_PLATFORM_QUADFORMAT='#define ISC_PLATFORM_QUADFORMAT "ll"'
2486	LWRES_PLATFORM_QUADFORMAT='#define LWRES_PLATFORM_QUADFORMAT "ll"'],
2487	[AC_MSG_RESULT(l)
2488	ISC_PLATFORM_QUADFORMAT='#define ISC_PLATFORM_QUADFORMAT "l"'
2489	LWRES_PLATFORM_QUADFORMAT='#define LWRES_PLATFORM_QUADFORMAT "l"'],
2490	[AC_MSG_RESULT(assuming target platform uses ll)
2491	ISC_PLATFORM_QUADFORMAT='#define ISC_PLATFORM_QUADFORMAT "ll"'
2492	LWRES_PLATFORM_QUADFORMAT='#define LWRES_PLATFORM_QUADFORMAT "ll"'])
2493AC_SUBST(ISC_PLATFORM_QUADFORMAT)
2494AC_SUBST(LWRES_PLATFORM_QUADFORMAT)
2495
2496#
2497# Security Stuff
2498#
2499# Note it is very recommended to *not* disable chroot(),
2500# this is only because chroot() was made obsolete by Posix.
2501AC_ARG_ENABLE(chroot,
2502	[  --disable-chroot        disable chroot])
2503case "$enable_chroot" in
2504	yes|'')
2505		AC_CHECK_FUNCS(chroot)
2506		;;
2507	no)
2508		;;
2509esac
2510AC_ARG_ENABLE(linux-caps,
2511	[  --disable-linux-caps	  disable linux capabilities])
2512case "$enable_linux_caps" in
2513	yes|'')
2514		AC_CHECK_HEADERS(linux/capability.h sys/capability.h)
2515		AC_CHECK_LIB(cap, cap_set_proc)
2516		;;
2517	no)
2518		;;
2519esac
2520AC_CHECK_HEADERS(sys/prctl.h)
2521
2522AC_CHECK_HEADERS(sys/un.h,
2523ISC_PLATFORM_HAVESYSUNH="#define ISC_PLATFORM_HAVESYSUNH 1"
2524,
2525ISC_PLATFORM_HAVESYSUNH="#undef ISC_PLATFORM_HAVESYSUNH"
2526)
2527AC_SUBST(ISC_PLATFORM_HAVESYSUNH)
2528
2529case "$host" in
2530*-solaris*)
2531	AC_DEFINE(NEED_SECURE_DIRECTORY, 1,
2532		  [Define if connect does not honour the permission on the UNIX domain socket.])
2533	;;
2534*-sunos*)
2535	AC_DEFINE(NEED_SECURE_DIRECTORY, 1,
2536		  [Define if connect does not honour the permission on the UNIX domain socket.])
2537	;;
2538esac
2539
2540#
2541# Time Zone Stuff
2542#
2543AC_CHECK_FUNC(tzset, AC_DEFINE(HAVE_TZSET))
2544
2545AC_MSG_CHECKING(for optarg declaration)
2546AC_TRY_COMPILE([
2547#include <unistd.h>
2548],
2549[optarg = 0;],
2550[AC_MSG_RESULT(yes)],
2551[AC_MSG_RESULT(no)
2552GEN_NEED_OPTARG="-DNEED_OPTARG=1"
2553AC_DEFINE(NEED_OPTARG, 1, [Defined if extern char *optarg is not declared.])])
2554
2555#
2556# BSD/OS, and perhaps some others, don't define rlim_t.
2557#
2558AC_MSG_CHECKING(for type rlim_t)
2559AC_TRY_COMPILE([
2560#include <sys/types.h>
2561#include <sys/time.h>
2562#include <sys/resource.h>],
2563[rlim_t rl = 19671212; return (0);],
2564[AC_MSG_RESULT(yes)
2565 ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE rlim_t"],
2566[AC_MSG_RESULT(no)
2567
2568AC_MSG_CHECKING(type of rlim_cur)
2569AC_TRY_RUN([
2570#include <sys/types.h>
2571#include <sys/time.h>
2572#include <sys/resource.h>
2573main() { struct rlimit r; exit(!(sizeof(r.rlim_cur) == sizeof(int)));}],
2574[AC_MSG_RESULT(int)
2575ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE int"],
2576[
2577AC_TRY_RUN([
2578#include <sys/types.h>
2579#include <sys/time.h>
2580#include <sys/resource.h>
2581main() { struct rlimit r; exit(!(sizeof(r.rlim_cur) == sizeof(long int)));}],
2582[AC_MSG_RESULT(long int)
2583ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE long int"],
2584[
2585AC_TRY_RUN([
2586#include <sys/types.h>
2587#include <sys/time.h>
2588#include <sys/resource.h>
2589main() { struct rlimit r; exit((!sizeof(r.rlim_cur) == sizeof(long long int)));}],
2590[AC_MSG_RESULT(long long int)
2591ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE long long int"],
2592[AC_MSG_ERROR([unable to determine sizeof rlim_cur])
2593],[AC_MSG_ERROR(this cannot happen)])
2594],[AC_MSG_ERROR(this cannot happen)])
2595],[
2596AC_ARG_WITH(rlimtype, , rlimtype="$withval", rlimtype="long long int")
2597ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE $rlimtype"
2598AC_MSG_RESULT(cannot determine type of rlim_cur when cross compiling - assuming $rlimtype)])
2599])
2600AC_SUBST(ISC_PLATFORM_RLIMITTYPE)
2601
2602#
2603# Older HP-UX doesn't have gettune
2604#
2605case "$host" in
2606  	*-hp-hpux*)
2607		AC_CHECK_HEADERS(sys/dyntune.h)
2608		;;
2609	*)
2610		;;
2611esac
2612
2613
2614#
2615# Compaq TruCluster requires more code for handling cluster IP aliases
2616#
2617case "$host" in
2618	*-dec-osf*)
2619		AC_CHECK_LIB(clua, clua_getaliasaddress, LIBS="-lclua $LIBS")
2620		AC_CHECK_FUNC(clua_getaliasaddress,
2621				AC_DEFINE(HAVE_TRUCLUSTER, 1,
2622					[Define if running under Compaq TruCluster]))
2623		;;
2624	*)
2625		;;
2626esac
2627
2628#
2629# Some hosts need msg_namelen to match the size of the socket structure.
2630# Some hosts don't set msg_namelen appropriately on return from recvmsg().
2631#
2632case $host in
2633*os2*|*hp-mpeix*)
2634	AC_DEFINE(BROKEN_RECVMSG, 1,
2635		  [Define if recvmsg() does not meet all of the BSD socket API specifications.])
2636	;;
2637esac
2638
2639#
2640# Microsoft has their own way of handling shared libraries that requires
2641# additional qualifiers on extern variables.  Unix systems don't need it.
2642#
2643AC_SUBST(ISC_PLATFORM_USEDECLSPEC)
2644ISC_PLATFORM_USEDECLSPEC="#undef ISC_PLATFORM_USEDECLSPEC"
2645AC_SUBST(LWRES_PLATFORM_USEDECLSPEC)
2646LWRES_PLATFORM_USEDECLSPEC="#undef LWRES_PLATFORM_USEDECLSPEC"
2647AC_SUBST(IRS_PLATFORM_USEDECLSPEC)
2648IRS_PLATFORM_USEDECLSPEC="#undef IRS_PLATFORM_USEDECLSPEC"
2649
2650#
2651# Random remaining OS-specific issues involving compiler warnings.
2652# XXXDCL print messages to indicate some compensation is being done?
2653#
2654AC_SUBST(ISC_PLATFORM_BRACEPTHREADONCEINIT)
2655ISC_PLATFORM_BRACEPTHREADONCEINIT="#undef ISC_PLATFORM_BRACEPTHREADONCEINIT"
2656
2657case "$host" in
2658	*-aix5.[[123]].*)
2659		hack_shutup_pthreadonceinit=yes
2660		;;
2661	*-bsdi3.1*)
2662		hack_shutup_sputaux=yes
2663		;;
2664	*-bsdi4.0*)
2665		hack_shutup_sigwait=yes
2666		hack_shutup_sputaux=yes
2667		;;
2668	[*-bsdi4.[12]*])
2669		hack_shutup_stdargcast=yes
2670		;;
2671	[*-solaris2.[89]])
2672		hack_shutup_pthreadonceinit=yes
2673		;;
2674	*-solaris2.1[[0-9]])
2675		AC_TRY_COMPILE([ #include <pthread.h> ], [ static pthread_once_t once_test = { PTHREAD_ONCE_INIT }; ], [hack_shutup_pthreadonceinit=yes], )
2676		;;
2677esac
2678
2679case "$hack_shutup_pthreadonceinit" in
2680	yes)
2681		#
2682		# Shut up PTHREAD_ONCE_INIT unbraced initializer warnings.
2683		#
2684		ISC_PLATFORM_BRACEPTHREADONCEINIT="#define ISC_PLATFORM_BRACEPTHREADONCEINIT 1"
2685		;;
2686esac
2687
2688case "$hack_shutup_sigwait" in
2689	yes)
2690		#
2691		# Shut up a -Wmissing-prototypes warning for sigwait().
2692		#
2693		AC_DEFINE(SHUTUP_SIGWAIT)
2694		;;
2695esac
2696
2697case "$hack_shutup_sputaux" in
2698	yes)
2699		#
2700		# Shut up a -Wmissing-prototypes warning from <stdio.h>.
2701		#
2702		AC_DEFINE(SHUTUP_SPUTAUX)
2703		;;
2704esac
2705
2706case "$hack_shutup_stdargcast" in
2707	yes)
2708		#
2709		# Shut up a -Wcast-qual warning from va_start().
2710		#
2711		AC_DEFINE(SHUTUP_STDARG_CAST)
2712		;;
2713esac
2714
2715AC_CHECK_HEADERS(strings.h,
2716  ISC_PLATFORM_HAVESTRINGSH="#define ISC_PLATFORM_HAVESTRINGSH 1"
2717,
2718  ISC_PLATFORM_HAVESTRINGSH="#undef ISC_PLATFORM_HAVESTRINGSH"
2719)
2720AC_SUBST(ISC_PLATFORM_HAVESTRINGSH)
2721
2722#
2723# Check for if_nametoindex() for IPv6 scoped addresses support
2724#
2725AC_CHECK_FUNC(if_nametoindex, ac_cv_have_if_nametoindex=yes,
2726		ac_cv_have_if_nametoindex=no)
2727case $ac_cv_have_if_nametoindex in
2728no)
2729	case "$host" in
2730	*-hp-hpux*)
2731		AC_CHECK_LIB(ipv6, if_nametoindex,
2732				ac_cv_have_if_nametoindex=yes
2733				LIBS="-lipv6 $LIBS",)
2734	;;
2735	esac
2736esac
2737case $ac_cv_have_if_nametoindex in
2738yes)
2739	ISC_PLATFORM_HAVEIFNAMETOINDEX="#define ISC_PLATFORM_HAVEIFNAMETOINDEX 1"
2740	;;
2741*)
2742	ISC_PLATFORM_HAVEIFNAMETOINDEX="#undef ISC_PLATFORM_HAVEIFNAMETOINDEX"
2743	;;
2744esac
2745AC_SUBST(ISC_PLATFORM_HAVEIFNAMETOINDEX)
2746
2747AC_CHECK_FUNCS(nanosleep usleep)
2748
2749#
2750# Machine architecture dependent features
2751#
2752AC_ARG_ENABLE(atomic,
2753	[  --enable-atomic	  enable machine specific atomic operations
2754			  [[default=autodetect]]],
2755			enable_atomic="$enableval",
2756			enable_atomic="autodetect")
2757case "$enable_atomic" in
2758	yes|''|autodetect)
2759		case "$host" in
2760		powerpc-ibm-aix*)
2761			if test "X$GCC" = "Xyes"; then
2762				AC_MSG_CHECKING([if asm("isc"); works])
2763				AC_TRY_COMPILE(,[
2764				main() { asm("ics"); exit(0); }
2765				],
2766				[AC_MSG_RESULT(yes)
2767				 use_atomic=yes],
2768				[
2769				saved_cflags="$CFLAGS"
2770				CFLAGS="$CFLAGS -Wa,-many"
2771				AC_TRY_RUN([
2772				main() { asm("ics"); exit(0); }
2773				],
2774				[AC_MSG_RESULT([yes, required -Wa,-many])
2775				 use_atomic=yes],
2776				[AC_MSG_RESULT([no, use_atomic disabled])
2777				 CFLAGS="$saved_cflags"
2778				 use_atomic=no],
2779				[AC_MSG_RESULT([cross compile, assume yes])
2780				 CFLAGS="$saved_cflags"
2781				 use_atomic=yes])
2782				]
2783				)
2784			else
2785				use_atomic=yes
2786			fi
2787			;;
2788		*)
2789			use_atomic=yes
2790			;;
2791		esac
2792		;;
2793	no)
2794		use_atomic=no
2795		arch=noatomic
2796		;;
2797esac
2798
2799ISC_PLATFORM_USEOSFASM="#undef ISC_PLATFORM_USEOSFASM"
2800if test "$use_atomic" = "yes"; then
2801	AC_MSG_CHECKING([architecture type for atomic operations])
2802	have_atomic=yes		# set default
2803	case "$host" in
2804	[i[3456]86-*])
2805		# XXX: some old x86 architectures actually do not support
2806		#      (some of) these operations.  Do we need stricter checks?
2807                AC_CHECK_SIZEOF([void *])
2808		if test $ac_cv_sizeof_void_p = 8; then
2809			arch=x86_64
2810			have_xaddq=yes
2811		else
2812			arch=x86_32
2813		fi
2814	;;
2815	x86_64-*|amd64-*)
2816                AC_CHECK_SIZEOF([void *])
2817		if test $ac_cv_sizeof_void_p = 8; then
2818			arch=x86_64
2819			have_xaddq=yes
2820		else
2821			arch=x86_32
2822		fi
2823	;;
2824	alpha*-*)
2825		arch=alpha
2826	;;
2827	powerpc-*|powerpc64-*)
2828		arch=powerpc
2829	;;
2830	mips-*|mipsel-*|mips64-*|mips64el-*)
2831		arch=mips
2832	;;
2833	ia64-*)
2834		arch=ia64
2835	;;
2836	*)
2837		have_atomic=no
2838		arch=noatomic
2839	;;
2840	esac
2841	AC_MSG_RESULT($arch)
2842fi
2843
2844if test "$have_atomic" = "yes"; then
2845	AC_MSG_CHECKING([compiler support for inline assembly code])
2846
2847	compiler=generic
2848	# Check whether the compiler supports the assembly syntax we provide.
2849	if test "X$GCC" = "Xyes"; then
2850		# GCC's ASM extension always works
2851		compiler=gcc
2852		if test $arch = "x86_64"; then
2853			# We can share the same code for gcc with x86_32
2854			arch=x86_32
2855		fi
2856		if test $arch = "powerpc"; then
2857			#
2858			# The MacOS (and maybe others) uses "r0" for register
2859			# zero. Under linux/ibm it is "0" for register 0.
2860			# Probe to see if we have a MacOS style assembler.
2861			#
2862			AC_MSG_CHECKING([Checking for MacOS style assembler syntax])
2863			AC_TRY_COMPILE(, [
2864			__asm__ volatile ("li r0, 0x0\n"::);
2865			], [
2866			AC_MSG_RESULT(yes)
2867			compiler="mac"
2868			ISC_PLATFORM_USEMACASM="#define ISC_PLATFORM_USEMACASM 1"
2869			], [AC_MSG_RESULT(no)])
2870		fi
2871	else
2872		case "$host" in
2873		alpha*-dec-osf*)
2874			# Tru64 compiler has its own syntax for inline
2875			# assembly.
2876			AC_TRY_COMPILE(, [
2877#ifndef __DECC
2878#error "unexpected compiler"
2879#endif
2880				return (0);],
2881				[compiler=osf],)
2882		;;
2883		powerpc-ibm-aix*)
2884			compiler=aix
2885		;;
2886		esac
2887	fi
2888	case "$compiler" in
2889	gcc)
2890		ISC_PLATFORM_USEGCCASM="#define ISC_PLATFORM_USEGCCASM 1"
2891		;;
2892	osf)
2893		ISC_PLATFORM_USEOSFASM="#define ISC_PLATFORM_USEOSFASM 1"
2894		;;
2895	aix)
2896		;;
2897	mac)
2898		;;
2899	*)
2900		# See if the generic __asm function works.  If not,
2901		# we need to disable the atomic operations.
2902		AC_TRY_LINK(, [
2903					__asm("nop")
2904				],
2905		[compiler="standard"
2906		ISC_PLATFORM_USESTDASM="#define ISC_PLATFORM_USESTDASM 1"],
2907		[compiler="not supported (atomic operations disabled)"
2908		have_atomic=no
2909		arch=noatomic ]);
2910		;;
2911	esac
2912
2913	AC_MSG_RESULT($compiler)
2914fi
2915
2916if test "$have_atomic" = "yes"; then
2917	ISC_PLATFORM_HAVEXADD="#define ISC_PLATFORM_HAVEXADD 1"
2918	ISC_PLATFORM_HAVECMPXCHG="#define ISC_PLATFORM_HAVECMPXCHG 1"
2919	ISC_PLATFORM_HAVEATOMICSTORE="#define ISC_PLATFORM_HAVEATOMICSTORE 1"
2920else
2921	ISC_PLATFORM_HAVEXADD="#undef ISC_PLATFORM_HAVEXADD"
2922	ISC_PLATFORM_HAVECMPXCHG="#undef ISC_PLATFORM_HAVECMPXCHG"
2923	ISC_PLATFORM_HAVEATOMICSTORE="#undef ISC_PLATFORM_HAVEATOMICSTORE"
2924fi
2925
2926if test "$have_xaddq" = "yes"; then
2927	ISC_PLATFORM_HAVEXADDQ="#define ISC_PLATFORM_HAVEXADDQ 1"
2928else
2929	ISC_PLATFORM_HAVEXADDQ="#undef ISC_PLATFORM_HAVEXADDQ"
2930fi
2931
2932AC_SUBST(ISC_PLATFORM_HAVEXADD)
2933AC_SUBST(ISC_PLATFORM_HAVEXADDQ)
2934AC_SUBST(ISC_PLATFORM_HAVECMPXCHG)
2935AC_SUBST(ISC_PLATFORM_HAVEATOMICSTORE)
2936
2937AC_SUBST(ISC_PLATFORM_USEGCCASM)
2938AC_SUBST(ISC_PLATFORM_USEOSFASM)
2939AC_SUBST(ISC_PLATFORM_USESTDASM)
2940AC_SUBST(ISC_PLATFORM_USEMACASM)
2941
2942ISC_ARCH_DIR=$arch
2943AC_SUBST(ISC_ARCH_DIR)
2944
2945#
2946# Activate "rrset-order fixed" or not?
2947#
2948AC_ARG_ENABLE(fixed-rrset,
2949	[  --enable-fixed-rrset    enable fixed rrset ordering
2950			  [[default=no]]],
2951			enable_fixed="$enableval",
2952			enable_fixed="no")
2953case "$enable_fixed" in
2954	yes)
2955		AC_DEFINE(DNS_RDATASET_FIXED, 1,
2956			  [Define to enable "rrset-order fixed" syntax.])
2957		;;
2958	no)
2959		;;
2960	*)
2961		;;
2962esac
2963
2964#
2965# Enable response policy rewriting using NS IP addresses
2966#
2967AC_ARG_ENABLE(rpz-nsip,
2968	[  --disable-rpz-nsip	  disable rpz-nsip rules [[default=enabled]]],
2969			enable_nsip="$enableval",
2970			enable_nsip="yes")
2971case "$enable_nsip" in
2972	yes)
2973		AC_DEFINE(ENABLE_RPZ_NSIP, 1,
2974			  [Define to enable rpz-nsip rules.])
2975		;;
2976	no)
2977		;;
2978	*)
2979		;;
2980esac
2981
2982#
2983# Enable response policy rewriting using NS name
2984#
2985AC_ARG_ENABLE(rpz-nsdname,
2986	[  --disable-rpz-nsdname	  disable rpz-nsdname rules [[default=enabled]]],
2987			enable_nsdname="$enableval",
2988			enable_nsdname="yes")
2989case "$enable_nsdname" in
2990	yes)
2991		AC_DEFINE(ENABLE_RPZ_NSDNAME, 1,
2992			  [Define to enable rpz-nsdname rules.])
2993		;;
2994	no)
2995		;;
2996	*)
2997		;;
2998esac
2999
3000#
3001# Activate "filter-aaaa-on-v4" or not?
3002#
3003AC_ARG_ENABLE(filter-aaaa,
3004	[  --enable-filter-aaaa    enable filtering of AAAA records over IPv4
3005			  [[default=no]]],
3006			enable_filter="$enableval",
3007			enable_filter="no")
3008case "$enable_filter" in
3009	yes)
3010		AC_DEFINE(ALLOW_FILTER_AAAA_ON_V4, 1,
3011			  [Define to enable the "filter-aaaa-on-v4" option.])
3012		;;
3013	no)
3014		;;
3015	*)
3016		;;
3017esac
3018
3019#
3020#  The following sets up how non-blocking i/o is established.
3021#  Sunos, cygwin and solaris 2.x (x<5) require special handling.
3022#
3023case "$host" in
3024*-sunos*) AC_DEFINE(PORT_NONBLOCK, O_NDELAY);;
3025*-cygwin*) AC_DEFINE(PORT_NONBLOCK, O_NDELAY);;
3026*-solaris2.[[01234]])
3027	AC_DEFINE(PORT_NONBLOCK, O_NONBLOCK)
3028	AC_DEFINE(USE_FIONBIO_IOCTL, 1,
3029		  [Defined if you need to use ioctl(FIONBIO) instead a fcntl call to make non-blocking.])
3030	;;
3031*) AC_DEFINE(PORT_NONBLOCK, O_NONBLOCK,
3032	     [Sets which flag to pass to open/fcntl to make non-blocking (O_NDELAY/O_NONBLOCK).])
3033	;;
3034esac
3035#
3036# Solaris 2.5.1 and earlier cannot bind() then connect() a TCP socket.
3037# This prevents the source address being set.
3038#
3039case "$host" in
3040*-solaris2.[[012345]]|*-solaris2.5.1)
3041	AC_DEFINE(BROKEN_TCP_BIND_BEFORE_CONNECT, 1,
3042		  [Define if you cannot bind() before connect() for TCP sockets.])
3043	;;
3044esac
3045#
3046# The following sections deal with tools used for formatting
3047# the documentation.  They are all optional, unless you are
3048# a developer editing the documentation source.
3049#
3050
3051#
3052# Look for TeX.
3053#
3054
3055AC_PATH_PROGS(LATEX, latex, latex)
3056AC_SUBST(LATEX)
3057
3058AC_PATH_PROGS(PDFLATEX, pdflatex, pdflatex)
3059AC_SUBST(PDFLATEX)
3060
3061#
3062# Look for w3m
3063#
3064
3065AC_PATH_PROGS(W3M, w3m, w3m)
3066AC_SUBST(W3M)
3067
3068#
3069# Look for xsltproc (libxslt)
3070#
3071
3072AC_PATH_PROG(XSLTPROC, xsltproc, xsltproc)
3073AC_SUBST(XSLTPROC)
3074
3075#
3076# Look for xmllint (libxml2)
3077#
3078
3079AC_PATH_PROG(XMLLINT, xmllint, xmllint)
3080AC_SUBST(XMLLINT)
3081
3082#
3083# Look for Doxygen
3084#
3085
3086AC_PATH_PROG(DOXYGEN, doxygen, doxygen)
3087AC_SUBST(DOXYGEN)
3088
3089#
3090# Subroutine for searching for an ordinary file (e.g., a stylesheet)
3091# in a number of directories:
3092#
3093#   NOM_PATH_FILE(VARIABLE, FILENAME, DIRECTORIES)
3094#
3095# If the file FILENAME is found in one of the DIRECTORIES, the shell
3096# variable VARIABLE is defined to its absolute pathname.  Otherwise,
3097# it is set to FILENAME, with no directory prefix (that's not terribly
3098# useful, but looks less confusing in substitutions than leaving it
3099# empty).  The variable VARIABLE will be substituted into output files.
3100#
3101
3102AC_DEFUN(NOM_PATH_FILE, [
3103$1=""
3104AC_MSG_CHECKING(for $2)
3105for d in $3
3106do
3107	f=$d/$2
3108	if test -f $f
3109	then
3110		$1=$f
3111		AC_MSG_RESULT($f)
3112		break
3113	fi
3114done
3115if test "X[$]$1" = "X"
3116then
3117	AC_MSG_RESULT("not found");
3118	$1=$2
3119fi
3120AC_SUBST($1)
3121])
3122
3123#
3124# Look for Docbook-XSL stylesheets.  Location probably varies by system.
3125# If it's not explicitly specified, guess where it might be found, based on
3126# where SGML stuff lives on some systems (FreeBSD is the only one we're sure
3127# of at the moment).
3128#
3129AC_MSG_CHECKING(for Docbook-XSL path)
3130AC_ARG_WITH(docbook-xsl,
3131[  --with-docbook-xsl=PATH Specify path for Docbook-XSL stylesheets],
3132   docbook_path="$withval", docbook_path="auto")
3133case "$docbook_path" in
3134auto)
3135	AC_MSG_RESULT(auto)
3136	docbook_xsl_trees="/usr/pkg/share/xsl/docbook /usr/local/share/xsl/docbook /usr/share/xsl/docbook /opt/local/share/xsl/docbook-xsl"
3137	;;
3138*)
3139	docbook_xsl_trees="$withval"
3140    	AC_MSG_RESULT($docbook_xsl_trees)
3141	;;
3142esac
3143
3144#
3145# Look for stylesheets we need.
3146#
3147
3148NOM_PATH_FILE(XSLT_DOCBOOK_STYLE_HTML, html/docbook.xsl, $docbook_xsl_trees)
3149NOM_PATH_FILE(XSLT_DOCBOOK_STYLE_XHTML, xhtml/docbook.xsl, $docbook_xsl_trees)
3150NOM_PATH_FILE(XSLT_DOCBOOK_STYLE_MAN, manpages/docbook.xsl, $docbook_xsl_trees)
3151NOM_PATH_FILE(XSLT_DOCBOOK_CHUNK_HTML, html/chunk.xsl, $docbook_xsl_trees)
3152NOM_PATH_FILE(XSLT_DOCBOOK_CHUNK_XHTML, xhtml/chunk.xsl, $docbook_xsl_trees)
3153NOM_PATH_FILE(XSLT_DOCBOOK_CHUNKTOC_HTML, html/chunktoc.xsl, $docbook_xsl_trees)
3154NOM_PATH_FILE(XSLT_DOCBOOK_CHUNKTOC_XHTML, xhtml/chunktoc.xsl, $docbook_xsl_trees)
3155NOM_PATH_FILE(XSLT_DOCBOOK_MAKETOC_HTML, html/maketoc.xsl, $docbook_xsl_trees)
3156NOM_PATH_FILE(XSLT_DOCBOOK_MAKETOC_XHTML, xhtml/maketoc.xsl, $docbook_xsl_trees)
3157
3158#
3159# Same dance for db2latex
3160#
3161# No idea where this lives except on FreeBSD.
3162#
3163
3164db2latex_xsl_trees="/usr/local/share"
3165
3166#
3167# Look for stylesheets we need.
3168#
3169
3170NOM_PATH_FILE(XSLT_DB2LATEX_STYLE, db2latex/xsl/docbook.xsl, $db2latex_xsl_trees)
3171
3172#
3173# Look for "admonition" image directory.  Can't use NOM_PATH_FILE()
3174# because it's a directory, so just do the same things, inline.
3175#
3176
3177AC_MSG_CHECKING(for db2latex/xsl/figures)
3178for d in $db2latex_xsl_trees
3179do
3180	dd=$d/db2latex/xsl/figures
3181	if test -d $dd
3182	then
3183		XSLT_DB2LATEX_ADMONITIONS=$dd
3184		AC_MSG_RESULT($dd)
3185		break
3186	fi
3187done
3188if test "X$XSLT_DB2LATEX_ADMONITIONS" = "X"
3189then
3190	AC_MSG_RESULT(not found)
3191	XSLT_DB2LATEX_ADMONITIONS=db2latex/xsl/figures
3192fi
3193AC_SUBST(XSLT_DB2LATEX_ADMONITIONS)
3194
3195#
3196# IDN support
3197#
3198AC_ARG_WITH(idn,
3199	[  --with-idn[=MPREFIX]      enable IDN support using idnkit [default PREFIX]],
3200	use_idn="$withval", use_idn="no")
3201case "$use_idn" in
3202yes)
3203	if test X$prefix = XNONE ; then
3204		idn_path=/usr/local
3205	else
3206		idn_path=$prefix
3207	fi
3208	;;
3209no)
3210	;;
3211*)
3212	idn_path="$use_idn"
3213	;;
3214esac
3215
3216iconvinc=
3217iconvlib=
3218AC_ARG_WITH(libiconv,
3219	[  --with-libiconv[=IPREFIX] GNU libiconv are in IPREFIX [default PREFIX]],
3220	use_libiconv="$withval", use_libiconv="no")
3221case "$use_libiconv" in
3222yes)
3223	if test X$prefix = XNONE ; then
3224		iconvlib="-L/usr/local/lib -R/usr/local/lib -liconv"
3225	else
3226		iconvlib="-L$prefix/lib -R$prefix/lib -liconv"
3227	fi
3228	;;
3229no)
3230	iconvlib=
3231	;;
3232*)
3233	iconvlib="-L$use_libiconv/lib -R$use_libiconv/lib -liconv"
3234	;;
3235esac
3236
3237AC_ARG_WITH(iconv,
3238	[  --with-iconv[=LIBSPEC]    specify iconv library [default -liconv]],
3239	iconvlib="$withval")
3240case "$iconvlib" in
3241no)
3242	iconvlib=
3243	;;
3244yes)
3245	iconvlib=-liconv
3246	;;
3247esac
3248
3249AC_ARG_WITH(idnlib,
3250	[  --with-idnlib=ARG       specify libidnkit],
3251	idnlib="$withval", idnlib="no")
3252if test "$idnlib" = yes; then
3253	AC_MSG_ERROR([You must specify ARG for --with-idnlib.])
3254fi
3255
3256IDNLIBS=
3257if test "$use_idn" != no; then
3258	AC_DEFINE(WITH_IDN, 1, [define if idnkit support is to be included.])
3259	STD_CINCLUDES="$STD_CINCLUDES -I$idn_path/include"
3260	if test "$idnlib" != no; then
3261		IDNLIBS="$idnlib $iconvlib"
3262	else
3263		IDNLIBS="-L$idn_path/lib -lidnkit $iconvlib"
3264	fi
3265fi
3266AC_SUBST(IDNLIBS)
3267
3268#
3269# Check whether to build Automated Test Framework unit tests
3270#
3271AC_ARG_WITH(atf,
3272	[  --with-atf=ARG          Automated Test Framework support],
3273	atf="$withval", atf="no")
3274if test "$atf" = yes; then
3275	atf=`pwd`/unit/atf
3276	ATFBUILD=atf-src
3277	AC_SUBST(ATFBUILD)
3278	AC_CONFIG_COMMANDS([atf-config],
3279		[(
3280		 mkdir -p unit/atf-src;
3281		 cd unit/atf-src;
3282		 case "$srcdir" in
3283		 /*) ;;
3284		 *) srcdir="../../$srcdir";;
3285		 esac
3286		 ${SHELL} ${srcdir}${srcdir:+/unit/atf-src/}./configure MISSING=: --prefix $atfdir;
3287		) ],
3288		[atfdir=`pwd`/unit/atf])
3289	AC_MSG_RESULT(building ATF from bind9/unit/atf-src)
3290fi
3291
3292ATFLIBS=
3293if test "$atf" != no; then
3294	AC_DEFINE(ATF_TEST, 1, [define if ATF unit tests are to be built.])
3295	STD_CINCLUDES="$STD_CINCLUDES -I$atf/include"
3296	ATFBIN="$atf/bin"
3297	ATFLIBS="-L$atf/lib -latf-c"
3298	if test "$want_openssl_hash" = yes; then
3299		ATFLIBS="-L$atf/lib -latf-c $DNS_CRYPTO_LIBS"
3300	fi
3301	UNITTESTS=tests
3302fi
3303AC_SUBST(ATFBIN)
3304AC_SUBST(ATFLIBS)
3305AC_SUBST(UNITTESTS)
3306
3307AC_CHECK_HEADERS(locale.h)
3308AC_CHECK_FUNCS(setlocale)
3309
3310#
3311# Substitutions
3312#
3313AC_SUBST(BIND9_TOP_BUILDDIR)
3314BIND9_TOP_BUILDDIR=`pwd`
3315
3316AC_SUBST(BIND9_ISC_BUILDINCLUDE)
3317AC_SUBST(BIND9_ISCCC_BUILDINCLUDE)
3318AC_SUBST(BIND9_ISCCFG_BUILDINCLUDE)
3319AC_SUBST(BIND9_DNS_BUILDINCLUDE)
3320AC_SUBST(BIND9_LWRES_BUILDINCLUDE)
3321AC_SUBST(BIND9_BIND9_BUILDINCLUDE)
3322if test "X$srcdir" != "X"; then
3323	BIND9_ISC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isc/include"
3324	BIND9_ISCCC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isccc/include"
3325	BIND9_ISCCFG_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isccfg/include"
3326	BIND9_DNS_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/dns/include"
3327	BIND9_LWRES_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/lwres/include"
3328	BIND9_BIND9_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/bind9/include"
3329else
3330	BIND9_ISC_BUILDINCLUDE=""
3331	BIND9_ISCCC_BUILDINCLUDE=""
3332	BIND9_ISCCFG_BUILDINCLUDE=""
3333	BIND9_DNS_BUILDINCLUDE=""
3334	BIND9_LWRES_BUILDINCLUDE=""
3335	BIND9_BIND9_BUILDINCLUDE=""
3336fi
3337
3338AC_SUBST_FILE(BIND9_MAKE_INCLUDES)
3339BIND9_MAKE_INCLUDES=$BIND9_TOP_BUILDDIR/make/includes
3340
3341AC_SUBST_FILE(BIND9_MAKE_RULES)
3342BIND9_MAKE_RULES=$BIND9_TOP_BUILDDIR/make/rules
3343
3344. $srcdir/version
3345BIND9_PRODUCT="PRODUCT=\"${PRODUCT}\""
3346AC_SUBST(BIND9_PRODUCT)
3347BIND9_DESCRIPTION="DESCRIPTION=\"${DESCRIPTION}\""
3348AC_SUBST(BIND9_DESCRIPTION)
3349BIND9_VERSION="VERSION=${MAJORVER}.${MINORVER}${PATCHVER:+.}${PATCHVER}${RELEASETYPE}${RELEASEVER}"
3350AC_SUBST(BIND9_VERSION)
3351
3352BIND9_SRCID="SRCID=unset"
3353if test -f $srcdir/srcid; then
3354	. $srcdir/srcid
3355	BIND9_SRCID="SRCID=$SRCID"
3356fi
3357AC_SUBST(BIND9_SRCID)
3358
3359if test -z "$ac_configure_args"; then
3360	BIND9_CONFIGARGS="defaults"
3361else
3362	for a in $ac_configure_args
3363	do
3364		BIND9_CONFIGARGS="$BIND9_CONFIGARGS $a"
3365	done
3366fi
3367BIND9_CONFIGARGS="`echo $BIND9_CONFIGARGS | sed 's/^ //'`"
3368BIND9_CONFIGARGS="CONFIGARGS=${BIND9_CONFIGARGS}"
3369AC_SUBST(BIND9_CONFIGARGS)
3370
3371AC_SUBST_FILE(LIBISC_API)
3372LIBISC_API=$srcdir/lib/isc/api
3373
3374AC_SUBST_FILE(LIBISCCC_API)
3375LIBISCCC_API=$srcdir/lib/isccc/api
3376
3377AC_SUBST_FILE(LIBISCCFG_API)
3378LIBISCCFG_API=$srcdir/lib/isccfg/api
3379
3380AC_SUBST_FILE(LIBDNS_API)
3381LIBDNS_API=$srcdir/lib/dns/api
3382
3383AC_SUBST_FILE(LIBBIND9_API)
3384LIBBIND9_API=$srcdir/lib/bind9/api
3385
3386AC_SUBST_FILE(LIBLWRES_API)
3387LIBLWRES_API=$srcdir/lib/lwres/api
3388
3389AC_SUBST_FILE(LIBIRS_API)
3390LIBIRS_API=$srcdir/lib/irs/api
3391
3392#
3393# Configure any DLZ drivers.
3394#
3395# If config.dlz.in selects one or more DLZ drivers, it will set
3396# CONTRIB_DLZ to a non-empty value, which will be our clue to
3397# build DLZ drivers in contrib.
3398#
3399# This section has to come after the libtool stuff because it needs to
3400# know how to name the driver object files.
3401#
3402
3403CONTRIB_DLZ=""
3404DLZ_DRIVER_INCLUDES=""
3405DLZ_DRIVER_LIBS=""
3406DLZ_DRIVER_SRCS=""
3407DLZ_DRIVER_OBJS=""
3408DLZ_SYSTEM_TEST=""
3409
3410#
3411# Configure support for building a shared library object
3412#
3413# Even when libtool is available it can't always be relied upon
3414# to build an object that can be dlopen()'ed, but this is necessary
3415# for building the dlzexternal system test, so we'll try it the
3416# old-fashioned way.
3417#
3418SO="so"
3419SO_CFLAGS=""
3420SO_LD=""
3421SO_TARGETS=""
3422
3423AC_ARG_WITH(dlopen,
3424	[  --with-dlopen=ARG       Support dynamically loadable DLZ drivers],
3425	dlopen="$withval", dlopen="yes")
3426
3427case $host in
3428	*-sunos*) dlopen="no"
3429		;;
3430esac
3431
3432if test "$dlopen" = "yes"; then
3433	AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
3434	if test "$have_dl" = "yes"; then
3435		LIBS="-ldl $LIBS"
3436	fi
3437        AC_CHECK_FUNCS(dlopen dlclose dlsym,,dlopen=no)
3438fi
3439
3440if test "$dlopen" = "yes"; then
3441	case $host in
3442		*-linux*)
3443			SO_CFLAGS="-fPIC"
3444			if test "$have_dl" = "yes"
3445			then
3446				if test "$use_libtool" = "yes"; then
3447					SO_LD="${CC} -Xcompiler -shared"
3448				else
3449					SO_LD="${CC} -shared"
3450				fi
3451			else
3452				SO_LD="ld -shared"
3453			fi
3454			;;
3455		*-freebsd*|*-openbsd*|*-netbsd*)
3456			SO_CFLAGS="-fpic"
3457			SO_LD="ld -Bshareable -x"
3458			;;
3459		*-solaris*)
3460			SO_CFLAGS="-KPIC"
3461			SO_LD="ld -G -z text"
3462                        ;;
3463		*-hp-hpux*)
3464			SO=sl
3465			SO_CFLAGS="+z"
3466			SO_LD="ld -b"
3467                        ;;
3468		*)
3469			SO_CFLAGS="-fPIC"
3470			;;
3471	esac
3472
3473	if test "X$GCC" = "Xyes"; then
3474		SO_CFLAGS="-fPIC"
3475                test -n "$SO_LD" || SO_LD="${CC} -shared"
3476	fi
3477
3478	# If we still don't know how to make shared objects, don't make any.
3479	if test -n "$SO_LD"; then
3480		SO_TARGETS="\${SO_TARGETS}"
3481		AC_DEFINE(ISC_DLZ_DLOPEN, 1,
3482			  [Define to allow building of objects for dlopen().])
3483	fi
3484fi
3485
3486AC_SUBST(SO)
3487AC_SUBST(SO_CFLAGS)
3488AC_SUBST(SO_LD)
3489AC_SUBST(SO_TARGETS)
3490
3491sinclude(contrib/dlz/config.dlz.in)
3492AC_MSG_CHECKING(contributed DLZ drivers)
3493
3494if test -n "$CONTRIB_DLZ"
3495then
3496	AC_MSG_RESULT(yes)
3497	DLZ_DRIVER_RULES=contrib/dlz/drivers/rules
3498	AC_CONFIG_FILES([$DLZ_DRIVER_RULES])
3499else
3500	AC_MSG_RESULT(no)
3501	DLZ_DRIVER_RULES=/dev/null
3502fi
3503
3504AC_SUBST(CONTRIB_DLZ)
3505AC_SUBST(DLZ_DRIVER_INCLUDES)
3506AC_SUBST(DLZ_DRIVER_LIBS)
3507AC_SUBST(DLZ_DRIVER_SRCS)
3508AC_SUBST(DLZ_DRIVER_OBJS)
3509AC_SUBST(DLZ_SYSTEM_TEST)
3510AC_SUBST_FILE(DLZ_DRIVER_RULES)
3511
3512if test "$cross_compiling" = "yes"; then
3513	if test -z "$BUILD_CC"; then
3514		AC_ERROR([BUILD_CC not set])
3515	fi
3516	BUILD_CFLAGS="$BUILD_CFLAGS"
3517	BUILD_CPPFLAGS="$BUILD_CPPFLAGS"
3518	BUILD_LDFLAGS="$BUILD_LDFLAGS"
3519	BUILD_LIBS="$BUILD_LIBS"
3520else
3521	BUILD_CC="$CC"
3522	BUILD_CFLAGS="$CFLAGS"
3523	BUILD_CPPFLAGS="$CPPFLAGS $GEN_NEED_OPTARG"
3524	BUILD_LDFLAGS="$LDFLAGS"
3525	BUILD_LIBS="$LIBS"
3526fi
3527
3528NEWFLAGS=""
3529for e in $BUILD_LDFLAGS ; do
3530    case $e in
3531	-L*)
3532	    case $host_os in
3533		netbsd*)
3534		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
3535		    NEWFLAGS="$NEWFLAGS $e $ee"
3536		    ;;
3537		freebsd*)
3538		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
3539		    NEWFLAGS="$NEWFLAGS $e $ee"
3540		    ;;
3541		solaris*)
3542		    ee=`echo $e | sed -e 's%^-L%-R%'`
3543		    NEWFLAGS="$NEWFLAGS $e $ee"
3544		    ;;
3545		*)
3546		    NEWFLAGS="$NEWFLAGS $e"
3547		    ;;
3548		esac
3549	    ;;
3550	*)
3551	    NEWFLAGS="$NEWFLAGS $e"
3552	    ;;
3553    esac
3554done
3555BUILD_LDFLAGS="$NEWFLAGS"
3556
3557NEWFLAGS=""
3558for e in $DNS_GSSAPI_LIBS ; do
3559    case $e in
3560	-L*)
3561	    case $host_os in
3562		netbsd*)
3563		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
3564		    NEWFLAGS="$NEWFLAGS $e $ee"
3565		    ;;
3566		freebsd*)
3567		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
3568		    NEWFLAGS="$NEWFLAGS $e $ee"
3569		    ;;
3570		solaris*)
3571		    ee=`echo $e | sed -e 's%^-L%-R%'`
3572		    NEWFLAGS="$NEWFLAGS $e $ee"
3573		    ;;
3574		*)
3575		    NEWFLAGS="$NEWFLAGS $e"
3576		    ;;
3577		esac
3578	    ;;
3579	*)
3580	    NEWFLAGS="$NEWFLAGS $e"
3581	    ;;
3582    esac
3583done
3584DNS_GSSAPI_LIBS="$NEWFLAGS"
3585
3586NEWFLAGS=""
3587for e in $DNS_CRYPTO_LIBS ; do
3588    case $e in
3589	-L*)
3590	    case $host_os in
3591		netbsd*)
3592		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
3593		    NEWFLAGS="$NEWFLAGS $e $ee"
3594		    ;;
3595		freebsd*)
3596		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
3597		    NEWFLAGS="$NEWFLAGS $e $ee"
3598		    ;;
3599		solaris*)
3600		    ee=`echo $e | sed -e 's%^-L%-R%'`
3601		    NEWFLAGS="$NEWFLAGS $e $ee"
3602		    ;;
3603		*)
3604		    NEWFLAGS="$NEWFLAGS $e"
3605		    ;;
3606		esac
3607	    ;;
3608	*)
3609	    NEWFLAGS="$NEWFLAGS $e"
3610	    ;;
3611    esac
3612done
3613DNS_CRYPTO_LIBS="$NEWFLAGS"
3614
3615AC_SUBST(BUILD_CC)
3616AC_SUBST(BUILD_CFLAGS)
3617AC_SUBST(BUILD_CPPFLAGS)
3618AC_SUBST(BUILD_LDFLAGS)
3619AC_SUBST(BUILD_LIBS)
3620
3621#
3622# Commands to run at the end of config.status.
3623# Don't just put these into configure, it won't work right if somebody
3624# runs config.status directly (which autoconf allows).
3625#
3626
3627AC_CONFIG_COMMANDS(
3628	[chmod],
3629	[chmod a+x isc-config.sh doc/doxygen/doxygen-input-filter])
3630
3631#
3632# Files to configure.  These are listed here because we used to
3633# specify them as arguments to AC_OUTPUT.  It's (now) ok to move these
3634# elsewhere if there's a good reason for doing so.
3635#
3636
3637AC_CONFIG_FILES([
3638  make/Makefile
3639  make/mkdep
3640	Makefile
3641	bin/Makefile
3642	bin/check/Makefile
3643	bin/confgen/Makefile
3644	bin/confgen/unix/Makefile
3645	bin/dig/Makefile
3646	bin/dnssec/Makefile
3647	bin/named/Makefile
3648	bin/named/unix/Makefile
3649	bin/nsupdate/Makefile
3650	bin/pkcs11/Makefile
3651	bin/python/Makefile
3652	bin/python/dnssec-checkds.py
3653	bin/python/dnssec-coverage.py
3654	bin/rndc/Makefile
3655	bin/tests/Makefile
3656	bin/tests/atomic/Makefile
3657	bin/tests/db/Makefile
3658	bin/tests/dst/Makefile
3659	bin/tests/dst/Kdh.+002+18602.key
3660	bin/tests/dst/Kdh.+002+18602.private
3661	bin/tests/dst/Kdh.+002+48957.key
3662	bin/tests/dst/Kdh.+002+48957.private
3663	bin/tests/dst/Ktest.+001+00002.key
3664	bin/tests/dst/Ktest.+001+54622.key
3665	bin/tests/dst/Ktest.+001+54622.private
3666	bin/tests/dst/Ktest.+003+23616.key
3667	bin/tests/dst/Ktest.+003+23616.private
3668	bin/tests/dst/Ktest.+003+49667.key
3669	bin/tests/dst/dst_2_data
3670	bin/tests/dst/t2_data_1
3671	bin/tests/dst/t2_data_2
3672	bin/tests/dst/t2_dsasig
3673	bin/tests/dst/t2_rsasig
3674	bin/tests/hashes/Makefile
3675	bin/tests/headerdep_test.sh
3676	bin/tests/master/Makefile
3677	bin/tests/mem/Makefile
3678	bin/tests/names/Makefile
3679	bin/tests/net/Makefile
3680	bin/tests/rbt/Makefile
3681	bin/tests/resolver/Makefile
3682	bin/tests/sockaddr/Makefile
3683	bin/tests/system/Makefile
3684	bin/tests/system/conf.sh
3685	bin/tests/system/dlz/prereq.sh
3686	bin/tests/system/dlzexternal/Makefile
3687	bin/tests/system/dlzexternal/ns1/named.conf
3688	bin/tests/system/ecdsa/prereq.sh
3689	bin/tests/system/filter-aaaa/Makefile
3690	bin/tests/system/gost/prereq.sh
3691	bin/tests/system/lwresd/Makefile
3692	bin/tests/system/rpz/Makefile
3693	bin/tests/system/rsabigexponent/Makefile
3694	bin/tests/system/tkey/Makefile
3695	bin/tests/system/tsiggss/Makefile
3696	bin/tests/tasks/Makefile
3697	bin/tests/timers/Makefile
3698	bin/tests/virtual-time/Makefile
3699	bin/tests/virtual-time/conf.sh
3700	bin/tools/Makefile
3701	contrib/check-secure-delegation.pl
3702	contrib/zone-edit.sh
3703	doc/Makefile
3704	doc/arm/Makefile
3705	doc/doxygen/Doxyfile
3706	doc/doxygen/Makefile
3707	doc/doxygen/doxygen-input-filter
3708	doc/misc/Makefile
3709	doc/xsl/Makefile
3710	doc/xsl/isc-docbook-chunk.xsl
3711	doc/xsl/isc-docbook-html.xsl
3712	doc/xsl/isc-docbook-latex.xsl
3713	doc/xsl/isc-manpage.xsl
3714	isc-config.sh
3715	lib/Makefile
3716	lib/bind9/Makefile
3717	lib/bind9/include/Makefile
3718	lib/bind9/include/bind9/Makefile
3719	lib/dns/Makefile
3720	lib/dns/include/Makefile
3721	lib/dns/include/dns/Makefile
3722	lib/dns/include/dst/Makefile
3723	lib/dns/tests/Makefile
3724	lib/export/Makefile
3725	lib/export/dns/Makefile
3726	lib/export/dns/include/Makefile
3727	lib/export/dns/include/dns/Makefile
3728	lib/export/dns/include/dst/Makefile
3729	lib/export/irs/Makefile
3730	lib/export/irs/include/Makefile
3731	lib/export/irs/include/irs/Makefile
3732	lib/export/isc/$thread_dir/Makefile
3733	lib/export/isc/$thread_dir/include/Makefile
3734	lib/export/isc/$thread_dir/include/isc/Makefile
3735	lib/export/isc/Makefile
3736	lib/export/isc/include/Makefile
3737	lib/export/isc/include/isc/Makefile
3738	lib/export/isc/nls/Makefile
3739	lib/export/isc/unix/Makefile
3740	lib/export/isc/unix/include/Makefile
3741	lib/export/isc/unix/include/isc/Makefile
3742	lib/export/isccfg/Makefile
3743	lib/export/isccfg/include/Makefile
3744	lib/export/isccfg/include/isccfg/Makefile
3745	lib/export/samples/Makefile
3746	lib/export/samples/Makefile-postinstall
3747	lib/irs/Makefile
3748	lib/irs/include/Makefile
3749	lib/irs/include/irs/Makefile
3750	lib/irs/include/irs/netdb.h
3751	lib/irs/include/irs/platform.h
3752	lib/isc/$arch/Makefile
3753	lib/isc/$arch/include/Makefile
3754	lib/isc/$arch/include/isc/Makefile
3755	lib/isc/$thread_dir/Makefile
3756	lib/isc/$thread_dir/include/Makefile
3757	lib/isc/$thread_dir/include/isc/Makefile
3758	lib/isc/Makefile
3759	lib/isc/include/Makefile
3760	lib/isc/include/isc/Makefile
3761	lib/isc/include/isc/platform.h
3762	lib/isc/tests/Makefile
3763	lib/isc/nls/Makefile
3764	lib/isc/unix/Makefile
3765	lib/isc/unix/include/Makefile
3766	lib/isc/unix/include/isc/Makefile
3767	lib/isccc/Makefile
3768	lib/isccc/include/Makefile
3769	lib/isccc/include/isccc/Makefile
3770	lib/isccfg/Makefile
3771	lib/isccfg/include/Makefile
3772	lib/isccfg/include/isccfg/Makefile
3773	lib/lwres/Makefile
3774	lib/lwres/include/Makefile
3775	lib/lwres/include/lwres/Makefile
3776	lib/lwres/include/lwres/netdb.h
3777	lib/lwres/include/lwres/platform.h
3778	lib/lwres/man/Makefile
3779	lib/lwres/unix/Makefile
3780	lib/lwres/unix/include/Makefile
3781	lib/lwres/unix/include/lwres/Makefile
3782	lib/tests/Makefile
3783	lib/tests/include/Makefile
3784	lib/tests/include/tests/Makefile
3785	unit/Makefile
3786	unit/unittest.sh
3787])
3788
3789#
3790# Do it
3791#
3792
3793AC_OUTPUT
3794
3795#
3796# Now that the Makefiles exist we can ensure that everything is rebuilt.
3797#
3798AC_ARG_WITH(make-clean,
3799[  --with-make-clean      Run "make clean" at end of configure [[yes|no]].],
3800    make_clean="$withval", make_clean="yes")
3801case "$make_clean" in
3802yes)
3803	make clean
3804	;;
3805esac
3806
3807if test "X$USE_OPENSSL" = "X"; then
3808cat << \EOF
3809BIND is being built without OpenSSL. This means it will not have DNSSEC support.
3810EOF
3811fi
3812
3813if test "X$OPENSSL_WARNING" != "X"; then
3814cat << \EOF
3815WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
3816WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
3817WARNING                                                                 WARNING
3818WARNING         Your OpenSSL crypto library may be vulnerable to        WARNING
3819WARNING         one or more of the the following known security         WARNING
3820WARNING         flaws:                                                  WARNING
3821WARNING                                                                 WARNING
3822WARNING         CAN-2002-0659, CAN-2006-4339, CVE-2006-2937 and         WARNING
3823WARNING         CVE-2006-2940.                                          WARNING
3824WARNING                                                                 WARNING
3825WARNING         It is recommended that you upgrade to OpenSSL           WARNING
3826WARNING         version 0.9.8d/0.9.7l (or greater).                     WARNING
3827WARNING                                                                 WARNING
3828WARNING         You can disable this warning by specifying:             WARNING
3829WARNING                                                                 WARNING
3830WARNING               --disable-openssl-version-check          	        WARNING
3831WARNING                                                                 WARNING
3832WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
3833WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
3834EOF
3835fi
3836
3837# Tell Emacs to edit this file in shell mode.
3838# Local Variables:
3839# mode: sh
3840# End:
3841