1# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
2#
3# This Source Code Form is subject to the terms of the Mozilla Public
4# License, v. 2.0. If a copy of the MPL was not distributed with this
5# file, you can obtain one at https://mozilla.org/MPL/2.0/.
6#
7# See the COPYRIGHT file distributed with this work for additional
8# information regarding copyright ownership.
9
10dnl
11AC_DIVERT_PUSH(1)dnl
12esyscmd([sed -e 's/^/# /' -e '/Portions of this code/,$d' COPYRIGHT])dnl
13AC_DIVERT_POP()dnl
14
15AC_INIT(BIND, [9.11], [info@isc.org], [], [https://www.isc.org/downloads/BIND/])
16AC_PREREQ(2.59)
17
18AC_CONFIG_HEADER(config.h)
19AC_CONFIG_MACRO_DIR([libtool.m4])
20
21AC_CANONICAL_HOST
22
23AC_PROG_MAKE_SET
24
25#
26# GNU libtool support
27#
28case $build_os in
29sunos*)
30    # Just set the maximum command line length for sunos as it otherwise
31    # takes a exceptionally long time to work it out. Required for libtool.
32
33    lt_cv_sys_max_cmd_len=4096;
34    ;;
35esac
36
37LFS_CFLAGS=`getconf LFS_CFLAGS 2>/dev/null`
38LFS_LDFLAGS=`getconf LFS_LDFLAGS 2>/dev/null`
39LFS_LIBS=`getconf LFS_LIBS 2>/dev/null`
40
41AC_SUBST([LFS_CFLAGS])
42AC_SUBST([LFS_LDFLAGS])
43AC_SUBST([LFS_LIBS])
44
45AC_PROG_LIBTOOL
46AC_PROG_INSTALL
47AC_PROG_LN_S
48
49AC_SUBST(STD_CINCLUDES)
50AC_SUBST(STD_CDEFINES)
51AC_SUBST(STD_CWARNINGS)
52AC_SUBST(CCOPT)
53AC_SUBST(CCNOOPT)
54AC_SUBST(BACKTRACECFLAGS)
55
56#
57# Use pkg-config
58#
59
60PKG_PROG_PKG_CONFIG
61
62# Warn if the user specified libbind, which is now deprecated
63#
64# [pairwise: skip]
65AC_ARG_ENABLE(libbind, AS_HELP_STRING([--enable-libbind], [deprecated]))
66
67case "$enable_libbind" in
68	yes)
69		AC_MSG_ERROR(['libbind' is no longer part of the BIND 9 distribution.
70It is available from http://www.isc.org as a separate download.])
71		;;
72	no|'')
73		;;
74esac
75
76# [pairwise: --enable-buffer-useinline, --disable-buffer-useinline]
77AC_ARG_ENABLE(buffer_useinline, AS_HELP_STRING([--enable-buffer-useinline],
78	      [define ISC_BUFFER_USEINLINE when compiling [[default=yes]]]),
79	      if test yes = "${enable}"
80	      then
81		      AC_DEFINE([ISC_BUFFER_USEINLINE], [1],
82			        [Define if you want to use inline buffers])
83	      fi,
84	      AC_DEFINE([ISC_BUFFER_USEINLINE], [1]))
85
86# [pairwise: --enable-warn-shadow, --disable-warn-shadow]
87AC_ARG_ENABLE(warn_shadow,
88	      AS_HELP_STRING([--enable-warn-shadow],
89			     [turn on -Wshadow when compiling]))
90
91# [pairwise: --enable-warn-error, --disable-warn-error]
92AC_ARG_ENABLE(warn_error,
93	      AS_HELP_STRING([--enable-warn-error],
94			    [turn on -Werror when compiling]))
95
96# [pairwise: --enable-developer, --disable-developer]
97AC_ARG_ENABLE(developer,
98	      AS_HELP_STRING([--enable-developer],
99			     [enable developer build settings]))
100XTARGETS=
101case "$enable_developer" in
102yes)
103	STD_CDEFINES="$STD_CDEFINES -DISC_LIST_CHECKINIT=1"
104	test "${enable_fixed_rrset+set}" = set || enable_fixed_rrset=yes
105	test "${enable_querytrace+set}" = set || enable_querytrace=yes
106	test "${enable_filter_aaaa+set}" = set || enable_filter_aaaa=yes
107	test "${with_cmocka+set}" = set || with_cmocka=yes
108	test "${with_dlz_filesystem+set}" = set || with_dlz_filesystem=yes
109	test "${enable_symtable+set}" = set || enable_symtable=all
110	test "${enable_warn_error+set}" = set || enable_warn_error=yes
111	test "${enable_warn_shadow+set}" = set || enable_warn_shadow=yes
112	test "${with_zlib+set}" = set || with_zlib=yes
113	XTARGETS='${XTARGETS}'
114	;;
115esac
116AC_SUBST(XTARGETS)
117
118# American Fuzzy Lop is not included in pairwise testing as fuzzing
119# tools are not present in the relevant Docker image.
120#
121# [pairwise: skip]
122AC_ARG_ENABLE(afl,
123	      AS_HELP_STRING([--enable-afl],
124			     [enable American Fuzzy Lop test harness
125				[default=no]]),
126	      [AC_DEFINE([ENABLE_AFL], [1],
127			 [Define to enable American Fuzzy Lop test harness])])
128case "$enable_afl" in
129yes)
130	LIBS="$LIBS -lpthread"
131	;;
132esac
133
134
135AC_CHECK_FUNCS(getrandom)
136
137# libseccomp sandboxing
138#
139# [pairwise: --enable-seccomp, --disable-seccomp]
140AC_ARG_ENABLE(seccomp,
141	      AS_HELP_STRING([--enable-seccomp],
142			     [enable support for libseccomp system call
143				 filtering [default=no]]))
144case "$enable_seccomp" in
145	yes)
146	case $host_os in
147	linux*)
148		;;
149	*)
150		AC_MSG_WARN([seccomp is not supported on non-linux platforms; disabling it])
151		enable_seccomp=no
152		;;
153	esac
154	AC_SEARCH_LIBS(seccomp_init, [seccomp])
155	if test "X$ac_cv_search_seccomp_init" = "X-lseccomp" ; then
156		AC_TRY_RUN([
157		#include <stdio.h>
158		#include <stdlib.h>
159		#include <errno.h>
160		#include <sys/prctl.h>
161		#include <linux/seccomp.h>
162
163		int main(void)
164		{
165			int ret;
166
167			ret = prctl(PR_GET_SECCOMP, 0, 0, 0, 0);
168			if (ret < 0) {
169				switch (errno) {
170				case ENOSYS:
171					return 1;
172				case EINVAL:
173					return 1;
174				default:
175					return 1;
176				}
177			}
178			ret =
179			prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0);
180			if (ret < 0) {
181				switch (errno) {
182				case EINVAL:
183					return 1;
184				case EFAULT:
185					return 0;
186				default:
187					return 1;
188			}
189		}
190	return 1;
191	}
192	]
193	, AC_DEFINE([HAVE_LIBSECCOMP], 1,
194	[Define to use libseccomp system call filtering.])
195	, []
196	)
197	fi
198		;;
199	*)
200		;;
201esac
202
203#
204# Make very sure that these are the first files processed by
205# config.status, since we use the processed output as the input for
206# AC_SUBST_FILE() substitutions in other files.
207#
208AC_CONFIG_FILES([make/rules make/includes])
209
210AC_PATH_PROG(AR, ar)
211ARFLAGS="cruv"
212AC_SUBST(AR)
213AC_SUBST(ARFLAGS)
214
215# The POSIX ln(1) program.  Non-POSIX systems may substitute
216# "copy" or something.
217LN=ln
218AC_SUBST(LN)
219
220case "$AR" in
221	"")
222		AC_MSG_ERROR([
223ar program not found.  Please fix your PATH to include the directory in
224which ar resides, or set AR in the environment with the full path to ar.
225])
226
227		;;
228esac
229
230#
231# Etags.
232#
233AC_PATH_PROGS(ETAGS, etags emacs-etags)
234
235#
236# Some systems, e.g. RH7, have the Exuberant Ctags etags instead of
237# GNU emacs etags, and it requires the -L flag.
238#
239if test "X$ETAGS" != "X"; then
240	AC_MSG_CHECKING(for Exuberant Ctags etags)
241	if $ETAGS --version 2>&1 | grep 'Exuberant Ctags' >/dev/null 2>&1; then
242		AC_MSG_RESULT(yes)
243		ETAGS="$ETAGS -L"
244	else
245		AC_MSG_RESULT(no)
246	fi
247fi
248AC_SUBST(ETAGS)
249
250#
251# Perl is optional; it is used only by some of the system test scripts.
252# Note: the backtrace feature (see below) uses perl to build the symbol table,
253# but it still compiles without perl, in which case an empty table will be used.
254#
255AC_PATH_PROGS(PERL, perl5 perl)
256AC_SUBST(PERL)
257
258#
259# Python is also optional but required by default so that dnssec-keymgr gets
260# installed unless explicitly prevented by the user using --without-python.
261#
262testminvers='import sys
263if (sys.version_info < (2,7)) or (sys.version_info < (3,2) and sys.version_info >= (3,0)):
264   exit(1)'
265
266testargparse='try: import argparse
267except: exit(1)'
268
269testply='try: import ply
270except: exit(1)'
271
272testsetup='try: from distutils.core import setup
273except: exit(1)'
274
275default_with_python="python python3 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python2 python2.7"
276
277AC_ARG_VAR([PYTHON], [path to python executable])
278
279# [pairwise: --with-python, --without-python]
280AC_ARG_WITH([python],
281	    AS_HELP_STRING([--with-python=PATH],
282			   [specify path to Python interpreter]),
283	    [], [with_python=$default_with_python])
284
285# [pairwise: skip]
286AC_ARG_WITH([python-install-dir],
287	    AS_HELP_STRING([--with-python-install-dir=PATH],
288			   [installation directory for Python modules]),
289	    [], with_python_install_dir="")
290
291AS_IF([test "$with_python" = "yes"],
292      [with_python=$default_with_python])
293
294AS_IF([test "$with_python" = "no"],
295      [AC_MSG_CHECKING([for Python support])
296       unset PYTHON
297       AC_MSG_RESULT([disabled])],
298      [for p in $with_python
299       do
300	 AS_CASE([$p],
301		 [/*],[PYTHON="$p"])
302
303	 AC_PATH_PROG([PYTHON], [$p])
304	 # Do not cache the result of the check from the previous line.  If the
305	 # first found Python interpreter has missing module dependencies and
306	 # the result of the above check is cached, subsequent module checks
307	 # will erroneously keep on using the cached path to the first found
308	 # Python interpreter instead of different ones.
309	 unset ac_cv_path_PYTHON
310
311	 AS_IF([test -z "$PYTHON"], [continue])
312
313	 AC_MSG_CHECKING([if $PYTHON is python2 version >= 2.7 or python3 version >= 3.2])
314	 AS_IF(["$PYTHON" -c "$testminvers" 2>/dev/null],
315	       [AC_MSG_RESULT([yes])],
316	       [AC_MSG_RESULT([no])
317		unset PYTHON
318		continue])
319
320	 AC_MSG_CHECKING([Python module 'argparse'])
321	 AS_IF(["$PYTHON" -c "$testargparse" 2>/dev/null],
322	       [AC_MSG_RESULT([yes])],
323	       [AC_MSG_RESULT([no])
324		unset PYTHON
325		continue])
326
327	 AC_MSG_CHECKING([Python module 'ply'])
328	 AS_IF(["$PYTHON" -c "$testply" 2>/dev/null],
329	       [AC_MSG_RESULT([yes])],
330	       [AC_MSG_RESULT([no])
331		unset PYTHON
332		continue])
333
334	 AC_MSG_CHECKING([Python module 'distutils.core setup'])
335	 AS_IF(["$PYTHON" -c "$testsetup" 2>/dev/null],
336	       [AC_MSG_RESULT([yes])],
337	       [AC_MSG_RESULT([no])
338		unset PYTHON
339		continue])
340
341	 # Stop looking any further once we find a Python interpreter
342	 # satisfying all requirements.
343	 break
344       done
345
346       AS_IF([test "X$PYTHON" = "X"],
347	     [AC_MSG_CHECKING([for Python support])
348	      AC_MSG_RESULT([no])
349	      AC_MSG_ERROR([m4_normalize(
350				[Python >= 2.7 or >= 3.2 and the PLY package
351                                 are required for dnssec-keymgr and other
352                                 Python-based tools. PLY may be
353                                 available from your OS package manager
354                                 as python-ply or python3-ply; it can also
355                                 be installed via pip. To build without
356                                 Python/PLY, use --without-python.]
357			    )])])])
358
359PYTHON_TOOLS=''
360CHECKDS=''
361COVERAGE=''
362KEYMGR=''
363AS_IF([test "X$PYTHON" != "X"],
364      [PYTHON_TOOLS=python
365       CHECKDS=checkds
366       COVERAGE=coverage
367       KEYMGR=keymgr
368       PYTHON_INSTALL_DIR="$with_python_install_dir"
369       AS_IF([test -n "$with_python_install_dir"],
370	     [PYTHON_INSTALL_LIB="--install-lib=$with_python_install_dir"])])
371AC_SUBST(CHECKDS)
372AC_SUBST(COVERAGE)
373AC_SUBST(KEYMGR)
374AC_SUBST(PYTHON_TOOLS)
375AC_SUBST(PYTHON_INSTALL_DIR)
376AC_SUBST(PYTHON_INSTALL_LIB)
377
378#
379# Special processing of paths depending on whether --prefix,
380# --sysconfdir or --localstatedir arguments were given.  What's
381# desired is some compatibility with the way previous versions
382# of BIND built; they defaulted to /usr/local for most parts of
383# the installation, but named.boot/named.conf was in /etc
384# and named.pid was in /var/run.
385#
386# So ... if none of --prefix, --sysconfdir or --localstatedir are
387# specified, set things up that way.  If --prefix is given, use
388# it for sysconfdir and localstatedir the way configure normally
389# would.  To change the prefix for everything but leave named.conf
390# in /etc or named.pid in /var/run, then do this the usual configure way:
391# ./configure --prefix=/somewhere --sysconfdir=/etc
392# ./configure --prefix=/somewhere --localstatedir=/var
393#
394# To put named.conf and named.pid in /usr/local with everything else,
395# set the prefix explicitly to /usr/local even though that's the default:
396# ./configure --prefix=/usr/local
397#
398case "$prefix" in
399	NONE)
400		case "$sysconfdir" in
401			'${prefix}/etc')
402				sysconfdir=/etc
403				;;
404		esac
405		case "$localstatedir" in
406			'${prefix}/var')
407				localstatedir=/var
408				;;
409		esac
410		;;
411esac
412expanded_sysconfdir=`eval echo $sysconfdir`
413AC_SUBST(expanded_sysconfdir)
414
415#
416# Make sure INSTALL uses an absolute path, else it will be wrong in all
417# Makefiles, since they use make/rules.in and INSTALL will be adjusted by
418# configure based on the location of the file where it is substituted.
419# Since in BIND9 INSTALL is only substituted into make/rules.in, an immediate
420# subdirectory of install-sh, This relative path will be wrong for all
421# directories more than one level down from install-sh.
422#
423case "$INSTALL" in
424	/*)
425		;;
426	*)
427		#
428		# Not all systems have dirname.
429		#
430		changequote({, })
431		ac_dir="`echo $INSTALL | sed 's%/[^/]*$%%'`"
432		changequote([, ])
433
434		ac_prog="`echo $INSTALL | sed 's%.*/%%'`"
435		test "X$ac_dir" = "X$ac_prog" && ac_dir=.
436		test -d "$ac_dir" && ac_dir="`(cd \"$ac_dir\" && pwd)`"
437		INSTALL="$ac_dir/$ac_prog"
438		;;
439esac
440
441AC_PROG_CC
442AC_PROG_CC_C99
443
444#
445# OS dependent CC flags
446#
447case "$host" in
448	# OSF 5.0: recv/send are only available with -D_POSIX_PII_SOCKET or
449	# -D_XOPEN_SOURCE_EXTENDED.
450	*-dec-osf*)
451		STD_CDEFINES="$STD_CDEFINES -D_POSIX_PII_SOCKET"
452		CPPFLAGS="$CPPFLAGS -D_POSIX_PII_SOCKET"
453		;;
454	#HP-UX: need -D_XOPEN_SOURCE_EXTENDED and -lxnet for CMSG macros
455	*-hp-hpux*)
456		STD_CDEFINES="$STD_CDEFINES -D_XOPEN_SOURCE_EXTENDED"
457		CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
458		LIBS="-lxnet $LIBS"
459		;;
460	# Solaris: need -D_XPG4_2 and -D__EXTENSIONS__ for CMSG macros
461	*-solaris*)
462		STD_CDEFINES="$STD_CDEFINES -D_XPG4_2 -D__EXTENSIONS__"
463		CPPFLAGS="$CPPFLAGS -D_XPG4_2 -D__EXTENSIONS__"
464		;;
465	# POSIX doesn't include the IPv6 Advanced Socket API and glibc hides
466	# parts of the IPv6 Advanced Socket API as a result.  This is stupid
467	# as it breaks how the two halves (Basic and Advanced) of the IPv6
468	# Socket API were designed to be used but we have to live with it.
469	# Define _GNU_SOURCE to pull in the IPv6 Advanced Socket API.
470	*-linux* | *-kfreebsd*-gnu*)
471		STD_CDEFINES="$STD_CDEFINES -D_GNU_SOURCE"
472		CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
473		;;
474	#
475	# Starting with OSX 10.7 (Lion) we must choose which IPv6 API to use.
476	# Setting this is sufficient to select the correct behavior for BIND 9.
477	#
478	*-darwin*)
479	  STD_CDEFINES="$STD_CDEFINES -D__APPLE_USE_RFC_3542"
480	  CPPFLAGS="$CPPFLAGS -D__APPLE_USE_RFC_3542"
481	  ;;
482esac
483
484#
485# CCNOOPT defaults to -O0 on gcc and disables optimization when is last
486#
487if test "X$CCNOOPT" = "X" -a "X$GCC" = "Xyes"; then
488	CCNOOPT="-O0"
489fi
490
491AC_HEADER_STDC
492
493AC_CHECK_HEADERS(fcntl.h regex.h sys/time.h unistd.h sys/mman.h sys/sockio.h sys/select.h sys/param.h sys/sysctl.h net/if6.h sys/socket.h net/route.h linux/netlink.h linux/rtnetlink.h,,,
494[$ac_includes_default
495#ifdef HAVE_SYS_PARAM_H
496# include <sys/param.h>
497#endif
498#ifdef HAVE_SYS_SOCKET_H
499# include <sys/socket.h>
500#endif
501])
502
503AC_C_CONST
504AC_C_INLINE
505AC_C_VOLATILE
506AC_CHECK_FUNC(sysctlbyname, AC_DEFINE(HAVE_SYSCTLBYNAME))
507AC_C_FLEXIBLE_ARRAY_MEMBER
508
509#
510# Check for the existence of mmap to enable the fast format zones
511#
512AC_CHECK_FUNCS(mmap)
513
514#
515# Older versions of HP/UX don't define seteuid() and setegid()
516#
517AC_CHECK_FUNCS(seteuid setresuid)
518AC_CHECK_FUNCS(setegid setresgid)
519
520# BSDI doesn't have ftello fseeko
521AC_CHECK_FUNCS(ftello fseeko)
522
523#
524# UnixWare 7.1.1 with the feature supplement to the UDK compiler
525# is reported to not support "static inline" (RT #1212).
526#
527AC_MSG_CHECKING(for static inline breakage)
528AC_TRY_COMPILE([
529	static inline int foo1() {
530		return 0;
531	}
532
533	static inline int foo2() {
534		return foo1();
535	}
536	], [foo1();],
537	[AC_MSG_RESULT(no)],
538	[AC_MSG_RESULT(yes)
539	 AC_DEFINE(inline, ,[Define to empty if your compiler does not support "static inline".])])
540
541AC_TYPE_SIZE_T
542AC_TYPE_SSIZE_T
543AC_TYPE_UINTPTR_T
544
545AC_CHECK_TYPE(socklen_t,
546[AC_DEFINE(ISC_SOCKADDR_LEN_T, socklen_t)],
547[
548AC_TRY_COMPILE(
549[
550#include <sys/types.h>
551#include <sys/socket.h>
552int getsockname(int, struct sockaddr *, size_t *);
553],[],
554[AC_DEFINE(ISC_SOCKADDR_LEN_T, size_t)],
555[AC_DEFINE(ISC_SOCKADDR_LEN_T, int)])
556],
557[
558#include <sys/types.h>
559#include <sys/socket.h>
560])
561AC_SUBST(ISC_SOCKADDR_LEN_T)
562AC_HEADER_TIME
563AC_MSG_CHECKING(for long long)
564AC_TRY_COMPILE([],[long long i = 0; return (0);],
565	[AC_MSG_RESULT(yes)
566		ISC_PLATFORM_HAVELONGLONG="#define ISC_PLATFORM_HAVELONGLONG 1"],
567	[AC_MSG_RESULT(no)
568		ISC_PLATFORM_HAVELONGLONG="#undef ISC_PLATFORM_HAVELONGLONG"])
569AC_SUBST(ISC_PLATFORM_HAVELONGLONG)
570
571#
572# check for uname library routine
573#
574AC_MSG_CHECKING(for uname)
575AC_TRY_COMPILE([
576#include <sys/utsname.h>
577#include <stdio.h>
578],
579[
580struct utsname uts;
581uname(&uts);
582printf("running on %s %s %s for %s\n",
583       uts.sysname, uts.release, uts.version, uts.machine);
584],
585	[AC_MSG_RESULT(yes)
586	 AC_DEFINE(HAVE_UNAME)],
587	[AC_MSG_RESULT(no)
588	 AC_MSG_WARN([uname is not correctly supported])])
589
590#
591# check for GCC noreturn attribute
592#
593AC_MSG_CHECKING(for GCC noreturn attribute)
594AC_TRY_COMPILE([],[void foo() __attribute__((noreturn));],
595	[AC_MSG_RESULT(yes)
596		ISC_PLATFORM_NORETURN_PRE="#define ISC_PLATFORM_NORETURN_PRE"
597		ISC_PLATFORM_NORETURN_POST="#define ISC_PLATFORM_NORETURN_POST __attribute__((noreturn))"],
598	[AC_MSG_RESULT(no)
599		ISC_PLATFORM_NORETURN_PRE="#define ISC_PLATFORM_NORETURN_PRE"
600		ISC_PLATFORM_NORETURN_POST="#define ISC_PLATFORM_NORETURN_POST"])
601AC_SUBST(ISC_PLATFORM_NORETURN_PRE)
602AC_SUBST(ISC_PLATFORM_NORETURN_POST)
603
604#
605# check if we have lifconf
606#
607AC_MSG_CHECKING(for struct lifconf)
608AC_TRY_COMPILE([
609#include <sys/types.h>
610#include <sys/socket.h>
611#include <net/if.h>
612],
613[
614struct lifconf lifconf;
615lifconf.lifc_len = 0;
616]
617,
618	[AC_MSG_RESULT(yes)
619		ISC_PLATFORM_HAVELIFCONF="#define ISC_PLATFORM_HAVELIFCONF 1"],
620	[AC_MSG_RESULT(no)
621		ISC_PLATFORM_HAVELIFCONF="#undef ISC_PLATFORM_HAVELIFCONF"])
622AC_SUBST(ISC_PLATFORM_HAVELIFCONF)
623
624#
625# check if we have kqueue
626#
627# [pairwise: --enable-kqueue, --disable-kqueue]
628AC_ARG_ENABLE(kqueue,
629	      AS_HELP_STRING([--enable-kqueue],
630			     [use BSD kqueue when available [default=yes]]),
631	      want_kqueue="$enableval",  want_kqueue="yes")
632case $want_kqueue in
633yes)
634	AC_CHECK_FUNC(kqueue, ac_cv_have_kqueue=yes, ac_cv_have_kqueue=no)
635	case $ac_cv_have_kqueue in
636	yes)
637		ISC_PLATFORM_HAVEKQUEUE="#define ISC_PLATFORM_HAVEKQUEUE 1"
638		;;
639	*)
640		ISC_PLATFORM_HAVEKQUEUE="#undef ISC_PLATFORM_HAVEKQUEUE"
641		;;
642	esac
643	;;
644*)
645	ISC_PLATFORM_HAVEKQUEUE="#undef ISC_PLATFORM_HAVEKQUEUE"
646	;;
647esac
648AC_SUBST(ISC_PLATFORM_HAVEKQUEUE)
649
650#
651# check if we have epoll.  Linux kernel 2.4 has epoll_create() which fails,
652# so we need to try running the code, not just test its existence.
653#
654# [pairwise: --enable-epoll, --disable-epoll]
655AC_ARG_ENABLE(epoll,
656	      AS_HELP_STRING([--enable-epoll],
657			     [use Linux epoll when available [default=auto]]),
658	      want_epoll="$enableval",  want_epoll="auto")
659case $want_epoll in
660auto)
661	AC_MSG_CHECKING(epoll support)
662	AC_TRY_RUN([
663#include <sys/epoll.h>
664int main() {
665	if (epoll_create(1) < 0)
666		return (1);
667	return (0);
668}
669],
670	[AC_MSG_RESULT(yes)
671	ISC_PLATFORM_HAVEEPOLL="#define ISC_PLATFORM_HAVEEPOLL 1"],
672	[AC_MSG_RESULT(no)
673	ISC_PLATFORM_HAVEEPOLL="#undef ISC_PLATFORM_HAVEEPOLL"],
674	[AC_MSG_RESULT(no)
675	ISC_PLATFORM_HAVEEPOLL="#undef ISC_PLATFORM_HAVEEPOLL"])
676	;;
677yes)
678	ISC_PLATFORM_HAVEEPOLL="#define ISC_PLATFORM_HAVEEPOLL 1"
679	;;
680*)
681	ISC_PLATFORM_HAVEEPOLL="#undef ISC_PLATFORM_HAVEEPOLL"
682	;;
683esac
684AC_SUBST(ISC_PLATFORM_HAVEEPOLL)
685
686#
687# check if we support /dev/poll
688#
689# [pairwise: --enable-devpoll, --disable-devpoll]
690AC_ARG_ENABLE(devpoll,
691	      AS_HELP_STRING([--enable-devpoll],
692			     [use /dev/poll when available [default=yes]]),
693	      want_devpoll="$enableval",  want_devpoll="yes")
694case $want_devpoll in
695yes)
696	AC_CHECK_HEADERS(sys/devpoll.h devpoll.h,
697	ISC_PLATFORM_HAVEDEVPOLL="#define ISC_PLATFORM_HAVEDEVPOLL 1"
698	,
699	ISC_PLATFORM_HAVEDEVPOLL="#undef ISC_PLATFORM_HAVEDEVPOLL"
700	)
701	;;
702*)
703	ISC_PLATFORM_HAVEDEVPOLL="#undef ISC_PLATFORM_HAVEDEVPOLL"
704	;;
705esac
706AC_SUBST(ISC_PLATFORM_HAVEDEVPOLL)
707
708#
709# check if we need to #include sys/select.h explicitly
710#
711case $ac_cv_header_unistd_h in
712yes)
713AC_MSG_CHECKING(if unistd.h or sys/types.h defines fd_set)
714AC_TRY_COMPILE([
715#include <sys/types.h> /* Ultrix */
716#include <unistd.h>],
717[fd_set read_set; return (0);],
718	[AC_MSG_RESULT(yes)
719	 ISC_PLATFORM_NEEDSYSSELECTH="#undef ISC_PLATFORM_NEEDSYSSELECTH"
720	 LWRES_PLATFORM_NEEDSYSSELECTH="#undef LWRES_PLATFORM_NEEDSYSSELECTH"],
721	[AC_MSG_RESULT(no)
722	case $ac_cv_header_sys_select_h in
723	yes)
724	 ISC_PLATFORM_NEEDSYSSELECTH="#define ISC_PLATFORM_NEEDSYSSELECTH 1"
725	 LWRES_PLATFORM_NEEDSYSSELECTH="#define LWRES_PLATFORM_NEEDSYSSELECTH 1"
726		;;
727	no)
728		AC_MSG_ERROR([need either working unistd.h or sys/select.h])
729		;;
730	esac
731	])
732	;;
733no)
734	case $ac_cv_header_sys_select_h in
735	yes)
736	     ISC_PLATFORM_NEEDSYSSELECTH="#define ISC_PLATFORM_NEEDSYSSELECTH 1"
737	     LWRES_PLATFORM_NEEDSYSSELECTH="#define LWRES_PLATFORM_NEEDSYSSELECTH 1"
738		;;
739	no)
740		AC_MSG_ERROR([need either unistd.h or sys/select.h])
741		;;
742	esac
743	;;
744esac
745AC_SUBST(ISC_PLATFORM_NEEDSYSSELECTH)
746AC_SUBST(LWRES_PLATFORM_NEEDSYSSELECTH)
747
748#
749# Find the machine's endian flavor.
750#
751AC_C_BIGENDIAN
752
753#
754# GeoIP support?
755#
756geoip2_default="no"
757
758# [pairwise: --with-geoip --without-geoip2, --without-geoip --with-geoip2=auto, --without-geoip --with-geoip2=yes, --without-geoip --without-geoip2]
759AC_ARG_WITH(geoip,
760	    AS_HELP_STRING([--with-geoip=PATH],
761			   [Build with legacy GeoIP support (yes|no|path)]),
762                           [
763                            use_geoip="$withval"
764                            geoip2_default="no"
765                           ],
766                           [use_geoip="no"])
767
768# [pairwise: skip]
769AC_ARG_WITH([geoip2],
770	    [AS_HELP_STRING([--with-geoip2=PATH],
771			    [Build with MaxMind GeoIP2 support (auto|yes|no|path) [default=no]])],
772	    [], with_geoip2="$geoip2_default")
773
774# specifying both --with-geoip and --with-geoip2 is an error.
775AS_IF([test "no" != "$with_geoip2" && test "no" != "$use_geoip"],
776      [AC_MSG_ERROR([--with-geoip and --with-geoip2 are incompatible])])
777
778GEOIP2LINKSRCS=
779GEOIP2LINKOBJS=
780AS_CASE([$with_geoip2],
781	[no],[],
782	[auto],[PKG_CHECK_MODULES([MAXMINDDB], [libmaxminddb],
783				      [AC_DEFINE([HAVE_GEOIP2], [1], [Build with GeoIP2 support])
784				       PKG_CHECK_VAR([MAXMINDDB_PREFIX], [libmaxminddb], [prefix], [], [AC_MSG_ERROR([libmaxminddb prefix not found in pkg-config; set MAXMINDDB_PREFIX in the environment])])
785				       GEOIP2LINKSRCS='${GEOIP2LINKSRCS}'
786				       GEOIP2LINKOBJS='${GEOIP2LINKOBJS}'
787				      ],[:])],
788	[yes],[PKG_CHECK_MODULES([MAXMINDDB], [libmaxminddb],
789				      [AC_DEFINE([HAVE_GEOIP2], [1], [Build with GeoIP2 support])
790				       PKG_CHECK_VAR([MAXMINDDB_PREFIX], [libmaxminddb], [prefix], [], [AC_MSG_ERROR([libmaxminddb prefix not found in pkg-config; set MAXMINDDB_PREFIX in the environment])])
791				       GEOIP2LINKSRCS='${GEOIP2LINKSRCS}'
792				       GEOIP2LINKOBJS='${GEOIP2LINKOBJS}'
793				      ])],
794	[ # default
795	    AX_SAVE_FLAGS([geoip2])
796	    MAXMINDDB_CFLAGS="-I$with_geoip2/include"
797	    MAXMINDDB_LIBS="-L$with_geoip2/lib"
798	    CFLAGS="$CFLAGS $MAXMINDDB_CFLAGS"
799	    LDFLAGS="$LDFLAGS $MAXMINDDB_LIBS"
800	    AC_SEARCH_LIBS([MMDB_open], [maxminddb],
801			   [AC_DEFINE([HAVE_GEOIP2], [1], [Build with GeoIP2 support])
802			    GEOIP2LINKSRCS='${GEOIP2LINKSRCS}'
803			    GEOIP2LINKOBJS='${GEOIP2LINKOBJS}'
804			    MAXMINDDB_LIBS="$MAXMINDDB_LIBS $ac_cv_search_MMDB_open"
805			    AC_MSG_NOTICE([GeoIP2 default database path set to $with_geoip2/share/GeoIP])
806			    AS_VAR_COPY([MAXMINDDB_PREFIX], [$with_geoip2])
807			   ],
808			   [AC_MSG_ERROR([GeoIP2 requested, but libmaxminddb not found])])
809	    AX_RESTORE_FLAGS([geoip2])
810	])
811AC_ARG_VAR([MAXMINDDB_PREFIX], [value of prefix for MAXMINDDB, overriding pkg-config])
812AC_SUBST([MAXMINDDB_CFLAGS])
813AC_SUBST([MAXMINDDB_LIBS])
814AC_SUBST([GEOIP2LINKSRCS])
815AC_SUBST([GEOIP2LINKOBJS])
816
817GEOIPLINKSRCS=
818GEOIPLINKOBJS=
819if test "yes" = "$use_geoip"
820then
821	for d in /usr /usr/local /opt/local
822	do
823		if test -f $d/include/GeoIP.h
824		then
825			use_geoip=$d
826			break
827		fi
828	done
829fi
830
831case "$use_geoip" in
832	no|'')
833		;;
834	*)
835		if test -d "$use_geoip" -o -L "$use_geoip"
836		then
837			CFLAGS="$CFLAGS -I$use_geoip/include"
838			CPPFLAGS="$CPPFLAGS -I$use_geoip/include"
839			LIBS="$LIBS -L$use_geoip/lib"
840			case "$host_os" in
841				netbsd*|openbsd*|solaris*)
842					LIBS="$LIBS -Wl,-rpath=$use_geoip/lib"
843					;;
844			esac
845		elif test "yes" = "$use_geoip"
846		then
847			AC_MSG_ERROR([GeoIP path not found])
848		else
849			AC_MSG_ERROR([GeoIP path $use_geoip does not exist])
850		fi
851		AC_CHECK_HEADER(GeoIP.h, [],
852			[AC_MSG_ERROR([GeoIP header file not found])]
853		)
854		AC_SEARCH_LIBS(GeoIP_id_by_addr_gl, GeoIP, [],
855			[AC_MSG_ERROR([suitable GeoIP library not found])]
856		)
857		AC_SEARCH_LIBS(fabsf, m, [],
858			[AC_MSG_ERROR([Math library not found])]
859		)
860		AC_DEFINE(HAVE_GEOIP, 1, Build with GeoIP support)
861		GEOIPLINKSRCS='${GEOIPLINKSRCS}'
862		GEOIPLINKOBJS='${GEOIPLINKOBJS}'
863		AC_MSG_CHECKING([for GeoIP support])
864		AC_MSG_RESULT([yes])
865
866		AC_MSG_CHECKING([for GeoIP Country IPv6 support])
867		AC_COMPILE_IFELSE(
868			[AC_LANG_PROGRAM([
869				#include <GeoIP.h>
870				#include <netinet/in.h>
871			], [
872				struct in6_addr in6;
873				GeoIP_country_name_by_ipnum_v6(NULL, in6);
874			])],
875			[
876				AC_MSG_RESULT([yes])
877				AC_DEFINE(HAVE_GEOIP_V6, 1, Build with GeoIP Country IPv6 support)
878			],
879			[AC_MSG_RESULT([no])]
880		)
881
882		AC_MSG_CHECKING([for GeoIP City IPv6 support])
883		AC_COMPILE_IFELSE(
884			[AC_LANG_PROGRAM([
885				#include <GeoIP.h>
886				#include <GeoIPCity.h>
887				#include <netinet/in.h>
888			], [
889				struct in6_addr in6;
890				int i = GEOIP_CITY_EDITION_REV0_V6;
891				GeoIP_record_by_ipnum_v6(NULL, in6);
892			])],
893			[
894				AC_MSG_RESULT([yes])
895				AC_DEFINE(HAVE_GEOIP_CITY_V6, 1, Build with GeoIP City IPv6 support)
896			],
897			[AC_MSG_RESULT([no])]
898		)
899		;;
900esac
901AC_SUBST(GEOIPLINKSRCS)
902AC_SUBST(GEOIPLINKOBJS)
903
904AC_MSG_CHECKING(for GSSAPI library)
905
906# [pairwise: --with-gssapi=yes, --with-gssapi=auto, --without-gssapi]
907AC_ARG_WITH(gssapi,
908	    AS_HELP_STRING([--with-gssapi=[PATH|[/path/]krb5-config]],
909			   [Specify path for system-supplied GSSAPI
910				[default=auto]]),
911	    use_gssapi="$withval", use_gssapi="auto")
912
913# first try using krb5-config, if that does not work then fall back to "yes" method.
914
915case "$use_gssapi" in
916*/krb5-config|krb5-config)
917    AC_MSG_RESULT(trying $use_gssapi)
918    if test krb5-config = "$use_gssapi"
919    then
920	AC_PATH_PROG(KRB5_CONFIG, $use_gssapi)
921    else
922	KRB5_CONFIG="$use_gssapi"
923    fi
924    gssapi_cflags=`$KRB5_CONFIG --cflags gssapi`
925    gssapi_libs=`$KRB5_CONFIG --libs gssapi`
926    krb5_cflags=`$KRB5_CONFIG --cflags krb5`
927    krb5_libs=`$KRB5_CONFIG --libs krb5`
928    saved_cppflags="$CPPFLAGS"
929    CPPFLAGS="$gssapi_cflags $krb5_cflags $CPPFLAGS"
930    AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h,
931	[ISC_PLATFORM_GSSAPIHEADER="#define ISC_PLATFORM_GSSAPIHEADER <$ac_header>"])
932    if test "" = "$ISC_PLATFORM_GSSAPIHEADER"; then
933	AC_MSG_RESULT([krb5-config: gssapi.h not found])
934	CPPFLAGS="$saved_cppflags"
935	use_gssapi="yes"
936    else
937	AC_CHECK_HEADERS(krb5/krb5.h krb5.h,
938	    [ISC_PLATFORM_KRB5HEADER="#define ISC_PLATFORM_KRB5HEADER <$ac_header>"])
939	if test "" = "$ISC_PLATFORM_KRB5HEADER"; then
940	    AC_MSG_RESULT([krb5-config: krb5.h not found])
941	    CPPFLAGS="$saved_cppflags"
942	    use_gssapi="yes"
943	else
944	    CPPFLAGS="$saved_cppflags"
945	    saved_libs="$LIBS"
946	    LIBS="$gssapi_libs $krb5_libs $LIBS"
947	    AC_MSG_CHECKING([krb5-config linking as $LIBS])
948	    AC_TRY_LINK( , [gss_acquire_cred();krb5_init_context()],
949		gssapi_linked=yes, gssapi_linked=no)
950	    case $gssapi_linked in
951		yes) AC_MSG_RESULT([krb5-config: linked]);;
952		no)  AC_MSG_RESULT([krb5-config: could not determine proper GSSAPI linkage])
953		    use_gssapi="yes"
954		    ;;
955	    esac
956	    LIBS=$saved_libs
957	fi
958    fi
959    if test "yes" = "$use_gssapi"; then
960	AC_MSG_CHECKING([for GSSAPI library, non krb5-config method])
961    fi
962    ;;
963esac
964
965case "$host" in
966*darwin*)
967	if test "yes" = "$use_gssapi" -o "auto" = "$use_gssapi"
968	then
969		use_gssapi=framework
970	fi
971	;;
972esac
973
974# gssapi is just the framework, we really require kerberos v5, so
975# look for those headers (the gssapi headers must be there, too)
976# The problem with this implementation is that it doesn't allow
977# for the specification of gssapi and krb5 headers in different locations,
978# which probably ought to be fixed although fixing might raise the issue of
979# trying to build with incompatible versions of gssapi and krb5.
980if test "yes" = "$use_gssapi" -o "auto" = "$use_gssapi"
981then
982	# first, deal with the obvious
983	if test \( -f /usr/include/kerberosv5/krb5.h -o \
984		   -f /usr/include/krb5/krb5.h -o \
985		   -f /usr/include/krb5.h \)   -a \
986		\( -f /usr/include/gssapi.h -o \
987		   -f /usr/include/gssapi/gssapi.h \)
988	then
989		use_gssapi=/usr
990	else
991	    krb5dirs="/usr/local /usr/local/krb5 /usr/local/kerberosv5 /usr/local/kerberos /usr/pkg /usr/krb5 /usr/kerberosv5 /usr/kerberos /usr"
992	    for d in $krb5dirs
993	    do
994		if test -f $d/include/gssapi/gssapi_krb5.h -o \
995			-f $d/include/krb5.h
996		then
997			if test -f $d/include/gssapi/gssapi.h -o \
998				-f $d/include/gssapi.h
999			then
1000				use_gssapi=$d
1001				break
1002			fi
1003		fi
1004	    done
1005	    if test "auto" = "$use_gssapi"
1006	    then
1007		use_gssapi="no"
1008	    fi
1009	fi
1010fi
1011
1012case "$use_gssapi" in
1013	no)
1014		AC_MSG_RESULT(disabled)
1015		USE_GSSAPI=''
1016		;;
1017	yes)
1018		AC_MSG_ERROR([--with-gssapi must specify a path])
1019		;;
1020	*/krb5-config|krb5-config)
1021		USE_GSSAPI='-DGSSAPI'
1022		DST_GSSAPI_INC="$gssapi_cflags $krb5_cflags"
1023		DNS_GSSAPI_LIBS="$gssapi_libs $krb5_libs"
1024		;;
1025	framework)
1026		USE_GSSAPI='-DGSSAPI'
1027		ISC_PLATFORM_GSSAPIHEADER="#define ISC_PLATFORM_GSSAPIHEADER <Kerberos/Kerberos.h>"
1028		ISC_PLATFORM_KRB5HEADER="#define ISC_PLATFORM_KRB5HEADER <Kerberos/Kerberos.h>"
1029		DNS_GSSAPI_LIBS="-framework Kerberos"
1030		AC_MSG_RESULT(framework)
1031		;;
1032
1033	*)
1034		AC_MSG_RESULT(looking in $use_gssapi/lib)
1035		USE_GSSAPI='-DGSSAPI'
1036		saved_cppflags="$CPPFLAGS"
1037		CPPFLAGS="-I$use_gssapi/include $CPPFLAGS"
1038		AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h,
1039		    [ISC_PLATFORM_GSSAPIHEADER="#define ISC_PLATFORM_GSSAPIHEADER <$ac_header>"
1040		     gssapi_hack="#include <$ac_header>"])
1041
1042		if test "" = "$ISC_PLATFORM_GSSAPIHEADER"; then
1043		    AC_MSG_ERROR([gssapi.h not found])
1044		fi
1045
1046		AC_CHECK_HEADERS(gssapi_krb5.h gssapi/gssapi_krb5.h,
1047		    [ISC_PLATFORM_GSSAPI_KRB5_HEADER="#define ISC_PLATFORM_GSSAPI_KRB5_HEADER <$ac_header>"
1048		     gssapi_krb5_hack="#include <$ac_header>"])
1049
1050		AC_CHECK_HEADERS(krb5.h krb5/krb5.h kerberosv5/krb5.h,
1051		    [ISC_PLATFORM_KRB5HEADER="#define ISC_PLATFORM_KRB5HEADER <$ac_header>"
1052		    krb5_hack="#include <$ac_header>"])
1053
1054		if test "" = "$ISC_PLATFORM_KRB5HEADER"; then
1055		    AC_MSG_ERROR([krb5.h not found])
1056		fi
1057
1058		#
1059		# XXXDCL This probably doesn't work right on all systems.
1060		# It will need to be worked on as problems become evident.
1061		#
1062		# Essentially the problems here relate to two different
1063		# areas.  The first area is building with either KTH
1064		# or MIT Kerberos, particularly when both are present on
1065		# the machine.  The other is static versus dynamic linking.
1066		#
1067		# On the KTH vs MIT issue, Both have libkrb5 that can mess
1068		# up the works if one implementation ends up trying to
1069		# use the other's krb.  This is unfortunately a situation
1070		# that very easily arises.
1071		#
1072		# Dynamic linking when the dependency information is built
1073		# into MIT's libgssapi_krb5 or KTH's libgssapi magically makes
1074		# all such problems go away, but when that setup is not
1075		# present, because either the dynamic libraries lack
1076		# dependencies or static linking is being done, then the
1077		# problems start to show up.
1078		saved_libs="$LIBS"
1079		for TRY_LIBS in \
1080		    "-lgssapi_krb5" \
1081		    "-lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err" \
1082		    "-lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lresolv" \
1083		    "-lgssapi" \
1084		    "-lgssapi -lkrb5 -ldes -lcrypt -lasn1 -lroken -lcom_err" \
1085		    "-lgssapi -lkrb5 -lcrypto -lcrypt -lasn1 -lroken -lcom_err" \
1086		    "-lgssapi -lkrb5 -lgssapi_krb5 -lcrypto -lcrypt -lasn1 -lroken -lcom_err" \
1087		    "-lgssapi -lkrb5 -lhx509 -lcrypto -lcrypt -lasn1 -lroken -lcom_err" \
1088		    "-lgss -lkrb5"
1089		do
1090		    # Note that this does not include $saved_libs, because
1091		    # on FreeBSD machines this configure script has added
1092		    # -L/usr/local/lib to LIBS, which can make the
1093		    # -lgssapi_krb5 test succeed with shared libraries even
1094		    # when you are trying to build with KTH in /usr/lib.
1095		    if test "/usr" = "$use_gssapi"
1096		    then
1097			    LIBS="$TRY_LIBS"
1098		    else
1099			    LIBS="-L$use_gssapi/lib $TRY_LIBS"
1100		    fi
1101		    AC_MSG_CHECKING(linking as $TRY_LIBS)
1102		    AC_TRY_LINK([
1103#include <sys/types.h>
1104$gssapi_hack
1105$gssapi_krb5_hack
1106$krb5_hack
1107				] , [gss_acquire_cred(NULL, NULL, 0, NULL, 0, NULL, NULL, NULL);krb5_init_context(NULL);
1108#if defined(HAVE_GSSAPI_KRB5_H) || defined(HAVE_GSSAPI_GSSAPI_KRB5_H)
1109gsskrb5_register_acceptor_identity(NULL);
1110#endif],
1111				gssapi_linked=yes, gssapi_linked=no)
1112		    case $gssapi_linked in
1113		    yes) AC_MSG_RESULT(yes); break ;;
1114		    no)  AC_MSG_RESULT(no) ;;
1115		    esac
1116		done
1117
1118		CPPFLAGS="$saved_cppflags"
1119
1120		case $gssapi_linked in
1121		no) AC_MSG_ERROR(could not determine proper GSSAPI linkage) ;;
1122		esac
1123
1124		#
1125		# XXXDCL Major kludge.  Tries to cope with KTH in /usr/lib
1126		# but MIT in /usr/local/lib and trying to build with KTH.
1127		# /usr/local/lib can end up earlier on the link lines.
1128		# Like most kludges, this one is not only inelegant it
1129		# is also likely to be the wrong thing to do at least as
1130		# many times as it is the right thing.  Something better
1131		# needs to be done.
1132		#
1133		if test "/usr" = "$use_gssapi" -a \
1134			-f /usr/local/lib/libkrb5.a; then
1135		    FIX_KTH_VS_MIT=yes
1136		fi
1137
1138		case "$FIX_KTH_VS_MIT" in
1139		yes)
1140		    case "$enable_static_linking" in
1141		    yes) gssapi_lib_suffix=".a"  ;;
1142		    *)   gssapi_lib_suffix=".so" ;;
1143		    esac
1144
1145		    for lib in $LIBS; do
1146			case $lib in
1147			-L*)
1148			    ;;
1149			-l*)
1150			    new_lib=`echo $lib |
1151				     sed -e s%^-l%$use_gssapi/lib/lib% \
1152					 -e s%$%$gssapi_lib_suffix%`
1153			    NEW_LIBS="$NEW_LIBS $new_lib"
1154			    ;;
1155			*)
1156			   AC_MSG_ERROR([KTH vs MIT Kerberos confusion!])
1157			    ;;
1158			esac
1159		    done
1160		    LIBS="$NEW_LIBS"
1161		    ;;
1162		esac
1163
1164		DST_GSSAPI_INC="-I$use_gssapi/include"
1165		DNS_GSSAPI_LIBS="$LIBS"
1166
1167		AC_MSG_RESULT(using GSSAPI from $use_gssapi/lib and $use_gssapi/include)
1168		LIBS="$saved_libs"
1169		;;
1170esac
1171
1172AC_SUBST(ISC_PLATFORM_HAVEGSSAPI)
1173AC_SUBST(ISC_PLATFORM_GSSAPIHEADER)
1174AC_SUBST(ISC_PLATFORM_GSSAPI_KRB5_HEADER)
1175AC_SUBST(ISC_PLATFORM_KRB5HEADER)
1176
1177AC_SUBST(USE_GSSAPI)
1178AC_SUBST(DST_GSSAPI_INC)
1179AC_SUBST(DNS_GSSAPI_LIBS)
1180DNS_CRYPTO_LIBS="$DNS_GSSAPI_LIBS $DNS_CRYPTO_LIBS"
1181
1182#
1183# Applications linking with libdns also need to link with these libraries.
1184#
1185
1186AC_SUBST(DNS_CRYPTO_LIBS)
1187
1188#
1189# was --with-randomdev specified?
1190#
1191AC_MSG_CHECKING(for random device)
1192
1193# [pairwise: skip]
1194AC_ARG_WITH(randomdev,
1195	    AS_HELP_STRING([--with-randomdev=PATH],
1196			   [Specify path for random device]),
1197	    use_randomdev="$withval", use_randomdev="unspec")
1198
1199case "$use_randomdev" in
1200	unspec)
1201		case "$cross_compiling" in
1202		yes)
1203			AC_MSG_RESULT(unspecified)
1204			AC_MSG_ERROR([ need --with-randomdev=PATH or --with-randomdev=no])
1205		esac
1206		case "$host" in
1207			*-openbsd*)
1208				devrandom=/dev/arandom
1209				;;
1210			*)
1211				devrandom=/dev/random
1212				;;
1213		esac
1214		AC_MSG_RESULT($devrandom)
1215		AC_CHECK_FILE($devrandom,
1216			      AC_DEFINE_UNQUOTED(PATH_RANDOMDEV,
1217						 "$devrandom"),)
1218
1219		;;
1220	yes)
1221		AC_MSG_ERROR([--with-randomdev must specify a path])
1222		;;
1223	no)
1224		AC_MSG_RESULT(disabled)
1225		;;
1226	*)
1227		AC_DEFINE_UNQUOTED(PATH_RANDOMDEV, "$use_randomdev")
1228		AC_MSG_RESULT(using "$use_randomdev")
1229		;;
1230esac
1231
1232#
1233# Only check dsa signature generation on these platforms when performing
1234# system tests.
1235#
1236CHECK_DSA=0
1237if grep "#define PATH_RANDOMDEV " confdefs.h > /dev/null
1238then
1239	case "$host" in
1240	*darwin*|*freebsd*)
1241		CHECK_DSA=1
1242		;;
1243	esac
1244fi
1245AC_SUBST(CHECK_DSA)
1246
1247#
1248# Do we have arc4random(), etc ?
1249# Will use stir and if not exist addrandom
1250#
1251AC_CHECK_FUNCS(arc4random)
1252AC_CHECK_FUNCS(arc4random_stir)
1253AC_CHECK_FUNCS(arc4random_addrandom)
1254
1255sinclude(config.threads.in)dnl
1256
1257if $use_threads
1258then
1259	if test "X$GCC" = "Xyes"; then
1260		case "$host" in
1261		*-freebsd*)
1262			CC="$CC -pthread"
1263			CCOPT="$CCOPT -pthread"
1264			CCNOOPT="$CCNOOPT -pthread"
1265			STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
1266			;;
1267		*-openbsd*)
1268			CC="$CC -pthread"
1269			CCOPT="$CCOPT -pthread"
1270			CCNOOPT="$CCNOOPT -pthread"
1271			;;
1272		*-solaris*)
1273			LIBS="$LIBS -lthread"
1274			;;
1275		*-ibm-aix*)
1276			STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
1277			;;
1278		esac
1279	else
1280		case $host in
1281		*-dec-osf*)
1282			CC="$CC -pthread"
1283			CCOPT="$CCOPT -pthread"
1284			CCNOOPT="$CCNOOPT -pthread"
1285			;;
1286		*-solaris*)
1287			CC="$CC"
1288			CCOPT="$CCOPT -mt"
1289			CCNOOPT="$CCNOOPT -mt"
1290			;;
1291		*-ibm-aix*)
1292			STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
1293			;;
1294		*-sco-sysv*uw*|*-*-sysv*UnixWare*)
1295			CC="$CC -Kthread"
1296			CCOPT="$CCOPT -Kthread"
1297			CCNOOPT="$CCNOOPT -Kthread"
1298			;;
1299		*-*-sysv*OpenUNIX*)
1300			CC="$CC -Kpthread"
1301			CCOPT="$CCOPT -Kpthread"
1302			CCNOOPT="$CCNOOPT -Kpthread"
1303			;;
1304		esac
1305	fi
1306	ALWAYS_DEFINES="-D_REENTRANT"
1307	ISC_PLATFORM_USETHREADS="#define ISC_PLATFORM_USETHREADS 1"
1308	THREADOPTOBJS='${THREADOPTOBJS}'
1309	THREADOPTSRCS='${THREADOPTSRCS}'
1310	thread_dir=pthreads
1311	#
1312	# We'd like to use sigwait() too
1313	#
1314	AC_CHECK_FUNC(sigwait,
1315		      AC_DEFINE(HAVE_SIGWAIT),
1316		      AC_CHECK_LIB(c, sigwait,
1317		      AC_DEFINE(HAVE_SIGWAIT),
1318		      AC_CHECK_LIB(pthread, sigwait,
1319				   AC_DEFINE(HAVE_SIGWAIT),
1320				   AC_CHECK_LIB(pthread, _Psigwait,
1321						AC_DEFINE(HAVE_SIGWAIT),))))
1322
1323	AC_CHECK_FUNC(pthread_attr_getstacksize,
1324		      AC_DEFINE(HAVE_PTHREAD_ATTR_GETSTACKSIZE),)
1325
1326	AC_CHECK_FUNC(pthread_attr_setstacksize,
1327		      AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACKSIZE),)
1328
1329	# [pairwise: --with-locktype=adaptive, --with-locktype=standard]
1330	AC_ARG_WITH(locktype,
1331		    AS_HELP_STRING([--with-locktype=ARG],
1332				   [Specify mutex lock type
1333					(adaptive or standard)]),
1334		    locktype="$withval", locktype="adaptive")
1335
1336	case "$locktype" in
1337		adaptive)
1338			AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1339
1340			AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1341			  #ifndef _GNU_SOURCE
1342			  #define _GNU_SOURCE
1343			  #endif
1344			  #include <pthread.h>
1345			]], [[
1346			  return (PTHREAD_MUTEX_ADAPTIVE_NP);
1347			]])],
1348			[ AC_MSG_RESULT(using adaptive lock type)
1349			  AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1350				    [Support for PTHREAD_MUTEX_ADAPTIVE_NP]) ],
1351			[ AC_MSG_RESULT(using standard lock type) ])
1352			;;
1353		standard)
1354			AC_MSG_RESULT(using standard lock type)
1355			;;
1356		*)
1357			AC_MSG_ERROR([You must specify "adaptive" or "standard" for --with-locktype.])
1358			;;
1359	esac
1360
1361	AC_CHECK_HEADERS(sched.h)
1362
1363	case "$host" in
1364	*solaris-*)
1365		AC_CHECK_LIB(rt, sched_yield)
1366		;;
1367	esac
1368
1369	AC_CHECK_FUNCS(sched_yield pthread_yield pthread_yield_np)
1370
1371	#
1372	# Additional OS-specific issues related to pthreads and sigwait.
1373	#
1374	case "$host" in
1375		#
1376		# One more place to look for sigwait.
1377		#
1378		*-freebsd*)
1379			AC_CHECK_LIB(c_r, sigwait, AC_DEFINE(HAVE_SIGWAIT),)
1380			case $host in
1381			*-freebsd5.[[012]]|*-freebsd5.[[012]].*);;
1382			*-freebsd5.[[3456789]]|*-freebsd5.[[3456789]].*)
1383				AC_DEFINE(NEED_PTHREAD_SCOPE_SYSTEM)
1384				;;
1385			*-freebsd6.*)
1386				AC_DEFINE(NEED_PTHREAD_SCOPE_SYSTEM)
1387				;;
1388			esac
1389			;;
1390		#
1391		# BSDI 3.0 through 4.0.1 needs pthread_init() to be
1392		# called before certain pthreads calls.	 This is deprecated
1393		# in BSD/OS 4.1.
1394		#
1395		*-bsdi3.*|*-bsdi4.0*)
1396			AC_DEFINE(NEED_PTHREAD_INIT)
1397			;;
1398		#
1399		# LinuxThreads requires some changes to the way we
1400		# deal with signals.
1401		#
1402		*-linux*)
1403			AC_DEFINE(HAVE_LINUXTHREADS)
1404			;;
1405		#
1406		# Ensure the right sigwait() semantics on Solaris and make
1407		# sure we call pthread_setconcurrency.
1408		#
1409		*-solaris*)
1410			AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
1411			AC_CHECK_FUNC(pthread_setconcurrency,
1412				      AC_DEFINE(CALL_PTHREAD_SETCONCURRENCY))
1413			;;
1414		#
1415		# UnixWare does things its own way.
1416		#
1417		*-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
1418			AC_DEFINE(HAVE_UNIXWARE_SIGWAIT)
1419			;;
1420	esac
1421
1422	# Look for functions relating to thread naming
1423	AC_CHECK_FUNCS(pthread_setname_np pthread_set_name_np)
1424	AC_CHECK_HEADERS([pthread_np.h], [], [], [#include <pthread.h>])
1425
1426	#
1427	# Look for sysconf to allow detection of the number of processors.
1428	#
1429	AC_CHECK_FUNC(sysconf, AC_DEFINE(HAVE_SYSCONF),)
1430
1431else
1432	ISC_PLATFORM_USETHREADS="#undef ISC_PLATFORM_USETHREADS"
1433	thread_dir=nothreads
1434	THREADOPTOBJS=""
1435	THREADOPTSRCS=""
1436	ALWAYS_DEFINES=""
1437fi
1438
1439AC_SUBST(ALWAYS_DEFINES)
1440AC_SUBST(ISC_PLATFORM_USETHREADS)
1441AC_SUBST(THREADOPTOBJS)
1442AC_SUBST(THREADOPTSRCS)
1443ISC_THREAD_DIR=$thread_dir
1444AC_SUBST(ISC_THREAD_DIR)
1445
1446AC_MSG_CHECKING(for libtool)
1447
1448# [pairwise: --with-libtool, --without-libtool]
1449AC_ARG_WITH(libtool, AS_HELP_STRING([--with-libtool], [use GNU libtool]),
1450	    use_libtool="$withval", use_libtool="no")
1451
1452case $use_libtool in
1453	yes)
1454		AC_MSG_RESULT(yes)
1455		AM_PROG_LIBTOOL
1456		O=lo
1457		A=la
1458		LIBTOOL_MKDEP_SED='s;\.o;\.lo;'
1459		LIBTOOL_MODE_COMPILE='--mode=compile --tag=CC'
1460		LIBTOOL_MODE_INSTALL='--mode=install --tag=CC'
1461		LIBTOOL_MODE_LINK='--mode=link --tag=CC'
1462		LIBTOOL_MODE_UNINSTALL='--mode=uninstall --tag=CC'
1463		INSTALL_LIBRARY='${INSTALL_PROGRAM}'
1464		case "$host" in
1465		*) LIBTOOL_ALLOW_UNDEFINED= ;;
1466		esac
1467		case "$host" in
1468		*-ibm-aix*) LIBTOOL_IN_MAIN="-Wl,-bI:T_testlist.imp" ;;
1469		*) LIBTOOL_IN_MAIN= ;;
1470		esac;
1471		;;
1472	*)
1473		AC_MSG_RESULT(no)
1474		O=o
1475		A=a
1476		LIBTOOL=
1477		AC_SUBST(LIBTOOL)
1478		LIBTOOL_MKDEP_SED=
1479		LIBTOOL_MODE_COMPILE=
1480		LIBTOOL_MODE_INSTALL=
1481		LIBTOOL_MODE_LINK=
1482		LIBTOOL_MODE_UNINSTALL=
1483		LIBTOOL_ALLOW_UNDEFINED=
1484		LIBTOOL_IN_MAIN=
1485		INSTALL_LIBRARY='${INSTALL_DATA}'
1486		;;
1487esac
1488AC_SUBST(INSTALL_LIBRARY)
1489
1490#
1491# was --enable-native-pkcs11 specified?
1492#  (note it implies both --without-openssl and --with-pkcs11)
1493#
1494# [pairwise: --enable-native-pkcs11 --with-dlopen, --disable-native-pkcs11 --with-dlopen, --disable-native-pkcs11 --without-dlopen]
1495AC_ARG_ENABLE(native-pkcs11,
1496	      AS_HELP_STRING([--enable-native-pkcs11],
1497			     [use native PKCS11 for all crypto [default=no]]),
1498	      want_native_pkcs11="$enableval", want_native_pkcs11="no")
1499
1500#
1501# was --with-openssl specified?
1502#
1503# "--enable-openssl-hash" is on purpose not being tested because it fails
1504# linking when either of --with-ecdsa, --with-gost, --with-eddsa, or --with-aes
1505# is used as well because it can't find f.e. HMAC_CTX_new() as "-lcrypto" is
1506# missing.
1507#
1508# [pairwise: --with-openssl, --with-openssl --disable-openssl-hash, --without-openssl]
1509AC_ARG_WITH(openssl,
1510	    AS_HELP_STRING([--with-openssl[=PATH]],
1511			   [Build with OpenSSL [yes|no|path].
1512				(Crypto is required for DNSSEC)]),
1513	    use_openssl="$withval", use_openssl="auto")
1514
1515#
1516# was --with-pkcs11 specified?
1517#
1518# [pairwise: skip]
1519AC_ARG_WITH(pkcs11,
1520	    AS_HELP_STRING([--with-pkcs11[=PATH]],
1521			   [Build with PKCS11 support [yes|no|path]
1522				(PATH is for the PKCS11 provider)]),
1523	    use_pkcs11="$withval", use_pkcs11="auto")
1524
1525#
1526# were --with-ecdsa, --with-gost, --with-eddsa, --with-aes specified
1527#
1528
1529# [pairwise: --with-ecdsa, --without-ecdsa]
1530AC_ARG_WITH(ecdsa, AS_HELP_STRING([--with-ecdsa], [Crypto ECDSA]),
1531	    with_ecdsa="$withval", with_ecdsa="auto")
1532
1533# GOST is not included in pairwise testing as it is not supported by the
1534# OpenSSL version present in the relevant Docker image.
1535#
1536# [pairwise: skip]
1537AC_ARG_WITH(gost,
1538	    AS_HELP_STRING([--with-gost], [Crypto GOST [yes|no|raw|asn1].]),
1539	    with_gost="$withval", with_gost="auto")
1540
1541# EdDSA is not included in pairwise testing as it is not supported by
1542# the SoftHSM version present in the relevant Docker image.
1543#
1544# [pairwise: skip]
1545AC_ARG_WITH(eddsa, AS_HELP_STRING([--with-eddsa], [Crypto EDDSA [yes|all|no].]),
1546	    with_eddsa="$withval", with_eddsa="auto")
1547
1548# [pairwise: --with-aes, --without-aes]
1549AC_ARG_WITH(aes, AS_HELP_STRING([--with-aes], [Crypto AES]),
1550	    with_aes="$withval", with_aes="yes")
1551
1552#
1553# was --enable-openssl-hash specified?
1554#
1555# "--enable-openssl-hash" is not being tested, see the reasoning in
1556# "--with-openssl" pairwise section.
1557#
1558# [pairwise: skip]
1559AC_ARG_ENABLE(openssl-hash,
1560	      AS_HELP_STRING([--enable-openssl-hash],
1561			     [use OpenSSL for hash functions [default=no]]),
1562	      want_openssl_hash="$enableval", want_openssl_hash="checkcc")
1563
1564AC_MSG_CHECKING(for OpenSSL library)
1565OPENSSL_WARNING=
1566openssldirs="/usr /usr/local /usr/local/ssl /opt/local /usr/pkg /usr/sfw"
1567if test "yes" = "$want_native_pkcs11"
1568then
1569	use_openssl="native_pkcs11"
1570	want_openssl_hash="no"
1571	AC_MSG_RESULT(use of native PKCS11 instead)
1572fi
1573
1574if test "auto" = "$use_openssl"
1575then
1576	for d in $openssldirs
1577	do
1578		if test -f $d/include/openssl/opensslv.h
1579		then
1580			use_openssl=$d
1581			break
1582		fi
1583	done
1584fi
1585OPENSSL_ECDSA=""
1586OPENSSL_GOST=""
1587OPENSSL_ED25519=""
1588gosttype="raw"
1589case "$with_gost" in
1590	raw)
1591		with_gost="yes"
1592		;;
1593	asn1)
1594		AC_DEFINE(PREFER_GOSTASN1, 1,
1595			  [Define if GOST private keys are encoded in ASN.1.])
1596		gosttype="asn1"
1597		with_gost="yes"
1598		;;
1599	auto|yes|no)
1600		;;
1601	*)
1602		AC_MSG_ERROR(unknown GOST private key encoding)
1603		;;
1604esac
1605
1606case "$use_openssl" in
1607	native_pkcs11)
1608		AC_MSG_RESULT(disabled because of native PKCS11)
1609		DST_OPENSSL_INC=""
1610		CRYPTO="-DPKCS11CRYPTO"
1611		OPENSSLECDSALINKOBJS=""
1612		OPENSSLECDSALINKSRCS=""
1613		OPENSSLEDDSALINKOBJS=""
1614		OPENSSLEDDSALINKSRCS=""
1615		OPENSSLGOSTLINKOBJS=""
1616		OPENSSLGOSTLINKSRCS=""
1617		OPENSSLLINKOBJS=""
1618		OPENSSLLINKSRCS=""
1619		;;
1620	no)
1621		AC_MSG_RESULT(no)
1622		DST_OPENSSL_INC=""
1623		CRYPTO=""
1624		OPENSSLECDSALINKOBJS=""
1625		OPENSSLECDSALINKSRCS=""
1626		OPENSSLEDDSALINKOBJS=""
1627		OPENSSLEDDSALINKSRCS=""
1628		OPENSSLGOSTLINKOBJS=""
1629		OPENSSLGOSTLINKSRCS=""
1630		OPENSSLLINKOBJS=""
1631		OPENSSLLINKSRCS=""
1632		;;
1633	auto)
1634		DST_OPENSSL_INC=""
1635		CRYPTO=""
1636		OPENSSLECDSALINKOBJS=""
1637		OPENSSLECDSALINKSRCS=""
1638		OPENSSLEDDSALINKOBJS=""
1639		OPENSSLEDDSALINKSRCS=""
1640		OPENSSLGOSTLINKOBJS=""
1641		OPENSSLGOSTLINKSRCS=""
1642		OPENSSLLINKOBJS=""
1643		OPENSSLLINKSRCS=""
1644		AC_MSG_ERROR(
1645[OpenSSL was not found in any of $openssldirs; use --with-openssl=/path
1646If you don't want OpenSSL, use --without-openssl])
1647		;;
1648	*)
1649		if test "yes" = "$want_native_pkcs11"
1650		then
1651			AC_MSG_RESULT()
1652			AC_MSG_ERROR([OpenSSL and native PKCS11 cannot be used together.])
1653		fi
1654		if test "yes" = "$use_openssl"
1655		then
1656			# User did not specify a path - guess it
1657			for d in $openssldirs
1658			do
1659				if test -f $d/include/openssl/opensslv.h
1660				then
1661					use_openssl=$d
1662					break
1663				fi
1664			done
1665			if test "yes" = "$use_openssl"
1666			then
1667				AC_MSG_RESULT(not found)
1668				AC_MSG_ERROR(
1669[OpenSSL was not found in any of $openssldirs; use --with-openssl=/path])
1670			fi
1671		elif ! test -f "$use_openssl"/include/openssl/opensslv.h
1672		then
1673			AC_MSG_ERROR(["$use_openssl/include/openssl/opensslv.h" not found])
1674		fi
1675		CRYPTO='-DOPENSSL'
1676		if test "/usr" = "$use_openssl"
1677		then
1678			DST_OPENSSL_INC=""
1679			DST_OPENSSL_LIBS="-lcrypto"
1680		else
1681			DST_OPENSSL_INC="-I$use_openssl/include"
1682			case $host in
1683			*-solaris*)
1684				DST_OPENSSL_LIBS="-L$use_openssl/lib -R$use_openssl/lib -lcrypto"
1685				;;
1686			*-hp-hpux*)
1687				DST_OPENSSL_LIBS="-L$use_openssl/lib -Wl,+b: -lcrypto"
1688				;;
1689			*-apple-darwin*)
1690				#
1691				# Apple's ld seaches for serially for dynamic
1692				# then static libraries.  This means you can't
1693				# use -L to override dynamic system libraries
1694				# with static ones when linking.  Instead
1695				# we specify a absolute path.
1696				#
1697				if test -f "$use_openssl/lib/libcrypto.dylib"
1698				then
1699					DST_OPENSSL_LIBS="-L$use_openssl/lib -lcrypto"
1700				else
1701					DST_OPENSSL_LIBS="$use_openssl/lib/libcrypto.a"
1702				fi
1703				;;
1704			*)
1705				DST_OPENSSL_LIBS="-L$use_openssl/lib -lcrypto"
1706				;;
1707			esac
1708		fi
1709		AC_MSG_RESULT(using OpenSSL from $use_openssl/lib and $use_openssl/include)
1710
1711		saved_cc="$CC"
1712		saved_cflags="$CFLAGS"
1713		saved_libs="$LIBS"
1714		CFLAGS="$DST_OPENSSL_INC $CFLAGS"
1715		LIBS="$DST_OPENSSL_LIBS $LIBS"
1716		AC_MSG_CHECKING(whether linking with OpenSSL works)
1717		AC_TRY_RUN([
1718#include <openssl/err.h>
1719int main() {
1720	ERR_clear_error();
1721	return (0);
1722}
1723],
1724		[AC_MSG_RESULT(yes)],
1725		[AC_MSG_RESULT(no)
1726		 AC_MSG_ERROR(Could not run test program using OpenSSL from
1727$use_openssl/lib and $use_openssl/include.
1728Please check the argument to --with-openssl and your
1729shared library configuration (e.g., LD_LIBRARY_PATH).)],
1730		[AC_MSG_RESULT(assuming it does work on target platform)])
1731
1732		AC_MSG_CHECKING(whether linking with OpenSSL requires -ldl)
1733		AC_TRY_LINK([
1734#include <openssl/opensslv.h>
1735#if !defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x10100004L)
1736#include <openssl/crypto.h>
1737#else
1738#include <openssl/err.h>
1739#include <openssl/dso.h>
1740#endif
1741],
1742[
1743#if !defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x10100004L)
1744OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL);
1745#else
1746DSO_METHOD_dlfcn();
1747#endif
1748],
1749		[AC_MSG_RESULT(no)],
1750		[LIBS="$LIBS -ldl"
1751		AC_TRY_LINK([
1752#if !defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x10100004L)
1753#include <openssl/crypto.h>
1754#else
1755#include <openssl/err.h>
1756#include <openssl/dso.h>
1757#endif
1758],
1759[
1760#if !defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x10100004L)
1761OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_ALL_BUILTIN, NULL);
1762#else
1763DSO_METHOD_dlfcn();
1764#endif
1765],
1766		[AC_MSG_RESULT(yes)
1767		DST_OPENSSL_LIBS="$DST_OPENSSL_LIBS -ldl"
1768		],
1769		 [AC_MSG_RESULT(unknown)
1770		 AC_MSG_ERROR(OpenSSL has unsupported dynamic loading)],
1771		[AC_MSG_RESULT(assuming it does work on target platform)])
1772		],
1773		[AC_MSG_RESULT(assuming it does work on target platform)]
1774		)
1775
1776	AC_MSG_CHECKING(for OpenSSL FIPS mode support)
1777	have_fips_mode=""
1778	AC_TRY_LINK([#include <openssl/crypto.h>],
1779		    [FIPS_mode();],
1780		    have_fips_mode=yes,
1781		    have_fips_mode=no)
1782	if test "x$have_fips_mode" = "xyes"
1783	then
1784		AC_DEFINE([HAVE_FIPS_MODE], [1],
1785			  [Define if OpenSSL provides FIPS_mode()])
1786		AC_MSG_RESULT(yes)
1787	else
1788		AC_MSG_RESULT(no)
1789	fi
1790
1791	AC_MSG_CHECKING(for OpenSSL DSA support)
1792	if test -f $use_openssl/include/openssl/dsa.h
1793	then
1794		AC_DEFINE(HAVE_OPENSSL_DSA)
1795		AC_MSG_RESULT(yes)
1796	else
1797		AC_MSG_RESULT(no)
1798	fi
1799
1800	AC_CHECK_FUNCS(EVP_sha256 EVP_sha384 EVP_sha512)
1801
1802	AC_CHECK_FUNCS([DH_get0_key ECDSA_SIG_get0 RSA_set0_key DSA_get0_pqg])
1803
1804	AC_MSG_CHECKING(for OpenSSL ECDSA support)
1805	have_ecdsa=""
1806	AC_TRY_RUN([
1807#include <openssl/ecdsa.h>
1808#include <openssl/objects.h>
1809int main() {
1810	EC_KEY *ec256, *ec384;
1811
1812#if !defined(HAVE_EVP_SHA256) || !defined(HAVE_EVP_SHA384)
1813	return (1);
1814#endif
1815	ec256 = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
1816	ec384 = EC_KEY_new_by_curve_name(NID_secp384r1);
1817	if (ec256 == NULL || ec384 == NULL)
1818		return (2);
1819	if (ec256 != NULL)
1820		EC_KEY_free(ec256);
1821	if (ec384 != NULL)
1822		EC_KEY_free(ec384);
1823	return (0);
1824}
1825],
1826	[AC_MSG_RESULT(yes)
1827	have_ecdsa="yes"],
1828	[AC_MSG_RESULT(no)
1829	have_ecdsa="no"],
1830	[AC_MSG_RESULT(using --with-ecdsa)])
1831	case "$with_ecdsa" in
1832	yes)
1833	    case "$have_ecdsa" in
1834	    no)  AC_MSG_ERROR([ecdsa not supported]) ;;
1835	    *)  have_ecdsa=yes ;;
1836	    esac
1837	    ;;
1838	no)
1839	    have_ecdsa=no ;;
1840	*)
1841	    case "$have_ecdsa" in
1842	    yes|no) ;;
1843	    *) AC_MSG_ERROR([need --with-ecdsa=[[yes or no]]]) ;;
1844	    esac
1845	    ;;
1846	esac
1847	case $have_ecdsa in
1848	yes)
1849		OPENSSL_ECDSA="yes"
1850		OPENSSLECDSALINKOBJS='${OPENSSLECDSALINKOBJS}'
1851		OPENSSLECDSALINKSRCS='${OPENSSLECDSALINKSRCS}'
1852		AC_DEFINE(HAVE_OPENSSL_ECDSA, 1,
1853			  [Define if your OpenSSL version supports ECDSA.])
1854		;;
1855	*)
1856		;;
1857	esac
1858
1859	AC_MSG_CHECKING(for OpenSSL GOST support)
1860	have_gost=""
1861	case "$use_pkcs11" in
1862		auto|no)
1863			;;
1864		*)
1865			if $use_threads; then
1866				CC="$CC -pthread"
1867			fi
1868			;;
1869	esac
1870	AC_TRY_RUN([
1871#include <openssl/conf.h>
1872#include <openssl/engine.h>
1873int main() {
1874#if !defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x10000000L)
1875	ENGINE *e;
1876	EC_KEY *ek;
1877
1878	ek = NULL;
1879	OPENSSL_config(NULL);
1880
1881	e = ENGINE_by_id("gost");
1882	if (e == NULL)
1883		return (1);
1884	if (ENGINE_init(e) <= 0)
1885		return (1);
1886	return (0);
1887#else
1888	return (1);
1889#endif
1890}
1891],
1892	[AC_MSG_RESULT(yes)
1893	have_gost="yes"],
1894	[AC_MSG_RESULT(no)
1895	have_gost="no"],
1896	[AC_MSG_RESULT(using --with-gost)])
1897	case "$with_gost" in
1898	yes)
1899	    case "$have_gost" in
1900	    no)  AC_MSG_ERROR([gost not supported]) ;;
1901	    *)  have_gost=yes ;;
1902	    esac
1903	    ;;
1904	no)
1905	    have_gost=no ;;
1906	*)
1907	    case "$have_gost" in
1908	    yes|no) ;;
1909	    *) AC_MSG_ERROR([need --with-gost=[[yes, no, raw or asn1]]]) ;;
1910	    esac
1911	    ;;
1912	esac
1913	case $have_gost in
1914	yes)
1915		OPENSSL_GOST="yes"
1916		OPENSSLGOSTLINKOBJS='${OPENSSLGOSTLINKOBJS}'
1917		OPENSSLGOSTLINKSRCS='${OPENSSLGOSTLINKSRCS}'
1918		AC_DEFINE(HAVE_OPENSSL_GOST, 1,
1919			  [Define if your OpenSSL version supports GOST.])
1920		;;
1921	*)
1922		;;
1923	esac
1924
1925	AC_MSG_CHECKING(for OpenSSL Ed25519 support)
1926	have_ed25519=""
1927	have_ed448=""
1928	AC_TRY_RUN([
1929#include <openssl/evp.h>
1930#include <openssl/objects.h>
1931int main() {
1932	EVP_PKEY_CTX *ctx;
1933
1934	ctx = EVP_PKEY_CTX_new_id(NID_ED25519, NULL);
1935	if (ctx == NULL) {
1936		return (2);
1937	}
1938	EVP_PKEY_CTX_free(ctx);
1939	return (0);
1940}
1941],
1942	[AC_MSG_RESULT(yes)
1943	have_ed25519="yes"],
1944	[AC_MSG_RESULT(no)
1945	have_ed25519="no"],
1946	[AC_MSG_RESULT(using --with-eddsa)])
1947	case "$with_eddsa" in
1948	yes|all)
1949	    case "$have_ed25519" in
1950	    no)  AC_MSG_ERROR([eddsa not supported]) ;;
1951	    *)  have_ed25519=yes ;;
1952	    esac
1953	    ;;
1954	no)
1955	    have_ed25519=no ;;
1956	*)
1957	    case "$have_ed25519" in
1958	    yes|no) ;;
1959	    *) AC_MSG_ERROR([need --with-eddsa=[[yes, all or no]]]) ;;
1960	    esac
1961	    ;;
1962	esac
1963	case $have_ed25519 in
1964	yes)
1965		OPENSSL_ED25519="yes"
1966		OPENSSLEDDSALINKOBJS='${OPENSSLEDDSALINKOBJS}'
1967		OPENSSLEDDSALINKSRCS='${OPENSSLEDDSALINKSRCS}'
1968		AC_DEFINE(HAVE_OPENSSL_ED25519, 1,
1969			  [Define if your OpenSSL version supports Ed25519.])
1970		AC_MSG_CHECKING(for OpenSSL Ed448 support)
1971		AC_TRY_RUN([
1972#include <openssl/evp.h>
1973#include <openssl/objects.h>
1974int main() {
1975	EVP_PKEY_CTX *ctx;
1976
1977	ctx = EVP_PKEY_CTX_new_id(NID_ED448, NULL);
1978	if (ctx == NULL) {
1979		return (2);
1980	}
1981	EVP_PKEY_CTX_free(ctx);
1982	return (0);
1983}
1984],
1985		[AC_MSG_RESULT([yes])
1986		have_ed448="yes"],
1987		[AC_MSG_RESULT([no])
1988		have_ed448="no"],
1989		[AC_MSG_RESULT(using --with-eddsa)])
1990		case $with_eddsa in
1991		all)
1992			have_ed448=yes ;;
1993		*)
1994			;;
1995		esac
1996		case $have_ed448 in
1997		yes)
1998			AC_DEFINE(HAVE_OPENSSL_ED448, 1,
1999				  [Define if your OpenSSL version supports Ed448.])
2000			;;
2001		*)
2002			;;
2003		esac
2004		;;
2005	*)
2006		;;
2007	esac
2008
2009	have_aes="no"
2010	AC_MSG_CHECKING(for OpenSSL AES support)
2011	AC_TRY_RUN([
2012#include <openssl/evp.h>
2013int main() {
2014	const EVP_CIPHER *aes128, *aes192, *aes256;
2015
2016	aes128 = EVP_aes_128_ecb();
2017	aes192 = EVP_aes_192_ecb();
2018	aes256 = EVP_aes_256_ecb();
2019	if (aes128 == NULL || aes192 == NULL || aes256 == NULL)
2020		return (1);
2021	return (0);
2022}
2023],
2024	[AC_MSG_RESULT(yes)
2025	 have_aes="evp"],
2026	[AC_CHECK_FUNC(AES_encrypt,
2027	[AC_MSG_RESULT(yes)
2028	 have_aes="yes"],
2029	[AC_MSG_RESULT(no)])],
2030	[AC_MSG_RESULT(using --with-aes)
2031	 # Expect cross-compiling with a modern OpenSSL
2032	 have_aes="evp"])
2033
2034	ISC_OPENSSL_INC=""
2035	ISC_OPENSSL_LIBS=""
2036	if test "yes" = "$with_aes"
2037	then
2038		case "$have_aes" in
2039		evp)
2040			AC_DEFINE(HAVE_OPENSSL_EVP_AES, 1,
2041				  [Define if your OpenSSL version supports EVP AES])
2042			ISC_OPENSSL_INC="$DST_OPENSSL_INC"
2043			ISC_OPENSSL_LIBS="$DST_OPENSSL_LIBS"
2044			;;
2045		yes)
2046			AC_DEFINE(HAVE_OPENSSL_AES, 1,
2047				  [Define if your OpenSSL version supports AES])
2048			ISC_OPENSSL_INC="$DST_OPENSSL_INC"
2049			ISC_OPENSSL_LIBS="$DST_OPENSSL_LIBS"
2050			;;
2051		*)
2052			;;
2053		esac
2054	fi
2055
2056	CC="$saved_cc"
2057	CFLAGS="$saved_cflags"
2058	LIBS="$saved_libs"
2059	OPENSSLLINKOBJS='${OPENSSLLINKOBJS}'
2060	OPENSSLLINKSRCS='${OPENSSLLINKSRCS}'
2061
2062	;;
2063esac
2064
2065#
2066# This would include the system openssl path (and linker options to use
2067# it as needed) if it is found.
2068#
2069
2070AC_SUBST(DST_OPENSSL_INC)
2071AC_SUBST(OPENSSLECDSALINKOBJS)
2072AC_SUBST(OPENSSLECDSALINKSRCS)
2073AC_SUBST(OPENSSLEDDSALINKOBJS)
2074AC_SUBST(OPENSSLEDDSALINKSRCS)
2075AC_SUBST(OPENSSLGOSTLINKOBJS)
2076AC_SUBST(OPENSSLGOSTLINKSRCS)
2077AC_SUBST(OPENSSLLINKOBJS)
2078AC_SUBST(OPENSSLLINKSRCS)
2079AC_SUBST(OPENSSL_ECDSA)
2080AC_SUBST(OPENSSL_ED25519)
2081AC_SUBST(OPENSSL_GOST)
2082
2083DNS_CRYPTO_LIBS="$DNS_CRYPTO_LIBS $DST_OPENSSL_LIBS"
2084
2085ISC_PLATFORM_WANTAES="#undef ISC_PLATFORM_WANTAES"
2086if test "yes" = "$with_aes"
2087then
2088	if test "X$CRYPTO" = "X"
2089	then
2090		with_aes="no"
2091	fi
2092fi
2093if test "yes" = "$with_aes"
2094then
2095	ISC_PLATFORM_WANTAES="#define ISC_PLATFORM_WANTAES 1"
2096fi
2097AC_SUBST(ISC_PLATFORM_WANTAES)
2098
2099#
2100# Choose Client Cookie algorithm
2101#
2102# [pairwise: skip]
2103AC_ARG_WITH([cc-alg],
2104	    [AS_HELP_STRING([--with-cc-alg=ALG], [deprecated])],
2105	    [:], [with_cc_alg="siphash24"])
2106
2107AS_CASE([$with_cc_alg],
2108	[siphash24],[:],
2109	[AC_MSG_WARN([The Client Cookie is always SipHash 2-4 based])])
2110
2111if test "checkcc" = "$want_openssl_hash"
2112then
2113	want_openssl_hash="no"
2114fi
2115
2116#
2117# Use OpenSSL for hash functions
2118#
2119
2120AC_MSG_CHECKING(for using OpenSSL for hash functions)
2121ISC_PLATFORM_OPENSSLHASH="#undef ISC_PLATFORM_OPENSSLHASH"
2122case $want_openssl_hash in
2123	yes)
2124		if test "$CRYPTO" != "-DOPENSSL"
2125		then
2126			AC_MSG_ERROR([No OpenSSL for hash functions])
2127		fi
2128		AC_MSG_RESULT(yes)
2129		ISC_PLATFORM_OPENSSLHASH="#define ISC_PLATFORM_OPENSSLHASH 1"
2130		ISC_OPENSSL_INC="$DST_OPENSSL_INC"
2131		ISC_OPENSSL_LIBS="$DST_OPENSSL_LIBS"
2132		;;
2133	no)
2134		AC_MSG_RESULT(no)
2135		;;
2136esac
2137AC_SUBST(ISC_PLATFORM_OPENSSLHASH)
2138AC_SUBST(ISC_OPENSSL_INC)
2139AC_SUBST(ISC_OPENSSL_LIBS)
2140
2141#
2142# PKCS11 (aka crypto hardware) support (--with moved just after openssl)
2143#
2144AC_MSG_CHECKING(for PKCS11 support)
2145
2146if test "auto" = "$use_pkcs11"
2147then
2148	if test "yes" = "$want_native_pkcs11"
2149	then
2150		use_pkcs11="yes"
2151	else
2152		use_pkcs11="no"
2153	fi
2154fi
2155
2156case "$use_pkcs11" in
2157	no)
2158		AC_MSG_RESULT(no)
2159		USE_PKCS11=""
2160		PKCS11_TEST=""
2161		PKCS11_TOOLS=""
2162		ISC_PK11_C=""
2163		ISC_PK11_O=""
2164		ISC_PK11_API_C=""
2165		ISC_PK11_API_O=""
2166		ISC_PK11_RESULT_C=""
2167		ISC_PK11_RESULT_O=""
2168		ISC_ISCPK11_API_C=""
2169		ISC_ISCPK11_API_O=""
2170		;;
2171	yes|*)
2172		AC_MSG_RESULT(yes)
2173		if ! $use_threads; then
2174			AC_MSG_ERROR([PKCS11 requires thread support])
2175		fi
2176		if test "X$CRYPTO" = "X-DOPENSSL"
2177		then
2178			AC_MSG_CHECKING(for OpenSSL with PKCS11 support)
2179			saved_cc="$CC"
2180			saved_cflags="$CFLAGS"
2181			saved_libs="$LIBS"
2182			CC="$CC -pthread"
2183			CFLAGS="$CFLAGS $DST_OPENSSL_INC"
2184			LIBS="$LIBS $DST_OPENSSL_LIBS"
2185			AC_TRY_RUN([
2186#include <openssl/conf.h>
2187#include <openssl/engine.h>
2188int main() {
2189	ENGINE *e;
2190
2191	OPENSSL_config(NULL);
2192	e = ENGINE_by_id("pkcs11");
2193	if (e == NULL)
2194		return (1);
2195	if (ENGINE_init(e) <= 0)
2196		return (1);
2197	return (0);
2198}
2199],
2200			[AC_MSG_RESULT(yes)
2201			PKCS11_TEST=pkcs11ssl
2202			PKCS11_ENGINE='-DPKCS11_ENGINE="\"pkcs11\""'],
2203			[AC_MSG_RESULT(no)
2204			PKCS11_TEST=''
2205			PKCS11_ENGINE='-DPKCS11_ENGINE=NULL'],
2206			[AC_MSG_RESULT(cross compile, defaulting to no)
2207			PKCS11_TEST=''
2208			PKCS11_ENGINE='-DPKCS11_ENGINE=NULL'])
2209			CC="$saved_cc"
2210			CFLAGS="$saved_cflags"
2211			LIBS="$saved_libs"
2212		else
2213			PKCS11_TEST=''
2214			PKCS11_ENGINE='-DPKCS11_ENGINE=NULL'
2215
2216		fi
2217		USE_PKCS11='-DUSE_PKCS11'
2218		PKCS11_TOOLS=pkcs11
2219		AC_CHECK_FUNC(getpassphrase, AC_DEFINE(HAVE_GETPASSPHRASE),)
2220		ISC_PK11_C="pk11.c"
2221		ISC_PK11_O="pk11.$O"
2222		ISC_PK11_API_C="pk11_api.c"
2223		ISC_PK11_API_O="pk11_api.$O"
2224		ISC_PK11_RESULT_C="pk11_result.c"
2225		ISC_PK11_RESULT_O="pk11_result.$O"
2226		ISC_ISCPK11_API_C="unix/pk11_api.c"
2227		ISC_ISCPK11_API_O="unix/pk11_api.$O"
2228		;;
2229esac
2230AC_SUBST(USE_PKCS11)
2231AC_SUBST(PKCS11_TOOLS)
2232AC_SUBST(PKCS11_ENGINE)
2233AC_SUBST(ISC_PK11_C)
2234AC_SUBST(ISC_PK11_O)
2235AC_SUBST(ISC_PK11_API_C)
2236AC_SUBST(ISC_PK11_API_O)
2237AC_SUBST(ISC_PK11_RESULT_C)
2238AC_SUBST(ISC_PK11_RESULT_O)
2239AC_SUBST(ISC_ISCPK11_API_C)
2240AC_SUBST(ISC_ISCPK11_API_O)
2241
2242AC_MSG_CHECKING(for PKCS11 tools)
2243case "$use_pkcs11" in
2244	no)
2245		PKCS11_PROVIDER="undefined"
2246		AC_MSG_RESULT(disabled)
2247		;;
2248	yes|'')
2249		PKCS11_PROVIDER="undefined"
2250		AC_MSG_RESULT(enabled)
2251		;;
2252	*)
2253		PKCS11_PROVIDER="$use_pkcs11"
2254		AC_MSG_RESULT([enabled, PKCS11 provider is $PKCS11_PROVIDER])
2255		;;
2256esac
2257
2258AC_SUBST(PKCS11_PROVIDER)
2259
2260PKCS11_ECDSA=""
2261PKCS11_GOST=""
2262PKCS11_ED25519=""
2263set_pk11_flavor="no"
2264AC_MSG_CHECKING(for native PKCS11)
2265
2266case "$want_native_pkcs11" in
2267	yes)
2268		AC_MSG_RESULT(using native PKCS11 crypto)
2269		PKCS11LINKOBJS='${PKCS11LINKOBJS}'
2270		PKCS11LINKSRCS='${PKCS11LINKSRCS}'
2271		PKCS11_TEST=pkcs11
2272		AC_MSG_CHECKING(for PKCS11 ECDSA)
2273		case "$with_ecdsa" in
2274		no)
2275			AC_MSG_RESULT(disabled)
2276			;;
2277		*)
2278			AC_MSG_RESULT(enabled)
2279			PKCS11_ECDSA="yes"
2280			AC_DEFINE(HAVE_PKCS11_ECDSA, 1,
2281				  [Define if your PKCS11 provider supports ECDSA.])
2282			;;
2283		esac
2284		AC_MSG_CHECKING(for PKCS11 GOST)
2285		case "$with_gost" in
2286		yes)
2287			AC_MSG_RESULT(enabled)
2288			PKCS11_GOST="yes"
2289			AC_DEFINE(HAVE_PKCS11_GOST, 1,
2290				  [Define if your PKCS11 provider supports GOST.])
2291			;;
2292		*)
2293			AC_MSG_RESULT(disabled)
2294			;;
2295		esac
2296		AC_MSG_CHECKING(for PKCS11 Ed25519)
2297		case "$with_eddsa" in
2298		yes|all)
2299			AC_MSG_RESULT(enabled)
2300			PKCS11_ED25519="yes"
2301			AC_DEFINE(HAVE_PKCS11_ED25519, 1,
2302				  [Define if your PKCS11 provider supports Ed25519.])
2303			AC_MSG_CHECKING(for PKCS11 Ed448)
2304			case "$with_eddsa" in
2305			all)
2306				AC_MSG_RESULT(enabled)
2307				AC_DEFINE(HAVE_PKCS11_ED448, 1,
2308					  [Define if your PKCS11 provider supports Ed448.])
2309				;;
2310			*)
2311				AC_MSG_RESULT(disabled)
2312				;;
2313			esac
2314			;;
2315		*)
2316			AC_MSG_RESULT(disabled)
2317			;;
2318		esac
2319		AC_MSG_CHECKING(for PKCS11 flavor)
2320		case "$PKCS11_PROVIDER" in
2321			*nfast*)
2322				AC_MSG_RESULT(Thales nCipher)
2323				# default
2324				pk11_flavor="PK11_THALES_FLAVOR"
2325				set_pk11_flavor="yes"
2326				;;
2327			*libsofthsm2*)
2328				AC_MSG_RESULT(SoftHSMv2)
2329				pk11_flavor="PK11_SOFTHSMV2_FLAVOR"
2330				set_pk11_flavor="yes"
2331				;;
2332			*libsofthsm*)
2333				AC_MSG_RESULT(SoftHSM)
2334				pk11_flavor="PK11_SOFTHSMV1_FLAVOR"
2335				set_pk11_flavor="yes"
2336				;;
2337			*cryptech*)
2338				AC_MSG_RESULT(Cryptech)
2339				pk11_flavor="PK11_CRYPTECH_FLAVOR"
2340				set_pk11_flavor="yes"
2341				;;
2342			*Keyper*)
2343				AC_MSG_RESULT(AEP Keyper)
2344				pk11_flavor="PK11_AEP_FLAVOR"
2345				set_pk11_flavor="yes"
2346				;;
2347			*libcs*)
2348				AC_MSG_RESULT(Utimaco HSM)
2349				pk11_flavor="PK11_UTIMACO_FLAVOR"
2350				set_pk11_flavor="yes"
2351				;;
2352			undefined)
2353				AC_MSG_RESULT(undefined provider?)
2354				;;
2355			*)
2356				AC_MSG_RESULT(unknown provider: tweaks are in lib/isc/include/pk11/site.h)
2357				;;
2358		esac
2359		if test "yes" = "$set_pk11_flavor" ; then
2360			CFLAGS="$CFLAGS -DPK11_FLAVOR=$pk11_flavor"
2361		fi
2362		;;
2363	no|'')
2364		AC_MSG_RESULT(disabled)
2365		;;
2366esac
2367
2368AC_SUBST(PKCS11LINKOBJS)
2369AC_SUBST(PKCS11LINKSRCS)
2370AC_SUBST(CRYPTO)
2371AC_SUBST(PKCS11_ECDSA)
2372AC_SUBST(PKCS11_GOST)
2373AC_SUBST(PKCS11_ED25519)
2374AC_SUBST(PKCS11_TEST)
2375
2376# for PKCS11 benchmarks
2377
2378have_clock_gt=no
2379AC_CHECK_FUNC(clock_gettime,have_clock_gt=yes,)
2380if test "no" = "$have_clock_gt"; then
2381	AC_CHECK_LIB(rt,clock_gettime,have_clock_gt=rt,)
2382fi
2383
2384if test "no" != "$have_clock_gt"; then
2385	AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if clock_gettime is available.])
2386fi
2387
2388if test "rt" = "$have_clock_gt"; then
2389	LIBS="-lrt $LIBS"
2390fi
2391
2392#
2393# was --with-lmdb specified?
2394#
2395AC_MSG_CHECKING(for lmdb library)
2396
2397# [pairwise: --with-lmdb=auto, --with-lmdb=yes, --without-lmdb]
2398AC_ARG_WITH(lmdb,
2399	    AS_HELP_STRING([--with-lmdb[=PATH]],
2400			   [build with LMDB library [yes|no|path]]),
2401	    use_lmdb="$withval", use_lmdb="auto")
2402
2403have_lmdb=""
2404case "$use_lmdb" in
2405	no)
2406		lmdb_libs=""
2407		;;
2408	auto|yes)
2409		for d in /usr /usr/local /opt/local
2410		do
2411			if test -f "${d}/include/lmdb.h"
2412			then
2413				if test ${d} != /usr
2414				then
2415					lmdb_cflags="-I ${d}/include"
2416					LIBS="$LIBS -L${d}/lib"
2417				fi
2418				have_lmdb="yes"
2419			fi
2420		done
2421		;;
2422	*)
2423		if test -f "${use_lmdb}/include/lmdb.h"
2424		then
2425			lmdb_cflags="-I${use_lmdb}/include"
2426			LIBS="$LIBS -L${use_lmdb}/lib"
2427			have_lmdb="yes"
2428		else
2429			AC_MSG_ERROR([$use_lmdb/include/lmdb.h not found.])
2430		fi
2431		;;
2432esac
2433
2434if test "X${have_lmdb}" != "X"
2435then
2436	AC_MSG_RESULT(yes)
2437	AC_SEARCH_LIBS([mdb_env_create], [lmdb], [],
2438		       [AC_MSG_ERROR([found lmdb include but not library.])
2439			have_lmdb=""])
2440elif test "X$use_lmdb" = Xyes
2441then
2442	AC_MSG_ERROR([include/lmdb.h not found.])
2443else
2444	AC_MSG_RESULT(no)
2445fi
2446
2447NZD_TOOLS=""
2448NZDSRCS=
2449NZDTARGETS=
2450if test "X${have_lmdb}" != "X"
2451then
2452	CFLAGS="$CFLAGS $lmdb_cflags"
2453	AC_DEFINE(HAVE_LMDB, 1, [Define if lmdb was found])
2454	NZD_TOOLS="nzd"
2455	NZDSRCS='${NZDSRCS}'
2456	NZDTARGETS='${NZDTARGETS}'
2457fi
2458AC_SUBST(NZD_TOOLS)
2459AC_SUBST(NZDSRCS)
2460AC_SUBST(NZDTARGETS)
2461
2462#
2463# was --with-libxml2 specified?
2464#
2465# [pairwise: --with-libxml2=auto, --with-libxml2=yes, --without-libxml2]
2466AC_ARG_WITH([libxml2],
2467	    [AS_HELP_STRING([--with-libxml2[=PATH]],
2468			   [build with libxml2 library (auto|yes|no|path) [default=auto]])],
2469	    [:], [with_libxml2="auto"])
2470
2471LIBXML2_CFLAGS=
2472LIBXML2_LIBS=
2473AS_CASE([$with_libxml2],
2474	[no],[:],
2475	[auto],[PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.6.0], [:], [:])],
2476	[yes],[PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.6.0])],
2477	[AC_MSG_CHECKING([for libxml2 library in $with_libxml2])
2478	 AS_IF([test -x "$with_libxml2/bin/xml2-config"],
2479	       [AC_MSG_RESULT([yes])
2480		LIBXML2_LIBS=`$with_libxml2/bin/xml2-config --libs`
2481		LIBXML2_CFLAGS=`$with_libxml2/bin/xml2-config --cflags`],
2482	       [AC_MSG_ERROR([not found])])])
2483
2484AS_IF([test -n "$LIBXML2_LIBS"],
2485      [AC_MSG_CHECKING([whether linking with libxml2 works])
2486       CFLAGS="$CFLAGS $LIBXML2_CFLAGS"
2487       LIBS="$LIBS $LIBXML2_LIBS"
2488       #
2489       # Sanity check xml2-config output.
2490       #
2491       AC_TRY_LINK([#include <libxml/xmlwriter.h>],
2492		   [return(xmlTextWriterStartElement(NULL, NULL));],
2493		   [AC_MSG_RESULT([yes])],
2494		   [AC_MSG_ERROR([no])])
2495       AC_DEFINE([HAVE_LIBXML2], [1], [Define if libxml2 was found])
2496       XMLSTATS=1])
2497AC_SUBST([XMLSTATS])
2498
2499#
2500# was --with-libjson specified?
2501#
2502AC_MSG_CHECKING(for json library)
2503
2504# [pairwise: --with-libjson=auto, --with-libjson=yes, --without-libjson]
2505AC_ARG_WITH(libjson,
2506	    AS_HELP_STRING([--with-libjson[=PATH]],
2507			   [build with libjson0 library [yes|no|path]]),
2508	    use_libjson="$withval", use_libjson="auto")
2509
2510have_libjson=""
2511have_libjson_c=""
2512case "$use_libjson" in
2513	no)
2514		libjson_libs=""
2515		;;
2516	auto|yes)
2517		for d in /usr /usr/local /opt/local
2518		do
2519			if test -f "${d}/include/json/json.h"
2520			then
2521				if test ${d} != /usr
2522				then
2523					libjson_cflags="-I ${d}/include"
2524					LIBS="$LIBS -L${d}/lib"
2525				fi
2526				have_libjson="yes"
2527			elif test -f "${d}/include/json-c/json.h"
2528			then
2529				if test ${d} != /usr
2530				then
2531					libjson_cflags="-I ${d}/include"
2532					LIBS="$LIBS -L${d}/lib"
2533				fi
2534				have_libjson="yes"
2535				have_libjson_c="yes"
2536			fi
2537		done
2538		;;
2539	*)
2540		if test -f "${use_libjson}/include/json/json.h"
2541		then
2542			libjson_cflags="-I${use_libjson}/include"
2543			LIBS="$LIBS -L${use_libjson}/lib"
2544			have_libjson="yes"
2545		elif test -f "${use_libjson}/include/json-c/json.h"
2546		then
2547			libjson_cflags="-I${use_libjson}/include"
2548			LIBS="$LIBS -L${use_libjson}/lib"
2549			have_libjson="yes"
2550			have_libjson_c="yes"
2551		else
2552			AC_MSG_ERROR([$use_libjson/include/json{,-c}/json.h not found.])
2553		fi
2554		;;
2555esac
2556
2557if test "X${have_libjson}" != "X"
2558then
2559	AC_MSG_RESULT(yes)
2560	AC_SEARCH_LIBS([json_object_new_int64], [json json-c], [],
2561		       [AC_MSG_ERROR([found libjson include but not library.])
2562			have_libjson=""])
2563elif test "X$use_libjson" = Xyes
2564then
2565	AC_MSG_ERROR([include/json{,-c}/json.h not found.])
2566else
2567	AC_MSG_RESULT(no)
2568fi
2569
2570if test "X${have_libjson}" != "X"
2571then
2572	CFLAGS="$CFLAGS $libjson_cflags"
2573	AC_DEFINE(HAVE_JSON, 1, [Define if libjson was found])
2574	if test "X${have_libjson_c}" = Xyes
2575	then
2576		AC_DEFINE(HAVE_JSON_C, 1, [Define if json-c was found])
2577	fi
2578	JSONSTATS=1
2579fi
2580AC_SUBST(JSONSTATS)
2581
2582#
2583# was --with-zlib specified?
2584#
2585AC_MSG_CHECKING(for zlib library)
2586
2587# [pairwise: --with-zlib=auto, --with-zlib=yes, --without-zlib]
2588AC_ARG_WITH(zlib,
2589	    AS_HELP_STRING([--with-zlib[=PATH]],
2590			   [build with zlib for HTTP compression
2591				[default=yes]]),
2592	    with_zlib="$withval", with_zlib="auto")
2593
2594have_zlib=""
2595case "$with_zlib" in
2596	no)
2597		zlib_libs=""
2598		;;
2599	auto|yes)
2600		for d in /usr /usr/local /opt/local
2601		do
2602			if test -f "${d}/include/zlib.h"
2603			then
2604				if test ${d} != /usr
2605				then
2606					zlib_cflags="-I ${d}/include"
2607					LIBS="$LIBS -L${d}/lib"
2608				fi
2609				have_zlib="yes"
2610			fi
2611		done
2612		;;
2613	*)
2614		if test -f "${with_zlib}/include/zlib.h"
2615		then
2616			zlib_cflags="-I${with_zlib}/include"
2617			LIBS="$LIBS -L${with_zlib}/lib"
2618			have_zlib="yes"
2619		else
2620			AC_MSG_ERROR([$with_zlib/include/zlib.h not found.])
2621		fi
2622		;;
2623esac
2624
2625if test "X${have_zlib}" != "X"
2626then
2627	AC_MSG_RESULT(yes)
2628	AC_SEARCH_LIBS([deflate], [z], [],
2629		       [AC_MSG_ERROR([found zlib include but not library.])
2630			have_zlib=""])
2631elif test "X$with_zlib" = Xyes
2632then
2633	AC_MSG_ERROR([include/zlib.h not found.])
2634else
2635	AC_MSG_RESULT(no)
2636fi
2637
2638ZLIB=
2639if test "X${have_zlib}" != "X"
2640then
2641	CFLAGS="$CFLAGS $zlib_cflags"
2642	AC_DEFINE(HAVE_ZLIB, 1, [Define if zlib was found])
2643	ZLIB=1
2644fi
2645AC_SUBST(ZLIB)
2646
2647
2648#
2649# In solaris 10, SMF can manage named service
2650#
2651AC_CHECK_LIB(scf, smf_enable_instance)
2652
2653#
2654# flockfile is usually provided by pthreads, but we may want to use it
2655# even if compiled with --disable-threads.  getc_unlocked might also not
2656# be defined.
2657#
2658AC_CHECK_FUNC(flockfile, AC_DEFINE(HAVE_FLOCKFILE),)
2659AC_CHECK_FUNC(getc_unlocked, AC_DEFINE(HAVE_GETCUNLOCKED),)
2660
2661#
2662# Indicate what the final decision was regarding threads.
2663#
2664AC_MSG_CHECKING(whether to build with threads)
2665if $use_threads; then
2666	AC_MSG_RESULT(yes)
2667else
2668	AC_MSG_RESULT(no)
2669fi
2670
2671#
2672# End of pthreads stuff.
2673#
2674
2675#
2676# Large File
2677#
2678# [pairwise: --enable-largefile, --disable-largefile]
2679AC_ARG_ENABLE(largefile,
2680	      AS_HELP_STRING([--enable-largefile], [64-bit file support]),
2681	      want_largefile="yes", want_largefile="no")
2682case $want_largefile in
2683	yes)
2684		ALWAYS_DEFINES="$ALWAYS_DEFINES -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
2685		;;
2686	*)
2687		;;
2688esac
2689
2690#
2691# Additional compiler settings.
2692#
2693MKDEPCC="$CC"
2694MKDEPCFLAGS="-M"
2695IRIX_DNSSEC_WARNINGS_HACK=""
2696
2697if test "X$GCC" = "Xyes"; then
2698	STD_CWARNINGS="$STD_CWARNINGS -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -Wpointer-arith"
2699	AC_MSG_CHECKING(if "$CC" supports -fno-strict-aliasing)
2700	SAVE_CFLAGS="$CFLAGS"
2701	CFLAGS="$CFLAGS -Werror -fno-strict-aliasing"
2702	AC_TRY_COMPILE(,, [FNOSTRICTALIASING=yes],[FNOSTRICTALIASING=no])
2703	CFLAGS="$SAVE_CFLAGS"
2704	if test "yes" = "$FNOSTRICTALIASING"; then
2705		AC_MSG_RESULT(yes)
2706		STD_CWARNINGS="$STD_CWARNINGS -fno-strict-aliasing"
2707	else
2708		AC_MSG_RESULT(no)
2709	fi
2710	#
2711	# turn off delete null pointer checks
2712	#
2713	AC_MSG_CHECKING(if "$CC" supports -fno-delete-null-pointer-checks)
2714	SAVE_CFLAGS="$CFLAGS"
2715	CFLAGS="$CFLAGS -Werror -fno-delete-null-pointer-checks"
2716	AC_TRY_COMPILE(,, [FNODELETENULLPOINTERCHECKS=yes],
2717			  [FNODELETENULLPOINTERCHECKS=no])
2718	CFLAGS="$SAVE_CFLAGS"
2719	if test "yes" = "$FNODELETENULLPOINTERCHECKS"; then
2720		AC_MSG_RESULT(yes)
2721		STD_CWARNINGS="$STD_CWARNINGS -fno-delete-null-pointer-checks"
2722	else
2723		AC_MSG_RESULT(no)
2724	fi
2725	case "$host" in
2726	*-hp-hpux*)
2727		CFLAGS="$CFLAGS -Wl,+vnocompatwarnings"
2728		BACKTRACECFLAGS="$BACKTRACECFLAGS -Wl,+vnocompatwarnings"
2729		;;
2730	esac
2731	if test "X$enable_warn_shadow" = Xyes; then
2732		STD_CWARNINGS="$STD_CWARNINGS -Wshadow"
2733	fi
2734	if test "X$enable_warn_error" = Xyes; then
2735		STD_CWARNINGS="$STD_CWARNINGS -Werror"
2736	fi
2737else
2738	case $host in
2739	*-dec-osf*)
2740		CC="$CC -std"
2741		CCOPT="$CCOPT -std"
2742		CCNOOPT="$CCNOOPT -std"
2743		MKDEPCC="$CC"
2744		;;
2745	*-hp-hpux*)
2746		CC="$CC -Ae -z"
2747		# The version of the C compiler that constantly warns about
2748		# 'const' as well as alignment issues is unfortunately not
2749		# able to be discerned via the version of the operating
2750		# system, nor does cc have a version flag.
2751		case "`$CC +W 123 2>&1`" in
2752		*Unknown?option*)
2753			STD_CWARNINGS="+w1"
2754			;;
2755		*)
2756			# Turn off the pointlessly noisy warnings.
2757			STD_CWARNINGS="+w1 +W 474,530,2193,2236"
2758			;;
2759		esac
2760		CCOPT="$CCOPT -Ae -z"
2761		CCNOOPT="$CCNOOPT -Ae -z"
2762		CFLAGS="$CFLAGS -Wl,+vnocompatwarnings"
2763		BACKTRACECFLAGS="$BACKTRACECFLAGS -Wl,+vnocompatwarnings"
2764		MKDEPPROG='cc -Ae -E -Wp,-M >/dev/null 2>>$TMP'
2765		;;
2766	*-sgi-irix*)
2767		STD_CWARNINGS="-fullwarn -woff 1209"
2768		#
2769		# Silence more than 250 instances of
2770		#   "prototyped function redeclared without prototype"
2771		# and 11 instances of
2772		#   "variable ... was set but never used"
2773		# from lib/dns/sec/openssl.
2774		#
2775		IRIX_DNSSEC_WARNINGS_HACK="-woff 1692,1552"
2776		;;
2777	*-solaris*)
2778		MKDEPCFLAGS="-xM"
2779		;;
2780	*-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
2781		# UnixWare
2782		CC="$CC -w"
2783		;;
2784	esac
2785fi
2786
2787AC_SUBST(MKDEPCC)
2788AC_SUBST(MKDEPCFLAGS)
2789AC_SUBST(MKDEPPROG)
2790AC_SUBST(IRIX_DNSSEC_WARNINGS_HACK)
2791
2792#
2793# NLS
2794#
2795AC_CHECK_FUNC(catgets, AC_DEFINE(HAVE_CATGETS),)
2796
2797#
2798# -lxnet buys us one big porting headache...  standards, gotta love 'em.
2799#
2800# AC_CHECK_LIB(xnet, socket, ,
2801#    AC_CHECK_LIB(socket, socket)
2802# )
2803#
2804# Use this for now, instead:
2805#
2806case "$host" in
2807	mips-sgi-irix*)
2808		;;
2809	*-linux*)
2810		;;
2811	*)
2812		AC_CHECK_LIB(socket, socket)
2813		AC_CHECK_LIB(nsl, inet_addr)
2814		;;
2815esac
2816
2817#
2818# Work around Solaris's select() limitations.
2819#
2820case "$host" in
2821	*-solaris2.[[89]]|*-solaris2.1?)
2822	AC_DEFINE(FD_SETSIZE, 65536,
2823		  [Solaris hack to get select_large_fdset.])
2824	;;
2825esac
2826
2827#
2828# Purify support
2829#
2830AC_MSG_CHECKING(whether to use purify)
2831
2832# Purify is not included in pairwise testing as that tool is not present
2833# in the relevant Docker image.
2834#
2835# [pairwise: skip]
2836AC_ARG_WITH(purify,
2837	    AS_HELP_STRING([--with-purify[=PATH]], [use Rational purify]),
2838	    use_purify="$withval", use_purify="no")
2839
2840case "$use_purify" in
2841	no)
2842		;;
2843	yes)
2844		AC_PATH_PROG(purify_path, purify, purify)
2845		;;
2846	*)
2847		purify_path="$use_purify"
2848		;;
2849esac
2850
2851case "$use_purify" in
2852	no)
2853		AC_MSG_RESULT(no)
2854		PURIFY=""
2855		;;
2856	*)
2857		if test -f "$purify_path" || test purify = "$purify_path"; then
2858			AC_MSG_RESULT($purify_path)
2859			PURIFYFLAGS="`echo $PURIFYOPTIONS`"
2860			PURIFY="$purify_path $PURIFYFLAGS"
2861		else
2862			AC_MSG_ERROR([$purify_path not found.
2863
2864Please choose the proper path with the following command:
2865
2866    configure --with-purify=PATH
2867])
2868		fi
2869		;;
2870esac
2871
2872AC_SUBST(PURIFY)
2873
2874#
2875# Google/Great Performance Tools CPU Profiler
2876#
2877AC_MSG_CHECKING(whether to use gperftools profiler)
2878
2879# Google/Great Performance Tools CPU Profiler is not included in
2880# pairwise testing as that tool is not present in the relevant Docker
2881# image.
2882#
2883# [pairwise: skip]
2884AC_ARG_WITH(gperftools-profiler,
2885	    AS_HELP_STRING([--with-gperftools-profiler],
2886			   [use gperftools CPU profiler]),
2887	    use_profiler="$withval", use_profiler="no")
2888
2889case $use_profiler in
2890	yes)
2891		AC_MSG_RESULT(yes)
2892		AC_DEFINE([HAVE_GPERFTOOLS_PROFILER], 1,
2893		[Define to use gperftools CPU profiler.])
2894		LIBS="$LIBS -lprofiler"
2895		;;
2896	*)
2897		AC_MSG_RESULT(no)
2898		;;
2899esac
2900
2901#
2902# enable/disable dumping stack backtrace.  Also check if the system supports
2903# glibc-compatible backtrace() function.
2904#
2905# [pairwise: --enable-backtrace, --disable-backtrace]
2906AC_ARG_ENABLE(backtrace,
2907	      AS_HELP_STRING([--enable-backtrace],
2908			     [log stack backtrace on abort [default=yes]]),
2909	      want_backtrace="$enableval",  want_backtrace="yes")
2910case $want_backtrace in
2911yes)
2912	ISC_PLATFORM_USEBACKTRACE="#define ISC_PLATFORM_USEBACKTRACE 1"
2913	AC_TRY_LINK([#include <execinfo.h>],
2914	[return (backtrace((void **)0, 0));],
2915	[AC_DEFINE([HAVE_LIBCTRACE], [], [if system have backtrace function])],
2916	[AC_TRY_LINK([#include <stddef.h>],
2917		     [return _Unwind_Backtrace(NULL, NULL);],
2918		     [AC_DEFINE([HAVE_UNWIND_BACKTRACE], [1], [define if the compiler supports _Unwind_Backtrace()])])])
2919	;;
2920*)
2921	ISC_PLATFORM_USEBACKTRACE="#undef ISC_PLATFORM_USEBACKTRACE"
2922	;;
2923esac
2924AC_SUBST(ISC_PLATFORM_USEBACKTRACE)
2925
2926# [pairwise: --enable-symtable, --disable-symtable]
2927AC_ARG_ENABLE(symtable,
2928	      AS_HELP_STRING([--enable-symtable],
2929			     [use internal symbol table for backtrace
2930			      [all|minimal(default)|none]]),
2931		want_symtable="$enableval",  want_symtable="minimal")
2932case $want_symtable in
2933yes|all|minimal)     # "yes" is a hidden value equivalent to "minimal"
2934	if test "" = "$PERL"
2935	then
2936		AC_MSG_ERROR([Internal symbol table requires perl but no perl is found.
2937Install perl or explicitly disable the feature by --disable-symtable.])
2938	fi
2939	if test "yes" = "$use_libtool"; then
2940		AC_MSG_WARN([Internal symbol table does not work with libtool.  Disabling symbol table.])
2941	else
2942		# we generate the internal symbol table only for those systems
2943		# known to work to avoid unexpected build failure.  Also, warn
2944		# about unsupported systems when the feature is enabled
2945		#  manually.
2946		case $host_os in
2947		freebsd*|netbsd*|openbsd*|linux*|solaris*|darwin*)
2948			MKSYMTBL_PROGRAM="$PERL"
2949			if test "all" = "$want_symtable"; then
2950				ALWAYS_MAKE_SYMTABLE="yes"
2951			fi
2952			;;
2953		*)
2954			if test "yes" = "$want_symtable" -o "all" = "$want_symtable"
2955			then
2956				AC_MSG_WARN([this system is not known to generate internal symbol table safely; disabling it])
2957			fi
2958		esac
2959	fi
2960	;;
2961*)
2962	;;
2963esac
2964AC_SUBST(MKSYMTBL_PROGRAM)
2965AC_SUBST(ALWAYS_MAKE_SYMTABLE)
2966
2967#
2968# File name extension for static archive files, for those few places
2969# where they are treated differently from dynamic ones.
2970#
2971SA=a
2972
2973AC_SUBST(O)
2974AC_SUBST(A)
2975AC_SUBST(SA)
2976AC_SUBST(LIBTOOL_MKDEP_SED)
2977AC_SUBST(LIBTOOL_MODE_COMPILE)
2978AC_SUBST(LIBTOOL_MODE_INSTALL)
2979AC_SUBST(LIBTOOL_MODE_LINK)
2980AC_SUBST(LIBTOOL_MODE_UNINSTALL)
2981AC_SUBST(LIBTOOL_ALLOW_UNDEFINED)
2982AC_SUBST(LIBTOOL_IN_MAIN)
2983
2984BIND9_CO_RULE=".c.$O:"
2985AC_SUBST(BIND9_CO_RULE)
2986
2987#
2988# Here begins a very long section to determine the system's networking
2989# capabilities.  The order of the tests is significant.
2990#
2991
2992#
2993# IPv6
2994#
2995# [pairwise: --enable-ipv6, --disable-ipv6]
2996AC_ARG_ENABLE(ipv6,
2997	      AS_HELP_STRING([--enable-ipv6], [use IPv6 [default=autodetect]]))
2998
2999case "$enable_ipv6" in
3000	yes|''|autodetect)
3001		AC_DEFINE(WANT_IPV6)
3002		;;
3003	no)
3004		;;
3005esac
3006
3007#
3008# We do the IPv6 compilation checking after libtool so that we can put
3009# the right suffix on the files.
3010#
3011AC_MSG_CHECKING(for IPv6 structures)
3012AC_TRY_COMPILE([
3013#include <sys/types.h>
3014#include <sys/socket.h>
3015#include <netinet/in.h>],
3016[struct sockaddr_in6 sin6; return (0);],
3017	[AC_MSG_RESULT(yes)
3018	 found_ipv6=yes],
3019	[AC_MSG_RESULT(no)
3020	 found_ipv6=no])
3021
3022#
3023# See whether IPv6 support is provided via a Kame add-on.
3024# This is done before other IPv6 linking tests to LIBS is properly set.
3025#
3026AC_MSG_CHECKING(for Kame IPv6 support)
3027
3028# Kame is not included in pairwise testing as it is not present in the
3029# relevant Docker image.
3030#
3031# [pairwise: skip]
3032AC_ARG_WITH(kame,
3033	    AS_HELP_STRING([--with-kame[=PATH]],
3034			   [use Kame IPv6 [default path /usr/local/v6]]),
3035	    use_kame="$withval", use_kame="no")
3036
3037case "$use_kame" in
3038	no)
3039		;;
3040	yes)
3041		kame_path=/usr/local/v6
3042		;;
3043	*)
3044		kame_path="$use_kame"
3045		;;
3046esac
3047
3048case "$use_kame" in
3049	no)
3050		AC_MSG_RESULT(no)
3051		;;
3052	*)
3053		if test -f $kame_path/lib/libinet6.a; then
3054			AC_MSG_RESULT($kame_path/lib/libinet6.a)
3055			LIBS="-L$kame_path/lib -linet6 $LIBS"
3056		else
3057			AC_MSG_ERROR([$kame_path/lib/libinet6.a not found.
3058
3059Please choose the proper path with the following command:
3060
3061    configure --with-kame=PATH
3062])
3063		fi
3064		;;
3065esac
3066
3067#
3068# Whether netinet6/in6.h is needed has to be defined in isc/platform.h.
3069# Including it on Kame-using platforms is very bad, though, because
3070# Kame uses #error against direct inclusion.   So include it on only
3071# the platform that is otherwise broken without it -- BSD/OS 4.0 through 4.1.
3072# This is done before the in6_pktinfo check because that's what
3073# netinet6/in6.h is needed for.
3074#
3075changequote({, })
3076case "$host" in
3077*-bsdi4.[01]*)
3078	ISC_PLATFORM_NEEDNETINET6IN6H="#define ISC_PLATFORM_NEEDNETINET6IN6H 1"
3079	LWRES_PLATFORM_NEEDNETINET6IN6H="#define LWRES_PLATFORM_NEEDNETINET6IN6H 1"
3080	isc_netinet6in6_hack="#include <netinet6/in6.h>"
3081	;;
3082*)
3083	ISC_PLATFORM_NEEDNETINET6IN6H="#undef ISC_PLATFORM_NEEDNETINET6IN6H"
3084	LWRES_PLATFORM_NEEDNETINET6IN6H="#undef LWRES_PLATFORM_NEEDNETINET6IN6H"
3085	isc_netinet6in6_hack=""
3086	;;
3087esac
3088changequote([, ])
3089
3090#
3091# This is similar to the netinet6/in6.h issue.
3092#
3093case "$host" in
3094*-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
3095	# UnixWare
3096	ISC_PLATFORM_NEEDNETINETIN6H="#define ISC_PLATFORM_NEEDNETINETIN6H 1"
3097	LWRES_PLATFORM_NEEDNETINETIN6H="#define LWRES_PLATFORM_NEEDNETINETIN6H 1"
3098	ISC_PLATFORM_FIXIN6ISADDR="#define ISC_PLATFORM_FIXIN6ISADDR 1"
3099	isc_netinetin6_hack="#include <netinet/in6.h>"
3100	;;
3101*)
3102	ISC_PLATFORM_NEEDNETINETIN6H="#undef ISC_PLATFORM_NEEDNETINETIN6H"
3103	LWRES_PLATFORM_NEEDNETINETIN6H="#undef LWRES_PLATFORM_NEEDNETINETIN6H"
3104	ISC_PLATFORM_FIXIN6ISADDR="#undef ISC_PLATFORM_FIXIN6ISADDR"
3105	isc_netinetin6_hack=""
3106	;;
3107esac
3108
3109#
3110# Now delve deeper into the suitability of the IPv6 support.
3111#
3112case "$found_ipv6" in
3113	yes)
3114		ISC_PLATFORM_HAVEIPV6="#define ISC_PLATFORM_HAVEIPV6 1"
3115		LWRES_PLATFORM_HAVEIPV6="#define LWRES_PLATFORM_HAVEIPV6 1"
3116
3117		AC_MSG_CHECKING(for in6_addr)
3118		AC_TRY_COMPILE([
3119#include <sys/types.h>
3120#include <sys/socket.h>
3121#include <netinet/in.h>
3122$isc_netinetin6_hack
3123$isc_netinet6in6_hack
3124],
3125[struct in6_addr in6; return (0);],
3126		[AC_MSG_RESULT(yes)
3127		 ISC_PLATFORM_HAVEINADDR6="#undef ISC_PLATFORM_HAVEINADDR6"
3128		 LWRES_PLATFORM_HAVEINADDR6="#undef LWRES_PLATFORM_HAVEINADDR6"
3129		 isc_in_addr6_hack=""],
3130		[AC_MSG_RESULT(no)
3131		 ISC_PLATFORM_HAVEINADDR6="#define ISC_PLATFORM_HAVEINADDR6 1"
3132		 LWRES_PLATFORM_HAVEINADDR6="#define LWRES_PLATFORM_HAVEINADDR6 1"
3133		 isc_in_addr6_hack="#define in6_addr in_addr6"])
3134
3135		AC_MSG_CHECKING(for in6addr_any)
3136		AC_TRY_LINK([
3137#include <sys/types.h>
3138#include <sys/socket.h>
3139#include <netinet/in.h>
3140$isc_netinetin6_hack
3141$isc_netinet6in6_hack
3142$isc_in_addr6_hack
3143],
3144		[struct in6_addr in6; in6 = in6addr_any; return (in6.s6_addr[0]);],
3145			[AC_MSG_RESULT(yes)
3146			 ISC_PLATFORM_NEEDIN6ADDRANY="#undef ISC_PLATFORM_NEEDIN6ADDRANY"
3147			 LWRES_PLATFORM_NEEDIN6ADDRANY="#undef LWRES_PLATFORM_NEEDIN6ADDRANY"],
3148			[AC_MSG_RESULT(no)
3149			 ISC_PLATFORM_NEEDIN6ADDRANY="#define ISC_PLATFORM_NEEDIN6ADDRANY 1"
3150			 LWRES_PLATFORM_NEEDIN6ADDRANY="#define LWRES_PLATFORM_NEEDIN6ADDRANY 1"])
3151
3152		AC_MSG_CHECKING(for in6addr_loopback)
3153		AC_TRY_LINK([
3154#include <sys/types.h>
3155#include <sys/socket.h>
3156#include <netinet/in.h>
3157$isc_netinetin6_hack
3158$isc_netinet6in6_hack
3159$isc_in_addr6_hack
3160],
3161		[struct in6_addr in6; in6 = in6addr_loopback; return (in6.s6_addr[0]);],
3162			[AC_MSG_RESULT(yes)
3163			 ISC_PLATFORM_NEEDIN6ADDRLOOPBACK="#undef ISC_PLATFORM_NEEDIN6ADDRLOOPBACK"
3164			 LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK="#undef LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK"],
3165			[AC_MSG_RESULT(no)
3166			 ISC_PLATFORM_NEEDIN6ADDRLOOPBACK="#define ISC_PLATFORM_NEEDIN6ADDRLOOPBACK 1"
3167			 LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK="#define LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK 1"])
3168
3169		AC_MSG_CHECKING(for sin6_scope_id in struct sockaddr_in6)
3170		AC_TRY_COMPILE([
3171#include <sys/types.h>
3172#include <sys/socket.h>
3173#include <netinet/in.h>
3174$isc_netinetin6_hack
3175$isc_netinet6in6_hack
3176],
3177		[struct sockaddr_in6 xyzzy; xyzzy.sin6_scope_id = 0; return (0);],
3178			[AC_MSG_RESULT(yes)
3179			 ISC_PLATFORM_HAVESCOPEID="#define ISC_PLATFORM_HAVESCOPEID 1"
3180			 result="#define LWRES_HAVE_SIN6_SCOPE_ID 1"],
3181			[AC_MSG_RESULT(no)
3182			 ISC_PLATFORM_HAVESCOPEID="#undef ISC_PLATFORM_HAVESCOPEID"
3183			 result="#undef LWRES_HAVE_SIN6_SCOPE_ID"])
3184		LWRES_HAVE_SIN6_SCOPE_ID="$result"
3185
3186		AC_MSG_CHECKING(for in6_pktinfo)
3187		AC_TRY_COMPILE([
3188#include <sys/types.h>
3189#include <sys/socket.h>
3190#include <netinet/in.h>
3191$isc_netinetin6_hack
3192$isc_netinet6in6_hack
3193],
3194		[struct in6_pktinfo xyzzy; return (0);],
3195			[AC_MSG_RESULT(yes)
3196			 ISC_PLATFORM_HAVEIN6PKTINFO="#define ISC_PLATFORM_HAVEIN6PKTINFO 1"],
3197			[AC_MSG_RESULT(no -- disabling runtime ipv6 support)
3198			 ISC_PLATFORM_HAVEIN6PKTINFO="#undef ISC_PLATFORM_HAVEIN6PKTINFO"])
3199		;;
3200	no)
3201		ISC_PLATFORM_HAVEIPV6="#undef ISC_PLATFORM_HAVEIPV6"
3202		LWRES_PLATFORM_HAVEIPV6="#undef LWRES_PLATFORM_HAVEIPV6"
3203		ISC_PLATFORM_NEEDIN6ADDRANY="#undef ISC_PLATFORM_NEEDIN6ADDRANY"
3204		LWRES_PLATFORM_NEEDIN6ADDRANY="#undef LWRES_PLATFORM_NEEDIN6ADDRANY"
3205		ISC_PLATFORM_HAVEIN6PKTINFO="#undef ISC_PLATFORM_HAVEIN6PKTINFO"
3206		LWRES_HAVE_SIN6_SCOPE_ID="#define LWRES_HAVE_SIN6_SCOPE_ID 1"
3207		ISC_PLATFORM_HAVESCOPEID="#define ISC_PLATFORM_HAVESCOPEID 1"
3208		ISC_IPV6_H="ipv6.h"
3209		ISC_IPV6_O="ipv6.$O"
3210		ISC_ISCIPV6_O="unix/ipv6.$O"
3211		ISC_IPV6_C="ipv6.c"
3212		;;
3213esac
3214
3215AC_MSG_CHECKING(for struct sockaddr_storage)
3216AC_TRY_COMPILE([
3217#include <sys/types.h>
3218#include <sys/socket.h>
3219$isc_netinetin6_hack
3220$isc_netinet6in6_hack
3221],
3222[struct sockaddr_storage storage; return (0);],
3223[AC_MSG_RESULT(yes)
3224ISC_PLATFORM_HAVESOCKADDRSTORAGE="#define ISC_PLATFORM_HAVESOCKADDRSTORAGE 1"],
3225[AC_MSG_RESULT(no)
3226ISC_PLATFORM_HAVESOCKADDRSTORAGE="#undef ISC_PLATFORM_HAVESOCKADDRSTORAGE"])
3227
3228AC_SUBST(ISC_PLATFORM_HAVEIPV6)
3229AC_SUBST(LWRES_PLATFORM_HAVEIPV6)
3230AC_SUBST(ISC_PLATFORM_NEEDNETINETIN6H)
3231AC_SUBST(LWRES_PLATFORM_NEEDNETINETIN6H)
3232AC_SUBST(ISC_PLATFORM_NEEDNETINET6IN6H)
3233AC_SUBST(LWRES_PLATFORM_NEEDNETINET6IN6H)
3234AC_SUBST(ISC_PLATFORM_HAVEINADDR6)
3235AC_SUBST(LWRES_PLATFORM_HAVEINADDR6)
3236AC_SUBST(ISC_PLATFORM_NEEDIN6ADDRANY)
3237AC_SUBST(LWRES_PLATFORM_NEEDIN6ADDRANY)
3238AC_SUBST(ISC_PLATFORM_NEEDIN6ADDRLOOPBACK)
3239AC_SUBST(LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK)
3240AC_SUBST(ISC_PLATFORM_HAVEIN6PKTINFO)
3241AC_SUBST(ISC_PLATFORM_FIXIN6ISADDR)
3242AC_SUBST(ISC_PLATFORM_HAVESOCKADDRSTORAGE)
3243AC_SUBST(ISC_IPV6_H)
3244AC_SUBST(ISC_IPV6_O)
3245AC_SUBST(ISC_ISCIPV6_O)
3246AC_SUBST(ISC_IPV6_C)
3247AC_SUBST(LWRES_HAVE_SIN6_SCOPE_ID)
3248AC_SUBST(ISC_PLATFORM_HAVESCOPEID)
3249
3250AC_MSG_CHECKING([for struct if_laddrreq])
3251AC_TRY_LINK([
3252#include <sys/types.h>
3253#include <net/if6.h>
3254],[ struct if_laddrreq a; ],
3255	[AC_MSG_RESULT(yes)
3256	ISC_PLATFORM_HAVEIF_LADDRREQ="#define ISC_PLATFORM_HAVEIF_LADDRREQ 1"],
3257	[AC_MSG_RESULT(no)
3258	ISC_PLATFORM_HAVEIF_LADDRREQ="#undef ISC_PLATFORM_HAVEIF_LADDRREQ"])
3259AC_SUBST(ISC_PLATFORM_HAVEIF_LADDRREQ)
3260
3261AC_MSG_CHECKING([for struct if_laddrconf])
3262AC_TRY_LINK([
3263#include <sys/types.h>
3264#include <net/if6.h>
3265],[ struct if_laddrconf a; ],
3266	[AC_MSG_RESULT(yes)
3267	ISC_PLATFORM_HAVEIF_LADDRCONF="#define ISC_PLATFORM_HAVEIF_LADDRCONF 1"],
3268	[AC_MSG_RESULT(no)
3269	ISC_PLATFORM_HAVEIF_LADDRCONF="#undef ISC_PLATFORM_HAVEIF_LADDRCONF"])
3270AC_SUBST(ISC_PLATFORM_HAVEIF_LADDRCONF)
3271
3272#
3273# Check for network functions that are often missing.  We do this
3274# after the libtool checking, so we can put the right suffix on
3275# the files.  It also needs to come after checking for a Kame add-on,
3276# which provides some (all?) of the desired functions.
3277#
3278
3279AC_MSG_CHECKING([for inet_ntop with IPv6 support])
3280AC_TRY_RUN([
3281#include <sys/types.h>
3282#include <sys/socket.h>
3283#include <netinet/in.h>
3284#include <arpa/inet.h>
3285main() {
3286char a[16],b[64]; return(inet_ntop(AF_INET6, a, b, sizeof(b)) == (char*)0);}],
3287	[AC_MSG_RESULT(yes)
3288	ISC_PLATFORM_NEEDNTOP="#undef ISC_PLATFORM_NEEDNTOP"],
3289
3290	[AC_MSG_RESULT(no)
3291	ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_ntop.$O"
3292	ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_ntop.c"
3293	ISC_PLATFORM_NEEDNTOP="#define ISC_PLATFORM_NEEDNTOP 1"],
3294	[AC_MSG_RESULT(assuming inet_ntop not needed)
3295	ISC_PLATFORM_NEEDNTOP="#undef ISC_PLATFORM_NEEDNTOP"])
3296
3297
3298# On NetBSD 1.4.2 and maybe others, inet_pton() incorrectly accepts
3299# addresses with less than four octets, like "1.2.3".  Also leading
3300# zeros should also be rejected.
3301
3302AC_MSG_CHECKING([for working inet_pton with IPv6 support])
3303AC_TRY_RUN([
3304#include <sys/types.h>
3305#include <sys/socket.h>
3306#include <netinet/in.h>
3307#include <arpa/inet.h>
3308main() { char a[16]; return (inet_pton(AF_INET, "1.2.3", a) == 1 ? 1 :
3309			     inet_pton(AF_INET, "1.2.3.04", a) == 1 ? 1 :
3310			     (inet_pton(AF_INET6, "::1.2.3.4", a) != 1)); }],
3311	[AC_MSG_RESULT(yes)
3312	ISC_PLATFORM_NEEDPTON="#undef ISC_PLATFORM_NEEDPTON"],
3313	[AC_MSG_RESULT(no)
3314	ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_pton.$O"
3315	ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_pton.c"
3316	ISC_PLATFORM_NEEDPTON="#define ISC_PLATFORM_NEEDPTON 1"],
3317	[AC_MSG_RESULT(assuming inet_pton needed)
3318	ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_pton.$O"
3319	ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_pton.c"
3320	ISC_PLATFORM_NEEDPTON="#define ISC_PLATFORM_NEEDPTON 1"])
3321
3322AC_SUBST(ISC_PLATFORM_NEEDNTOP)
3323AC_SUBST(ISC_PLATFORM_NEEDPTON)
3324
3325#
3326# Look for a 4.4BSD-style sa_len member in struct sockaddr.
3327#
3328case "$host" in
3329	*-dec-osf*)
3330		# Turn on 4.4BSD style sa_len support.
3331		AC_DEFINE(_SOCKADDR_LEN)
3332		;;
3333esac
3334
3335AC_MSG_CHECKING(for sa_len in struct sockaddr)
3336AC_TRY_COMPILE([
3337#include <sys/types.h>
3338#include <sys/socket.h>],
3339[struct sockaddr sa; sa.sa_len = 0; return (0);],
3340	[AC_MSG_RESULT(yes)
3341	ISC_PLATFORM_HAVESALEN="#define ISC_PLATFORM_HAVESALEN 1"
3342	LWRES_PLATFORM_HAVESALEN="#define LWRES_PLATFORM_HAVESALEN 1"],
3343	[AC_MSG_RESULT(no)
3344	ISC_PLATFORM_HAVESALEN="#undef ISC_PLATFORM_HAVESALEN"
3345	LWRES_PLATFORM_HAVESALEN="#undef LWRES_PLATFORM_HAVESALEN"])
3346AC_SUBST(ISC_PLATFORM_HAVESALEN)
3347AC_SUBST(LWRES_PLATFORM_HAVESALEN)
3348
3349#
3350# Look for a 4.4BSD or 4.3BSD struct msghdr
3351#
3352AC_MSG_CHECKING(for struct msghdr flavor)
3353AC_TRY_COMPILE([
3354#include <sys/types.h>
3355#include <sys/socket.h>],
3356[struct msghdr msg; msg.msg_flags = 0; return (0);],
3357	[AC_MSG_RESULT(4.4BSD)
3358	ISC_PLATFORM_MSGHDRFLAVOR="#define ISC_NET_BSD44MSGHDR 1"],
3359	[AC_MSG_RESULT(4.3BSD)
3360	ISC_PLATFORM_MSGHDRFLAVOR="#define ISC_NET_BSD43MSGHDR 1"])
3361AC_SUBST(ISC_PLATFORM_MSGHDRFLAVOR)
3362
3363#
3364# Look for in_port_t.
3365#
3366AC_MSG_CHECKING(for type in_port_t)
3367AC_TRY_COMPILE([
3368#include <sys/types.h>
3369#include <netinet/in.h>],
3370[in_port_t port = 25; return (0);],
3371	[AC_MSG_RESULT(yes)
3372	ISC_PLATFORM_NEEDPORTT="#undef ISC_PLATFORM_NEEDPORTT"],
3373	[AC_MSG_RESULT(no)
3374	ISC_PLATFORM_NEEDPORTT="#define ISC_PLATFORM_NEEDPORTT 1"])
3375AC_SUBST(ISC_PLATFORM_NEEDPORTT)
3376
3377#
3378# Allow forcibly disabling TCP Fast Open support as autodetection might yield
3379# confusing results on some systems (e.g. FreeBSD; see set_tcp_fastopen()
3380# comment in lib/isc/unix/socket.c).
3381#
3382# [pairwise: --enable-tcp-fastopen, --disable-tcp-fastopen]
3383AC_ARG_ENABLE(tcp_fastopen,
3384	      AS_HELP_STRING([--disable-tcp-fastopen],
3385		     [disable TCP Fast Open support [default=autodetect]]))
3386
3387AC_MSG_CHECKING(for TCP_FASTOPEN socket option)
3388case "$enable_tcp_fastopen" in
3389yes|''|autodetect)
3390	AC_EGREP_CPP(has_tfo, [
3391#include <sys/types.h>
3392#include <sys/socket.h>
3393#include <netinet/tcp.h>
3394#ifdef TCP_FASTOPEN
3395int has_tfo() { return (0); }
3396#endif
3397],
3398		[AC_MSG_RESULT(yes)
3399		ISC_PLATFORM_HAVETFO="#define ISC_PLATFORM_HAVETFO 1"],
3400		[AC_MSG_RESULT(no)
3401		ISC_PLATFORM_HAVETFO="#undef ISC_PLATFORM_HAVETFO"])
3402
3403		;;
3404	no)
3405		AC_MSG_RESULT(disabled)
3406		ISC_PLATFORM_HAVETFO="#undef ISC_PLATFORM_HAVETFO"
3407		;;
3408esac
3409AC_SUBST(ISC_PLATFORM_HAVETFO)
3410
3411#
3412# Check for addrinfo
3413#
3414AC_MSG_CHECKING(for struct addrinfo)
3415AC_TRY_COMPILE([
3416#include <netdb.h>],
3417[struct addrinfo a; return (0);],
3418	[AC_MSG_RESULT(yes)
3419	ISC_LWRES_NEEDADDRINFO="#undef ISC_LWRES_NEEDADDRINFO"
3420	ISC_IRS_NEEDADDRINFO="#undef ISC_IRS_NEEDADDRINFO"
3421	AC_DEFINE(HAVE_ADDRINFO)],
3422	[AC_MSG_RESULT(no)
3423	ISC_LWRES_NEEDADDRINFO="#define ISC_LWRES_NEEDADDRINFO 1"
3424	ISC_IRS_NEEDADDRINFO="#define ISC_IRS_NEEDADDRINFO 1"])
3425AC_SUBST(ISC_LWRES_NEEDADDRINFO)
3426AC_SUBST(ISC_IRS_NEEDADDRINFO)
3427
3428#
3429# Check for rrsetinfo
3430#
3431AC_MSG_CHECKING(for struct rrsetinfo)
3432AC_TRY_COMPILE([
3433#include <netdb.h>],
3434[struct rrsetinfo r; return (0);],
3435	[AC_MSG_RESULT(yes)
3436	ISC_LWRES_NEEDRRSETINFO="#undef ISC_LWRES_NEEDRRSETINFO"],
3437	[AC_MSG_RESULT(no)
3438	ISC_LWRES_NEEDRRSETINFO="#define ISC_LWRES_NEEDRRSETINFO 1"])
3439AC_SUBST(ISC_LWRES_NEEDRRSETINFO)
3440
3441AC_MSG_CHECKING(for int sethostent)
3442AC_TRY_COMPILE([
3443#include <netdb.h>],
3444[int i = sethostent(0); return(0);],
3445	[AC_MSG_RESULT(yes)
3446	ISC_LWRES_SETHOSTENTINT="#define ISC_LWRES_SETHOSTENTINT 1"],
3447	[AC_MSG_RESULT(no)
3448	ISC_LWRES_SETHOSTENTINT="#undef ISC_LWRES_SETHOSTENTINT"])
3449AC_SUBST(ISC_LWRES_SETHOSTENTINT)
3450
3451AC_MSG_CHECKING(for int endhostent)
3452AC_TRY_COMPILE([
3453#include <netdb.h>],
3454[int i = endhostent(); return(0);],
3455	[AC_MSG_RESULT(yes)
3456	ISC_LWRES_ENDHOSTENTINT="#define ISC_LWRES_ENDHOSTENTINT 1"],
3457	[AC_MSG_RESULT(no)
3458	ISC_LWRES_ENDHOSTENTINT="#undef ISC_LWRES_ENDHOSTENTINT"])
3459AC_SUBST(ISC_LWRES_ENDHOSTENTINT)
3460
3461AC_MSG_CHECKING(for getnetbyaddr(in_addr_t, ...))
3462AC_TRY_COMPILE([
3463#include <netdb.h>
3464struct netent *getnetbyaddr(in_addr_t, int);],
3465[],
3466	[AC_MSG_RESULT(yes)
3467	ISC_LWRES_GETNETBYADDRINADDR="#define ISC_LWRES_GETNETBYADDRINADDR 1"],
3468	[AC_MSG_RESULT(no)
3469	ISC_LWRES_GETNETBYADDRINADDR="#undef ISC_LWRES_GETNETBYADDRINADDR"])
3470AC_SUBST(ISC_LWRES_GETNETBYADDRINADDR)
3471
3472AC_MSG_CHECKING(for int setnetent)
3473AC_TRY_COMPILE([
3474#include <netdb.h>],
3475[int i = setnetent(0); return(0);],
3476	[AC_MSG_RESULT(yes)
3477	ISC_LWRES_SETNETENTINT="#define ISC_LWRES_SETNETENTINT 1"],
3478	[AC_MSG_RESULT(no)
3479	ISC_LWRES_SETNETENTINT="#undef ISC_LWRES_SETNETENTINT"])
3480AC_SUBST(ISC_LWRES_SETNETENTINT)
3481
3482AC_MSG_CHECKING(for int endnetent)
3483AC_TRY_COMPILE([
3484#include <netdb.h>],
3485[int i = endnetent(); return(0);],
3486	[AC_MSG_RESULT(yes)
3487	ISC_LWRES_ENDNETENTINT="#define ISC_LWRES_ENDNETENTINT 1"],
3488	[AC_MSG_RESULT(no)
3489	ISC_LWRES_ENDNETENTINT="#undef ISC_LWRES_ENDNETENTINT"])
3490AC_SUBST(ISC_LWRES_ENDNETENTINT)
3491
3492AC_MSG_CHECKING(for gethostbyaddr(const void *, size_t, ...))
3493AC_TRY_COMPILE([
3494#include <netdb.h>
3495struct hostent *gethostbyaddr(const void *, size_t, int);],
3496[return(0);],
3497	[AC_MSG_RESULT(yes)
3498	ISC_LWRES_GETHOSTBYADDRVOID="#define ISC_LWRES_GETHOSTBYADDRVOID 1"],
3499	[AC_MSG_RESULT(no)
3500	ISC_LWRES_GETHOSTBYADDRVOID="#undef ISC_LWRES_GETHOSTBYADDRVOID"])
3501AC_SUBST(ISC_LWRES_GETHOSTBYADDRVOID)
3502
3503AC_MSG_CHECKING(for h_errno in netdb.h)
3504AC_TRY_COMPILE([
3505#include <netdb.h>],
3506[h_errno = 1; return(0);],
3507	[AC_MSG_RESULT(yes)
3508	ISC_LWRES_NEEDHERRNO="#undef ISC_LWRES_NEEDHERRNO"],
3509	[AC_MSG_RESULT(no)
3510	ISC_LWRES_NEEDHERRNO="#define ISC_LWRES_NEEDHERRNO 1"])
3511AC_SUBST(ISC_LWRES_NEEDHERRNO)
3512
3513#
3514# Sadly, the definitions of system-supplied getnameinfo(3) vary.  Try to catch
3515# known variations here:
3516#
3517AC_MSG_CHECKING(for getnameinfo prototype definitions)
3518AC_TRY_COMPILE([
3519#include <sys/types.h>
3520#include <sys/socket.h>
3521#include <netdb.h>
3522int getnameinfo(const struct sockaddr *, socklen_t, char *,
3523		socklen_t, char *, socklen_t, int);],
3524[ return (0);],
3525	[AC_MSG_RESULT(socklen_t for buflen; int for flags)
3526	 AC_DEFINE(IRS_GETNAMEINFO_SOCKLEN_T, socklen_t,
3527		   [Define to the sockaddr length type used by getnameinfo(3).])
3528	 AC_DEFINE(IRS_GETNAMEINFO_BUFLEN_T, socklen_t,
3529		   [Define to the buffer length type used by getnameinfo(3).])
3530	 AC_DEFINE(IRS_GETNAMEINFO_FLAGS_T, int,
3531		   [Define to the flags type used by getnameinfo(3).])],
3532[AC_TRY_COMPILE([
3533#include <sys/types.h>
3534#include <sys/socket.h>
3535#include <netdb.h>
3536int getnameinfo(const struct sockaddr *, socklen_t, char *,
3537		size_t, char *, size_t, int);],
3538[ return (0);],
3539	[AC_MSG_RESULT(size_t for buflen; int for flags)
3540	 AC_DEFINE(IRS_GETNAMEINFO_SOCKLEN_T, socklen_t)
3541	 AC_DEFINE(IRS_GETNAMEINFO_BUFLEN_T, size_t)
3542	 AC_DEFINE(IRS_GETNAMEINFO_FLAGS_T, int)],
3543[AC_TRY_COMPILE([
3544#include <sys/types.h>
3545#include <sys/socket.h>
3546#include <netdb.h>
3547int getnameinfo(const struct sockaddr *, size_t, char *,
3548		size_t, char *, size_t, int);],
3549[ return (0);],
3550	[AC_MSG_RESULT(size_t for buflen; int for flags)
3551	 AC_DEFINE(IRS_GETNAMEINFO_SOCKLEN_T, size_t)
3552	 AC_DEFINE(IRS_GETNAMEINFO_BUFLEN_T, size_t)
3553	 AC_DEFINE(IRS_GETNAMEINFO_FLAGS_T, int)],
3554[AC_MSG_RESULT(not match any subspecies; socklen_t for buflen; u_int for flags)
3555AC_DEFINE(IRS_GETNAMEINFO_SOCKLEN_T, socklen_t)
3556AC_DEFINE(IRS_GETNAMEINFO_BUFLEN_T, socklen_t)
3557AC_DEFINE(IRS_GETNAMEINFO_FLAGS_T, unsigned int)])])])
3558
3559#
3560# ...and same for gai_strerror().
3561#
3562AC_MSG_CHECKING(for gai_strerror prototype definitions)
3563AC_TRY_COMPILE([
3564#include <sys/types.h>
3565#include <sys/socket.h>
3566#include <netdb.h>
3567char *gai_strerror(int ecode);],
3568[ return (0); ],
3569	[AC_MSG_RESULT(returning char *)
3570	 AC_DEFINE([IRS_GAISTRERROR_RETURN_T], [char *],
3571	 [return type of gai_strerror])],
3572[AC_MSG_RESULT(not match any subspecies; assume standard definition)
3573AC_DEFINE([IRS_GAISTRERROR_RETURN_T], [const char *])])
3574
3575AC_CHECK_FUNC(getipnodebyname,
3576	[ISC_LWRES_GETIPNODEPROTO="#undef ISC_LWRES_GETIPNODEPROTO"],
3577	[ISC_LWRES_GETIPNODEPROTO="#define ISC_LWRES_GETIPNODEPROTO 1"])
3578AC_CHECK_FUNC(getnameinfo,
3579	[ISC_LWRES_GETNAMEINFOPROTO="#undef ISC_LWRES_GETNAMEINFOPROTO"],
3580	[ISC_LWRES_GETNAMEINFOPROTO="#define ISC_LWRES_GETNAMEINFOPROTO 1"])
3581AC_CHECK_FUNC(getaddrinfo,
3582	[ISC_LWRES_GETADDRINFOPROTO="#undef ISC_LWRES_GETADDRINFOPROTO"
3583	AC_DEFINE(HAVE_GETADDRINFO)],
3584	[ISC_LWRES_GETADDRINFOPROTO="#define ISC_LWRES_GETADDRINFOPROTO 1"])
3585AC_CHECK_FUNC(gai_strerror, AC_DEFINE(HAVE_GAISTRERROR))
3586AC_SUBST(ISC_LWRES_GETIPNODEPROTO)
3587AC_SUBST(ISC_LWRES_GETADDRINFOPROTO)
3588AC_SUBST(ISC_LWRES_GETNAMEINFOPROTO)
3589AC_SUBST(ISC_IRS_GETNAMEINFOSOCKLEN)
3590
3591# [pairwise: --enable-getifaddrs, --disable-getifaddrs]
3592AC_ARG_ENABLE(getifaddrs,
3593	      AS_HELP_STRING([--enable-getifaddrs],
3594			     [enable the use of getifaddrs() [yes|no].]),
3595    want_getifaddrs="$enableval",  want_getifaddrs="yes")
3596
3597#
3598# This interface iteration code for getifaddrs() will fall back to using
3599# /proc/net/if_inet6 if getifaddrs() in glibc doesn't return any IPv6
3600# addresses.
3601#
3602case $want_getifaddrs in
3603glibc)
3604AC_MSG_WARN("--enable-getifaddrs=glibc is no longer required")
3605AC_CHECK_FUNC(getifaddrs, AC_DEFINE(HAVE_GETIFADDRS))
3606;;
3607yes)
3608AC_CHECK_FUNC(getifaddrs, AC_DEFINE(HAVE_GETIFADDRS))
3609;;
3610no)
3611;;
3612esac
3613
3614#
3615# Look for a sysctl call to get the list of network interfaces.
3616#
3617case $ac_cv_header_sys_sysctl_h in
3618yes)
3619AC_MSG_CHECKING(for interface list sysctl)
3620AC_EGREP_CPP(found_rt_iflist, [
3621#include <sys/param.h>
3622#include <sys/sysctl.h>
3623#include <sys/socket.h>
3624#ifdef NET_RT_IFLIST
3625found_rt_iflist
3626#endif
3627],
3628	[AC_MSG_RESULT(yes)
3629	 AC_DEFINE(HAVE_IFLIST_SYSCTL)],
3630	[AC_MSG_RESULT(no)])
3631;;
3632esac
3633
3634#
3635# Check for some other useful functions that are not ever-present.
3636#
3637
3638# We test for strsep() using AC_TRY_LINK instead of AC_CHECK_FUNC
3639# because AIX 4.3.3 with patches for bos.adt.include to version 4.3.3.77
3640# reportedly defines strsep() without declaring it in <string.h> when
3641# -D_LINUX_SOURCE_COMPAT is not defined [RT #2190], and
3642# AC_CHECK_FUNC() incorrectly succeeds because it declares
3643# the function itself.
3644AC_MSG_CHECKING(for correctly declared strsep())
3645AC_TRY_LINK([#include <string.h>], [char *sp; char *foo = strsep(&sp, ".");],
3646	[AC_MSG_RESULT(yes); ISC_PLATFORM_NEEDSTRSEP="#undef ISC_PLATFORM_NEEDSTRSEP"],
3647	[AC_MSG_RESULT(no); ISC_PLATFORM_NEEDSTRSEP="#define ISC_PLATFORM_NEEDSTRSEP 1"])
3648AC_SUBST(ISC_PLATFORM_NEEDSTRSEP)
3649
3650AC_CHECK_FUNC(memmove,
3651	[ISC_PLATFORM_NEEDMEMMOVE="#undef ISC_PLATFORM_NEEDMEMMOVE"],
3652	[ISC_PLATFORM_NEEDMEMMOVE="#define ISC_PLATFORM_NEEDMEMMOVE 1"])
3653AC_SUBST(ISC_PLATFORM_NEEDMEMMOVE)
3654
3655AC_CHECK_FUNC(strtoul,
3656	[ISC_PLATFORM_NEEDSTRTOUL="#undef ISC_PLATFORM_NEEDSTRTOUL"
3657	 LWRES_PLATFORM_NEEDSTRTOUL="#undef LWRES_PLATFORM_NEEDSTRTOUL"
3658	 GENRANDOMLIB=""],
3659	[ISC_PLATFORM_NEEDSTRTOUL="#define ISC_PLATFORM_NEEDSTRTOUL 1"
3660	 LWRES_PLATFORM_NEEDSTRTOUL="#define LWRES_PLATFORM_NEEDSTRTOUL 1"
3661	 GENRANDOMLIB='${ISCLIBS}'])
3662AC_SUBST(ISC_PLATFORM_NEEDSTRTOUL)
3663AC_SUBST(LWRES_PLATFORM_NEEDSTRTOUL)
3664AC_SUBST(GENRANDOMLIB)
3665
3666AC_CHECK_FUNC(strlcpy,
3667	[ISC_PLATFORM_NEEDSTRLCPY="#undef ISC_PLATFORM_NEEDSTRLCPY"
3668	 LWRES_PLATFORM_NEEDSTRLCPY="#undef LWRES_PLATFORM_NEEDSTRLCPY"],
3669	[ISC_PLATFORM_NEEDSTRLCPY="#define ISC_PLATFORM_NEEDSTRLCPY 1"
3670	 LWRES_PLATFORM_NEEDSTRLCPY="#define LWRES_PLATFORM_NEEDSTRLCPY 1"])
3671AC_SUBST(ISC_PLATFORM_NEEDSTRLCPY)
3672AC_SUBST(LWRES_PLATFORM_NEEDSTRLCPY)
3673
3674AC_CHECK_FUNC(strlcat,
3675	[ISC_PLATFORM_NEEDSTRLCAT="#undef ISC_PLATFORM_NEEDSTRLCAT"],
3676	[ISC_PLATFORM_NEEDSTRLCAT="#define ISC_PLATFORM_NEEDSTRLCAT 1"])
3677AC_SUBST(ISC_PLATFORM_NEEDSTRLCAT)
3678
3679AC_CHECK_FUNC(strcasestr,
3680	[ISC_PLATFORM_NEEDSTRCASESTR="#undef ISC_PLATFORM_NEEDSTRCASESTR"],
3681	[ISC_PLATFORM_NEEDSTRCASESTR="#define ISC_PLATFORM_NEEDSTRCASESTR 1"])
3682AC_SUBST(ISC_PLATFORM_NEEDSTRCASESTR)
3683
3684AC_SUBST(READLINE_LIB)
3685
3686# [pairwise: --with-readline=auto, --with-readline=yes, --without-readline]
3687AC_ARG_WITH(readline,
3688	    AS_HELP_STRING([--with-readline[=LIBSPEC]],
3689			   [specify readline library [default auto]]),
3690	    use_readline="$withval", use_readline="auto")
3691case "$use_readline" in
3692no)	;;
3693*)
3694	saved_LIBS="$LIBS"
3695	case "$use_readline" in
3696	yes|auto) try_readline="-ledit"; or_readline="-lreadline" ;;
3697	*) try_readline="$use_readline"
3698	esac
3699	for readline in "$try_readline" $or_readline
3700	do
3701		LIBS="$readline"
3702		AC_MSG_NOTICE(checking for readline with $readline)
3703		AC_CHECK_FUNCS(readline)
3704		if test "yes" = "$ac_cv_func_readline"
3705		then
3706			READLINE_LIB="$readline"
3707			break
3708		fi
3709		for lib in -lterminfo -ltermcap -lncurses -lcurses
3710		do
3711			AC_MSG_NOTICE(checking for readline with $readline $lib)
3712			unset ac_cv_func_readline
3713			LIBS="$readline $lib"
3714			AC_CHECK_FUNCS(readline)
3715			if test "yes" = "$ac_cv_func_readline"
3716			then
3717				READLINE_LIB="$readline $lib"
3718				break
3719			fi
3720		done
3721		if test "yes" = "$ac_cv_func_readline"
3722		then
3723			break
3724		fi
3725	done
3726	if test "auto" != "$use_readline" &&
3727	   test "X$READLINE_LIB" = "X"
3728	then
3729		AC_MSG_ERROR([The readline library was not found.])
3730	fi
3731	LIBS="$saved_LIBS"
3732	;;
3733esac
3734if test "yes" = "$ac_cv_func_readline"
3735then
3736	case "$READLINE_LIB" in
3737	*edit*)
3738		AC_CHECK_HEADERS(editline/readline.h)
3739		AC_CHECK_HEADERS(edit/readline/readline.h)
3740		AC_CHECK_HEADERS(edit/readline/history.h)
3741		;;
3742	esac
3743	AC_CHECK_HEADERS(readline/readline.h)
3744	AC_CHECK_HEADERS(readline/history.h)
3745fi
3746
3747ISC_PRINT_OBJS=
3748ISC_PRINT_SRCS=
3749ISC_PLATFORM_NEEDPRINTF='#undef ISC_PLATFORM_NEEDPRINTF'
3750ISC_PLATFORM_NEEDFPRINTF='#undef ISC_PLATFORM_NEEDFPRINTF'
3751ISC_PLATFORM_NEEDSPRINTF='#undef ISC_PLATFORM_NEEDSPRINTF'
3752ISC_PLATFORM_NEEDVSNPRINTF='#undef ISC_PLATFORM_NEEDVSNPRINTF'
3753LWRES_PLATFORM_NEEDVSNPRINTF='#undef LWRES_PLATFORM_NEEDVSNPRINTF'
3754
3755AC_MSG_CHECKING(sprintf return type)
3756AC_TRY_COMPILE([
3757#include <stdio.h>
3758],
3759[ char buf[2]; return(*sprintf(buf,"x"));],
3760[AC_MSG_RESULT(char *)
3761ISC_PRINT_OBJS="print.$O"
3762ISC_PRINT_SRCS="print.c"
3763ISC_PLATFORM_NEEDSPRINTF="#define ISC_PLATFORM_NEEDSPRINTF"
3764LWRES_PLATFORM_NEEDSPRINTF="#define LWRES_PLATFORM_NEEDSPRINTF"
3765],[AC_MSG_RESULT(int)])
3766
3767AC_CHECK_FUNC(vsnprintf, [],
3768	[ISC_PRINT_OBJS="print.$O"
3769	 ISC_PRINT_SRCS="print.c"
3770	 ISC_PLATFORM_NEEDVSNPRINTF="#define ISC_PLATFORM_NEEDVSNPRINTF 1"
3771	 LWRES_PLATFORM_NEEDVSNPRINTF="#define LWRES_PLATFORM_NEEDVSNPRINTF 1"])
3772
3773AC_MSG_CHECKING(printf for %z support)
3774AC_TRY_RUN([
3775#include <stdio.h>
3776
3777int
3778main() {
3779	size_t j = 0;
3780	char buf[100];
3781	buf[0] = 0;
3782	sprintf(buf, "%zu", j);
3783	return ((buf[0] == '0' && buf[1] == '\0') ? 0 : 1);
3784}
3785],
3786	[AC_MSG_RESULT(yes)],
3787	[AC_MSG_RESULT(no)
3788	ISC_PRINT_OBJS="print.$O"
3789	ISC_PRINT_SRCS="print.c"
3790	ISC_PLATFORM_NEEDPRINTF='#define ISC_PLATFORM_NEEDPRINTF 1'
3791	ISC_PLATFORM_NEEDFPRINTF='#define ISC_PLATFORM_NEEDFPRINTF 1'
3792	ISC_PLATFORM_NEEDFSRINTF='#define ISC_PLATFORM_NEEDSPRINTF 1'
3793	ISC_PLATFORM_NEEDVSNPRINTF="#define ISC_PLATFORM_NEEDVSNPRINTF 1"
3794	LWRES_PLATFORM_NEEDVSNPRINTF="#define LWRES_PLATFORM_NEEDVSNPRINTF 1"],
3795	[AC_MSG_RESULT(assuming target platform supports %z)])
3796
3797AC_SUBST(ISC_PLATFORM_NEEDPRINTF)
3798AC_SUBST(ISC_PLATFORM_NEEDFPRINTF)
3799AC_SUBST(ISC_PLATFORM_NEEDSPRINTF)
3800AC_SUBST(ISC_PLATFORM_NEEDVSNPRINTF)
3801AC_SUBST(LWRES_PLATFORM_NEEDSPRINTF)
3802AC_SUBST(LWRES_PLATFORM_NEEDVSNPRINTF)
3803
3804ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS $ISC_PRINT_OBJS"
3805ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS $ISC_PRINT_SRCS"
3806AC_SUBST(ISC_EXTRA_OBJS)
3807AC_SUBST(ISC_EXTRA_SRCS)
3808
3809AC_CHECK_FUNC(strerror, AC_DEFINE(HAVE_STRERROR))
3810
3811AC_SUBST(DST_EXTRA_OBJS)
3812AC_SUBST(DST_EXTRA_SRCS)
3813
3814#
3815# Security Stuff
3816#
3817# Note it is very recommended to *not* disable chroot(),
3818# this is only because chroot() was made obsolete by Posix.
3819#
3820# [pairwise: --enable-chroot, --disable-chroot]
3821AC_ARG_ENABLE(chroot, AS_HELP_STRING([--disable-chroot], [disable chroot]))
3822case "$enable_chroot" in
3823	yes|'')
3824		AC_CHECK_FUNCS(chroot)
3825		;;
3826	no)
3827		;;
3828esac
3829
3830# [pairwise: --enable-linux-caps, --disable-linux-caps]
3831AC_ARG_ENABLE(linux-caps,
3832	      AS_HELP_STRING([--disable-linux-caps],
3833			     [disable linux capabilities]))
3834case "$enable_linux_caps" in
3835	yes|'')
3836		AC_CHECK_HEADERS(linux/types.h)
3837		AC_CHECK_HEADERS([sys/capability.h])
3838		AC_CHECK_HEADERS([linux/capability.h], [], [],
3839				 [#ifdef HAVE_LINUX_TYPES_H
3840				  #include <linux/types.h>
3841				  #endif
3842				 ])
3843		AC_CHECK_LIB(cap, cap_set_proc)
3844		;;
3845	no)
3846		;;
3847esac
3848AC_CHECK_HEADERS(sys/prctl.h)
3849
3850AC_CHECK_HEADERS(sys/un.h,
3851ISC_PLATFORM_HAVESYSUNH="#define ISC_PLATFORM_HAVESYSUNH 1"
3852,
3853ISC_PLATFORM_HAVESYSUNH="#undef ISC_PLATFORM_HAVESYSUNH"
3854)
3855AC_SUBST(ISC_PLATFORM_HAVESYSUNH)
3856
3857case "$host" in
3858*-solaris*)
3859	AC_DEFINE(NEED_SECURE_DIRECTORY, 1,
3860		  [Define if connect does not honour the permission on the UNIX domain socket.])
3861	;;
3862*-sunos*)
3863	AC_DEFINE(NEED_SECURE_DIRECTORY, 1,
3864		  [Define if connect does not honour the permission on the UNIX domain socket.])
3865	;;
3866esac
3867
3868#
3869# Time Zone Stuff
3870#
3871AC_CHECK_FUNC(tzset, AC_DEFINE(HAVE_TZSET))
3872
3873AC_MSG_CHECKING(for optarg declaration)
3874AC_TRY_COMPILE([
3875#include <unistd.h>
3876],
3877[optarg = 0;],
3878[AC_MSG_RESULT(yes)],
3879[AC_MSG_RESULT(no)
3880GEN_NEED_OPTARG="-DNEED_OPTARG=1"
3881AC_DEFINE(NEED_OPTARG, 1, [Defined if extern char *optarg is not declared.])])
3882
3883#
3884# Check for nanoseconds in file stats
3885#
3886AC_MSG_CHECKING(st_mtim.tv_nsec)
3887AC_TRY_COMPILE([#include <sys/fcntl.h>],[struct stat s; return(s.st_mtim.tv_nsec);],
3888	[AC_MSG_RESULT(yes)
3889	ISC_PLATFORM_HAVESTATNSEC="#define ISC_PLATFORM_HAVESTATNSEC 1"],
3890	[AC_MSG_RESULT(no)
3891	ISC_PLATFORM_HAVESTATNSEC="#undef ISC_PLATFORM_HAVESTATNSEC"])
3892AC_SUBST(ISC_PLATFORM_HAVESTATNSEC)
3893
3894#
3895# BSD/OS, and perhaps some others, don't define rlim_t.
3896#
3897AC_MSG_CHECKING(for type rlim_t)
3898AC_TRY_COMPILE([
3899#include <sys/types.h>
3900#include <sys/time.h>
3901#include <sys/resource.h>],
3902[rlim_t rl = 19671212; return (0);],
3903[AC_MSG_RESULT(yes)
3904 ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE rlim_t"],
3905[AC_MSG_RESULT(no)
3906
3907AC_MSG_CHECKING(type of rlim_cur)
3908AC_TRY_RUN([
3909#include <sys/types.h>
3910#include <sys/time.h>
3911#include <sys/resource.h>
3912main() { struct rlimit r; exit(!(sizeof(r.rlim_cur) == sizeof(int)));}],
3913[AC_MSG_RESULT(int)
3914ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE int"],
3915[
3916AC_TRY_RUN([
3917#include <sys/types.h>
3918#include <sys/time.h>
3919#include <sys/resource.h>
3920main() { struct rlimit r; exit(!(sizeof(r.rlim_cur) == sizeof(long int)));}],
3921[AC_MSG_RESULT(long int)
3922ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE long int"],
3923[
3924AC_TRY_RUN([
3925#include <sys/types.h>
3926#include <sys/time.h>
3927#include <sys/resource.h>
3928main() { struct rlimit r; exit((!sizeof(r.rlim_cur) == sizeof(long long int)));}],
3929[AC_MSG_RESULT(long long int)
3930ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE long long int"],
3931[AC_MSG_ERROR([unable to determine sizeof rlim_cur])
3932],[AC_MSG_ERROR(this cannot happen)])
3933],[AC_MSG_ERROR(this cannot happen)])
3934],[
3935
3936# [pairwise: skip]
3937AC_ARG_WITH(rlimtype, , rlimtype="$withval", rlimtype="long long int")
3938ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE $rlimtype"
3939AC_MSG_RESULT(cannot determine type of rlim_cur when cross compiling - assuming $rlimtype)])
3940])
3941AC_SUBST(ISC_PLATFORM_RLIMITTYPE)
3942
3943#
3944# Older HP-UX doesn't have gettune
3945#
3946case "$host" in
3947	*-hp-hpux*)
3948		AC_CHECK_HEADERS(sys/dyntune.h)
3949		;;
3950	*)
3951		;;
3952esac
3953
3954
3955#
3956# Compaq TruCluster requires more code for handling cluster IP aliases
3957#
3958case "$host" in
3959	*-dec-osf*)
3960		AC_CHECK_LIB(clua, clua_getaliasaddress, LIBS="-lclua $LIBS")
3961		AC_CHECK_FUNC(clua_getaliasaddress,
3962				AC_DEFINE(HAVE_TRUCLUSTER, 1,
3963					[Define if running under Compaq TruCluster]))
3964		;;
3965	*)
3966		;;
3967esac
3968
3969#
3970# Some hosts need msg_namelen to match the size of the socket structure.
3971# Some hosts don't set msg_namelen appropriately on return from recvmsg().
3972#
3973case $host in
3974*os2*|*hp-mpeix*)
3975	AC_DEFINE(BROKEN_RECVMSG, 1,
3976		  [Define if recvmsg() does not meet all of the BSD socket API specifications.])
3977	;;
3978esac
3979
3980#
3981# Microsoft has their own way of handling shared libraries that requires
3982# additional qualifiers on extern variables.  Unix systems don't need it.
3983#
3984AC_SUBST(ISC_PLATFORM_USEDECLSPEC)
3985ISC_PLATFORM_USEDECLSPEC="#undef ISC_PLATFORM_USEDECLSPEC"
3986AC_SUBST(LWRES_PLATFORM_USEDECLSPEC)
3987LWRES_PLATFORM_USEDECLSPEC="#undef LWRES_PLATFORM_USEDECLSPEC"
3988AC_SUBST(IRS_PLATFORM_USEDECLSPEC)
3989IRS_PLATFORM_USEDECLSPEC="#undef IRS_PLATFORM_USEDECLSPEC"
3990
3991#
3992# Random remaining OS-specific issues involving compiler warnings.
3993# XXXDCL print messages to indicate some compensation is being done?
3994#
3995AC_SUBST(ISC_PLATFORM_BRACEPTHREADONCEINIT)
3996ISC_PLATFORM_BRACEPTHREADONCEINIT="#undef ISC_PLATFORM_BRACEPTHREADONCEINIT"
3997
3998case "$host" in
3999	*-aix5.[[123]].*)
4000		hack_shutup_pthreadonceinit=yes
4001		;;
4002	*-bsdi3.1*)
4003		hack_shutup_sputaux=yes
4004		;;
4005	*-bsdi4.0*)
4006		hack_shutup_sigwait=yes
4007		hack_shutup_sputaux=yes
4008		;;
4009	[*-bsdi4.[12]*])
4010		hack_shutup_stdargcast=yes
4011		;;
4012	[*-solaris2.[89]])
4013		hack_shutup_pthreadonceinit=yes
4014		;;
4015	*-solaris2.1[[0-9]])
4016		AC_TRY_COMPILE([ #include <pthread.h> ], [ static pthread_once_t once_test = { PTHREAD_ONCE_INIT }; ], [hack_shutup_pthreadonceinit=yes], )
4017		;;
4018esac
4019
4020case "$hack_shutup_pthreadonceinit" in
4021	yes)
4022		#
4023		# Shut up PTHREAD_ONCE_INIT unbraced initializer warnings.
4024		#
4025		ISC_PLATFORM_BRACEPTHREADONCEINIT="#define ISC_PLATFORM_BRACEPTHREADONCEINIT 1"
4026		;;
4027esac
4028
4029case "$hack_shutup_sigwait" in
4030	yes)
4031		#
4032		# Shut up a -Wmissing-prototypes warning for sigwait().
4033		#
4034		AC_DEFINE(SHUTUP_SIGWAIT)
4035		;;
4036esac
4037
4038case "$hack_shutup_sputaux" in
4039	yes)
4040		#
4041		# Shut up a -Wmissing-prototypes warning from <stdio.h>.
4042		#
4043		AC_DEFINE(SHUTUP_SPUTAUX)
4044		;;
4045esac
4046
4047case "$hack_shutup_stdargcast" in
4048	yes)
4049		#
4050		# Shut up a -Wcast-qual warning from va_start().
4051		#
4052		AC_DEFINE(SHUTUP_STDARG_CAST)
4053		;;
4054esac
4055
4056AC_CHECK_HEADERS(strings.h,
4057  ISC_PLATFORM_HAVESTRINGSH="#define ISC_PLATFORM_HAVESTRINGSH 1"
4058,
4059  ISC_PLATFORM_HAVESTRINGSH="#undef ISC_PLATFORM_HAVESTRINGSH"
4060)
4061AC_SUBST(ISC_PLATFORM_HAVESTRINGSH)
4062
4063#
4064# Check for if_nametoindex() for IPv6 scoped addresses support
4065#
4066AC_CHECK_FUNC(if_nametoindex, ac_cv_have_if_nametoindex=yes,
4067		ac_cv_have_if_nametoindex=no)
4068case $ac_cv_have_if_nametoindex in
4069no)
4070	case "$host" in
4071	*-hp-hpux*)
4072		AC_CHECK_LIB(ipv6, if_nametoindex,
4073				ac_cv_have_if_nametoindex=yes
4074				LIBS="-lipv6 $LIBS",)
4075	;;
4076	esac
4077esac
4078case $ac_cv_have_if_nametoindex in
4079yes)
4080	ISC_PLATFORM_HAVEIFNAMETOINDEX="#define ISC_PLATFORM_HAVEIFNAMETOINDEX 1"
4081	AC_DEFINE(HAVE_IF_NAMETOINDEX, 1,
4082	[Define to 1 if you have the if_nametoindex function.])
4083	;;
4084*)
4085	ISC_PLATFORM_HAVEIFNAMETOINDEX="#undef ISC_PLATFORM_HAVEIFNAMETOINDEX"
4086	;;
4087esac
4088AC_SUBST(ISC_PLATFORM_HAVEIFNAMETOINDEX)
4089
4090AC_CHECK_FUNCS(nanosleep usleep explicit_bzero)
4091
4092#
4093# Machine architecture dependent features
4094#
4095have_stdatomic=no
4096AC_MSG_CHECKING(for usable stdatomic.h)
4097AC_TRY_COMPILE([
4098#include <stdio.h>
4099#include <stdatomic.h>
4100],
4101[
4102  #if ATOMIC_INT_LOCK_FREE == 2 && ATOMIC_LONG_LOCK_FREE == 2
4103  atomic_int_fast32_t val = 0; atomic_fetch_add_explicit(&val, 1, memory_order_relaxed);
4104  #else
4105  #error stdatomic not lock free
4106  #endif
4107],
4108        [AC_MSG_RESULT(yes)
4109	 have_stdatomic=yes
4110	 ISC_PLATFORM_HAVESTDATOMIC="#define ISC_PLATFORM_HAVESTDATOMIC 1"],
4111	[AC_MSG_RESULT(no)
4112	 have_stdatomic=no
4113	 ISC_PLATFORM_HAVESTDATOMIC="#undef ISC_PLATFORM_HAVESTDATOMIC"])
4114
4115# [pairwise: --enable-atomic, --disable-atomic]
4116AC_ARG_ENABLE(atomic,
4117	      AS_HELP_STRING([--enable-atomic],
4118			     [enable machine specific atomic operations [default=autodetect]]),
4119			enable_atomic="$enableval",
4120			enable_atomic="autodetect")
4121case "$enable_atomic" in
4122	yes|''|autodetect)
4123		case "$host" in
4124		powerpc-ibm-aix*)
4125			if test "X$GCC" = "Xyes"; then
4126				AC_MSG_CHECKING([if asm("ics"); works])
4127				AC_TRY_COMPILE(,[
4128				main() { asm("ics"); exit(0); }
4129				],
4130				[AC_MSG_RESULT(yes)
4131				 use_atomic=yes],
4132				[
4133				saved_cflags="$CFLAGS"
4134				CFLAGS="$CFLAGS -Wa,-many"
4135				AC_TRY_RUN([
4136				main() { asm("ics"); exit(0); }
4137				],
4138				[AC_MSG_RESULT([yes, required -Wa,-many])
4139				 use_atomic=yes],
4140				[AC_MSG_RESULT([no, use_atomic disabled])
4141				 CFLAGS="$saved_cflags"
4142				 use_atomic=no],
4143				[AC_MSG_RESULT([cross compile, assume yes])
4144				 CFLAGS="$saved_cflags"
4145				 use_atomic=yes])
4146				]
4147				)
4148			else
4149				use_atomic=yes
4150			fi
4151			;;
4152		*)
4153			use_atomic=yes
4154			;;
4155		esac
4156		;;
4157	no)
4158		have_stdatomic=no
4159		ISC_PLATFORM_HAVESTDATOMIC="#undef ISC_PLATFORM_HAVESTDATOMIC"
4160		use_atomic=no
4161		arch=noatomic
4162		;;
4163esac
4164
4165if test "X$have_stdatomic" = "Xyes"; then
4166    AC_MSG_CHECKING(if -latomic is needed to use 64-bit stdatomic.h primitives)
4167    AC_LINK_IFELSE(
4168	[AC_LANG_PROGRAM([#include <stdatomic.h>],
4169			 [atomic_int_fast64_t val = 0; atomic_fetch_add_explicit(&val, 1, memory_order_relaxed);])],
4170	[AC_MSG_RESULT(no)
4171	 ISC_ATOMIC_LIBS=""],
4172	[AC_MSG_RESULT(yes)
4173	 ISC_ATOMIC_LIBS="-latomic"]
4174    )
4175    LIBS="$LIBS $ISC_ATOMIC_LIBS"
4176fi
4177
4178AC_SUBST(ISC_PLATFORM_HAVESTDATOMIC)
4179
4180ISC_PLATFORM_USEOSFASM="#undef ISC_PLATFORM_USEOSFASM"
4181ISC_PLATFORM_USEGCCASM="#undef ISC_PLATFORM_USEGCCASM"
4182ISC_PLATFORM_USESTDASM="#undef ISC_PLATFORM_USESTDASM"
4183ISC_PLATFORM_USEMACASM="#undef ISC_PLATFORM_USEMACASM"
4184if test "yes" = "$use_atomic"; then
4185	have_atomic=yes		# set default
4186	case "$host" in
4187	[i[3456]86-*])
4188		# XXX: some old x86 architectures actually do not support
4189		#      (some of) these operations.  Do we need stricter checks?
4190		AC_CHECK_SIZEOF([void *])
4191		if test $ac_cv_sizeof_void_p = 8; then
4192			arch=x86_64
4193			have_xaddq=yes
4194		else
4195			arch=x86_32
4196		fi
4197	;;
4198	x86_64-*|amd64-*)
4199		AC_CHECK_SIZEOF([void *])
4200		if test $ac_cv_sizeof_void_p = 8; then
4201			arch=x86_64
4202			have_xaddq=yes
4203		else
4204			arch=x86_32
4205		fi
4206	;;
4207	alpha*-*)
4208		arch=alpha
4209	;;
4210	powerpc-*|powerpc64*-*|powerpc64el-*)
4211		arch=powerpc
4212	;;
4213	mips-*|mipsel-*|mips64-*|mips64el-*)
4214		arch=mips
4215	;;
4216	ia64-*)
4217		arch=ia64
4218	;;
4219	*)
4220		have_atomic=no
4221		arch=noatomic
4222	;;
4223	esac
4224	AC_MSG_CHECKING([architecture type for atomic operations])
4225	AC_MSG_RESULT($arch)
4226fi
4227
4228if test "yes" = "$have_atomic"; then
4229	AC_MSG_CHECKING([compiler support for inline assembly code])
4230
4231	compiler=generic
4232	# Check whether the compiler supports the assembly syntax we provide.
4233	if test "X$GCC" = "Xyes"; then
4234		# GCC's ASM extension always works
4235		compiler=gcc
4236		if test $arch = "x86_64"; then
4237			# We can share the same code for gcc with x86_32
4238			arch=x86_32
4239		fi
4240		if test $arch = "powerpc"; then
4241			#
4242			# The MacOS (and maybe others) uses "r0" for register
4243			# zero. Under linux/ibm it is "0" for register 0.
4244			# Probe to see if we have a MacOS style assembler.
4245			#
4246			AC_MSG_CHECKING([Checking for MacOS style assembler syntax])
4247			AC_TRY_COMPILE(, [
4248			__asm__ volatile ("li r0, 0x0\n"::);
4249			], [
4250			AC_MSG_RESULT(yes)
4251			compiler="mac"
4252			ISC_PLATFORM_USEMACASM="#define ISC_PLATFORM_USEMACASM 1"
4253			], [AC_MSG_RESULT(no)])
4254		fi
4255	else
4256		case "$host" in
4257		alpha*-dec-osf*)
4258			# Tru64 compiler has its own syntax for inline
4259			# assembly.
4260			AC_TRY_COMPILE(, [
4261#ifndef __DECC
4262#error "unexpected compiler"
4263#endif
4264				return (0);],
4265				[compiler=osf],)
4266		;;
4267		powerpc-ibm-aix*)
4268			compiler=aix
4269		;;
4270		esac
4271	fi
4272	case "$compiler" in
4273	gcc)
4274		ISC_PLATFORM_USEGCCASM="#define ISC_PLATFORM_USEGCCASM 1"
4275		;;
4276	osf)
4277		ISC_PLATFORM_USEOSFASM="#define ISC_PLATFORM_USEOSFASM 1"
4278		;;
4279	aix)
4280		;;
4281	mac)
4282		;;
4283	*)
4284		# See if the generic __asm function works.  If not,
4285		# we need to disable the atomic operations.
4286		AC_TRY_LINK(, [
4287					__asm("nop")
4288				],
4289		[compiler="standard"
4290		ISC_PLATFORM_USESTDASM="#define ISC_PLATFORM_USESTDASM 1"],
4291		[compiler="not supported (atomic operations disabled)"
4292		have_atomic=no
4293		arch=noatomic ]);
4294		;;
4295	esac
4296
4297	AC_MSG_RESULT($compiler)
4298fi
4299
4300if test "yes" = "$have_atomic"; then
4301	ISC_PLATFORM_HAVEXADD="#define ISC_PLATFORM_HAVEXADD 1"
4302	ISC_PLATFORM_HAVECMPXCHG="#define ISC_PLATFORM_HAVECMPXCHG 1"
4303	ISC_PLATFORM_HAVEATOMICSTORE="#define ISC_PLATFORM_HAVEATOMICSTORE 1"
4304	if test "yes" = "$have_xaddq"; then
4305		ISC_PLATFORM_HAVEXADDQ="#define ISC_PLATFORM_HAVEXADDQ 1"
4306		ISC_PLATFORM_HAVEATOMICSTOREQ="#define ISC_PLATFORM_HAVEATOMICSTOREQ 1"
4307	else
4308		ISC_PLATFORM_HAVEXADDQ="#undef ISC_PLATFORM_HAVEXADDQ"
4309		ISC_PLATFORM_HAVEATOMICSTOREQ="#undef ISC_PLATFORM_HAVEATOMICSTOREQ"
4310	fi
4311else
4312	ISC_PLATFORM_HAVEXADD="#undef ISC_PLATFORM_HAVEXADD"
4313	ISC_PLATFORM_HAVECMPXCHG="#undef ISC_PLATFORM_HAVECMPXCHG"
4314	ISC_PLATFORM_HAVEATOMICSTORE="#undef ISC_PLATFORM_HAVEATOMICSTORE"
4315	ISC_PLATFORM_HAVEXADDQ="#undef ISC_PLATFORM_HAVEXADDQ"
4316	ISC_PLATFORM_HAVEATOMICSTOREQ="#undef ISC_PLATFORM_HAVEATOMICSTOREQ"
4317fi
4318
4319AC_SUBST(ISC_PLATFORM_HAVEXADD)
4320AC_SUBST(ISC_PLATFORM_HAVEXADDQ)
4321AC_SUBST(ISC_PLATFORM_HAVECMPXCHG)
4322AC_SUBST(ISC_PLATFORM_HAVEATOMICSTORE)
4323AC_SUBST(ISC_PLATFORM_HAVEATOMICSTOREQ)
4324
4325AC_SUBST(ISC_PLATFORM_USEGCCASM)
4326AC_SUBST(ISC_PLATFORM_USEOSFASM)
4327AC_SUBST(ISC_PLATFORM_USESTDASM)
4328AC_SUBST(ISC_PLATFORM_USEMACASM)
4329
4330ISC_ARCH_DIR=$arch
4331AC_SUBST(ISC_ARCH_DIR)
4332
4333#
4334# Check for __builtin_unreachable
4335#
4336AC_MSG_CHECKING([compiler support for __builtin_unreachable()])
4337AC_LINK_IFELSE(
4338  [AC_LANG_PROGRAM(
4339     [[]],
4340     [[__builtin_unreachable();]]
4341   )],
4342  [AC_MSG_RESULT([yes])
4343   AC_DEFINE([HAVE_BUILTIN_UNREACHABLE], [1], [define if the compiler supports __builtin_unreachable().])
4344  ],
4345  [AC_MSG_RESULT([no])
4346  ])
4347
4348#
4349# Check for __builtin_expect
4350#
4351AC_MSG_CHECKING([compiler support for __builtin_expect])
4352AC_TRY_LINK(, [
4353	return (__builtin_expect(1, 1) ? 1 : 0);
4354], [
4355	have_builtin_expect=yes
4356	AC_MSG_RESULT(yes)
4357], [
4358	have_builtin_expect=no
4359	AC_MSG_RESULT(no)
4360])
4361if test "yes" = "$have_builtin_expect"; then
4362	AC_DEFINE(HAVE_BUILTIN_EXPECT, 1, [Define to 1 if the compiler supports __builtin_expect.])
4363fi
4364
4365#
4366# Check for __builtin_clz
4367#
4368AC_MSG_CHECKING([compiler support for __builtin_clz])
4369AC_TRY_LINK(, [
4370	return (__builtin_clz(0xff) == 24 ? 1 : 0);
4371], [
4372	have_builtin_clz=yes
4373	AC_MSG_RESULT(yes)
4374], [
4375	have_builtin_clz=no
4376	AC_MSG_RESULT(no)
4377])
4378if test "yes" = "$have_builtin_clz"; then
4379	AC_DEFINE(HAVE_BUILTIN_CLZ, 1, [Define to 1 if the compiler supports __builtin_clz.])
4380fi
4381
4382#
4383# CPU relax (for spin locks)
4384#
4385if $use_threads
4386then
4387	case "$host" in
4388	[i[3456]86-*])
4389		# x86_32
4390		AC_MSG_CHECKING([if asm("rep; nop"); works])
4391		AC_TRY_COMPILE(,[asm("rep; nop");],
4392		[AC_MSG_RESULT(yes)
4393		 ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"],
4394		[AC_MSG_RESULT(no)],
4395		[AC_MSG_RESULT([cross compile, assume yes])
4396		 ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"])
4397		;;
4398	x86_64-*|amd64-*)
4399		# x86_64
4400		AC_MSG_CHECKING([if asm("rep; nop"); works])
4401		AC_TRY_COMPILE(,[asm("rep; nop");],
4402		[AC_MSG_RESULT(yes)
4403		 ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"],
4404		[AC_MSG_RESULT(no)],
4405		[AC_MSG_RESULT([cross compile, assume yes])
4406		 ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"rep; nop\")"])
4407		;;
4408	ia64-*)
4409		# ia64
4410		AC_MSG_CHECKING([if asm("hint @pause"); works])
4411		AC_TRY_COMPILE(,[asm("hint @pause");],
4412		[AC_MSG_RESULT(yes)
4413		 ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"hint @pause\")"],
4414		[AC_MSG_RESULT(no)],
4415		[AC_MSG_RESULT([cross compile, assume yes])
4416		 ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP asm(\"hint @pause\")"])
4417		;;
4418	sparc-*)
4419		# sparc
4420		AC_MSG_CHECKING([if cpu_relax(); or __cpu_relax(); works])
4421		AC_CHECK_FUNC(cpu_relax,
4422		[AC_MSG_RESULT(yes)
4423		 ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP cpu_relax()"],
4424		 [AC_CHECK_FUNC(__cpu_relax,
4425		  [AC_MSG_RESULT(yes)
4426		   ISC_PLATFORM_BUSYWAITNOP="#define ISC_PLATFORM_BUSYWAITNOP __cpu_relax()"],
4427		   [AC_MSG_RESULT(no)])])
4428		;;
4429	esac
4430fi
4431
4432AC_SUBST(ISC_PLATFORM_BUSYWAITNOP)
4433
4434#
4435# Activate "rrset-order fixed" or not?
4436#
4437# [pairwise: --enable-fixed-rrset, --disable-fixed-rrset]
4438AC_ARG_ENABLE(fixed-rrset,
4439	      AS_HELP_STRING([--enable-fixed-rrset],
4440			     [enable fixed rrset ordering [default=no]]),
4441	      enable_fixed="$enableval", enable_fixed="no")
4442case "$enable_fixed" in
4443	yes)
4444		AC_DEFINE(DNS_RDATASET_FIXED, 1,
4445			  [Define to enable "rrset-order fixed" syntax.])
4446		;;
4447	no)
4448		;;
4449	*)
4450		;;
4451esac
4452
4453#
4454# Enable response policy rewriting using NS IP addresses
4455#
4456# [pairwise: --enable-rpz-nsip, --disable-rpz-nsip]
4457AC_ARG_ENABLE(rpz-nsip,
4458	      AS_HELP_STRING([--disable-rpz-nsip],
4459			     [disable rpz nsip rules [default=enabled]]),
4460	      enable_nsip="$enableval", enable_nsip="yes")
4461case "$enable_nsip" in
4462	yes)
4463		AC_DEFINE(ENABLE_RPZ_NSIP, 1,
4464			  [Define to enable rpz-nsip rules.])
4465		;;
4466	no)
4467		;;
4468	*)
4469		;;
4470esac
4471
4472#
4473# Enable response policy rewriting using NS name
4474#
4475# [pairwise: --enable-rpz-nsdname, --disable-rpz-nsdname]
4476AC_ARG_ENABLE(rpz-nsdname,
4477	      AS_HELP_STRING([--disable-rpz-nsdname],
4478			     [disable rpz nsdname rules [default=enabled]]),
4479	      enable_nsdname="$enableval", enable_nsdname="yes")
4480case "$enable_nsdname" in
4481	yes)
4482		AC_DEFINE(ENABLE_RPZ_NSDNAME, 1,
4483			  [Define to enable rpz-nsdname rules.])
4484		;;
4485	no)
4486		;;
4487	*)
4488		;;
4489esac
4490
4491#
4492# Activate "filter-aaaa-on-v4/v6" or not?
4493#
4494# [pairwise: --enable-filter-aaaa, --disable-filter-aaaa]
4495AC_ARG_ENABLE(filter-aaaa,
4496	[  --enable-filter-aaaa    enable filtering of AAAA records [[default=no]]],
4497			enable_filter="$enableval",
4498			enable_filter="no")
4499case "$enable_filter" in
4500	yes)
4501		AC_DEFINE(ALLOW_FILTER_AAAA, 1,
4502			  [Define to enable the "filter-aaaa-on-v4" and "filter-aaaa-on-v6" options.])
4503		;;
4504	no)
4505		;;
4506	*)
4507		;;
4508esac
4509
4510#
4511# Activate dnstap?
4512#
4513# [pairwise: --enable-dnstap, --disable-dnstap]
4514AC_ARG_ENABLE(dnstap,
4515	      AS_HELP_STRING([--enable-dnstap],
4516			     [enable dnstap support
4517				(requires fstrm, protobuf-c)]),
4518	      use_dnstap=$enableval, use_dnstap=no)
4519
4520DNSTAP=
4521DNSTAPSRCS=
4522DNSTAPOBJS=
4523DNSTAPTARGETS=
4524if test "x$use_dnstap" != "xno"; then
4525	if ! $use_threads; then
4526		AC_MSG_ERROR([Dnstap requires threads.])
4527	fi
4528
4529	# [pairwise: skip]
4530	AC_ARG_WITH([protobuf-c],
4531		    AS_HELP_STRING([--with-protobuf-c=path],
4532				   [Path where protobuf-c is installed,
4533					for dnstap]), [
4534	    # workaround for protobuf-c includes at old dir
4535	    # before protobuf-c-1.0.0
4536	    if test -f $withval/include/google/protobuf-c/protobuf-c.h
4537	    then
4538		CFLAGS="$CFLAGS -I$withval/include/google"
4539	    else
4540		CFLAGS="$CFLAGS -I$withval/include"
4541	    fi
4542	    LDFLAGS="$LDFLAGS -L$withval/lib"
4543	    AC_PATH_PROG([PROTOC_C], [protoc-c], [],
4544			 [$PATH$PATH_SEPARATOR$withval/bin])
4545	], [
4546	    # workaround for protobuf-c includes at old dir
4547	    # before protobuf-c-1.0.0
4548	    if test -f /usr/include/google/protobuf-c/protobuf-c.h
4549	    then
4550		CFLAGS="$CFLAGS -I/usr/include/google"
4551	    else
4552		if test -f /usr/local/include/google/protobuf-c/protobuf-c.h
4553		then
4554		    CFLAGS="$CFLAGS -I/usr/local/include/google"
4555		    LDFLAGS="$LDFLAGS -L/usr/local/lib"
4556		fi
4557	    fi
4558	    AC_PATH_PROG([PROTOC_C],[protoc-c])
4559	])
4560	if test -z "$PROTOC_C"; then
4561		AC_MSG_ERROR([The protoc-c program was not found.])
4562	fi
4563
4564	# [pairwise: skip]
4565	AC_ARG_WITH([libfstrm], AS_HELP_STRING([--with-libfstrm=path],
4566		    [Path where libfstrm is installed, for dnstap]), [
4567	    CFLAGS="$CFLAGS -I$withval/include"
4568	    LDFLAGS="$LDFLAGS -L$withval/lib"
4569	    AC_PATH_PROG([FSTRM_CAPTURE], [fstrm_capture], [], [$PATH$PATH_SEPARATOR$withval/bin])
4570	],[
4571	    AC_PATH_PROG([FSTRM_CAPTURE], [fstrm_capture])
4572	])
4573
4574	AC_SEARCH_LIBS([fstrm_iothr_init], [fstrm], [],
4575		       AC_MSG_ERROR([The fstrm library was not found. Please install fstrm!]))
4576	AC_SEARCH_LIBS([protobuf_c_message_pack], [protobuf-c], [],
4577		       AC_MSG_ERROR([The protobuf-c library was not found. Please install protobuf-c!]))
4578
4579	AC_DEFINE(HAVE_DNSTAP, 1, [Define to 1 to enable dnstap support])
4580	DNSTAP=dnstap
4581	DNSTAPSRCS='${DNSTAPSRCS}'
4582	DNSTAPOBJS='${DNSTAPOBJS}'
4583	DNSTAPTARGETS='${DNSTAPTARGETS}'
4584fi
4585AC_SUBST(DNSTAP)
4586AC_SUBST(DNSTAPSRCS)
4587AC_SUBST(DNSTAPOBJS)
4588AC_SUBST(DNSTAPTARGETS)
4589
4590#
4591#  The following sets up how non-blocking i/o is established.
4592#  Sunos, cygwin and solaris 2.x (x<5) require special handling.
4593#
4594case "$host" in
4595*-sunos*) AC_DEFINE(PORT_NONBLOCK, O_NDELAY);;
4596*-cygwin*) AC_DEFINE(PORT_NONBLOCK, O_NDELAY);;
4597*-solaris2.[[01234]])
4598	AC_DEFINE(PORT_NONBLOCK, O_NONBLOCK)
4599	AC_DEFINE(USE_FIONBIO_IOCTL, 1,
4600		  [Defined if you need to use ioctl(FIONBIO) instead a fcntl call to make non-blocking.])
4601	;;
4602*) AC_DEFINE(PORT_NONBLOCK, O_NONBLOCK,
4603	     [Sets which flag to pass to open/fcntl to make non-blocking (O_NDELAY/O_NONBLOCK).])
4604	;;
4605esac
4606#
4607# Solaris 2.5.1 and earlier cannot bind() then connect() a TCP socket.
4608# This prevents the source address being set.
4609#
4610case "$host" in
4611*-solaris2.[[012345]]|*-solaris2.5.1)
4612	AC_DEFINE(BROKEN_TCP_BIND_BEFORE_CONNECT, 1,
4613		  [Define if you cannot bind() before connect() for TCP sockets.])
4614	;;
4615esac
4616#
4617# The following sections deal with tools used for formatting
4618# the documentation.  They are all optional, unless you are
4619# a developer editing the documentation source.
4620#
4621
4622#
4623# Look for TeX.
4624#
4625
4626AC_PATH_PROGS(LATEX, latex, latex)
4627AC_SUBST(LATEX)
4628
4629AC_PATH_PROGS(PDFLATEX, pdflatex, pdflatex)
4630AC_SUBST(PDFLATEX)
4631
4632AC_PATH_PROGS(DBLATEX, dblatex, dblatex)
4633AC_SUBST(DBLATEX)
4634
4635#
4636# Look for w3m
4637#
4638
4639AC_PATH_PROGS(W3M, w3m, w3m)
4640AC_SUBST(W3M)
4641
4642#
4643# Look for pandoc
4644#
4645AC_PATH_PROG(PANDOC, pandoc, pandoc)
4646AC_SUBST(PANDOC)
4647
4648
4649#
4650# Look for xsltproc (libxslt)
4651#
4652
4653AC_PATH_PROG(XSLTPROC, xsltproc, xsltproc)
4654AC_SUBST(XSLTPROC)
4655
4656#
4657# Look for xmllint (libxml2)
4658#
4659
4660AC_PATH_PROG(XMLLINT, xmllint, xmllint)
4661AC_SUBST(XMLLINT)
4662
4663#
4664# Look for Doxygen
4665#
4666
4667AC_PATH_PROG(DOXYGEN, doxygen, doxygen)
4668AC_SUBST(DOXYGEN)
4669
4670#
4671# Look for curl
4672#
4673
4674AC_PATH_PROG(CURL, curl, curl)
4675AC_SUBST(CURL)
4676
4677#
4678# Subroutine for searching for an ordinary file (e.g., a stylesheet)
4679# in a number of directories:
4680#
4681#   NOM_PATH_FILE(VARIABLE, FILENAME, DIRECTORIES)
4682#
4683# If the file FILENAME is found in one of the DIRECTORIES, the shell
4684# variable VARIABLE is defined to its absolute pathname.  Otherwise,
4685# it is set to FILENAME, with no directory prefix (that's not terribly
4686# useful, but looks less confusing in substitutions than leaving it
4687# empty).  The variable VARIABLE will be substituted into output files.
4688#
4689
4690AC_DEFUN([NOM_PATH_FILE], [
4691$1=""
4692AC_MSG_CHECKING(for $2)
4693for d in $3
4694do
4695	f=$d/$2
4696	if test -f $f
4697	then
4698		$1=$f
4699		AC_MSG_RESULT($f)
4700		break
4701	fi
4702done
4703if test "X[$]$1" = "X"
4704then
4705	AC_MSG_RESULT("not found");
4706	$1=$2
4707fi
4708AC_SUBST($1)
4709])
4710
4711#
4712# Look for Docbook-XSL stylesheets.  Location probably varies by system.
4713# If it's not explicitly specified, guess where it might be found, based on
4714# where SGML stuff lives on some systems (FreeBSD is the only one we're sure
4715# of at the moment).
4716#
4717AC_MSG_CHECKING(for Docbook-XSL path)
4718
4719# [pairwise: skip]
4720AC_ARG_WITH(docbook-xsl,
4721	    AS_HELP_STRING([--with-docbook-xsl[=PATH]],
4722			   [specify path for Docbook-XSL stylesheets]),
4723   docbook_path="$withval", docbook_path="auto")
4724case "$docbook_path" in
4725auto)
4726	AC_MSG_RESULT(auto)
4727	docbook_xsl_trees="/usr/pkg/share/xsl/docbook /usr/local/share/xsl/docbook-ns /usr/local/share/xsl/docbook /usr/share/xsl/docbook /usr/share/sgml/docbook/xsl-stylesheets /opt/local/share/xsl/docbook-xsl /opt/local/share/xsl/docbook-xsl-nons /usr/share/xml/docbook/stylesheet/docbook-xsl"
4728	;;
4729*)
4730	docbook_xsl_trees="$withval"
4731	AC_MSG_RESULT($docbook_xsl_trees)
4732	;;
4733esac
4734
4735#
4736# Look for stylesheets we need.
4737#
4738
4739NOM_PATH_FILE(XSLT_DOCBOOK_STYLE_HTML, html/docbook.xsl, $docbook_xsl_trees)
4740NOM_PATH_FILE(XSLT_DOCBOOK_STYLE_XHTML, xhtml/docbook.xsl, $docbook_xsl_trees)
4741NOM_PATH_FILE(XSLT_DOCBOOK_STYLE_MAN, manpages/docbook.xsl, $docbook_xsl_trees)
4742NOM_PATH_FILE(XSLT_DOCBOOK_CHUNK_HTML, html/chunk.xsl, $docbook_xsl_trees)
4743NOM_PATH_FILE(XSLT_DOCBOOK_CHUNK_XHTML, xhtml/chunk.xsl, $docbook_xsl_trees)
4744NOM_PATH_FILE(XSLT_DOCBOOK_CHUNKTOC_HTML, html/chunktoc.xsl, $docbook_xsl_trees)
4745NOM_PATH_FILE(XSLT_DOCBOOK_CHUNKTOC_XHTML, xhtml/chunktoc.xsl, $docbook_xsl_trees)
4746NOM_PATH_FILE(XSLT_DOCBOOK_MAKETOC_HTML, html/maketoc.xsl, $docbook_xsl_trees)
4747NOM_PATH_FILE(XSLT_DOCBOOK_MAKETOC_XHTML, xhtml/maketoc.xsl, $docbook_xsl_trees)
4748
4749#
4750# IDN support using idnkit
4751#
4752# idnkit is not included in pairwise testing as it is not present in the
4753# relevant Docker image.
4754#
4755# [pairwise: skip]
4756AC_ARG_WITH(idnkit,
4757	    AS_HELP_STRING([--with-idnkit[=PATH]],
4758			   [enable IDN support using idnkit [yes|no|path]]),
4759	use_idnkit="$withval", use_idnkit="no")
4760case "$use_idnkit" in
4761yes)
4762	if test X$prefix = XNONE ; then
4763		idnkit_path=/usr/local
4764	else
4765		idnkit_path=$prefix
4766	fi
4767	;;
4768no)
4769	;;
4770*)
4771	idnkit_path="$use_idnkit"
4772	;;
4773esac
4774
4775iconvinc=
4776iconvlib=
4777
4778# [pairwise: --with-libiconv, --without-libiconv]
4779AC_ARG_WITH(libiconv,
4780	    AS_HELP_STRING([--with-libiconv[=IPREFIX]],
4781			   [GNU libiconv are in IPREFIX [default PREFIX]]),
4782	use_libiconv="$withval", use_libiconv="no")
4783case "$use_libiconv" in
4784yes)
4785	if test X$prefix = XNONE ; then
4786		iconvlib="-L/usr/local/lib -R/usr/local/lib -liconv"
4787	else
4788		iconvlib="-L$prefix/lib -R$prefix/lib -liconv"
4789	fi
4790	;;
4791no)
4792	iconvlib=
4793	;;
4794*)
4795	iconvlib="-L$use_libiconv/lib -R$use_libiconv/lib -liconv"
4796	;;
4797esac
4798
4799# [pairwise: --with-iconv, --without-iconv]
4800AC_ARG_WITH(iconv,
4801	    AS_HELP_STRING([--with-iconv[=LIBSPEC]],
4802			   [specify iconv library [default -liconv]]),
4803	    iconvlib="$withval")
4804case "$iconvlib" in
4805no)
4806	iconvlib=
4807	;;
4808yes)
4809	iconvlib=-liconv
4810	;;
4811esac
4812
4813# [pairwise: skip]
4814AC_ARG_WITH(idnlib,
4815	    AS_HELP_STRING([--with-idnlib=ARG], [specify libidnkit]),
4816	    idnlib="$withval", idnlib="no")
4817if test "yes" = "$idnlib"; then
4818	AC_MSG_ERROR([You must specify ARG for --with-idnlib.])
4819fi
4820
4821IDNKIT_LIBS=
4822if test "no" != "$use_idnkit"; then
4823	AC_DEFINE(WITH_IDNKIT, 1, [define if idnkit support is to be included.])
4824	STD_CINCLUDES="$STD_CINCLUDES -I$idnkit_path/include"
4825	if test "no" != "$idnlib"; then
4826		IDNKIT_LIBS="$idnlib $iconvlib"
4827	else
4828		IDNKIT_LIBS="-L$idnkit_path/lib -lidnkit $iconvlib"
4829	fi
4830fi
4831AC_SUBST(IDNKIT_LIBS)
4832
4833#
4834# IDN support using libidn2
4835#
4836
4837LIBIDN2_CFLAGS=
4838LIBIDN2_LDFLAGS=
4839LIBIDN2_LIBS=
4840
4841# [pairwise: --with-libidn2=yes, --without-libidn2]
4842AC_ARG_WITH(libidn2,
4843	AS_HELP_STRING([--with-libidn2[=PATH]], [enable IDN support using GNU libidn2 [yes|no|path]]),
4844	use_libidn2="$withval", use_libidn2="no")
4845AS_CASE([$use_libidn2],
4846	[no],[:],
4847	[yes],[:],
4848	[*],[
4849	    LIBIDN2_CFLAGS="-I$use_libidn2/include"
4850	    LIBIDN2_LDFLAGS="-L$use_libidn2/lib"
4851	])
4852
4853AS_IF([test "$use_libidn2" != "no"],
4854      [save_CFLAGS="$CFLAGS"
4855       save_LIBS="$LIBS"
4856       save_LDFLAGS="$LDFLAGS"
4857       CFLAGS="$LIBIDN2_CFLAGS $CFLAGS"
4858       LDFLAGS="$LIBIDN2_LDFLAGS $LDFLAGS"
4859       AC_SEARCH_LIBS([idn2_to_ascii_8z], [idn2],
4860		      [AC_DEFINE(WITH_IDN_SUPPORT, 1, [define if IDN input support is to be included.])
4861                       AC_DEFINE(WITH_LIBIDN2, 1, [define if libidn2 support is to be included.])
4862                       LIBIDN2_LIBS="$LIBIDN2_LDFLAGS -lidn2"],
4863		      [AC_MSG_ERROR([libidn2 requested, but not found])])
4864       AC_TRY_LINK([#include <idn2.h>],
4865		   [idn2_to_unicode_8zlz(".", NULL, IDN2_NONTRANSITIONAL|IDN2_NFC_INPUT);],
4866		   [AC_MSG_RESULT(yes)
4867		    AC_DEFINE(WITH_IDN_OUT_SUPPORT, 1, [define if IDN output support is to be included.])],
4868		   [AC_MSG_RESULT([no])])
4869       CFLAGS="$save_CFLAGS"
4870       LIBS="$save_LIBS"
4871       LDFLAGS="$save_LDFLAGS"
4872      ])
4873AC_SUBST([LIBIDN2_CFLAGS])
4874AC_SUBST([LIBIDN2_LIBS])
4875
4876#
4877# IDN support in general
4878#
4879
4880# check if idnkit and libidn2 are not used at the same time
4881if test "$use_idnkit" != no && test "$use_libidn2" != no; then
4882    AC_MSG_ERROR([idnkit and libidn2 cannot be used at the same time.])
4883fi
4884# the IDN support is on
4885if test "$use_idnkit" != no || test "$use_libidn2" != no; then
4886	AC_DEFINE(WITH_IDN_SUPPORT, 1, [define if IDN input support is to be included.])
4887	if test "$use_libidn2" = no || test "$use_libidn2_out" != no; then
4888		AC_DEFINE(WITH_IDN_OUT_SUPPORT, 1, [define if IDN output support is to be included.])
4889	fi
4890fi
4891
4892#
4893# Check whether to build with cmocka unit testing framework
4894#
4895# [pairwise: --with-cmocka, --without-cmocka]
4896AC_ARG_WITH([cmocka],
4897	    [AS_HELP_STRING([--with-cmocka=no],[enable cmocka based tests (default is no)])],
4898	    [:],[with_cmocka=no])
4899
4900AS_CASE([$with_cmocka],
4901	[no],[:],
4902	[yes],[
4903            PKG_CHECK_MODULES([CMOCKA], [cmocka >= 1.0.0],
4904			      [AC_DEFINE([HAVE_CMOCKA], [1], [Use cmocka])])
4905            ],
4906	[*],[
4907	    save_CFLAGS="$CFLAGS"
4908	    save_LIBS="$LIBS"
4909	    CFLAGS="$CFLAGS -I$with_cmocka/include"
4910	    LIBS="$LIBS -L$with_cmocka/lib"
4911	    AC_CHECK_HEADERS([cmocka.h],
4912			     [:],
4913			     [AC_MSG_ERROR([cmocka.h not found])],
4914			     [#include <stdarg.h>
4915			      #include <stddef.h>
4916			      #include <setjmp.h>
4917			     ])
4918	    AC_SEARCH_LIBS([cmocka_set_message_output],
4919			   [cmocka],
4920			   [
4921			       CMOCKA_CFLAGS="-Iwith_cmocka/include"
4922			       CMOCKA_LIBS="-L$with_cmocka/lib -lcmocka"
4923			       AC_DEFINE([HAVE_CMOCKA], [1], [Use cmocka])
4924			   ],
4925			   [AC_MSG_ERROR([cmocka unit testing framework not found in $with_cmocka path])])
4926	    ])
4927AC_SUBST([CMOCKA_CFLAGS])
4928AC_SUBST([CMOCKA_LIBS])
4929
4930#
4931# Check for kyua execution engine if CMocka was requested
4932# and bail out if execution engine was not found
4933#
4934AC_ARG_VAR([KYUA], [path to kyua execution engine])
4935AS_IF([test "$with_cmocka" != "no"],
4936      [AC_PATH_PROGS([KYUA], [kyua], [])
4937       AS_IF([test -z "$KYUA"],
4938             [AC_MSG_WARN([kyua test execution engine not found])],
4939             [UNITTESTS=tests])])
4940AC_SUBST([KYUA])
4941AC_SUBST([UNITTESTS])
4942
4943#
4944# Check for -Wl,--wrap= support
4945#
4946
4947save_LDFLAGS=$LDFLAGS
4948LDFLAGS="--wrap=printf"
4949
4950LD_WRAP_TESTS=false
4951enable_ld_wrap=no
4952AC_MSG_CHECKING([for linker support for --wrap option])
4953AC_LINK_IFELSE(
4954    [AC_LANG_PROGRAM([#include <stdio.h>], [__wrap_printf("success"); return (0);])],
4955    [enable_ld_wrap=yes
4956     LD_WRAP_TESTS=true
4957     AC_DEFINE([LD_WRAP], [1], [define if the linker supports --wrap option])
4958     AC_MSG_RESULT([yes])],
4959    [AC_MSG_RESULT([no])])
4960# AM_CONDITIONAL([LD_WRAP], [test $enable_ld_wrap = yes])
4961AC_SUBST([LD_WRAP_TESTS])
4962
4963LDFLAGS=$save_LDFLAGS
4964
4965#
4966# Check for i18n
4967#
4968AC_CHECK_HEADERS(locale.h)
4969AC_CHECK_FUNCS(setlocale)
4970
4971#
4972# was --with-tuning specified?
4973#
4974# [pairwise: --with-tuning=large, --without-tuning]
4975AC_ARG_WITH(tuning,
4976	    AS_HELP_STRING([--with-tuning=ARG],
4977			   [Specify server tuning (large or default)]),
4978	    use_tuning="$withval", use_tuning="no")
4979
4980case "$use_tuning" in
4981	large)
4982		if ! $use_threads; then
4983			AC_MSG_ERROR([Large-system tuning requires threads.])
4984		fi
4985		AC_DEFINE(TUNE_LARGE, 1, [Define to use large-system tuning.])
4986		AC_MSG_RESULT(using large-system tuning)
4987		;;
4988	no|default)
4989		AC_MSG_RESULT(using default tuning)
4990		;;
4991	yes|*)
4992		AC_MSG_ERROR([You must specify "large" or "default" for --with-tuning.])
4993		;;
4994esac
4995
4996#
4997# was --enable-querytrace specified?
4998#
4999# [pairwise: --enable-querytrace, --disable-querytrace]
5000AC_ARG_ENABLE(querytrace,
5001	      AS_HELP_STRING([--enable-querytrace],
5002			     [enable very verbose query trace logging
5003				[default=no]]),
5004	      want_querytrace="$enableval", want_querytrace="no")
5005
5006AC_MSG_CHECKING([whether to enable query trace logging])
5007case "$want_querytrace" in
5008yes)
5009	AC_MSG_RESULT(yes)
5010	AC_DEFINE(WANT_QUERYTRACE, 1, [Define to enable very verbose query trace logging.])
5011	;;
5012no)
5013	AC_MSG_RESULT(no)
5014	;;
5015*)
5016	AC_MSG_ERROR("--enable-querytrace requires yes or no")
5017	;;
5018esac
5019
5020#
5021# Substitutions
5022#
5023AC_SUBST(BIND9_TOP_BUILDDIR)
5024BIND9_TOP_BUILDDIR=`pwd`
5025
5026AC_SUBST(BIND9_ISC_BUILDINCLUDE)
5027AC_SUBST(BIND9_ISCCC_BUILDINCLUDE)
5028AC_SUBST(BIND9_ISCCFG_BUILDINCLUDE)
5029AC_SUBST(BIND9_DNS_BUILDINCLUDE)
5030AC_SUBST(BIND9_LWRES_BUILDINCLUDE)
5031AC_SUBST(BIND9_BIND9_BUILDINCLUDE)
5032AC_SUBST(BIND9_IRS_BUILDINCLUDE)
5033if test "X$srcdir" != "X"; then
5034	BIND9_ISC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isc/include"
5035	BIND9_ISCCC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isccc/include"
5036	BIND9_ISCCFG_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isccfg/include"
5037	BIND9_DNS_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/dns/include"
5038	BIND9_LWRES_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/lwres/include"
5039	BIND9_BIND9_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/bind9/include"
5040	BIND9_IRS_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/irs/include"
5041else
5042	BIND9_ISC_BUILDINCLUDE=""
5043	BIND9_ISCCC_BUILDINCLUDE=""
5044	BIND9_ISCCFG_BUILDINCLUDE=""
5045	BIND9_DNS_BUILDINCLUDE=""
5046	BIND9_LWRES_BUILDINCLUDE=""
5047	BIND9_BIND9_BUILDINCLUDE=""
5048	BIND9_IRS_BUILDINCLUDE=""
5049fi
5050
5051AC_SUBST_FILE(BIND9_MAKE_INCLUDES)
5052BIND9_MAKE_INCLUDES=$BIND9_TOP_BUILDDIR/make/includes
5053
5054AC_SUBST_FILE(BIND9_MAKE_RULES)
5055BIND9_MAKE_RULES=$BIND9_TOP_BUILDDIR/make/rules
5056
5057. "$srcdir/version"
5058BIND9_PRODUCT="PRODUCT=\"${PRODUCT}\""
5059AC_SUBST(BIND9_PRODUCT)
5060BIND9_DESCRIPTION="DESCRIPTION=\"${DESCRIPTION}\""
5061AC_SUBST(BIND9_DESCRIPTION)
5062BIND9_VERSION="${MAJORVER}.${MINORVER}${PATCHVER:+.}${PATCHVER}${RELEASETYPE}${RELEASEVER}${EXTENSIONS}"
5063AC_SUBST(BIND9_VERSION)
5064BIND9_MAJOR="MAJOR=${MAJORVER}.${MINORVER}"
5065AC_SUBST(BIND9_MAJOR)
5066BIND9_VERSIONSTRING="${PRODUCT} ${MAJORVER}.${MINORVER}${PATCHVER:+.}${PATCHVER}${RELEASETYPE}${RELEASEVER}${EXTENSIONS}${DESCRIPTION:+ }${DESCRIPTION}"
5067AC_SUBST(BIND9_VERSIONSTRING)
5068BIND9_VERSIONSHORT="${PRODUCT} ${MAJORVER}.${MINORVER}${PATCHVER:+.}${PATCHVER}${RELEASETYPE}${RELEASEVER}${EXTENSIONS}"
5069AC_SUBST(BIND9_VERSIONSHORT)
5070
5071BIND9_SRCID="SRCID=unset_id"
5072if test -f "${srcdir}/srcid"; then
5073	. "${srcdir}/srcid"
5074	BIND9_SRCID="SRCID=$SRCID"
5075elif test -d "${srcdir}/.git"; then
5076	BIND9_SRCID="SRCID="`(cd "${srcdir}";git rev-parse --short HEAD)`
5077fi
5078
5079AC_SUBST(BIND9_SRCID)
5080
5081if test -z "$ac_configure_args"; then
5082	BIND9_CONFIGARGS="defaults"
5083else
5084	for a in $ac_configure_args
5085	do
5086		BIND9_CONFIGARGS="$BIND9_CONFIGARGS $a"
5087	done
5088fi
5089BIND9_CONFIGARGS="`echo $BIND9_CONFIGARGS | sed 's/^ //'`"
5090BIND9_CONFIGARGS="CONFIGARGS=${BIND9_CONFIGARGS}"
5091AC_SUBST(BIND9_CONFIGARGS)
5092
5093AC_SUBST_FILE(LIBISC_API)
5094LIBISC_API="$srcdir/lib/isc/api"
5095
5096AC_SUBST_FILE(LIBISCCC_API)
5097LIBISCCC_API="$srcdir/lib/isccc/api"
5098
5099AC_SUBST_FILE(LIBISCCFG_API)
5100LIBISCCFG_API="$srcdir/lib/isccfg/api"
5101
5102AC_SUBST_FILE(LIBDNS_API)
5103LIBDNS_API="$srcdir/lib/dns/api"
5104
5105AC_SUBST_FILE(LIBDNS_MAPAPI)
5106LIBDNS_MAPAPI="$srcdir/lib/dns/mapapi"
5107
5108AC_SUBST_FILE(LIBBIND9_API)
5109LIBBIND9_API="$srcdir/lib/bind9/api"
5110
5111AC_SUBST_FILE(LIBLWRES_API)
5112LIBLWRES_API="$srcdir/lib/lwres/api"
5113
5114AC_SUBST_FILE(LIBIRS_API)
5115LIBIRS_API="$srcdir/lib/irs/api"
5116
5117#
5118# Configure any DLZ drivers.
5119#
5120# If config.dlz.in selects one or more DLZ drivers, it will set
5121# CONTRIB_DLZ to a non-empty value, which will be our clue to
5122# build DLZ drivers in contrib.
5123#
5124# This section has to come after the libtool stuff because it needs to
5125# know how to name the driver object files.
5126#
5127
5128CONTRIB_DLZ=""
5129DLZ_DRIVER_INCLUDES=""
5130DLZ_DRIVER_LIBS=""
5131DLZ_DRIVER_SRCS=""
5132DLZ_DRIVER_OBJS=""
5133DLZ_SYSTEM_TEST=""
5134DLZ_DRIVER_MYSQL_INCLUDES=""
5135DLZ_DRIVER_MYSQL_LIBS=""
5136
5137#
5138# Configure support for building a shared library object
5139#
5140# Even when libtool is available it can't always be relied upon
5141# to build an object that can be dlopen()'ed, but this is necessary
5142# for building the dlzexternal system test, so we'll try it the
5143# old-fashioned way.
5144#
5145SO="so"
5146SO_CFLAGS=""
5147SO_LDFLAGS=""
5148SO_LD=""
5149SO_TARGETS=""
5150SO_STRIP="cat"
5151
5152# [pairwise: skip]
5153AC_ARG_WITH([dlopen],
5154	    AS_HELP_STRING([--with-dlopen=ARG],
5155			   [support dynamically loadable DLZ drivers]),
5156	    [], [with_dlopen="auto"])
5157
5158#
5159# Disable for SunOS
5160#
5161AS_CASE([$host],[*-sunos*],[with_dlopen="no"])
5162
5163#
5164# If PIC is disabled, dlopen must also be
5165#
5166AS_IF([test "$pic_mode" = "no"],
5167      [AS_CASE([$with_dlopen],
5168	       [auto],[with_dlopen="no"],
5169	       [yes],[AC_MSG_ERROR([--with-dlopen requires PIC])])])
5170
5171AS_CASE([$with_dlopen],
5172	[auto|yes],[
5173	  # -fsanitize=thread hijacks dlopen and dlclose so use dlsym.
5174	  AC_SEARCH_LIBS([dlsym],[dl])
5175	  AC_CHECK_FUNCS([dlopen dlclose dlsym],
5176			 [with_dlopen="yes"],
5177			 [with_dlopen="no"])
5178	])
5179
5180AS_IF([test "$with_dlopen" = "yes"],
5181      [AS_CASE([$host],
5182	       [*-linux*|*-gnu*],[
5183		 LDFLAGS="${LDFLAGS} -Wl,--export-dynamic"
5184		 SO_CFLAGS="-fPIC"
5185		 SO_LDFLAGS=""
5186		 AS_IF([test "$use_libtool" = "yes"],[
5187			 SO_LDFLAGS="-Xcompiler -shared"
5188			 SO_LD="${CC}"
5189		       ],[
5190			 SO_LDFLAGS="-shared"
5191			 SO_LD="${CC}"
5192		       ])
5193	       ],
5194	       [*-freebsd*|*-openbsd*|*-netbsd*],[
5195		 LDFLAGS="${LDFLAGS} -Wl,-E"
5196		 SO_CFLAGS="-fpic"
5197		 AS_IF([test "$use_libtool" = "yes"],[
5198			 SO_LDFLAGS="-Xcompiler -shared"
5199			 SO_LD="${CC}"
5200		       ],[
5201			 SO_LDFLAGS="-shared"
5202			 SO_LD="${CC}"
5203		       ])
5204	       ],
5205	       [*-darwin*],[
5206		 SO_CFLAGS="-fPIC"
5207                 SO_LD="${CC}"
5208		 AS_IF([test "$use_libtool" = "yes"],[
5209			 SO_LDFLAGS="-Xcompiler -dynamiclib -undefined dynamic_lookup"
5210		       ],[
5211			 SO_LDFLAGS="-dynamiclib -undefined dynamic_lookup"
5212		       ])
5213	       ],
5214	       [*-solaris*],[
5215		 SO_CFLAGS="-KPIC"
5216		 SO_LDFLAGS="-G -z text"
5217		 SO_LD="ld"
5218	       ],
5219	       [ia64-hp-hpux*],[
5220		 SO_CFLAGS="+z"
5221	         SO_LDFLAGS="-b"
5222		 SO_LD="${CC}"
5223	       ],
5224	       [
5225		 SO_CFLAGS="-fPIC"
5226	       ])
5227       AS_IF([test "$GCC" = "yes"],[
5228	       SO_CFLAGS="-fPIC"
5229	       AS_IF([test -z "$SO_LD"],
5230		     [AS_IF([test "$use_libtool" = "yes"],[
5231			      SO_LDFLAGS="-Xcompiler -shared"
5232			      SO_LD="${CC}"
5233			    ],[
5234			      SO_LDFLAGS="-shared"
5235			      SO_LD="${CC}"
5236			    ])
5237		     ])
5238	     ])
5239       # If we still don't know how to make shared objects, don't make any.
5240       AS_IF([test -n "$SO_LD"],
5241	     [SO_TARGETS="\${SO_TARGETS}"
5242	      AC_DEFINE([ISC_DLZ_DLOPEN], [1],
5243			[Define to allow building of objects for dlopen().])
5244	     ])
5245      ])
5246
5247AS_IF([test "$with_dlopen" = "no" -a "$want_native_pkcs11" = "yes"],
5248      [AC_MSG_ERROR([PKCS11 requires dlopen() support])])
5249
5250CFLAGS="$CFLAGS $SO_CFLAGS"
5251
5252AC_SUBST(SO)
5253AC_SUBST(SO_CFLAGS)
5254AC_SUBST(SO_LDFLAGS)
5255AC_SUBST(SO_LD)
5256AC_SUBST(SO_STRIP)
5257AC_SUBST(SO_TARGETS)
5258sinclude(contrib/dlz/config.dlz.in)
5259AC_MSG_CHECKING(contributed DLZ drivers)
5260
5261if test -n "$CONTRIB_DLZ"
5262then
5263	AC_MSG_RESULT(yes)
5264	DLZ_DRIVER_RULES=contrib/dlz/drivers/rules
5265	AC_CONFIG_FILES([$DLZ_DRIVER_RULES
5266		contrib/dlz/modules/mysql/Makefile
5267		contrib/dlz/modules/mysqldyn/Makefile])
5268else
5269	AC_MSG_RESULT(no)
5270	DLZ_DRIVER_RULES=/dev/null
5271fi
5272
5273AC_SUBST(CONTRIB_DLZ)
5274AC_SUBST(DLZ_DRIVER_INCLUDES)
5275AC_SUBST(DLZ_DRIVER_LIBS)
5276AC_SUBST(DLZ_DRIVER_SRCS)
5277AC_SUBST(DLZ_DRIVER_OBJS)
5278AC_SUBST(DLZ_SYSTEM_TEST)
5279AC_SUBST(DLZ_DRIVER_MYSQL_INCLUDES)
5280AC_SUBST(DLZ_DRIVER_MYSQL_LIBS)
5281AC_SUBST_FILE(DLZ_DRIVER_RULES)
5282
5283if test "yes" = "$cross_compiling"; then
5284	if test -z "$BUILD_CC"; then
5285		AC_MSG_ERROR([BUILD_CC not set])
5286	fi
5287	BUILD_CFLAGS="$BUILD_CFLAGS"
5288	BUILD_CPPFLAGS="$BUILD_CPPFLAGS"
5289	BUILD_LDFLAGS="$BUILD_LDFLAGS"
5290	BUILD_LIBS="$BUILD_LIBS"
5291else
5292	BUILD_CC="$CC"
5293	BUILD_CFLAGS="$CFLAGS"
5294	BUILD_CPPFLAGS="$CPPFLAGS $GEN_NEED_OPTARG"
5295	BUILD_LDFLAGS="$LDFLAGS"
5296	BUILD_LIBS="$LIBS"
5297fi
5298
5299NEWFLAGS=""
5300for e in $BUILD_LDFLAGS ; do
5301    case $e in
5302	-L*)
5303	    case $host_os in
5304		netbsd*)
5305		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
5306		    NEWFLAGS="$NEWFLAGS $e $ee"
5307		    ;;
5308		freebsd*)
5309		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
5310		    NEWFLAGS="$NEWFLAGS $e $ee"
5311		    ;;
5312		solaris*)
5313		    ee=`echo $e | sed -e 's%^-L%-R%'`
5314		    NEWFLAGS="$NEWFLAGS $e $ee"
5315		    ;;
5316		*)
5317		    NEWFLAGS="$NEWFLAGS $e"
5318		    ;;
5319		esac
5320	    ;;
5321	*)
5322	    NEWFLAGS="$NEWFLAGS $e"
5323	    ;;
5324    esac
5325done
5326BUILD_LDFLAGS="$NEWFLAGS"
5327
5328NEWFLAGS=""
5329for e in $DNS_GSSAPI_LIBS ; do
5330    case $e in
5331	-L*)
5332	    case $host_os in
5333		netbsd*)
5334		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
5335		    NEWFLAGS="$NEWFLAGS $e $ee"
5336		    ;;
5337		freebsd*)
5338		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
5339		    NEWFLAGS="$NEWFLAGS $e $ee"
5340		    ;;
5341		solaris*)
5342		    ee=`echo $e | sed -e 's%^-L%-R%'`
5343		    NEWFLAGS="$NEWFLAGS $e $ee"
5344		    ;;
5345		*)
5346		    NEWFLAGS="$NEWFLAGS $e"
5347		    ;;
5348		esac
5349	    ;;
5350	*)
5351	    NEWFLAGS="$NEWFLAGS $e"
5352	    ;;
5353    esac
5354done
5355DNS_GSSAPI_LIBS="$NEWFLAGS"
5356
5357NEWFLAGS=""
5358for e in $ISC_OPENSSL_LIBS ; do
5359    case $e in
5360	-L*)
5361	    case $host_os in
5362		netbsd*)
5363		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
5364		    NEWFLAGS="$NEWFLAGS $e $ee"
5365		    ;;
5366		freebsd*)
5367		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
5368		    NEWFLAGS="$NEWFLAGS $e $ee"
5369		    ;;
5370		solaris*)
5371		    ee=`echo $e | sed -e 's%^-L%-R%'`
5372		    NEWFLAGS="$NEWFLAGS $e $ee"
5373		    ;;
5374		*)
5375		    NEWFLAGS="$NEWFLAGS $e"
5376		    ;;
5377		esac
5378	    ;;
5379	*)
5380	    NEWFLAGS="$NEWFLAGS $e"
5381	    ;;
5382    esac
5383done
5384ISC_OPENSSL_LIBS="$NEWFLAGS"
5385
5386NEWFLAGS=""
5387for e in $DNS_CRYPTO_LIBS ; do
5388    case $e in
5389	-L*)
5390	    case $host_os in
5391		netbsd*)
5392		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
5393		    NEWFLAGS="$NEWFLAGS $e $ee"
5394		    ;;
5395		freebsd*)
5396		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
5397		    NEWFLAGS="$NEWFLAGS $e $ee"
5398		    ;;
5399		solaris*)
5400		    ee=`echo $e | sed -e 's%^-L%-R%'`
5401		    NEWFLAGS="$NEWFLAGS $e $ee"
5402		    ;;
5403		*)
5404		    NEWFLAGS="$NEWFLAGS $e"
5405		    ;;
5406		esac
5407	    ;;
5408	*)
5409	    NEWFLAGS="$NEWFLAGS $e"
5410	    ;;
5411    esac
5412done
5413DNS_CRYPTO_LIBS="$NEWFLAGS"
5414
5415AC_SUBST(BUILD_CC)
5416AC_SUBST(BUILD_CFLAGS)
5417AC_SUBST(BUILD_CPPFLAGS)
5418AC_SUBST(BUILD_LDFLAGS)
5419AC_SUBST(BUILD_LIBS)
5420
5421#
5422# Commands to run at the end of config.status.
5423# Don't just put these into configure, it won't work right if somebody
5424# runs config.status directly (which autoconf allows).
5425#
5426
5427AC_CONFIG_COMMANDS(
5428	[chmod],
5429	[chmod a+x isc-config.sh doc/doxygen/doxygen-input-filter])
5430
5431#
5432# Files to configure.  These are listed here because we used to
5433# specify them as arguments to AC_OUTPUT.  It's (now) ok to move these
5434# elsewhere if there's a good reason for doing so.
5435#
5436
5437AC_CONFIG_FILES([
5438	Makefile
5439	bin/Makefile
5440	bin/check/Makefile
5441	bin/confgen/Makefile
5442	bin/confgen/unix/Makefile
5443	bin/delv/Makefile
5444	bin/dig/Makefile
5445	bin/dnssec/Makefile
5446	bin/named/Makefile
5447	bin/named/unix/Makefile
5448	bin/nsupdate/Makefile
5449	bin/pkcs11/Makefile
5450	bin/python/Makefile
5451	bin/python/dnssec-checkds.py
5452	bin/python/dnssec-coverage.py
5453	bin/python/dnssec-keymgr.py
5454	bin/python/isc/Makefile
5455	bin/python/isc/__init__.py
5456	bin/python/isc/checkds.py
5457	bin/python/isc/coverage.py
5458	bin/python/isc/dnskey.py
5459	bin/python/isc/eventlist.py
5460	bin/python/isc/keydict.py
5461	bin/python/isc/keyevent.py
5462	bin/python/isc/keymgr.py
5463	bin/python/isc/keyseries.py
5464	bin/python/isc/keyzone.py
5465	bin/python/isc/policy.py
5466	bin/python/isc/rndc.py
5467	bin/python/isc/tests/Makefile
5468	bin/python/isc/tests/dnskey_test.py
5469	bin/python/isc/tests/policy_test.py
5470	bin/python/isc/utils.py
5471	bin/rndc/Makefile
5472	bin/tests/Makefile
5473	bin/tests/headerdep_test.sh
5474	bin/tests/optional/Makefile
5475	bin/tests/pkcs11/Makefile
5476	bin/tests/pkcs11/benchmarks/Makefile
5477	bin/tests/system/Makefile
5478	bin/tests/system/conf.sh
5479	bin/tests/system/dlzexternal/Makefile
5480	bin/tests/system/dlzexternal/ns1/dlzs.conf
5481	bin/tests/system/dyndb/Makefile
5482	bin/tests/system/dyndb/driver/Makefile
5483	bin/tests/system/inline/checkdsa.sh
5484	bin/tests/system/lwresd/Makefile
5485	bin/tests/system/pipelined/Makefile
5486	bin/tests/system/rndc/Makefile
5487	bin/tests/system/rsabigexponent/Makefile
5488	bin/tests/system/tkey/Makefile
5489	bin/tests/virtual-time/Makefile
5490	bin/tests/virtual-time/conf.sh
5491	bin/tools/Makefile
5492	contrib/scripts/check-secure-delegation.pl
5493	contrib/scripts/zone-edit.sh
5494	doc/Makefile
5495	doc/arm/Makefile
5496	doc/arm/noteversion.xml
5497	doc/arm/pkgversion.xml
5498	doc/arm/releaseinfo.xml
5499	doc/doxygen/Doxyfile
5500	doc/doxygen/Makefile
5501	doc/doxygen/doxygen-input-filter
5502	doc/misc/Makefile
5503	doc/tex/Makefile
5504	doc/tex/armstyle.sty
5505	doc/xsl/Makefile
5506	doc/xsl/isc-docbook-chunk.xsl
5507	doc/xsl/isc-docbook-html.xsl
5508	doc/xsl/isc-manpage.xsl
5509	doc/xsl/isc-notes-html.xsl
5510	isc-config.sh
5511	lib/Makefile
5512	lib/bind9/Makefile
5513	lib/bind9/include/Makefile
5514	lib/bind9/include/bind9/Makefile
5515	lib/dns/Makefile
5516	lib/dns/include/Makefile
5517	lib/dns/include/dns/Makefile
5518	lib/dns/include/dst/Makefile
5519	lib/dns/tests/Makefile
5520	lib/irs/Makefile
5521	lib/irs/include/Makefile
5522	lib/irs/include/irs/Makefile
5523	lib/irs/include/irs/netdb.h
5524	lib/irs/include/irs/platform.h
5525	lib/irs/tests/Makefile
5526	lib/isc/$arch/Makefile
5527	lib/isc/$arch/include/Makefile
5528	lib/isc/$arch/include/isc/Makefile
5529	lib/isc/$thread_dir/Makefile
5530	lib/isc/$thread_dir/include/Makefile
5531	lib/isc/$thread_dir/include/isc/Makefile
5532	lib/isc/Makefile
5533	lib/isc/include/Makefile
5534	lib/isc/include/isc/Makefile
5535	lib/isc/include/isc/platform.h
5536	lib/isc/include/pk11/Makefile
5537	lib/isc/include/pkcs11/Makefile
5538	lib/isc/nls/Makefile
5539	lib/isc/tests/Makefile
5540	lib/isc/unix/Makefile
5541	lib/isc/unix/include/Makefile
5542	lib/isc/unix/include/isc/Makefile
5543	lib/isc/unix/include/pkcs11/Makefile
5544	lib/isccc/Makefile
5545	lib/isccc/include/Makefile
5546	lib/isccc/include/isccc/Makefile
5547	lib/isccc/tests/Makefile
5548	lib/isccfg/Makefile
5549	lib/isccfg/include/Makefile
5550	lib/isccfg/include/isccfg/Makefile
5551	lib/isccfg/tests/Makefile
5552	lib/lwres/Makefile
5553	lib/lwres/include/Makefile
5554	lib/lwres/include/lwres/Makefile
5555	lib/lwres/include/lwres/netdb.h
5556	lib/lwres/include/lwres/platform.h
5557	lib/lwres/man/Makefile
5558	lib/lwres/tests/Makefile
5559	lib/lwres/unix/Makefile
5560	lib/lwres/unix/include/Makefile
5561	lib/lwres/unix/include/lwres/Makefile
5562	lib/samples/Makefile
5563	lib/samples/Makefile-postinstall
5564	make/Makefile
5565	make/mkdep
5566	unit/unittest.sh
5567	util/check-make-install
5568])
5569
5570#
5571# Do it
5572#
5573
5574AC_OUTPUT
5575
5576#
5577# Now that the Makefiles exist we can ensure that everything is rebuilt.
5578#
5579# [pairwise: --with-make-clean, --without-make-clean]
5580AC_ARG_WITH(make-clean,
5581	    AS_HELP_STRING([--with-make-clean],
5582			   [run "make clean" at end of configure [yes|no]]),
5583	    make_clean="$withval", make_clean="yes")
5584case "$make_clean" in
5585yes)
5586	if test "yes" != "$no_create"
5587	then
5588		if test "yes" = "$silent"
5589		then
5590			make clean > /dev/null
5591		else
5592			make clean
5593		fi
5594	fi
5595	;;
5596esac
5597
5598# [pairwise: --enable-full-report, --disable-full-report]
5599AC_ARG_ENABLE(full-report,
5600	      AS_HELP_STRING([--enable-full-report],
5601			     [report values of all configure options]))
5602
5603report() {
5604    echo "==============================================================================="
5605    echo "Configuration summary:"
5606    echo "-------------------------------------------------------------------------------"
5607    echo "Optional features enabled:"
5608    if $use_threads; then
5609	echo "    Multiprocessing support (--enable-threads)"
5610	if test "yes" = "$enable_full_report" -o "standard" = "$locktype"; then
5611	    echo "        Mutex lock type: $locktype"
5612	fi
5613    fi
5614    test "large" = "$use_tuning" && echo "    Large-system tuning (--with-tuning)"
5615    test "no" = "$use_dnstap" || \
5616	    echo "    Allow 'dnstap' packet logging (--enable-dnstap)"
5617    test -z "$MAXMINDDB_LIBS" || echo "    GeoIP2 access control (--with-geoip2)"
5618    test "no" = "$use_geoip" || echo "    Legacy GeoIP access control (--with-geoip)"
5619    test "no" = "$use_gssapi" || echo "    GSS-API (--with-gssapi)"
5620
5621    # these lines are only printed if run with --enable-full-report
5622    if test "yes" = "$enable_full_report"; then
5623	test "no" = "$enable_ipv6" -o "no" = "$found_ipv6" || \
5624	    echo "    IPv6 support (--enable-ipv6)"
5625	test "X$CRYPTO" = "X" -o "yes" = "$want_native_pkcs11" || \
5626		echo "    OpenSSL cryptography/DNSSEC (--with-openssl)"
5627	test "X$PYTHON" = "X" || echo "    Python tools (--with-python)"
5628	test "X$XMLSTATS" = "X" || echo "    XML statistics (--with-libxml2)"
5629	test "X$JSONSTATS" = "X" || echo "    JSON statistics (--with-libjson)"
5630	test "X$ZLIB" = "X" || echo "    HTTP zlib compression (--with-zlib)"
5631	test "X$NZD_TOOLS" = "X" || echo "    LMDB database to store configuration for 'addzone' zones (--with-lmdb)"
5632	test "no" = "$use_libidn2" || echo "    IDN support (--with-libidn2)"
5633    fi
5634
5635    if test "no" != "$use_pkcs11"; then
5636	if test "yes" = "$want_native_pkcs11"; then
5637	    echo "    Native PKCS#11/Cryptoki support (--enable-native-pkcs11)"
5638	else
5639	    echo "    PKCS#11/Cryptoki support using OpenSSL (--with-pkcs11)"
5640	fi
5641	echo "        Provider library: $PKCS11_PROVIDER"
5642    fi
5643    if test "yes" = "$OPENSSL_GOST" -o "yes" = "$PKCS11_GOST"; then
5644	echo "    GOST algorithm support (encoding: $gosttype) (--with-gost)"
5645    fi
5646    test "yes" = "$OPENSSL_ECDSA" -o "$PKCS11_ECDSA" && \
5647	echo "    ECDSA algorithm support (--with-ecdsa)"
5648    test "yes" = "$OPENSSL_ED25519" -o "$PKCS11_ED25519" && \
5649	echo "    EDDSA algorithm support (--with-eddsa)"
5650    test "yes" = "$enable_fixed" && \
5651	echo "    Allow 'fixed' rrset-order (--enable-fixed-rrset)"
5652    test "yes" = "$enable_filter" && \
5653	echo "    AAAA filtering (--enable-filter-aaaa)"
5654    test "yes" = "$enable_seccomp" && \
5655	echo "    Use libseccomp system call filtering (--enable-seccomp)"
5656    test "yes" = "$want_backtrace" && \
5657	echo "    Print backtrace on crash (--enable-backtrace)"
5658    test "minimal" = "$want_symtable" && \
5659	echo "    Use symbol table for backtrace, named only (--enable-symtable)"
5660    test "yes" = "$want_symtable" -o "all" = "$want_symtable" && \
5661	echo "    Use symbol table for backtrace, all binaries (--enable-symtable=all)"
5662    test "no" = "$use_libtool" || echo "    Use GNU libtool (--with-libtool)"
5663    test "yes" = "$want_querytrace" && \
5664	echo "    Very verbose query trace logging (--enable-querytrace)"
5665    test "no" = "$with_cmocka" || echo "    CMocka Unit Testing Framework (--with-cmocka)"
5666
5667    echo "    Dynamically loadable zone (DLZ) drivers:"
5668    test "no" = "$use_dlz_bdb" || \
5669	echo "        Berkeley DB (--with-dlz-bdb)"
5670    test "no" = "$use_dlz_ldap" || \
5671	echo "        LDAP (--with-dlz-ldap)"
5672    test "no" = "$use_dlz_mysql" || \
5673	echo "        MySQL (--with-dlz-mysql)"
5674    test "no" = "$use_dlz_odbc" || \
5675	echo "        ODBC (--with-dlz-odbc)"
5676    test "no" = "$use_dlz_postgres" || \
5677	echo "        Postgres (--with-dlz-postgres)"
5678    test "no" = "$use_dlz_filesystem" || \
5679	echo "        Filesystem (--with-dlz-filesystem)"
5680    test "no" = "$use_dlz_stub" || \
5681	echo "        Stub (--with-dlz-stub)"
5682    test "$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"
5683
5684    echo "-------------------------------------------------------------------------------"
5685
5686    echo "Features disabled or unavailable on this platform:"
5687    $use_threads || echo "    Multiprocessing support (--enable-threads)"
5688    test "no" = "$enable_ipv6" -o "no" = "$found_ipv6" && \
5689	    echo "    IPv6 support (--enable-ipv6)"
5690    test "large" = "$use_tuning" || echo "    Large-system tuning (--with-tuning)"
5691
5692    test "no" = "$use_dnstap" && \
5693	    echo "    Allow 'dnstap' packet logging (--enable-dnstap)"
5694    test -z "$MAXMINDDB_LIBS" && echo "    GeoIP2 access control (--with-geoip2)"
5695    test "no" = "$use_gssapi" && echo "    GSS-API (--with-gssapi)"
5696
5697    test "yes" = "$enable_fixed" || \
5698	echo "    Allow 'fixed' rrset-order (--enable-fixed-rrset)"
5699
5700    if test "X$CRYPTO" = "X" -o "yes" = "$want_native_pkcs11"
5701    then
5702	echo "    OpenSSL cryptography/DNSSEC (--with-openssl)"
5703    elif test "no" = "$use_pkcs11"; then
5704	echo "    PKCS#11/Cryptoki support (--with-pkcs11)"
5705    fi
5706    test "yes" = "$want_native_pkcs11" ||
5707	echo "    Native PKCS#11/Cryptoki support (--enable-native-pkcs11)"
5708    test "X$CRYPTO" = "X" -o "yes" = "$OPENSSL_GOST" -o "yes" = "$PKCS11_GOST" || \
5709	echo "    GOST algorithm support (--with-gost)"
5710    test "X$CRYPTO" = "X" -o "yes" = "$OPENSSL_ECDSA" -o "yes" = "$PKCS11_ECDSA" || \
5711	echo "    ECDSA algorithm support (--with-ecdsa)"
5712    test "X$CRYPTO" = "X" -o "yes" = "$OPENSSL_ED25519" -o "yes" = "$PKCS11_ED25519" || \
5713	echo "    EDDSA algorithm support (--with-eddsa)"
5714
5715    test "yes" = "$enable_seccomp" || \
5716	echo "    Use libseccomp system call filtering (--enable-seccomp)"
5717    test "yes" = "$want_backtrace" || \
5718	echo "    Print backtrace on crash (--enable-backtrace)"
5719    test "yes" = "$want_querytrace" || \
5720	echo "    Very verbose query trace logging (--enable-querytrace)"
5721
5722    test "yes" = "$use_libtool" || echo "    Use GNU libtool (--with-libtool)"
5723    test "no" = "$with_cmocka" && echo "    CMocka Unit Testng Framework (--with-cmocka)"
5724
5725    test "X$PYTHON" = "X" && echo "    Python tools (--with-python)"
5726    test "X$XMLSTATS" = "X" && echo "    XML statistics (--with-libxml2)"
5727    test "X$JSONSTATS" = "X" && echo "    JSON statistics (--with-libjson)"
5728    test "X$ZLIB" = "X" && echo "    HTTP zlib compression (--with-zlib)"
5729    test "X$NZD_TOOLS" = "X" && echo "    LMDB database to store configuration for 'addzone' zones (--with-lmdb)"
5730    test "no" = "$use_libidn2" && echo "    IDN support (--with-libidn2)"
5731
5732    echo "-------------------------------------------------------------------------------"
5733    echo "Configured paths:"
5734    echo "    prefix: $prefix"
5735    echo "    sysconfdir: $sysconfdir"
5736    echo "    localstatedir: $localstatedir"
5737    echo "-------------------------------------------------------------------------------"
5738    echo "Compiler: $CC"
5739    if test "yes" = "$GCC"; then
5740	$CC --version 2>&1 | sed 's/^/    /'
5741    else
5742	case "$host_os" in
5743	    solaris*)
5744		$CC -V 2>&1 | sed 's/^/    /'
5745		;;
5746	    *)
5747		$CC --version 2>&1 | sed 's/^/    /'
5748	esac
5749    fi
5750    if test "X$ac_unrecognized_opts" != "X"; then
5751	echo "Unrecognized options:"
5752	echo "    $ac_unrecognized_opts"
5753    fi
5754
5755    if test "yes" != "$enable_full_report"; then
5756	echo "-------------------------------------------------------------------------------"
5757	echo "For more detail, use --enable-full-report."
5758    fi
5759    echo "==============================================================================="
5760}
5761
5762if test "yes" != "$silent"; then
5763	report
5764fi
5765
5766if test "X$CRYPTO" = "X"; then
5767cat << \EOF
5768BIND 9 is being built without cryptography support. This means it will
5769not have DNSSEC support. Use --with-openssl, or --with-pkcs11 and
5770--enable-native-pkcs11 to enable cryptography.
5771EOF
5772fi
5773
5774# Tell Emacs to edit this file in shell mode.
5775# Local Variables:
5776# mode: sh
5777# End:
5778