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