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