1# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
2#
3# SPDX-License-Identifier: MPL-2.0
4#
5# This Source Code Form is subject to the terms of the Mozilla Public
6# License, v. 2.0.  If a copy of the MPL was not distributed with this
7# file, you can obtain one at https://mozilla.org/MPL/2.0/.
8#
9# See the COPYRIGHT file distributed with this work for additional
10# information regarding copyright ownership.
11
12#
13# Defining the version in m4 requires a bit of dancing around,
14# so the strings are properly concatenated, as you can't use
15# a shell variable in AC_INIT
16#
17m4_define([bind_VERSION_MAJOR], 9)dnl
18m4_define([bind_VERSION_MINOR], 18)dnl
19m4_define([bind_VERSION_PATCH], 24)dnl
20m4_define([bind_VERSION_EXTRA], )dnl
21m4_define([bind_DESCRIPTION], [(Extended Support Version)])dnl
22m4_define([bind_SRCID], [m4_esyscmd_s([git rev-parse --short HEAD | cut -b1-7])])dnl
23m4_define([bind_PKG_VERSION], [[bind_VERSION_MAJOR.bind_VERSION_MINOR.bind_VERSION_PATCH]bind_VERSION_EXTRA])dnl
24
25#
26# Autoconf initialization
27#
28AC_INIT([BIND], bind_PKG_VERSION, [https://gitlab.isc.org/isc-projects/bind9/-/issues/new?issuable_template=Bug], [], [https://www.isc.org/downloads/])
29AC_PREREQ([2.69])
30
31AC_DEFINE([PACKAGE_VERSION_MAJOR], ["][bind_VERSION_MAJOR]["], [BIND 9 Major part of the version])
32AC_DEFINE([PACKAGE_VERSION_MINOR], ["][bind_VERSION_MINOR]["], [BIND 9 Minor part of the version])
33AC_DEFINE([PACKAGE_VERSION_PATCH], ["][bind_VERSION_PATCH]["], [BIND 9 Patch part of the version])
34AC_DEFINE([PACKAGE_VERSION_EXTRA], ["][bind_VERSION_EXTRA]["], [BIND 9 Extra part of the version])
35AC_DEFINE([PACKAGE_DESCRIPTION], [m4_ifnblank(bind_DESCRIPTION, [" ]bind_DESCRIPTION["], [])], [An extra string to print after PACKAGE_STRING])
36AC_DEFINE([PACKAGE_SRCID], ["][bind_SRCID]["], [A short hash from git])
37
38bind_CONFIGARGS="${ac_configure_args:-default}"
39AC_DEFINE_UNQUOTED([PACKAGE_CONFIGARGS], ["$bind_CONFIGARGS"], [Either 'defaults' or used ./configure options])
40
41AC_DEFINE([PACKAGE_BUILDER], ["make"], [make or Visual Studio])
42
43#
44# Get the Canonical System Type
45#
46AC_CANONICAL_BUILD
47AC_CANONICAL_HOST
48AC_CANONICAL_TARGET
49
50AC_CONFIG_SRCDIR([bin/named/main.c])
51AM_INIT_AUTOMAKE([1.14 tar-pax foreign subdir-objects dist-xz no-dist-gzip -Wall -Werror])
52AM_SILENT_RULES([yes])
53AM_EXTRA_RECURSIVE_TARGETS([test unit doc])
54
55AC_CONFIG_HEADERS([config.h])
56AC_CONFIG_MACRO_DIR([m4])
57
58#
59# Enable maintainer mode by default only when building from git repository
60# and not cross compling
61#
62AS_IF([test "$cross_compiling" = no],
63      [AM_MAINTAINER_MODE(m4_ifset([bind_SRCID],[enable],[disable]))],
64      [AM_MAINTAINER_MODE([disable])])
65
66#
67# Enable system extensions to C and POSIX
68#
69AC_USE_SYSTEM_EXTENSIONS
70
71#
72# Compiler compatibility flags
73#
74m4_version_prereq([2.70],
75		  [AC_PROG_CC],
76		  [AC_PROG_CC_C99])
77AC_PROG_CPP_WERROR
78
79#
80# Find build compiler when cross compiling
81#
82AX_PROG_CC_FOR_BUILD
83
84#
85# Find the machine's endian flavor.
86#
87AC_C_BIGENDIAN
88
89#
90# Enable large file support
91#
92AC_SYS_LARGEFILE
93AC_FUNC_FSEEKO
94
95# Enable RFC 3542 APIs on macOS
96AC_DEFINE([__APPLE_USE_RFC_3542], [1], [Select RFC3542 IPv6 API on macOS])
97
98AC_PROG_MAKE_SET
99
100# Checks for programs.
101m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) # call AM_PROG_AR only if available
102
103AC_PROG_INSTALL
104AC_PROG_LN_S
105AX_POSIX_SHELL
106AC_PROG_MKDIR_P
107
108# Initialize libtool
109LT_INIT([disable-static dlopen pic-only])
110
111AS_IF([test "$enable_static" != "no" && test "$enable_developer" != "yes"],
112      [AC_MSG_ERROR([Static linking is not supported as it disables dlopen() and certain security features (e.g. RELRO, ASLR)])])
113
114#
115# Set the default CFLAGS, CPPFLAGS, and LDFLAGS
116#
117STD_CFLAGS="-Wall -Wextra -Wwrite-strings -Wpointer-arith -Wno-missing-field-initializers -Wformat -Wshadow"
118
119# These should be always errors
120STD_CFLAGS="$STD_CFLAGS -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=format-security -Werror=parentheses -Werror=implicit -Werror=strict-prototypes -Werror=vla"
121
122STD_LDFLAGS=""
123
124# ... except in test code
125TEST_CFLAGS="-Wno-vla"
126
127# Fortify the sources by default
128STD_CPPFLAGS="-D_FORTIFY_SOURCE=2"
129
130#
131# Additional compiler settings.
132#
133AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing],
134		      [STD_CFLAGS="$STD_CFLAGS -fno-strict-aliasing"])
135# Clang only issues a warning so use -Werror to force a error.
136AX_CHECK_COMPILE_FLAG([-Werror -fno-delete-null-pointer-checks],
137		      [STD_CFLAGS="$STD_CFLAGS -fno-delete-null-pointer-checks"])
138AX_CHECK_COMPILE_FLAG([-fdiagnostics-show-option],
139		      [STD_CFLAGS="$STD_CFLAGS -fdiagnostics-show-option"])
140
141AX_CHECK_LINK_FLAG([-Wl,--export-dynamic],
142		   [STD_LDFLAGS="$STD_LDFLAGS -Wl,--export-dynamic"])
143
144host_macos=no
145AS_CASE([$host],[*-darwin*],[host_macos=yes])
146AM_CONDITIONAL([HOST_MACOS], [test "$host_macos" = "yes"])
147
148#
149# Change defaults for developers if not explicity set.
150# Needs to be before the option is tested.
151#
152# [pairwise: --enable-developer, --disable-developer]
153AC_ARG_ENABLE([developer],
154	      [AS_HELP_STRING([--enable-developer],
155			      [enable developer build settings])])
156
157AS_IF([test "$enable_developer" = "yes"],
158      [DEVELOPER_MODE=yes
159       STD_CPPFLAGS="$STD_CPPFLAGS -DISC_MEM_DEFAULTFILL=1 -DISC_MEM_TRACKLINES=1 -DISC_LIST_CHECKINIT=1"
160       test "${enable_fixed_rrset+set}" = set || enable_fixed_rrset=yes
161       test "${enable_querytrace+set}" = set || enable_querytrace=yes
162       test "${with_cmocka+set}" = set || with_cmocka=yes
163       test "${with_zlib+set}" = set || with_zlib=yes
164       test "${enable_warn_error+set}" = set || enable_warn_error=yes
165       ])
166
167AC_SUBST([DEVELOPER_MODE])
168AC_SUBST([STD_CFLAGS])
169AC_SUBST([STD_CPPFLAGS])
170AC_SUBST([STD_LDFLAGS])
171AC_SUBST([TEST_CFLAGS])
172
173# [pairwise: --enable-warn-error, --disable-warn-error]
174AC_ARG_ENABLE([warn_error],
175	      [AS_HELP_STRING([--enable-warn-error],
176			      [turn on -Werror when compiling])],
177	      [],[enable_warn_error=no])
178AS_IF([test "$enable_warn_error" = "yes"],
179      [STD_CFLAGS="$STD_CFLAGS -Werror"])
180
181#
182# Use pkg-config
183#
184
185PKG_PROG_PKG_CONFIG
186AS_IF([test -z "$PKG_CONFIG"],
187      [AC_MSG_ERROR([The pkg-config script could not be found or is too old.])])
188
189# Fuzzing is not included in pairwise testing as fuzzing tools are
190# not present in the relevant Docker image.
191#
192# [pairwise: skip]
193AC_ARG_ENABLE([fuzzing],
194	      [AS_HELP_STRING([--enable-fuzzing=<afl|libfuzzer|ossfuzz>],
195			      [Enable fuzzing using American Fuzzy Lop or libFuzzer (default=no)])],
196	      [],
197	      [enable_fuzzing=no])
198
199AC_MSG_CHECKING([whether to enable fuzzing mode])
200AS_CASE([$enable_fuzzing],
201	[no],[AC_MSG_RESULT([no])],
202	[afl],[
203	  AC_MSG_RESULT([using AFL])
204	  AC_DEFINE([ENABLE_AFL], [1],
205		    [Define to enable American Fuzzy Lop test harness])
206	  STD_CFLAGS="$STD_CFLAGS -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1"
207	  FUZZ_LOG_COMPILER="afl.sh"],
208	[libfuzzer],[
209	  AC_MSG_RESULT([using libFuzzer])
210	  STD_CFLAGS="$STD_CFLAGS -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1 -fsanitize=fuzzer-no-link,address,undefined"
211	  LDFLAGS="$LDFLAGS -fsanitize=address,undefined"
212	  FUZZ_LDFLAGS="-fsanitize=fuzzer,address,undefined"
213	  FUZZ_LOG_COMPILER="libfuzzer.sh"],
214	[ossfuzz],[
215	    AC_MSG_RESULT([using OSS-Fuzz])
216	    FUZZ_LDFLAGS="$LIB_FUZZING_ENGINE"],
217	[*],[AC_MSG_ERROR([You need to explicitly select the fuzzer])])
218AM_CONDITIONAL([HAVE_FUZZ_LOG_COMPILER], [test -n "$FUZZ_LOG_COMPILER"])
219AC_SUBST([FUZZ_LOG_COMPILER])
220AC_SUBST([FUZZ_LDFLAGS])
221
222AS_IF([test "$enable_fuzzing" = "afl"],
223      [AC_MSG_CHECKING("for AFL enabled compiler")
224       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
225					  [#ifndef __AFL_COMPILER
226					   #error AFL compiler required
227					   #endif
228					  ])],
229			 [AC_MSG_RESULT([yes])],
230			 [AC_MSG_ERROR([set CC=afl-<gcc|clang> when --enable-fuzzing=afl is used])])
231      ])
232
233#
234# Perl is optional; it is used only by some of the system test scripts.
235#
236AC_PATH_PROGS([PERL], [perl5 perl])
237AC_SUBST([PERL])
238AM_CONDITIONAL([HAVE_PERL], [test -n "$PERL"])
239
240#
241# Python is optional, it is used only by some of the system test scripts.
242#
243AM_PATH_PYTHON([3.6], [], [:])
244AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != ":"])
245
246AC_PATH_PROGS([PYTEST], [pytest-3 py.test-3 pytest py.test pytest-pypy], [])
247AS_IF([test -z "$PYTEST"],
248      [AC_MSG_WARN([pytest not found, some system tests will be skipped])])
249AC_SUBST([PYTEST])
250AM_CONDITIONAL([HAVE_PYTEST], [test -n "$PYTEST"])
251
252#
253# xsltproc is optional, it is used only by system test scripts.
254#
255AC_PATH_PROG([XSLTPROC], [xsltproc])
256
257#
258# Using Solaris linker with gcc on Solaris breaks Thread Local Storage
259#
260AS_CASE([$host],
261	[*-solaris*],[
262	    AS_IF([test "$GCC" = "yes"],
263		  [LDFLAGS="$LDFLAGS -zrelax=transtls"
264		   AC_MSG_WARN([When using GNU C Compiler on Solaris, -zrelax=transtls linker flag is used to fix bug in Thread Local Storage])
265		  ])
266	])
267
268AC_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], [], [],
269		 [$ac_includes_default
270		  #ifdef HAVE_SYS_PARAM_H
271		  # include <sys/param.h>
272		  #endif
273		  #ifdef HAVE_SYS_SOCKET_H
274		  # include <sys/socket.h>
275		  #endif
276		 ])
277
278#
279# Check for thread local storage
280#
281AC_CHECK_HEADERS([threads.h])
282AX_TLS([AS_IF([test "$ac_cv_tls" != "thread_local"],
283	      [AC_DEFINE_UNQUOTED([thread_local], [$ac_cv_tls], [Define if the compiler uses a different keyword than thread_local for TLS variables])])],
284       [AC_MSG_ERROR([Thread Local Storage support required, update your toolchain to build BIND 9])])
285
286AC_C_CONST
287AC_C_INLINE
288AC_C_VOLATILE
289
290#
291# Check for yield support on ARM processors
292#
293AS_CASE([$host],
294	[arm*],
295	[AC_MSG_CHECKING([for yield instruction support])
296	 AC_COMPILE_IFELSE(
297	     [AC_LANG_PROGRAM([[]],
298			     [[__asm__ __volatile__ ("yield")]])],
299	     [AC_MSG_RESULT([yes])
300	      AC_DEFINE([HAVE_ARM_YIELD], [1],
301			[define if the ARM yield instruction is available])],
302	     [AC_MSG_RESULT([no])])])
303
304#
305# Check for pause support on SPARC processors
306#
307AS_CASE([$host],
308	[sparc*],
309	[AC_MSG_CHECKING([for pause instruction support])
310	 AC_COMPILE_IFELSE(
311	     [AC_LANG_PROGRAM([[]],
312			     [[__asm__ __volatile__ ("pause")]])],
313	     [AC_MSG_RESULT([yes])
314	      AC_DEFINE([HAVE_SPARC_PAUSE], [1],
315			[define if the SPARC pause instruction is available])],
316	     [AC_MSG_RESULT([no])])])
317
318AC_CHECK_FUNCS([sysctlbyname])
319
320#
321# Older versions of HP/UX don't define seteuid() and setegid()
322#
323AC_CHECK_FUNCS([seteuid setresuid])
324AC_CHECK_FUNCS([setegid setresgid])
325
326AC_TYPE_SIZE_T
327AC_TYPE_SSIZE_T
328AC_TYPE_UINTPTR_T
329
330#
331# check for uname library routine
332#
333AC_MSG_CHECKING([for uname])
334AC_COMPILE_IFELSE(
335  [AC_LANG_PROGRAM(
336     [[#include <sys/utsname.h>
337       #include <stdio.h>
338      ]],
339     [[
340       struct utsname uts;
341       uname(&uts);
342       printf("running on %s %s %s for %s\n",
343	      uts.sysname, uts.release, uts.version, uts.machine);
344     ]])],
345  [AC_MSG_RESULT(yes)
346   AC_DEFINE([HAVE_UNAME], [1], [define if uname is available])
347  ],
348  [AC_MSG_RESULT(no)
349   AC_MSG_WARN([uname is not correctly supported])
350  ])
351
352#
353# check for GCC noreturn attribute
354#
355AX_GCC_FUNC_ATTRIBUTE([noreturn])
356
357#
358# check for GCC malloc attribute
359#
360AX_GCC_FUNC_ATTRIBUTE([malloc])
361
362AC_MSG_CHECKING([for extended malloc attributes])
363AC_COMPILE_IFELSE(
364  [AC_LANG_PROGRAM(
365     [[
366       #include <stddef.h>
367       #include <stdlib.h>
368	   __attribute__ ((malloc, malloc (free, 1))
369	   void * xmalloc(size_t sz) { return malloc(sz); }
370     ]],
371     [[
372       void *p = xmalloc(8);
373	   free(p);
374     ]])],
375  [AC_MSG_RESULT(yes)
376   AC_DEFINE([HAVE_MALLOC_EXT_ATTR], [1], [define if extended attributes for malloc are available])
377  ],
378  [AC_MSG_RESULT(no)])
379
380#
381# check for GCC returns_nonnull attribute
382#
383AX_GCC_FUNC_ATTRIBUTE([returns_nonnull])
384
385#
386# GeoIP support?
387#
388# Should be on by default if libmaxminddb exists.
389#
390# [pairwise: --enable-geoip --with-maxminddb=auto, --enable-geoip --with-maxminddb=yes, --disable-geoip]
391AC_ARG_ENABLE([geoip],
392	      [AS_HELP_STRING([--disable-geoip],
393			      [support GeoIP2 geolocation ACLs if available [default=yes]])],
394	      [], [enable_geoip="yes"])
395
396# [pairwise: skip]
397AC_ARG_WITH([maxminddb],
398	    [AS_HELP_STRING([--with-maxminddb=PATH],
399			    [Build with MaxMind GeoIP2 support (auto|yes|no|path) [default=auto]])],
400	    [], [with_maxminddb="auto"])
401
402AS_IF([test "$enable_geoip" = "yes"],
403      [AS_CASE([$with_maxminddb],
404	       [no],[AC_MSG_ERROR([Use '--disable-geoip' to disable the GeoIP])],
405	       [auto],[PKG_CHECK_MODULES([MAXMINDDB], [libmaxminddb],
406					 [AC_DEFINE([HAVE_GEOIP2], [1], [Build with GeoIP2 support])
407					  PKG_CHECK_VAR([MAXMINDDB_PREFIX], [libmaxminddb], [prefix], [], [AC_MSG_ERROR([libmaxminddb prefix not found in pkg-config; set MAXMINDDB_PREFIX in the environment])])
408					 ],[:])],
409	       [yes],[PKG_CHECK_MODULES([MAXMINDDB], [libmaxminddb],
410					[AC_DEFINE([HAVE_GEOIP2], [1], [Build with GeoIP2 support])
411					 PKG_CHECK_VAR([MAXMINDDB_PREFIX], [libmaxminddb], [prefix], [], [AC_MSG_ERROR([libmaxminddb prefix not found in pkg-config; set MAXMINDDB_PREFIX in the environment])])
412					])],
413	       [ # default
414		   AX_SAVE_FLAGS([maxminddb])
415		   MAXMINDDB_CFLAGS="-I$with_maxminddb/include"
416		   MAXMINDDB_LIBS="-L$with_maxminddb/lib"
417		   CFLAGS="$CFLAGS $MAXMINDDB_CFLAGS"
418		   LIBS="$LIBS $MAXMINDDB_LIBS"
419		   AC_SEARCH_LIBS([MMDB_open], [maxminddb],
420				  [AC_DEFINE([HAVE_GEOIP2], [1], [Build with GeoIP2 support])
421				   MAXMINDDB_LIBS="$MAXMINDDB_LIBS $ac_cv_search_MMDB_open"
422				   AC_MSG_NOTICE([GeoIP2 default database path set to $with_maxminddb/share/GeoIP])
423				   AS_VAR_COPY([MAXMINDDB_PREFIX], [with_maxminddb])
424				  ],
425				  [AC_MSG_ERROR([GeoIP2 requested, but libmaxminddb not found])])
426		   AX_RESTORE_FLAGS([maxminddb])
427	       ])
428       AC_ARG_VAR([MAXMINDDB_PREFIX], [value of prefix for MAXMINDDB, overriding pkg-config])
429])
430
431AM_CONDITIONAL([HAVE_GEOIP2], [test -n "$MAXMINDDB_LIBS"])
432
433AC_SUBST([MAXMINDDB_CFLAGS])
434AC_SUBST([MAXMINDDB_LIBS])
435
436AX_PTHREAD
437
438LIBS="$PTHREAD_LIBS $LIBS"
439CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
440CC="$PTHREAD_CC"
441
442AC_CHECK_FUNCS([pthread_attr_getstacksize pthread_attr_setstacksize pthread_barrier_init])
443
444# [pairwise: --with-locktype=adaptive, --with-locktype=standard]
445AC_ARG_WITH([locktype],
446	    AS_HELP_STRING([--with-locktype=ARG],
447			   [Specify mutex lock type
448			    (adaptive or standard)]),
449	    [], [with_locktype="adaptive"])
450
451AS_CASE([$with_locktype],
452	[adaptive],[
453	  AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
454	  AC_COMPILE_IFELSE(
455	    [AC_LANG_PROGRAM(
456	       [[
457		 #ifndef _GNU_SOURCE
458		 #define _GNU_SOURCE
459		 #endif
460		 #include <pthread.h>
461	       ]],
462	       [[
463		 return (PTHREAD_MUTEX_ADAPTIVE_NP);
464	       ]]
465	     )],
466	    [AC_MSG_RESULT([using adaptive lock type])
467	     AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
468		       [Support for PTHREAD_MUTEX_ADAPTIVE_NP]) ],
469	    [AC_MSG_RESULT([using standard lock type])]
470	  )],
471	[standard],[AC_MSG_RESULT([using standard lock type])],
472	[AC_MSG_ERROR([You must specify "adaptive" or "standard" for --with-locktype.])]
473       )
474
475AC_CHECK_HEADERS([sched.h])
476
477AC_SEARCH_LIBS([sched_yield],[rt])
478AC_CHECK_FUNCS([sched_yield pthread_yield pthread_yield_np])
479
480# Look for functions relating to thread naming
481AC_CHECK_FUNCS([pthread_setname_np pthread_set_name_np])
482AC_CHECK_HEADERS([pthread_np.h], [], [], [#include <pthread.h>])
483
484# libuv
485PKG_CHECK_MODULES([LIBUV], [libuv >= 1.37.0], [],
486		  [PKG_CHECK_MODULES([LIBUV], [libuv >= 1.0.0 libuv < 1.35.0], [],
487				     [AC_MSG_ERROR([libuv >= 1.0.0 (except 1.35.0 and 1.36.0) not found])])])
488
489AX_SAVE_FLAGS([libuv])
490CFLAGS="$CFLAGS $LIBUV_CFLAGS"
491LIBS="$LIBS $LIBUV_LIBS"
492
493# libuv recvmmsg support
494AC_CHECK_DECLS([UV_UDP_MMSG_FREE, UV_UDP_MMSG_CHUNK], [], [], [[#include <uv.h>]])
495AC_MSG_CHECKING([whether struct msghdr uses padding for alignment])
496AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/socket.h>],
497				   [const struct msghdr h = { .__pad1 = 0, .__pad2 = 0 };])],
498		  [AC_MSG_RESULT([yes])
499		   AC_DEFINE([HAVE_DECL_UV_UDP_RECVMMSG],
500			     [0], [Disable recvmmsg support on systems with MUSL glibc])],
501		  [AC_MSG_RESULT([no])
502		   AC_CHECK_DECLS([UV_UDP_RECVMMSG], [], [], [[#include <uv.h>]])])
503
504AX_RESTORE_FLAGS([libuv])
505
506# [pairwise: --enable-doh --with-libnghttp2=auto, --enable-doh --with-libnghttp2=yes, --disable-doh]
507AC_ARG_ENABLE([doh],
508	      [AS_HELP_STRING([--disable-doh], [disable DNS over HTTPS, removes dependency on libnghttp2 (default is --enable-doh)])],
509	      [], [enable_doh=yes])
510
511# [pairwise: skip]
512AC_ARG_WITH([libnghttp2],
513	    [AS_HELP_STRING([--with-libnghttp2],
514			    [build with libnghttp2 library [yes|no|auto] (default is auto)])],
515	    [], [with_libnghttp2="auto"])
516
517AS_IF([test "$enable_doh" = "yes"],
518      [AS_CASE([$with_libnghttp2],
519	       [no],[AC_MSG_ERROR([Use '--disable-doh' to disable DNS-over-HTTPS support])],
520	       [auto|yes],[PKG_CHECK_MODULES([LIBNGHTTP2], [libnghttp2 >= 1.6.0],
521					     [AC_DEFINE([HAVE_LIBNGHTTP2], [1], [Build with DNS-over-HTTPS support])],
522					     [AC_MSG_ERROR(m4_normalize([DNS-over-HTTPS support requested, but libnghttp2 not found.
523									 Either install libnghttp2 or use --disable-doh.]))])],
524	       [AC_MSG_ERROR([Specifying libnghttp2 installation path is not supported, adjust PKG_CONFIG_PATH instead])])])
525
526AM_CONDITIONAL([HAVE_LIBNGHTTP2], [test -n "$LIBNGHTTP2_LIBS"])
527
528
529#
530# flockfile is usually provided by pthreads
531#
532AC_CHECK_FUNCS([flockfile getc_unlocked])
533
534#
535# Look for sysconf to allow detection of the number of processors.
536#
537AC_CHECK_FUNCS([sysconf])
538
539#
540# Do we want to use pthread rwlock?
541#
542# [pairwise: --enable-pthread-rwlock, --disable-pthread-rwlock]
543AC_ARG_ENABLE([pthread_rwlock],
544	      [AS_HELP_STRING([--enable-pthread-rwlock],
545			      [use pthread rwlock instead of internal rwlock implementation])],
546	      [], [enable_pthread_rwlock=no])
547
548AS_IF([test "$enable_pthread_rwlock" = "yes"],
549      [AC_CHECK_FUNCS([pthread_rwlock_rdlock], [],
550		      [AC_MSG_ERROR([pthread_rwlock_rdlock requested but not found])])
551       AC_DEFINE([USE_PTHREAD_RWLOCK],[1],[Define if you want to use pthread rwlock implementation])
552      ])
553
554CRYPTO=OpenSSL
555
556#
557# OpenSSL/LibreSSL is mandatory
558#
559PKG_CHECK_MODULES([OPENSSL], [libssl libcrypto], [],
560		  [AX_CHECK_OPENSSL([:],[AC_MSG_FAILURE([OpenSSL/LibreSSL not found])])])
561
562AX_SAVE_FLAGS([openssl])
563
564CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
565LIBS="$LIBS $OPENSSL_LIBS"
566
567AC_MSG_CHECKING([for OpenSSL >= 1.0.0 or LibreSSL >= 2.7.0])
568AC_COMPILE_IFELSE(
569    [AC_LANG_PROGRAM([[#include <openssl/opensslv.h>]],
570		     [[#if (!defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER < 0x1000000fL)) || \\
571			   (defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER < 0x02070000fL))
572		       #error OpenSSL >= 1.0.0 or LibreSSL >= 2.7.0 required
573		       #endif
574		      ]])],
575    [AC_MSG_RESULT([yes])],
576    [AC_MSG_FAILURE([not found])])
577
578#
579# Check for functions added in OpenSSL or LibreSSL
580#
581
582AC_CHECK_FUNCS([BIO_read_ex BIO_write_ex])
583AC_CHECK_FUNCS([BN_GENCB_new])
584AC_CHECK_FUNCS([CRYPTO_zalloc])
585AC_CHECK_FUNCS([ERR_get_error_all])
586AC_CHECK_FUNCS([EVP_CIPHER_CTX_new EVP_CIPHER_CTX_free])
587AC_CHECK_FUNCS([EVP_MD_CTX_new EVP_MD_CTX_free EVP_MD_CTX_reset EVP_MD_CTX_get0_md])
588AC_CHECK_FUNCS([EVP_PKEY_new_raw_private_key EVP_PKEY_eq])
589AC_CHECK_FUNCS([OPENSSL_init_ssl OPENSSL_init_crypto OPENSSL_cleanup])
590AC_CHECK_FUNCS([SSL_CTX_set_keylog_callback])
591AC_CHECK_FUNCS([SSL_CTX_set_min_proto_version])
592AC_CHECK_FUNCS([SSL_CTX_up_ref])
593AC_CHECK_FUNCS([SSL_read_ex SSL_peek_ex SSL_write_ex])
594AC_CHECK_FUNCS([SSL_CTX_set1_cert_store X509_STORE_up_ref])
595AC_CHECK_FUNCS([SSL_SESSION_is_resumable])
596
597#
598# Check for algorithm support in OpenSSL
599#
600
601AC_CHECK_FUNCS([EVP_DigestSignInit EVP_DigestVerifyInit], [:],
602	       [AC_MSG_FAILURE([EVP_DigestSignInit/EVP_DigestVerifyInit support in OpenSSL is mandatory.])])
603
604AC_MSG_CHECKING([for ECDSA P-256 support])
605AC_COMPILE_IFELSE(
606    [AC_LANG_PROGRAM([[#include <openssl/evp.h>]],
607		     [[EVP_PKEY_CTX *kctx = EVP_PKEY_CTX_new_id(NID_X9_62_prime256v1, NULL);]])],
608    [AC_MSG_RESULT([yes])],
609    [AC_MSG_FAILURE([not found.  ECDSA P-256 support in OpenSSL is mandatory.])])
610
611AC_MSG_CHECKING([for ECDSA P-384 support])
612AC_COMPILE_IFELSE(
613    [AC_LANG_PROGRAM([[#include <openssl/evp.h>]],
614		     [[EVP_PKEY_CTX *kctx = EVP_PKEY_CTX_new_id(NID_secp384r1, NULL);]])],
615    [AC_MSG_RESULT([yes])],
616    [AC_MSG_FAILURE([not found.  ECDSA P-384 support in OpenSSL is mandatory.])])
617
618AC_MSG_CHECKING([for Ed25519 support])
619AC_COMPILE_IFELSE(
620    [AC_LANG_PROGRAM([[#include <openssl/evp.h>]],
621		     [[EVP_PKEY_CTX *kctx = EVP_PKEY_CTX_new_id(NID_ED25519, NULL);]])],
622    [AC_DEFINE([HAVE_OPENSSL_ED25519], [1], [define if OpenSSL supports Ed25519])
623     AC_MSG_RESULT([yes])],
624    [AC_MSG_RESULT([no])])
625
626AC_MSG_CHECKING([for Ed448 support])
627AC_COMPILE_IFELSE(
628    [AC_LANG_PROGRAM([[#include <openssl/evp.h>]],
629		     [[EVP_PKEY_CTX *kctx = EVP_PKEY_CTX_new_id(NID_ED448, NULL);]])],
630    [AC_DEFINE([HAVE_OPENSSL_ED448], [1], [define if OpenSSL supports Ed448])
631     AC_MSG_RESULT([yes])],
632    [AC_MSG_RESULT([no])])
633
634#
635# Check for OpenSSL SHA-1 support
636#
637AC_CHECK_FUNCS([EVP_sha1], [:],
638	       [AC_MSG_FAILURE([SHA-1 support in OpenSSL is mandatory.])])
639
640#
641# Check for OpenSSL SHA-2 support
642#
643AC_CHECK_FUNCS([EVP_sha224 EVP_sha256 EVP_sha384 EVP_sha512], [:],
644	       [AC_MSG_FAILURE([SHA-2 support in OpenSSL is mandatory.])])
645
646#
647# Check for OpenSSL AES support
648#
649AC_CHECK_FUNCS([EVP_aes_128_ecb EVP_aes_192_ecb EVP_aes_256_ecb], [:],
650	       [AC_MSG_FAILURE([AES support in OpenSSL is mandatory.])])
651
652#
653# Check for OpenSSL 1.1.x/LibreSSL functions
654#
655AC_CHECK_FUNCS([DH_get0_key ECDSA_SIG_get0 RSA_set0_key EVP_PKEY_get0_EC_KEY])
656
657AC_CHECK_FUNCS([TLS_server_method TLS_client_method])
658
659#
660# Check whether FIPS mode is available and whether we should enable it
661#
662# FIPS is not included in pairwise testing as the relevant Docker image
663# does not support FIPS mode.
664#
665# [pairwise: skip]
666AC_ARG_ENABLE([fips-mode],
667	      [AS_HELP_STRING([--enable-fips-mode],
668			      [enable FIPS mode in OpenSSL library [default=no]])],
669	      [], [enable_fips_mode="no"])
670
671AC_MSG_CHECKING([whether to enable FIPS mode in OpenSSL library])
672AS_CASE([$enable_fips_mode],
673	[yes], [AC_MSG_RESULT([yes])
674		AC_CHECK_FUNCS([FIPS_mode],
675			       [], [AC_MSG_FAILURE([OpenSSL FIPS mode requested but not available.])])],
676	[no], [AC_MSG_RESULT([no])])
677
678AX_RESTORE_FLAGS([openssl])
679
680AC_SUBST([OPENSSL_CFLAGS])
681AC_SUBST([OPENSSL_LIBS])
682
683AC_CHECK_FUNCS([clock_gettime])
684
685# [pairwise: --with-gssapi=yes, --with-gssapi=auto, --without-gssapi]
686AC_ARG_WITH([gssapi],
687	    [AS_HELP_STRING([--with-gssapi=[PATH|[/path/]krb5-config]],
688			   [Specify path for system-supplied GSSAPI
689				[default=auto]])],
690	    [], [with_gssapi="auto"])
691
692KRB5_CONFIG=
693AS_CASE([$with_gssapi],
694	[no],[AC_MSG_CHECKING([for GSSAPI support])
695	      AC_MSG_RESULT([no])],
696	[yes],[AC_PATH_PROG([KRB5_CONFIG], [krb5-config])
697	       AS_IF([test -z "$KRB5_CONFIG"],
698		     [AC_MSG_ERROR([krb5-config required but not found])])],
699	[auto],[AC_PATH_PROG([KRB5_CONFIG], [krb5-config])],
700	[*krb5-config*],[KRB5_CONFIG="$with_gssapi"],
701	[AC_MSG_ERROR([--with-gssapi requires yes|no|auto|/path/to/krb5-config])])
702
703GSSAPI_CFLAGS=
704GSSAPI_LIBS=
705KRB5_CFLAGS=
706KRB5_LIBS=
707AS_IF([test -n "$KRB5_CONFIG"],
708      [AC_MSG_CHECKING([for gssapi libraries])
709       AX_SAVE_FLAGS([gssapi])
710       GSSAPI_CFLAGS=`"$KRB5_CONFIG" --cflags gssapi`
711       GSSAPI_LIBS=`"$KRB5_CONFIG" --libs gssapi`
712       CFLAGS="$CFLAGS $GSSAPI_CFLAGS"
713       LIBS="$LIBS $GSSAPI_LIBS"
714       AC_MSG_RESULT([$GSSAPI_CFLAGS $GSSAPI_LIBS])
715       AC_CHECK_HEADERS([gssapi/gssapi.h], [],
716			[AC_CHECK_HEADERS([gssapi.h], [],
717					  [AC_MSG_ERROR([neither gssapi/gssapi.h nor gssapi.h found])])])
718       AC_CHECK_HEADERS([gssapi/gssapi_krb5.h],
719			[AC_CHECK_HEADERS([gssapi_krb5.h], []
720					  [AC_MSG_ERROR([neither gssapi/gssapi_krb5.h nor gssapi_krb5.h found])])])
721       AC_CHECK_FUNCS([gss_acquire_cred],[],
722		      [AC_MSG_ERROR([linking with $GSSAPI_LIBS does not work])])
723       AX_RESTORE_FLAGS([gssapi])
724
725       AC_MSG_CHECKING([for krb5 libraries])
726       AX_SAVE_FLAGS([krb5])
727       KRB5_CFLAGS=`"$KRB5_CONFIG" --cflags krb5`
728       KRB5_LIBS=`$KRB5_CONFIG --libs krb5`
729       CFLAGS="$CFLAGS $KRB5_CFLAGS"
730       LIBS="$CFLAGS $KRB5_LIBS"
731       AC_MSG_RESULT([$KRB5_CFLAGS $KRB5_LIBS])
732       AC_CHECK_HEADERS([krb5/krb5.h], [],
733			[AC_CHECK_HEADERS([krb5.h], [],
734					  [AC_MSG_ERROR([neither krb5/krb5.h nor krb5 found])])])
735       AC_CHECK_FUNCS([krb5_init_context], [],
736		      [AC_MSG_ERROR([linking with $KRB5_LIBS failed])])
737       AX_RESTORE_FLAGS([krb5])
738
739       AC_DEFINE([HAVE_GSSAPI], [1], [Define to 1 if you have the Kerberos Framework available])
740       # kludge to silence compiler warnings which recommend use of GSS.framework on macOS
741       AS_CASE([$host],[*-darwin*],[CFLAGS="$CFLAGS -Wno-deprecated-declarations"])])
742AM_CONDITIONAL([HAVE_GSSAPI], [test -n "$GSSAPI_LIBS"])
743AC_SUBST([GSSAPI_CFLAGS])
744AC_SUBST([GSSAPI_LIBS])
745AC_SUBST([KRB5_CFLAGS])
746AC_SUBST([KRB5_LIBS])
747
748#
749# was --with-lmdb specified?
750#
751
752# [pairwise: --with-lmdb=auto, --with-lmdb=yes, --without-lmdb]
753AC_ARG_WITH([lmdb],
754	    [AS_HELP_STRING([--with-lmdb=@<:@PATH@:>@],
755			    [use LMDB library @<:@default=auto@:>@, optionally specify the prefix for lmdb library])],
756	    [:],
757	    [with_lmdb="auto"])
758
759ac_lib_lmdb_found=no
760AS_CASE([$with_lmdb],
761	[no],[],
762	[auto|yes], [PKG_CHECK_MODULES([LMDB], [lmdb],
763				       [ac_lib_lmdb_found=yes],
764				       [for ac_lib_lmdb_path in /usr /usr/local /opt /opt/local; do
765						AX_LIB_LMDB([$ac_lib_lmdb_path],
766							    [ac_lib_lmdb_found=yes
767							     break])
768					done
769				       ])],
770	[AX_LIB_LMDB([$with_lmdb],[ac_lib_lmdb_found=yes])])
771
772# don't fail when in automatic mode
773AS_IF([test "$with_lmdb" = "auto" && test "$ac_lib_lmdb_found" = "no"],
774      [with_lmdb=no])
775
776# hard fail when LMDB requested, but not found
777AS_IF([test "$with_lmdb" != "no" && test "$ac_lib_lmdb_found" != "yes"],
778      [AC_MSG_ERROR([LMDB requested, but not found])])
779
780AS_IF([test "$ac_lib_lmdb_found" = "yes"],
781      [AC_DEFINE([HAVE_LMDB], [1], [Use lmdb library])])
782
783AC_SUBST([LMDB_CFLAGS])
784AC_SUBST([LMDB_LIBS])
785AM_CONDITIONAL([HAVE_LMDB], [test -n "$LMDB_LIBS"])
786
787#
788# was --with-libxml2 specified?
789#
790# [pairwise: --with-libxml2=auto, --with-libxml2=yes, --without-libxml2]
791AC_ARG_WITH([libxml2],
792	    [AS_HELP_STRING([--with-libxml2],
793			    [build with libxml2 library [yes|no|auto] (default is auto)])],
794	    [], [with_libxml2="auto"])
795
796AS_CASE([$with_libxml2],
797	[no],[],
798	[auto],[PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.6.0],
799				  [AC_DEFINE([HAVE_LIBXML2], [1], [Use libxml2 library])],
800				  [:])],
801	[yes],[PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.6.0],
802				 [AC_DEFINE([HAVE_LIBXML2], [1], [Use libxml2 library])])],
803	[AC_MSG_ERROR([Specifying libxml2 installation path is not supported, adjust PKG_CONFIG_PATH instead])])
804
805AM_CONDITIONAL([HAVE_LIBXML2], [test -n "$LIBXML2_LIBS"])
806
807#
808# was --with-json-c specified?
809#
810# [pairwise: --with-json-c=detect, --with-json-c=yes, --without-json-c]
811AC_ARG_WITH([json-c],
812	    [AS_HELP_STRING([--with-json-c],
813			    [build with json-c library [yes|no|detect] (default is detect)])],
814	    [], [with_json_c="detect"])
815
816AS_CASE([$with_json_c],
817	[no],[],
818	[detect],[PKG_CHECK_MODULES([JSON_C], [json-c >= 0.11],
819				    [AC_DEFINE([HAVE_JSON_C], [1], [Use json-c library])],
820				    [:])],
821	[yes],[PKG_CHECK_MODULES([JSON_C], [json-c >= 0.11],
822				 [AC_DEFINE([HAVE_JSON_C], [1], [Use json-c library])])],
823	[AC_MSG_ERROR([Specifying json-c installation path is not supported, adjust PKG_CONFIG_PATH instead])]
824       )
825
826AM_CONDITIONAL([HAVE_JSON_C], [test -n "$JSON_C_LIBS"])
827
828AC_SUBST([JSON_C_CFLAGS])
829AC_SUBST([JSON_C_LIBS])
830
831#
832# was --with-zlib specified?
833#
834# [pairwise: --with-zlib=auto, --with-zlib=yes, --without-zlib]
835AC_ARG_WITH([zlib],
836	    [AS_HELP_STRING([--with-zlib],
837			    [build with zlib for HTTP compression
838			     [default=yes]])],
839	    [], with_zlib="auto")
840
841AS_CASE([$with_zlib],
842       [no],[],
843       [auto],[PKG_CHECK_MODULES([ZLIB], [zlib],
844				 [AC_DEFINE([HAVE_ZLIB], [1], [Use zlib library])],
845				 [:])],
846       [yes],[PKG_CHECK_MODULES([ZLIB], [zlib],
847				[AC_DEFINE([HAVE_ZLIB], [1], [Use zlib library])])],
848       [AC_MSG_ERROR([Specifying zlib installation path is not supported, adjust PKG_CONFIG_PATH instead])])
849AC_SUBST([ZLIB_CFLAGS])
850AC_SUBST([ZLIB_LIBS])
851
852#
853# Check if the system supports glibc-compatible backtrace() function.
854#
855AC_CHECK_HEADERS([execinfo.h],
856		 [AC_SEARCH_LIBS([backtrace_symbols], [execinfo],
857				 [AC_CHECK_FUNCS([backtrace_symbols])])])
858
859#
860# We do the IPv6 compilation checking after libtool so that we can put
861# the right suffix on the files.
862#
863AC_MSG_CHECKING([for IPv6 structures])
864AC_COMPILE_IFELSE(
865  [AC_LANG_PROGRAM(
866     [[
867       #include <sys/types.h>
868       #include <sys/socket.h>
869       #include <netinet/in.h>
870     ]],
871     [[
872       struct sockaddr_in6 sin6;
873       struct in6_addr in6;
874       struct in6_pktinfo in6_pi;
875       struct sockaddr_storage storage;
876       in6 = in6addr_any;
877       in6 = in6addr_loopback;
878       sin6.sin6_scope_id = 0;
879       return (0);
880     ]])],
881  [AC_MSG_RESULT([yes])],
882  [AC_MSG_FAILURE([IPv6 support is mandatory])])
883
884#
885# Allow forcibly disabling TCP Fast Open support as autodetection might yield
886# confusing results on some systems (e.g. FreeBSD; see set_tcp_fastopen()
887# comment in lib/isc/socket.c).
888#
889# [pairwise: --enable-tcp-fastopen, --disable-tcp-fastopen]
890AC_ARG_ENABLE([tcp_fastopen],
891	      [AS_HELP_STRING([--disable-tcp-fastopen],
892			      [disable TCP Fast Open support [default=yes]])],
893	      [], [enable_tcp_fastopen="yes"])
894
895AS_IF([test "$enable_tcp_fastopen" = "yes"],
896      [AC_DEFINE([ENABLE_TCP_FASTOPEN], [1], [define if you want TCP_FASTOPEN enabled if available])])
897
898#
899# Check for some other useful functions that are not ever-present.
900#
901AC_CHECK_FUNCS([strlcpy strlcat strnstr])
902
903#
904# Check for readline support
905#
906
907# editline is not included in pairwise testing as the library
908# is not present in the relevant Docker image.
909#
910# GNU Readline is not included in pairwise testing as the library
911# in the relevant Docker image does not support pkg-config.
912#
913# [pairwise: --with-readline=auto, --with-readline=yes, --with-readline=libedit, --without-readline]
914AC_ARG_WITH([readline],
915	    [AS_HELP_STRING([--with-readline=yes|no|libedit|readline],
916			    [specify readline library [default auto]])],
917	    [], [with_readline="auto"])
918
919AS_CASE([$with_readline],
920	[no],[],
921	[auto|yes],
922	[PKG_CHECK_MODULES([READLINE], [libedit],
923			   [AC_DEFINE([HAVE_READLINE_LIBEDIT], [1], [Build with libedit support])],
924			   [PKG_CHECK_MODULES([READLINE], [libeditline],
925					      [AC_DEFINE([HAVE_READLINE_EDITLINE], [1], [Build with editline support.])],
926					      [PKG_CHECK_MODULES([READLINE], [readline],
927								 [AC_DEFINE([HAVE_READLINE_READLINE], [1], [Build with readline support.])],
928								 [AS_IF([test "$with_readline" = "yes"],
929									[AC_MSG_ERROR([readline support requested, but none of the libraries have been found.])])])])])],
930	[libedit],
931	[PKG_CHECK_MODULES([READLINE], [libedit],
932			   [AC_DEFINE([HAVE_READLINE_LIBEDIT], [1], [Build with libedit support])])],
933	[editline],
934	[PKG_CHECK_MODULES([READLINE], [libeditline],
935			   [AC_DEFINE([HAVE_READLINE_EDITLINE], [1], [Build with editline support])])],
936	[readline],
937	[PKG_CHECK_MODULES([READLINE], [readline],
938			   [AC_DEFINE([HAVE_READLINE_READLINE], [1], [Build with readline support])])],
939	[AC_MSG_ERROR([Unknown readline '$with_readline' library requested.])])
940AM_CONDITIONAL([HAVE_READLINE], [test -n "$READLINE_LIBS"])
941AC_SUBST([READLINE_CFLAGS])
942AC_SUBST([READLINE_LIBS])
943
944#
945# Security Stuff
946#
947# Note it is very recommended to *not* disable chroot(),
948# this is only because chroot() was made obsolete by Posix.
949#
950# [pairwise: --enable-chroot, --disable-chroot]
951AC_ARG_ENABLE(chroot, AS_HELP_STRING([--disable-chroot], [disable chroot]))
952case "$enable_chroot" in
953	yes|'')
954		AC_CHECK_FUNCS(chroot)
955		;;
956	no)
957		;;
958esac
959
960LIBCAP_LIBS=""
961AC_MSG_CHECKING([whether to enable Linux capabilities])
962
963# [pairwise: --enable-linux-caps, --disable-linux-caps]
964AC_ARG_ENABLE([linux-caps],
965	      [AS_HELP_STRING([--disable-linux-caps],
966			      [disable Linux capabilities])],
967	      [],
968	      [AS_CASE([$host],
969		       [*-linux*],[enable_linux_caps=yes],
970		       [enable_linux_caps=no])])
971
972AS_IF([test "$enable_linux_caps" = "yes"],
973      [AC_MSG_RESULT([yes])
974       AC_CHECK_HEADERS([sys/capability.h],
975			[],
976			[AC_MSG_ERROR(m4_normalize([sys/capability.h header is required for Linux capabilities support.
977						    Either install libcap or use --disable-linux-caps.]))])
978       AX_SAVE_FLAGS([cap])
979       AC_SEARCH_LIBS([cap_set_proc], [cap],
980		      [LIBCAP_LIBS="$ac_cv_search_cap_set_proc"],
981		      [AC_MSG_ERROR(m4_normalize([libcap is required for Linux capabilities support.
982						  Either install libcap or use --disable-linux-caps.]))])
983       AX_RESTORE_FLAGS([cap])],
984      [AC_MSG_RESULT([no])])
985AC_SUBST([LIBCAP_LIBS])
986
987case "$host" in
988*-solaris*)
989	AC_DEFINE(NEED_SECURE_DIRECTORY, 1,
990		  [Define if connect does not honour the permission on the UNIX domain socket.])
991	;;
992esac
993
994#
995# Time Zone Stuff
996#
997AC_CHECK_FUNCS([tzset])
998
999AC_MSG_CHECKING(for optarg declaration)
1000AC_COMPILE_IFELSE(
1001  [AC_LANG_PROGRAM(
1002     [[#include <unistd.h>]],
1003     [[optarg = 0;]]
1004   )],
1005  [AC_MSG_RESULT(yes)],
1006  [AC_MSG_RESULT(no)
1007   GEN_NEED_OPTARG="-DNEED_OPTARG=1"
1008   AC_DEFINE(NEED_OPTARG, 1, [Defined if extern char *optarg is not declared.])]
1009)
1010
1011#
1012# Check for nanoseconds in file stats
1013#
1014AC_MSG_CHECKING([for st_mtim.tv_nsec])
1015AC_COMPILE_IFELSE(
1016  [AC_LANG_PROGRAM(
1017     [[#include <sys/stat.h>]],
1018     [[struct stat s;
1019       return(s.st_mtim.tv_nsec);
1020      ]])],
1021  [AC_MSG_RESULT([yes])
1022   AC_DEFINE([HAVE_STAT_NSEC], [1], [define if struct stat has st_mtim.tv_nsec field])],
1023  [AC_MSG_RESULT([no])])
1024
1025#
1026# Check for if_nametoindex() for IPv6 scoped addresses support
1027#
1028AC_CHECK_FUNCS([if_nametoindex])
1029
1030ISC_ATOMIC_LIBS=""
1031AC_CHECK_HEADERS(
1032  [stdatomic.h],
1033  [AC_MSG_CHECKING([for memory model aware atomic operations])
1034   AC_COMPILE_IFELSE(
1035     [AC_LANG_PROGRAM(
1036	[[#include <stdatomic.h>]],
1037	[[atomic_int_fast32_t val = 0; atomic_fetch_add_explicit(&val, 1, memory_order_relaxed);]]
1038      )],
1039     [AC_MSG_RESULT([stdatomic.h])
1040      AC_MSG_CHECKING([whether -latomic is needed for 64-bit stdatomic.h functions])
1041      AC_LINK_IFELSE(
1042	[AC_LANG_PROGRAM(
1043	   [[#include <stdatomic.h>]],
1044	   [[atomic_int_fast64_t val = 0; atomic_fetch_add_explicit(&val, 1, memory_order_relaxed);]]
1045	 )],
1046	[AC_MSG_RESULT([no])],
1047	[ISC_ATOMIC_LIBS="-latomic"
1048	 AX_SAVE_FLAGS([atomic])
1049	 LIBS="$LIBS $ISC_ATOMIC_LIBS"
1050	 AC_LINK_IFELSE(
1051	   [AC_LANG_PROGRAM(
1052	      [[#include <stdatomic.h>]],
1053	      [[atomic_int_fast64_t val = 0; atomic_fetch_add_explicit(&val, 1, memory_order_relaxed);]]
1054	    )],
1055	   [AC_MSG_RESULT([yes])],
1056	   [AC_MSG_FAILURE([libatomic needed, but linking with -latomic failed, please fix your toolchain.])])
1057	 AX_RESTORE_FLAGS([atomic])
1058	])
1059     ],
1060     [AC_MSG_FAILURE([stdatomic.h header found, but compilation failed, please fix your toolchain.])]
1061   )],
1062  [AC_MSG_CHECKING([for memory model aware atomic operations])
1063   AC_COMPILE_IFELSE(
1064     [AC_LANG_PROGRAM(
1065	[[#include <inttypes.h>]],
1066	[[int32_t val = 0; __atomic_fetch_add(&val, 1, __ATOMIC_RELAXED);]]
1067      )],
1068     [AC_MSG_RESULT([__atomic builtins])
1069      AC_DEFINE([HAVE___ATOMIC], [1], [define if __atomic builtins are not available])
1070      AC_MSG_CHECKING([whether -latomic is needed for 64-bit __atomic builtins])
1071      AC_LINK_IFELSE(
1072	[AC_LANG_PROGRAM(
1073	   [[#include <inttypes.h>]],
1074	   [[int64_t val = 0; __atomic_fetch_add(&val, 1, __ATOMIC_RELAXED);]]
1075	 )],
1076	[AC_MSG_RESULT([no])],
1077	[ISC_ATOMIC_LIBS="-latomic"
1078	 AX_SAVE_FLAGS([atomic])
1079	 LIBS="$LIBS $ISC_ATOMIC_LIBS"
1080	 AC_LINK_IFELSE(
1081	   [AC_LANG_PROGRAM(
1082	      [[#include <inttypes.h>]],
1083	      [[int64_t val = 0; __atomic_fetch_add(&val, 1, __ATOMIC_RELAXED);]]
1084	    )],
1085	   [AC_MSG_RESULT([yes])],
1086	   [AC_MSG_FAILURE([libatomic needed, but linking with -latomic failed, please fix your toolchain.])])
1087	 AX_RESTORE_FLAGS([atomic])
1088	])
1089     ],
1090     [AC_MSG_FAILURE([not found])
1091     ])
1092  ])
1093LIBS="$LIBS $ISC_ATOMIC_LIBS"
1094
1095AC_CHECK_HEADERS([stdalign.h stdnoreturn.h])
1096
1097AC_CHECK_HEADERS([uchar.h])
1098
1099#
1100# Check for __builtin_unreachable
1101#
1102AC_MSG_CHECKING([compiler support for __builtin_unreachable()])
1103AC_LINK_IFELSE(
1104  [AC_LANG_PROGRAM(
1105     [[]],
1106     [[__builtin_unreachable();]]
1107   )],
1108  [AC_MSG_RESULT([yes])
1109   AC_DEFINE([HAVE_BUILTIN_UNREACHABLE], [1], [define if the compiler supports __builtin_unreachable().])
1110  ],
1111  [AC_MSG_RESULT([no])
1112  ])
1113
1114#
1115# Check for __builtin_clz
1116#
1117AC_MSG_CHECKING([compiler support for __builtin_clz])
1118AC_LINK_IFELSE(
1119  [AC_LANG_PROGRAM(
1120     [[]],
1121     [[return (__builtin_clz(0xff) == 24 ? 1 : 0);]]
1122   )],
1123  [AC_MSG_RESULT([yes])
1124   AC_DEFINE(HAVE_BUILTIN_CLZ, 1, [Define to 1 if the compiler supports __builtin_clz.])
1125  ],
1126  [AC_MSG_RESULT([no])]
1127)
1128
1129#
1130# Check for __builtin_uadd_overflow
1131#
1132AC_MSG_CHECKING([compiler support for __builtin_*_overflow()])
1133AC_LINK_IFELSE(
1134  [AC_LANG_PROGRAM(
1135     [[#include <limits.h>]],
1136     [[return (__builtin_uadd_overflow(UINT_MAX, UINT_MAX, &(unsigned int){ 0 }));]]
1137   )],
1138  [AC_MSG_RESULT([yes])
1139   AC_DEFINE([HAVE_BUILTIN_OVERFLOW], [1], [define if the compiler supports __builtin_*_overflow().])
1140  ],
1141  [AC_MSG_RESULT([no])
1142  ])
1143
1144#
1145# Activate "rrset-order fixed" or not?
1146#
1147# [pairwise: --enable-fixed-rrset, --disable-fixed-rrset]
1148AC_ARG_ENABLE([fixed-rrset],
1149	      [AS_HELP_STRING([--enable-fixed-rrset],
1150			      [enable fixed rrset ordering [default=no]])],
1151	      [], [enable_fixed_rrset="no"])
1152AS_IF([test "$enable_fixed_rrset" = "yes"],
1153      [AC_DEFINE([DNS_RDATASET_FIXED], [1],
1154		 [Define to enable "rrset-order fixed" syntax.])])
1155
1156#
1157# Activate dnstap?
1158#
1159# [pairwise: --enable-dnstap, --disable-dnstap]
1160AC_ARG_ENABLE([dnstap],
1161	      [AS_HELP_STRING([--enable-dnstap],
1162			      [enable dnstap support
1163			       (requires fstrm, protobuf-c)])],
1164	      [], [enable_dnstap=no])
1165
1166AS_IF([test "$enable_dnstap" != "no"],
1167      [PKG_CHECK_MODULES([DNSTAP], [libfstrm libprotobuf-c], [],
1168			 [AC_MSG_FAILURE([Required libraries (fstrm, protobuf-c) were not found, please install them.])])
1169       AC_PATH_PROG([FSTRM_CAPTURE], [fstrm_capture])
1170       AC_PATH_PROG([PROTOC_C], [protoc-c])
1171       AS_IF([test -z "$PROTOC_C"],
1172	     [AC_MSG_ERROR([protoc-c compiler not found])])
1173       AC_DEFINE([HAVE_DNSTAP], 1, [Define to 1 to enable dnstap support])
1174      ])
1175
1176AC_SUBST([DNSTAP_CFLAGS])
1177AC_SUBST([DNSTAP_LIBS])
1178AM_CONDITIONAL([HAVE_DNSTAP], [test "$enable_dnstap" != "no"])
1179#
1180# The following sections deal with tools used for formatting
1181# the documentation.  They are all optional, unless you are
1182# a developer editing the documentation source.
1183#
1184
1185#
1186# Look for sphinx-build
1187#
1188AC_ARG_VAR([SPHINX_BUILD], [path to sphinx-build binary used to build the documentation])
1189AC_PATH_PROG([SPHINX_BUILD], [sphinx-build], [])
1190AM_CONDITIONAL([HAVE_SPHINX_BUILD], [test -n "$SPHINX_BUILD"])
1191
1192AC_PATH_PROG([XELATEX], [xelatex], [])
1193AC_PATH_PROG([LATEXMK], [latexmk], [])
1194AM_CONDITIONAL([HAVE_XELATEX], [test -n "$XELATEX" && test -n "$LATEXMK"])
1195
1196#
1197# Build the man pages only if we have prebuilt manpages or we can build them from RST sources
1198#
1199AM_CONDITIONAL([BUILD_MANPAGES], [test -e doc/man/named.conf.5in || test -n "$SPHINX_BUILD"])
1200
1201#
1202# Pull release date from CHANGES file last modification date
1203# for reproducible builds
1204#
1205release_date=`date -u -r CHANGES +%Y-%m-%d`
1206AC_SUBST([RELEASE_DATE], $release_date)
1207
1208#
1209# Look for Doxygen
1210#
1211AC_PATH_PROGS([DOXYGEN], [doxygen])
1212
1213AC_CONFIG_FILES([doc/doxygen/doxygen-input-filter],
1214		[chmod +x doc/doxygen/doxygen-input-filter])
1215
1216#
1217# Look for curl
1218#
1219
1220AC_PATH_PROG(CURL, curl, curl)
1221AC_SUBST(CURL)
1222
1223#
1224# Look for nc
1225#
1226
1227AC_PATH_PROGS(NC, nc, nc)
1228AC_SUBST(NC)
1229
1230#
1231# IDN support using libidn2
1232#
1233
1234LIBIDN2_CFLAGS=
1235LIBIDN2_LIBS=
1236
1237# [pairwise: --with-libidn2=yes, --without-libidn2]
1238AC_ARG_WITH([libidn2],
1239	    [AS_HELP_STRING([--with-libidn2[=PATH]], [enable IDN support using GNU libidn2 [yes|no(default)|path]])],
1240	    [with_libidn2="$withval"], [with_libidn2="no"])
1241AS_CASE([$with_libidn2],
1242	[yes],	[PKG_CHECK_MODULES([LIBIDN2], [libidn2],
1243				   [AC_DEFINE([HAVE_LIBIDN2], [1], [Define if libidn2 was found])])],
1244	[no],	[],
1245	[*],	[AX_SAVE_FLAGS([libidn2])
1246		 LIBIDN2_CFLAGS="-I$with_libidn2/include"
1247		 LIBIDN2_LIBS="-L$with_libidn2/lib"
1248		 CFLAGS="$CFLAGS $LIBIDN2_CFLAGS"
1249		 LIBS="$LIBS $LIBIDN2_LIBS"
1250		 AC_CHECK_HEADERS([idn2.h],
1251				  [],
1252				  [AC_MSG_ERROR([idn2.h not found])])
1253		 AC_SEARCH_LIBS([idn2_to_ascii_lz], [idn2],
1254				[LIBIDN2_LIBS="$LIBIDN2_LIBS $ac_cv_search_idn2_to_ascii_lz"
1255				 AC_DEFINE([HAVE_LIBIDN2], [1], [Define if libidn2 was found])],
1256				[AC_MSG_ERROR([libidn2 requested, but not found])])
1257		AX_RESTORE_FLAGS([libidn2])])
1258AC_SUBST([LIBIDN2_CFLAGS])
1259AC_SUBST([LIBIDN2_LIBS])
1260
1261#
1262# Check whether to build with cmocka unit testing framework
1263#
1264# [pairwise: --with-cmocka=detect, --with-cmocka=yes, --without-cmocka]
1265AC_ARG_WITH([cmocka],
1266	    [AS_HELP_STRING([--with-cmocka=detect],[enable CMocka based tests (default is detect)])],
1267	    [],[with_cmocka=detect])
1268
1269AS_CASE([$with_cmocka],
1270	[no],[],
1271	[detect],[PKG_CHECK_MODULES([CMOCKA], [cmocka >= 1.1.3],
1272				    [AC_DEFINE([HAVE_CMOCKA], [1], [Use CMocka])
1273				     with_cmocka=yes],[with_cmocka=no])],
1274	[yes],[PKG_CHECK_MODULES([CMOCKA], [cmocka >= 1.1.3],
1275				 [AC_DEFINE([HAVE_CMOCKA], [1], [Use CMocka])])],
1276	[AC_MSG_ERROR([Use PKG_CONFIG_PATH to specify path to CMocka library])]
1277       )
1278AC_SUBST([CMOCKA_CFLAGS])
1279AC_SUBST([CMOCKA_LIBS])
1280
1281AM_CONDITIONAL([HAVE_CMOCKA], [test "$with_cmocka" = "yes"])
1282
1283#
1284# Compile with jemalloc (either provided as package or wired in the system on FreeBSD)
1285#
1286# [pairwise: --with-jemalloc=detect, --with-jemalloc=yes, --without-jemalloc]
1287AC_ARG_WITH([jemalloc],
1288	    [AS_HELP_STRING([--with-jemalloc=detect],[enable jemalloc memory allocator (default is detect)])],
1289	    [],[with_jemalloc=detect])
1290
1291AS_CASE([$with_jemalloc],
1292	[no],[],
1293	[yes],[AX_CHECK_JEMALLOC(
1294		 [AC_DEFINE([HAVE_JEMALLOC], [1], [Define to 1 if jemalloc is available])],
1295		 [AC_MSG_ERROR([jemalloc not found])])],
1296	[AX_CHECK_JEMALLOC(
1297	   [AC_DEFINE([HAVE_JEMALLOC], [1], [Define to 1 if jemalloc is available])
1298	    with_jemalloc=yes],
1299	   [AC_MSG_WARN([jemalloc not found; performance will be reduced])
1300	    with_jemalloc=no])])
1301
1302AS_IF([test "$with_jemalloc" = "no"],
1303      [AS_CASE([$host],
1304	       [*-freebsd*],[AC_MSG_ERROR([You cannot compile without jemalloc; jemalloc is the system allocator on FreeBSD])])
1305       AC_CHECK_FUNCS([malloc_size malloc_usable_size])])
1306
1307AM_CONDITIONAL([HAVE_JEMALLOC], [test "$with_jemalloc" = "yes"])
1308
1309#
1310# was --with-tuning specified?
1311#
1312# [pairwise: --with-tuning=small, --without-tuning]
1313AC_ARG_WITH([tuning],
1314	    AS_HELP_STRING([--with-tuning=ARG],
1315			   [Specify server tuning (default or small)]),
1316	    [],[with_tuning=no])
1317
1318AS_CASE([$with_tuning],
1319	[small],[AC_MSG_NOTICE(using small system tuning)],
1320	[AC_DEFINE(TUNE_LARGE, 1, [Define to use default system tuning.])
1321	 AC_MSG_NOTICE(using default system tuning)])
1322
1323#
1324# was --enable-querytrace or --enable-singletrace specified?
1325#
1326# [pairwise: --enable-singletrace --enable-querytrace, --disable-singletrace --enable-querytrace, --disable-singletrace --disable-querytrace]
1327AC_ARG_ENABLE([singletrace],
1328	      AS_HELP_STRING([--enable-singletrace],
1329			     [enable single-query trace logging
1330			      [default=no]]),
1331	      enable_singletrace="$enableval", enable_singletrace="no")
1332
1333AC_MSG_CHECKING([whether to enable single-query trace logging])
1334case "$enable_singletrace" in
1335yes)
1336	enable_querytrace=yes
1337	AC_MSG_RESULT(yes)
1338	AC_DEFINE(WANT_SINGLETRACE, 1, [Define to enable single-query tracing.])
1339	;;
1340no)
1341	AC_MSG_RESULT(no)
1342	;;
1343*)
1344	AC_MSG_ERROR("--enable-singletrace requires yes or no")
1345	;;
1346esac
1347
1348# [pairwise: skip]
1349AC_ARG_ENABLE(querytrace,
1350	      AS_HELP_STRING([--enable-querytrace],
1351			     [enable very verbose query trace logging
1352				[default=no]]),
1353	      enable_querytrace="$enableval",
1354	      enable_querytrace="$enable_singletrace")
1355
1356AC_MSG_CHECKING([whether to enable query trace logging])
1357case "$enable_querytrace" in
1358yes)
1359	AC_MSG_RESULT(yes)
1360	AC_DEFINE(WANT_QUERYTRACE, 1, [Define to enable very verbose query trace logging.])
1361	;;
1362no)
1363       AS_IF([test "$enable_singletrace" = "yes"],
1364	     [AC_MSG_ERROR([--enable-singletrace requires --enable-querytrace])])
1365	AC_MSG_RESULT(no)
1366	;;
1367*)
1368	AC_MSG_ERROR("--enable-querytrace requires yes or no (not $enable_querytrace)")
1369	;;
1370esac
1371
1372#
1373# Was --disable-auto-validation specified?
1374#
1375
1376validation_default=auto
1377
1378# [pairwise: --enable-auto-validation, --disable-auto-validation]
1379AC_ARG_ENABLE(auto-validation,
1380	      AS_HELP_STRING([--enable-auto-validation],
1381			     [turn on DNSSEC validation by default, using the IANA root key [default=yes]]),
1382	      [:],[enable_auto_validation=yes])
1383AS_IF([test "$enable_auto_validation" = "no"],[validation_default=yes])
1384AC_DEFINE_UNQUOTED([VALIDATION_DEFAULT], ["$validation_default"], [the default value of dnssec-validation option])
1385
1386#
1387#
1388# Response policy rewriting using DNS Response Policy Service (DNSRPS)
1389# interface.
1390#
1391# DNSRPS can be compiled into BIND everywhere with a reasonably
1392# modern C compiler.  It is enabled on systems with dlopen() and librpz.so.
1393#
1394dnsrps_avail=yes
1395AC_MSG_CHECKING([for librpz __attribute__s])
1396AC_COMPILE_IFELSE(
1397  [AC_LANG_PROGRAM(
1398     [[]],
1399     [[
1400       extern void f(char *p __attribute__((unused)), ...)
1401       __attribute__((format(printf,1,2))) __attribute__((__noreturn__));
1402     ]])],
1403  [
1404    librpz_have_attr=yes
1405    AC_DEFINE([LIBRPZ_HAVE_ATTR], [1], [have __attribute__s used in librpz.h])
1406    AC_MSG_RESULT([yes])
1407  ],[
1408    librpz_have_attr=no
1409    AC_MSG_RESULT([no])
1410  ])
1411
1412# [pairwise: --enable-dnsrps --enable-dnsrps-dl, --disable-dnsrps]
1413AC_ARG_ENABLE([dnsrps-dl],
1414	      [AS_HELP_STRING([--enable-dnsrps-dl],
1415			      [DNS Response Policy Service delayed link
1416			       [default=$librpz_dl]])],
1417	      [enable_librpz_dl="$enableval"], [enable_librpz_dl="$with_dlopen"])
1418
1419AS_IF([test "$enable_librpz_dl" = "yes" -a "$with_dlopen" = "no"],
1420      [AC_MSG_ERROR([DNS Response Policy Service delayed link requires dlopen to be enabled])])
1421
1422# [pairwise: skip]
1423AC_ARG_WITH([dnsrps-libname],
1424	    [AS_HELP_STRING([--with-dnsrps-libname],
1425			    [DNSRPS provider library name (librpz.so)])],
1426	    [librpz_name="$withval"], [librpz_name="librpz.so"])
1427
1428# [pairwise: skip]
1429AC_ARG_WITH([dnsrps-dir],
1430	    [AS_HELP_STRING([--with-dnsrps-dir],
1431			    [path to DNSRPS provider library])],
1432	    [librpz_path="$withval/$librpz_name"], [librpz_path="$librpz_name"])
1433AC_DEFINE_UNQUOTED([DNSRPS_LIBRPZ_PATH], ["$librpz_path"],
1434		   [dnsrps $librpz_name])
1435AS_IF([test "$enable_librpz_dl" = "yes"],
1436      [
1437	dnsrps_lib_open=2
1438      ],[
1439	dnsrps_lib_open=1
1440	# Add librpz.so to linked libraries if we are not using dlopen()
1441	AC_SEARCH_LIBS([librpz_client_create], [rpz], [],
1442		[dnsrps_lib_open=0
1443		 dnsrps_avail=no])
1444      ])
1445AC_DEFINE_UNQUOTED([DNSRPS_LIB_OPEN], [$dnsrps_lib_open],
1446		   [0=no DNSRPS  1=static link  2=dlopen()])
1447
1448# [pairwise: skip]
1449AC_ARG_ENABLE([dnsrps],
1450	      AS_HELP_STRING([--enable-dnsrps],
1451			     [enable DNS Response Policy Service API]),
1452	      [enable_dnsrps=$enableval], [enable_dnsrps=no])
1453
1454AS_IF([test "$enable_dnsrps" != "no"],[
1455	AS_IF([test "$dnsrps_avail" != "yes"],
1456	      [AC_MSG_ERROR([dlopen and librpz.so needed for DNSRPS])])
1457	AS_IF([test "$dnsrps_lib_open" = "0"],
1458	      [AC_MSG_ERROR([dlopen and librpz.so needed for DNSRPS])])
1459	AC_DEFINE([USE_DNSRPS], [1], [Enable DNS Response Policy Service API])
1460      ])
1461
1462AC_CHECK_HEADERS([glob.h])
1463
1464#
1465# Support for constructor and destructor attributes
1466#
1467AX_GCC_FUNC_ATTRIBUTE([constructor])
1468AX_GCC_FUNC_ATTRIBUTE([destructor])
1469
1470#
1471# Files to configure.  These are listed here because we used to
1472# specify them as arguments to AC_OUTPUT.
1473#
1474
1475# Top
1476
1477AC_CONFIG_FILES([Makefile])
1478
1479# Binaries
1480
1481AC_CONFIG_FILES([bin/Makefile
1482		 bin/named/Makefile
1483		 bin/rndc/Makefile
1484		 bin/dig/Makefile
1485		 bin/delv/Makefile
1486		 bin/dnssec/Makefile
1487		 bin/tools/Makefile
1488		 bin/nsupdate/Makefile
1489		 bin/check/Makefile
1490		 bin/confgen/Makefile
1491		 bin/plugins/Makefile])
1492
1493# Libraries
1494
1495AC_CONFIG_FILES([lib/Makefile
1496		 lib/isc/Makefile
1497		 lib/dns/Makefile
1498		 lib/ns/Makefile
1499		 lib/irs/Makefile
1500		 lib/isccfg/Makefile
1501		 lib/isccc/Makefile
1502		 lib/bind9/Makefile])
1503
1504# Documentation
1505
1506AC_CONFIG_FILES([doc/Makefile
1507		 doc/arm/Makefile
1508		 doc/man/Makefile
1509		 doc/misc/Makefile])
1510
1511# Unit Tests
1512
1513AC_CONFIG_FILES([tests/Makefile
1514		 tests/isc/Makefile
1515		 tests/dns/Makefile
1516		 tests/ns/Makefile
1517		 tests/irs/Makefile
1518		 tests/isccfg/Makefile
1519		 tests/libtest/Makefile])
1520
1521AC_CONFIG_FILES([tests/unit-test-driver.sh],
1522		[chmod +x tests/unit-test-driver.sh])
1523
1524# System Tests
1525
1526AC_CONFIG_FILES([bin/tests/Makefile
1527		 bin/tests/system/Makefile
1528		 bin/tests/system/conf.sh
1529		 bin/tests/system/dyndb/driver/Makefile
1530		 bin/tests/system/dlzexternal/driver/Makefile
1531		 bin/tests/system/hooks/driver/Makefile])
1532
1533AC_CONFIG_FILES([bin/tests/system/ifconfig.sh],
1534		[chmod +x bin/tests/system/ifconfig.sh])
1535AC_CONFIG_FILES([bin/tests/system/legacy.run.sh],
1536		[chmod +x bin/tests/system/legacy.run.sh])
1537AC_CONFIG_FILES([bin/tests/system/start.sh],
1538		[chmod +x bin/tests/system/start.sh])
1539AC_CONFIG_FILES([bin/tests/system/stop.sh],
1540		[chmod +x bin/tests/system/stop.sh])
1541
1542# Fuzz Tests
1543
1544AC_CONFIG_FILES([fuzz/Makefile])
1545
1546# Misc
1547
1548AC_CONFIG_FILES([util/check-make-install])
1549
1550#
1551# Do it
1552#
1553
1554AC_OUTPUT
1555
1556# [pairwise: --enable-full-report, --disable-full-report]
1557AC_ARG_ENABLE(full-report,
1558	      AS_HELP_STRING([--enable-full-report],
1559			     [report values of all configure options]))
1560
1561report() {
1562    echo "==============================================================================="
1563    echo "Configuration summary:"
1564    echo "-------------------------------------------------------------------------------"
1565    echo "Optional features enabled:"
1566    if test "yes" = "$with_jemalloc"; then
1567	echo "    Memory allocator: jemalloc"
1568    fi
1569    if test "yes" = "$enable_full_report" -o "standard" = "$with_locktype"; then
1570	echo "    Mutex lock type: $with_locktype"
1571    fi
1572    test "small" = "$with_tuning" && echo "    Small-system tuning (--with-tuning)"
1573    test "no" = "$enable_dnstap" || \
1574	    echo "    Allow 'dnstap' packet logging (--enable-dnstap)"
1575    test -z "$MAXMINDDB_LIBS" || echo "    GeoIP2 access control (--enable-geoip)"
1576    test -z "$GSSAPI_LIBS" || echo "    GSS-API (--with-gssapi)"
1577
1578    # these lines are only printed if run with --enable-full-report
1579    if test "yes" = "$enable_full_report"; then
1580	test -z "$LIBXML2_LIBS" || echo "    XML statistics (--with-libxml2)"
1581	test -z "$JSON_C_LIBS" || echo "    JSON statistics (--with-json-c): $JSON_C_CFLAGS $JSON_C_LIBS"
1582	test -z "$ZLIB_LIBS" || echo "    HTTP zlib compression (--with-zlib)"
1583	test -z "$LMDB_LIBS" || echo "    LMDB database to store configuration for 'addzone' zones (--with-lmdb)"
1584	test -z "$LIBIDN2_LIBS" || echo "    IDN support (--with-libidn2)"
1585    fi
1586
1587    test "yes" = "$enable_dnsrps" && \
1588	echo "    DNS Response Policy Service interface (--enable-dnsrps)"
1589    test "yes" = "$enable_fixed_rrset" && \
1590	echo "    Allow 'fixed' rrset-order (--enable-fixed-rrset)"
1591    test "yes" = "$enable_querytrace" && \
1592	echo "    Very verbose query trace logging (--enable-querytrace)"
1593    test "yes" = "$enable_singletrace" && \
1594	echo "    Single-query trace logging (--enable-singletrace)"
1595    test -z "$HAVE_CMOCKA" || echo "    CMocka Unit Testing Framework (--with-cmocka)"
1596
1597    test "auto" = "$validation_default" && echo "    DNSSEC validation active by default (--enable-auto-validation)"
1598
1599    echo "-------------------------------------------------------------------------------"
1600
1601    echo "Features disabled or unavailable on this platform:"
1602    if test "no" = "$with_jemalloc"; then
1603      echo "    Memory allocator: system"
1604      echo
1605      echo "    +------------------------------------------+"
1606      echo "    |             ==== WARNING ====            |"
1607      echo "    |                                          |"
1608      echo "    | This is NOT a recommended configuration. |"
1609      echo "    | Using the system memory allocator causes |"
1610      echo "    | reduced performance and increased memory |"
1611      echo "    | fragmentation. Installing the jemalloc   |"
1612      echo "    | memory allocator (version >= 4.0.0) is   |"
1613      echo "    | strongly recommended.                    |"
1614      echo "    +------------------------------------------+"
1615      echo
1616    fi
1617    test "small" = "$with_tuning" || echo "    Small-system tuning (--with-tuning)"
1618
1619    test "no" = "$enable_dnstap" && \
1620	    echo "    Allow 'dnstap' packet logging (--enable-dnstap)"
1621    test -z "$MAXMINDDB_LIBS" && echo "    GeoIP2 access control (--enable-geoip)"
1622    test -z "$GSSAPI_LIBS" && echo "    GSS-API (--with-gssapi)"
1623
1624    test "no" = "$enable_dnsrps" && \
1625	echo "    DNS Response Policy Service interface (--enable-dnsrps)"
1626
1627    test "yes" = "$enable_fixed_rrset" || \
1628	echo "    Allow 'fixed' rrset-order (--enable-fixed-rrset)"
1629
1630    test "yes" = "$validation_default" && echo "    DNSSEC validation requires configuration (--enable-auto-validation)"
1631
1632    test "yes" = "$enable_querytrace" || \
1633	echo "    Very verbose query trace logging (--enable-querytrace)"
1634    test "yes" = "$enable_singletrace" || \
1635	echo "    Single-query trace logging (--enable-singletrace)"
1636
1637    test "no" = "$with_cmocka" && echo "    CMocka Unit Testing Framework (--with-cmocka)"
1638
1639    test -z "$LIBXML2_LIBS" && echo "    XML statistics (--with-libxml2)"
1640    test -z "$JSON_C_LIBS" && echo "    JSON statistics (--with-json-c)"
1641    test -z "$ZLIB_LIBS" && echo "    HTTP zlib compression (--with-zlib)"
1642    test -z "$LMDB_LIBS" && echo "    LMDB database to store configuration for 'addzone' zones (--with-lmdb)"
1643    test -z "$LIBIDN2_LIBS" && echo "    IDN support (--with-libidn2)"
1644
1645    echo "-------------------------------------------------------------------------------"
1646    echo "Configured paths:"
1647    echo "    prefix: $prefix"
1648    echo "    sysconfdir: $sysconfdir"
1649    echo "    localstatedir: $localstatedir"
1650    echo "-------------------------------------------------------------------------------"
1651    echo "Compiler: $CC"
1652    AS_IF([test "$GCC" = "yes"],
1653	  [$CC --version 2>&1 | sed 's/^/    /'],
1654	  [AS_CASE([$host],
1655		   [*-solaris*],[$CC -V 2>&1 | sed 's/^/    /'],
1656		   [$CC --version 2>&1 | sed 's/^/    /'])])
1657    echo "CFLAGS: $STD_CFLAGS $CFLAGS"
1658    echo "CPPFLAGS: $STD_CPPFLAGS $CPPFLAGS"
1659    echo "LDFLAGS: $LDFLAGS"
1660
1661    if test "X$ac_unrecognized_opts" != "X"; then
1662	echo "-------------------------------------------------------------------------------"
1663	echo "Unrecognized options:"
1664	echo "    $ac_unrecognized_opts"
1665    fi
1666
1667    if test "yes" != "$enable_full_report"; then
1668	echo "-------------------------------------------------------------------------------"
1669	echo "For more detail, use --enable-full-report."
1670    fi
1671    echo "==============================================================================="
1672}
1673
1674if test "yes" != "$silent"; then
1675	report
1676fi
1677
1678# Tell Emacs to edit this file in shell mode.
1679# Local Variables:
1680# mode: sh
1681# End:
1682