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