configure.ac revision 1.1.1.10
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
10AC_INIT(BIND, [9.16], [info@isc.org], [], [https://www.isc.org/downloads/])
11AC_PREREQ([2.60])
12
13#
14# Enable maintainer mode by default, but allow to disable it in the CI
15#
16AM_MAINTAINER_MODE([enable])
17
18AC_CONFIG_HEADER(config.h)
19AC_CONFIG_MACRO_DIR([m4])
20
21AC_CANONICAL_HOST
22
23#
24# Enable system extensions to C and POSIX
25#
26AC_USE_SYSTEM_EXTENSIONS
27
28#
29# Enable large file support
30#
31AC_SYS_LARGEFILE
32AC_FUNC_FSEEKO
33
34LFS_CFLAGS=`getconf LFS_CFLAGS 2>/dev/null`
35LFS_LDFLAGS=`getconf LFS_LDFLAGS 2>/dev/null`
36LFS_LIBS=`getconf LFS_LIBS 2>/dev/null`
37
38AC_SUBST([LFS_CFLAGS])
39AC_SUBST([LFS_LDFLAGS])
40AC_SUBST([LFS_LIBS])
41
42# Enable RFC 3542 APIs on macOS
43AC_DEFINE([__APPLE_USE_RFC_3542], [1], [Select RFC3542 IPv6 API on macOS])
44
45AC_PROG_MAKE_SET
46
47AC_PROG_LIBTOOL
48AC_PROG_INSTALL
49AC_PROG_LN_S
50AX_POSIX_SHELL
51AC_PROG_MKDIR_P
52
53AC_SUBST(STD_CINCLUDES)
54AC_SUBST(STD_CDEFINES)
55AC_SUBST(STD_CWARNINGS)
56AC_SUBST(CCOPT)
57AC_SUBST(CCNOOPT)
58AC_SUBST(BACKTRACECFLAGS)
59
60#
61# Use pkg-config
62#
63
64PKG_PROG_PKG_CONFIG
65AS_IF([test -z "$PKG_CONFIG"],
66      [AC_MSG_ERROR([The pkg-config script could not be found or is too old.])])
67
68# [pairwise: --enable-buffer-useinline, --disable-buffer-useinline]
69AC_ARG_ENABLE(buffer_useinline,
70	      AS_HELP_STRING([--enable-buffer-useinline],
71		             [define ISC_BUFFER_USEINLINE when compiling
72				[default=yes]]),
73	      if test yes = "${enable}"
74	      then
75		      AC_DEFINE([ISC_BUFFER_USEINLINE], [1],
76			        [Define if you want to use inline buffers])
77	      fi,
78	      AC_DEFINE([ISC_BUFFER_USEINLINE], [1]))
79
80# [pairwise: --enable-warn-shadow, --disable-warn-shadow]
81AC_ARG_ENABLE([warn_shadow],
82	      [AS_HELP_STRING([--enable-warn-shadow],
83			      [turn on -Wshadow when compiling])])
84
85# [pairwise: --enable-warn-error, --disable-warn-error]
86AC_ARG_ENABLE([warn_error],
87	      [AS_HELP_STRING([--enable-warn-error],
88			      [turn on -Werror when compiling])])
89
90# [pairwise: --enable-developer, --disable-developer]
91AC_ARG_ENABLE([developer],
92	      [AS_HELP_STRING([--enable-developer],
93			      [enable developer build settings])])
94
95XTARGETS=
96AS_IF([test "$enable_developer" = "yes"],
97      [STD_CDEFINES="$STD_CDEFINES -DISC_MEM_DEFAULTFILL=1 -DISC_LIST_CHECKINIT=1"
98       test "${enable_fixed_rrset+set}" = set || enable_fixed_rrset=yes
99       test "${enable_querytrace+set}" = set || enable_querytrace=yes
100       test "${with_cmocka+set}" = set || with_cmocka=yes
101       test "${with_dlz_filesystem+set}" = set || with_dlz_filesystem=yes
102       test "${enable_symtable+set}" = set || enable_symtable=all
103       test "${enable_warn_error+set}" = set || enable_warn_error=yes
104       test "${enable_warn_shadow+set}" = set || enable_warn_shadow=yes
105       test "${with_zlib+set}" = set || with_zlib=yes
106       XTARGETS='${XTARGETS}'
107       ])
108AC_SUBST([XTARGETS])
109
110# Fuzzing is not included in pairwise testing as fuzzing tools are
111# not present in the relevant Docker image.
112#
113# [pairwise: skip]
114AC_ARG_ENABLE([fuzzing],
115	      [AS_HELP_STRING([--enable-fuzzing=<afl|libfuzzer>],
116			      [Enable fuzzing using American Fuzzy Lop or libFuzzer (default=no)])],
117	      [],
118	      [enable_fuzzing=no])
119
120AC_MSG_CHECKING([whether to enable fuzzing mode])
121AS_CASE([$enable_fuzzing],
122	[no],[AC_MSG_RESULT([no])],
123	[afl],[
124	  AC_MSG_RESULT([using AFL])
125	  AC_DEFINE([ENABLE_AFL], [1],
126		    [Define to enable American Fuzzy Lop test harness])
127	  CFLAGS="$CFLAGS -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1"
128	  LIBS="$LIBS -lpthread"],
129	[libfuzzer],[
130	  AC_MSG_RESULT([using libFuzzer])
131	  CFLAGS="$CFLAGS -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1 -fsanitize=fuzzer,address,undefined"
132	  LDFLAGS="$LDFLAGS -fsanitize=fuzzer,address,undefined"],
133	[*],[AC_MSG_ERROR([You need to explicitly select the fuzzer])])
134
135AS_IF([test "$enable_fuzzing" = "afl"],
136      [AC_MSG_CHECKING("for AFL enabled compiler")
137       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
138					  [#ifndef __AFL_COMPILER
139					   #error AFL compiler required
140					   #endif
141					  ])],
142			 [AC_MSG_RESULT([yes])],
143			 [AC_MSG_ERROR([set CC=afl-<gcc|clang> when --enable-fuzzing=afl is used])])
144      ])
145
146# [pairwise: --enable-mutex-atomics, --disable-mutex-atomics]
147AC_ARG_ENABLE(mutex_atomics,
148	      AS_HELP_STRING([--enable-mutex-atomics],
149		             [emulate atomics by mutex-locked variables, useful for debugging
150				[default=no]]),
151	      [],
152	      [enable_mutex_atomics=no])
153
154AC_MSG_CHECKING([whether to emulate atomics with mutexes])
155case "$enable_mutex_atomics" in
156yes)
157        AC_MSG_RESULT(yes)
158        AC_DEFINE(ISC_MUTEX_ATOMICS, 1, [Define to emulate atomic variables with mutexes.])
159        ;;
160no)
161        AC_MSG_RESULT(no)
162        ;;
163*)
164        AC_MSG_ERROR("--enable-mutex-atomics requires yes or no")
165        ;;
166esac
167
168#
169# Make very sure that these are the first files processed by
170# config.status, since we use the processed output as the input for
171# AC_SUBST_FILE() substitutions in other files.
172#
173AC_CONFIG_FILES([make/rules make/includes])
174
175AC_PATH_PROG(AR, ar)
176ARFLAGS="cruv"
177AC_SUBST(AR)
178AC_SUBST(ARFLAGS)
179
180# The POSIX ln(1) program.  Non-POSIX systems may substitute
181# "copy" or something.
182LN=ln
183AC_SUBST(LN)
184
185case "$AR" in
186	"")
187		AC_MSG_ERROR([
188ar program not found.  Please fix your PATH to include the directory in
189which ar resides, or set AR in the environment with the full path to ar.
190])
191
192		;;
193esac
194
195#
196# Look for w3m
197#
198AC_PATH_PROGS(W3M, w3m, w3m)
199AC_SUBST(W3M)
200
201#
202# Look for pandoc
203#
204AC_PATH_PROG(PANDOC, pandoc, pandoc)
205AC_SUBST(PANDOC)
206
207#
208# Perl is optional; it is used only by some of the system test scripts.
209# Note: the backtrace feature (see below) uses perl to build the symbol table,
210# but it still compiles without perl, in which case an empty table will be used.
211#
212AC_PATH_PROGS(PERL, perl5 perl)
213AC_SUBST(PERL)
214
215#
216# Python is also optional but required by default so that dnssec-keymgr gets
217# installed unless explicitly prevented by the user using --without-python.
218#
219testminvers='import sys
220if (sys.version_info < (2,7)) or (sys.version_info < (3,2) and sys.version_info >= (3,0)):
221   exit(1)'
222
223testargparse='try: import argparse
224except: exit(1)'
225
226testply='try: import ply
227except: exit(1)'
228
229testsetup='try: from distutils.core import setup
230except: exit(1)'
231
232default_with_python="python python3 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python2 python2.7"
233
234AC_ARG_VAR([PYTHON], [path to python executable])
235
236# [pairwise: --with-python, --without-python]
237AC_ARG_WITH([python],
238	    AS_HELP_STRING([--with-python=PATH],
239			   [specify path to Python interpreter]),
240	    [], [with_python=$default_with_python])
241
242# [pairwise: skip]
243AC_ARG_WITH([python-install-dir],
244	    AS_HELP_STRING([--with-python-install-dir=PATH],
245			   [installation directory for Python modules]),
246	    [], with_python_install_dir="")
247
248AS_IF([test "$with_python" = "yes"],
249      [with_python=$default_with_python])
250
251AS_IF([test "$with_python" = "no"],
252      [AC_MSG_CHECKING([for Python support])
253       unset PYTHON
254       AC_MSG_RESULT([disabled])],
255      [for p in $with_python
256       do
257	 AS_CASE([$p],
258		 [/*],[PYTHON="$p"])
259
260	 AC_PATH_PROG([PYTHON], [$p])
261	 # Do not cache the result of the check from the previous line.  If the
262	 # first found Python interpreter has missing module dependencies and
263	 # the result of the above check is cached, subsequent module checks
264	 # will erroneously keep on using the cached path to the first found
265	 # Python interpreter instead of different ones.
266	 unset ac_cv_path_PYTHON
267
268	 AS_IF([test -z "$PYTHON"], [continue])
269
270	 AC_MSG_CHECKING([if $PYTHON is python2 version >= 2.7 or python3 version >= 3.2])
271	 AS_IF(["$PYTHON" -c "$testminvers" 2>/dev/null],
272	       [AC_MSG_RESULT([yes])],
273	       [AC_MSG_RESULT([no])
274		unset PYTHON
275		continue])
276
277	 AC_MSG_CHECKING([Python module 'argparse'])
278	 AS_IF(["$PYTHON" -c "$testargparse" 2>/dev/null],
279	       [AC_MSG_RESULT([yes])],
280	       [AC_MSG_RESULT([no])
281		unset PYTHON
282		continue])
283
284	 AC_MSG_CHECKING([Python module 'ply'])
285	 AS_IF(["$PYTHON" -c "$testply" 2>/dev/null],
286	       [AC_MSG_RESULT([yes])],
287	       [AC_MSG_RESULT([no])
288		unset PYTHON
289		continue])
290
291	 AC_MSG_CHECKING([Python module 'distutils.core setup'])
292	 AS_IF(["$PYTHON" -c "$testsetup" 2>/dev/null],
293	       [AC_MSG_RESULT([yes])],
294	       [AC_MSG_RESULT([no])
295		unset PYTHON
296		continue])
297
298	 # Stop looking any further once we find a Python interpreter
299	 # satisfying all requirements.
300	 break
301       done
302
303       AS_IF([test "X$PYTHON" = "X"],
304	     [AC_MSG_CHECKING([for Python support])
305	      AC_MSG_RESULT([no])
306	      AC_MSG_ERROR([m4_normalize(
307				[Python >= 2.7 or >= 3.2 and the PLY package
308                                 are required for dnssec-keymgr and other
309                                 Python-based tools. PLY may be
310                                 available from your OS package manager
311                                 as python-ply or python3-ply; it can also
312                                 be installed via pip. To build without
313                                 Python/PLY, use --without-python.]
314			    )])])])
315
316PYTHON_TOOLS=''
317CHECKDS=''
318COVERAGE=''
319KEYMGR=''
320AS_IF([test "X$PYTHON" != "X"],
321      [PYTHON_TOOLS=python
322       CHECKDS=checkds
323       COVERAGE=coverage
324       KEYMGR=keymgr
325       PYTHON_INSTALL_DIR="$with_python_install_dir"
326       AS_IF([test -n "$with_python_install_dir"],
327	     [PYTHON_INSTALL_LIB="--install-lib=$with_python_install_dir"])])
328AC_SUBST(CHECKDS)
329AC_SUBST(COVERAGE)
330AC_SUBST(KEYMGR)
331AC_SUBST(PYTHON_TOOLS)
332AC_SUBST(PYTHON_INSTALL_DIR)
333AC_SUBST(PYTHON_INSTALL_LIB)
334
335#
336# expanded_sysconfdir is needed for replacement in the python utilities
337#
338expanded_sysconfdir=`eval echo $sysconfdir`
339AC_SUBST(expanded_sysconfdir)
340
341#
342# Make sure INSTALL uses an absolute path, else it will be wrong in all
343# Makefiles, since they use make/rules.in and INSTALL will be adjusted by
344# configure based on the location of the file where it is substituted.
345# Since in BIND9 INSTALL is only substituted into make/rules.in, an immediate
346# subdirectory of install-sh, This relative path will be wrong for all
347# directories more than one level down from install-sh.
348#
349case "$INSTALL" in
350	/*)
351		;;
352	*)
353		#
354		# Not all systems have dirname.
355		#
356		changequote({, })
357		ac_dir="`echo $INSTALL | sed 's%/[^/]*$%%'`"
358		changequote([, ])
359
360		ac_prog="`echo $INSTALL | sed 's%.*/%%'`"
361		test "X$ac_dir" = "X$ac_prog" && ac_dir=.
362		test -d "$ac_dir" && ac_dir="`(cd \"$ac_dir\" && pwd)`"
363		INSTALL="$ac_dir/$ac_prog"
364		;;
365esac
366
367AC_PATH_PROGS([PYTEST], [pytest-3 py.test-3 pytest pytest-pypy], [])
368AS_IF([test -z "$PYTEST"],
369      [AC_MSG_WARN([pytest not found, some system tests will be skipped])])
370AC_SUBST([PYTEST])
371
372
373AC_PROG_CC
374AC_PROG_CC_C99
375
376#
377# Using Solaris linker with gcc on Solaris breaks Thread Local Storage
378#
379AS_CASE([$host],
380	[*-solaris*],[
381	    AS_IF([test "$GCC" = "yes"],
382		  [LDFLAGS="$LDFLAGS -zrelax=transtls"
383		   AC_MSG_WARN([When using GNU C Compiler on Solaris, -zrelax=transtls linker flag is used to fix bug in Thread Local Storage])
384		  ])
385	],
386	[*-darwin*],[LDFLAGS="$LDFLAGS -Wl,-flat_namespace"])
387
388#
389# CCNOOPT defaults to -O0 on gcc and disables optimization when is last
390#
391if test "X$CCNOOPT" = "X" -a "X$GCC" = "Xyes"; then
392	CCNOOPT="-O0"
393fi
394
395AC_HEADER_STDC
396
397AC_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,,,
398[$ac_includes_default
399#ifdef HAVE_SYS_PARAM_H
400# include <sys/param.h>
401#endif
402#ifdef HAVE_SYS_SOCKET_H
403# include <sys/socket.h>
404#endif
405])
406
407#
408# Check for thread local storage
409#
410AC_CHECK_HEADERS([threads.h],
411		 [
412		     AC_MSG_CHECKING([for C11 Thread-Local Storage using thread_local])
413		     AC_COMPILE_IFELSE(
414			 [AC_LANG_PROGRAM(
415			      [
416				  #include <threads.h>
417			      ],[
418				  static thread_local int tls = 0;
419				  return (tls);
420			      ])
421			 ],[
422			     AC_MSG_RESULT([yes])
423			     AC_DEFINE([HAVE_THREAD_LOCAL],[1],[Define if thread_local keyword is available])
424			     AC_DEFINE([HAVE_TLS],[1],[Define if Thread-Local Storage is available])
425			 ],[
426			     AC_MSG_ERROR([Thread Local Storage support required, update your toolchain to build BIND 9])
427			 ])
428		 ],[
429		     AC_MSG_CHECKING([for Thread-Local Storage using __thread])
430		     AC_COMPILE_IFELSE(
431			 [AC_LANG_PROGRAM(
432			      [
433			      ],[
434				  static __thread int tls = 0;
435				  return (tls);
436			      ])
437			 ],[
438			     AC_MSG_RESULT([yes])
439			     AC_DEFINE([HAVE___THREAD],[1],[Define if __thread keyword is available])
440			     AC_DEFINE([HAVE_TLS],[1],[Define if Thread-Local Storage is available])
441			 ],[
442			     AC_MSG_ERROR([Thread Local Storage support required, update your toolchain to build BIND 9])
443			 ])
444		 ])
445
446AC_C_CONST
447AC_C_INLINE
448AC_C_VOLATILE
449AC_C_FLEXIBLE_ARRAY_MEMBER
450
451#
452# Check for yield support on ARM processors
453#
454AS_CASE([$host],
455	[arm*],
456	[AC_MSG_CHECKING([for yield instruction support])
457	 AC_COMPILE_IFELSE(
458	     [AC_LANG_PROGRAM([[]],
459			     [[__asm__ __volatile__ ("yield")]])],
460	     [AC_MSG_RESULT([yes])
461	      AC_DEFINE([HAVE_ARM_YIELD], [1],
462			[define if the ARM yield instruction is available])],
463	     [AC_MSG_RESULT([no])])])
464
465#
466# Check for pause support on SPARC processors
467#
468AS_CASE([$host],
469	[sparc*],
470	[AC_MSG_CHECKING([for pause instruction support])
471	 AC_COMPILE_IFELSE(
472	     [AC_LANG_PROGRAM([[]],
473			     [[__asm__ __volatile__ ("pause")]])],
474	     [AC_MSG_RESULT([yes])
475	      AC_DEFINE([HAVE_SPARC_PAUSE], [1],
476			[define if the SPARC pause instruction is available])],
477	     [AC_MSG_RESULT([no])])])
478
479AC_CHECK_FUNCS([sysctlbyname])
480
481#
482# Check for the existence of mmap to enable the fast format zones
483#
484AC_CHECK_FUNCS(mmap)
485
486#
487# Older versions of HP/UX don't define seteuid() and setegid()
488#
489AC_CHECK_FUNCS(seteuid setresuid)
490AC_CHECK_FUNCS(setegid setresgid)
491
492AC_TYPE_SIZE_T
493AC_TYPE_SSIZE_T
494AC_TYPE_UINTPTR_T
495
496AC_HEADER_TIME
497
498#
499# check for uname library routine
500#
501AC_MSG_CHECKING([for uname])
502AC_COMPILE_IFELSE(
503  [AC_LANG_PROGRAM(
504     [[#include <sys/utsname.h>
505       #include <stdio.h>
506      ]],
507     [[
508       struct utsname uts;
509       uname(&uts);
510       printf("running on %s %s %s for %s\n",
511	      uts.sysname, uts.release, uts.version, uts.machine);
512     ]])],
513  [AC_MSG_RESULT(yes)
514   AC_DEFINE([HAVE_UNAME], [1], [define if uname is available])
515  ],
516  [AC_MSG_RESULT(no)
517   AC_MSG_WARN([uname is not correctly supported])
518  ])
519
520#
521# check for GCC noreturn attribute
522#
523AC_MSG_CHECKING(for GCC noreturn attribute)
524AC_TRY_COMPILE([],[void foo() __attribute__((noreturn));],
525	[AC_MSG_RESULT(yes)
526		ISC_PLATFORM_NORETURN_PRE="#define ISC_PLATFORM_NORETURN_PRE"
527		ISC_PLATFORM_NORETURN_POST="#define ISC_PLATFORM_NORETURN_POST __attribute__((noreturn))"],
528	[AC_MSG_RESULT(no)
529		ISC_PLATFORM_NORETURN_PRE="#define ISC_PLATFORM_NORETURN_PRE"
530		ISC_PLATFORM_NORETURN_POST="#define ISC_PLATFORM_NORETURN_POST"])
531AC_SUBST(ISC_PLATFORM_NORETURN_PRE)
532AC_SUBST(ISC_PLATFORM_NORETURN_POST)
533
534#
535# check if we have kqueue
536#
537# [pairwise: --enable-kqueue, --disable-kqueue]
538AC_ARG_ENABLE([kqueue],
539	      [AS_HELP_STRING([--enable-kqueue],
540			      [use BSD kqueue when available [default=yes]])],
541	      [], enable_kqueue="yes")
542
543AS_IF([test "$enable_kqueue" = "yes"],
544      [AC_CHECK_FUNCS([kqueue])])
545
546#
547# check if we have epoll.  Linux kernel 2.4 has epoll_create() which fails,
548# so we need to try running the code, not just test its existence.
549#
550# [pairwise: --enable-epoll, --disable-epoll]
551AC_ARG_ENABLE([epoll],
552	      [AS_HELP_STRING([--enable-epoll],
553			      [use Linux epoll when available [default=auto]])],
554	      [], [enable_epoll="yes"])
555
556AS_IF([test "$enable_epoll" = "yes"],
557      [AC_CHECK_FUNCS([epoll_create1])])
558
559#
560# check if we support /dev/poll
561#
562# [pairwise: --enable-devpoll, --disable-devpoll]
563AC_ARG_ENABLE([devpoll],
564	      [AS_HELP_STRING([--enable-devpoll],
565			      [use /dev/poll when available [default=yes]])],
566	      [], [enable_devpoll="yes"])
567AS_IF([test "$enable_devpoll" = "yes"],
568      [AC_CHECK_HEADERS([sys/devpoll.h devpoll.h])])
569
570#
571# Find the machine's endian flavor.
572#
573AC_C_BIGENDIAN
574
575#
576# GeoIP support?
577#
578# Should be on by default if libmaxminddb exists.
579#
580# [pairwise: skip]
581AC_ARG_WITH([geoip2],
582	    [AS_HELP_STRING([--with-geoip2],
583			    [deprecated, use --with-maxminddb])],
584	    [AC_MSG_WARN([--with-geoip2 is DEPRECATED and will be removed in a future release, use --with-maxminddb instead])],
585	    [with_geoip2="auto"])
586
587# [pairwise: --enable-geoip --with-maxminddb=auto, --enable-geoip --with-maxminddb=yes, --disable-geoip]
588AC_ARG_ENABLE([geoip],
589	      [AS_HELP_STRING([--disable-geoip],
590			      [support GeoIP2 geolocation ACLs if available [default=yes]])],
591	      [], [enable_geoip="yes"])
592
593# [pairwise: skip]
594AC_ARG_WITH([maxminddb],
595	    [AS_HELP_STRING([--with-maxminddb=PATH],
596			    [Build with MaxMind GeoIP2 support (auto|yes|no|path) [default=auto]])],
597	    [], [with_maxminddb="$with_geoip2"])
598
599GEOIP2LINKSRCS=
600GEOIP2LINKOBJS=
601AS_IF([test "$enable_geoip" = "yes"],
602      [AS_CASE([$with_maxminddb],
603	       [no],[AC_MSG_ERROR([Use '--disable-geoip' to disable the GeoIP])],
604	       [auto],[PKG_CHECK_MODULES([MAXMINDDB], [libmaxminddb],
605					 [AC_DEFINE([HAVE_GEOIP2], [1], [Build with GeoIP2 support])
606					  PKG_CHECK_VAR([MAXMINDDB_PREFIX], [libmaxminddb], [prefix], [], [AC_MSG_ERROR([libmaxminddb prefix not found in pkg-config; set MAXMINDDB_PREFIX in the environment])])
607					  GEOIP2LINKSRCS='${GEOIP2LINKSRCS}'
608					  GEOIP2LINKOBJS='${GEOIP2LINKOBJS}'
609					 ],[:])],
610	       [yes],[PKG_CHECK_MODULES([MAXMINDDB], [libmaxminddb],
611					[AC_DEFINE([HAVE_GEOIP2], [1], [Build with GeoIP2 support])
612					 PKG_CHECK_VAR([MAXMINDDB_PREFIX], [libmaxminddb], [prefix], [], [AC_MSG_ERROR([libmaxminddb prefix not found in pkg-config; set MAXMINDDB_PREFIX in the environment])])
613					 GEOIP2LINKSRCS='${GEOIP2LINKSRCS}'
614					 GEOIP2LINKOBJS='${GEOIP2LINKOBJS}'
615					])],
616	       [ # default
617		   AX_SAVE_FLAGS([maxminddb])
618		   MAXMINDDB_CFLAGS="-I$with_maxminddb/include"
619		   MAXMINDDB_LIBS="-L$with_maxminddb/lib"
620		   CFLAGS="$CFLAGS $MAXMINDDB_CFLAGS"
621		   LDFLAGS="$LDFLAGS $MAXMINDDB_LIBS"
622		   AC_SEARCH_LIBS([MMDB_open], [maxminddb],
623				  [AC_DEFINE([HAVE_GEOIP2], [1], [Build with GeoIP2 support])
624				   GEOIP2LINKSRCS='${GEOIP2LINKSRCS}'
625				   GEOIP2LINKOBJS='${GEOIP2LINKOBJS}'
626				   MAXMINDDB_LIBS="$MAXMINDDB_LIBS $ac_cv_search_MMDB_open"
627				   AC_MSG_NOTICE([GeoIP2 default database path set to $with_maxminddb/share/GeoIP])
628				   AS_VAR_COPY([MAXMINDDB_PREFIX], [$with_maxminddb])
629				  ],
630				  [AC_MSG_ERROR([GeoIP2 requested, but libmaxminddb not found])])
631		   AX_RESTORE_FLAGS([maxminddb])
632	       ])
633       AC_ARG_VAR([MAXMINDDB_PREFIX], [value of prefix for MAXMINDDB, overriding pkg-config])
634])
635
636AC_SUBST([MAXMINDDB_CFLAGS])
637AC_SUBST([MAXMINDDB_LIBS])
638AC_SUBST([GEOIP2LINKSRCS])
639AC_SUBST([GEOIP2LINKOBJS])
640
641#
642# Do we have arc4random(), etc ?
643#
644AC_CHECK_FUNCS(arc4random arc4random_buf arc4random_uniform getrandom)
645
646AX_PTHREAD
647
648LIBS="$PTHREAD_LIBS $LIBS"
649CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
650CC="$PTHREAD_CC"
651
652AC_CHECK_FUNCS([pthread_attr_getstacksize pthread_attr_setstacksize])
653
654# [pairwise: --with-locktype=adaptive, --with-locktype=standard]
655AC_ARG_WITH([locktype],
656	    AS_HELP_STRING([--with-locktype=ARG],
657			   [Specify mutex lock type
658			    (adaptive or standard)]),
659	    [], [with_locktype="adaptive"])
660
661AS_CASE([$with_locktype],
662	[adaptive],[
663	  AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
664	  AC_COMPILE_IFELSE(
665	    [AC_LANG_PROGRAM(
666	       [[
667		 #ifndef _GNU_SOURCE
668		 #define _GNU_SOURCE
669		 #endif
670		 #include <pthread.h>
671	       ]],
672	       [[
673		 return (PTHREAD_MUTEX_ADAPTIVE_NP);
674	       ]]
675	     )],
676	    [AC_MSG_RESULT([using adaptive lock type])
677	     AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
678		       [Support for PTHREAD_MUTEX_ADAPTIVE_NP]) ],
679	    [AC_MSG_RESULT([using standard lock type])]
680	  )],
681	[standard],[AC_MSG_RESULT([using standard lock type])],
682	[AC_MSG_ERROR([You must specify "adaptive" or "standard" for --with-locktype.])]
683       )
684
685AC_CHECK_HEADERS([sched.h])
686
687AC_SEARCH_LIBS([sched_yield],[rt])
688AC_CHECK_FUNCS([sched_yield pthread_yield pthread_yield_np])
689
690AC_CHECK_HEADERS([sys/cpuset.h])
691AC_CHECK_HEADERS([sys/procset.h])
692AC_CHECK_FUNCS([pthread_setaffinity_np cpuset_setaffinity processor_bind sched_setaffinity])
693
694# Look for functions relating to thread naming
695AC_CHECK_FUNCS([pthread_setname_np pthread_set_name_np])
696AC_CHECK_HEADERS([pthread_np.h], [], [], [#include <pthread.h>])
697
698# libuv
699AC_MSG_CHECKING(for libuv)
700PKG_CHECK_MODULES([LIBUV], [libuv >= 1.0.0], [],
701		  [AC_MSG_ERROR([libuv not found])])
702AC_SUBST([LIBUV_CFLAGS])
703AC_SUBST([LIBUV_LIBS])
704
705AX_SAVE_FLAGS([libuv])
706CFLAGS="$CFLAGS $LIBUV_CFLAGS"
707LIBS="$LDFLAGS $LIBUV_LIBS"
708# Those functions are only provided in newer versions of libuv, we'll be emulating them
709# for now
710AC_CHECK_FUNCS([uv_handle_get_data uv_handle_set_data uv_import uv_udp_connect uv_translate_sys_error])
711AX_RESTORE_FLAGS([libuv])
712
713#
714# flockfile is usually provided by pthreads
715#
716AC_CHECK_FUNCS([flockfile getc_unlocked])
717
718#
719# Look for sysconf to allow detection of the number of processors.
720#
721AC_CHECK_FUNCS([sysconf])
722
723AC_SUBST(ALWAYS_DEFINES)
724
725AC_MSG_CHECKING(for libtool)
726
727# [pairwise: --with-libtool, --without-libtool]
728AC_ARG_WITH(libtool, AS_HELP_STRING([--with-libtool], [use GNU libtool]),
729	    use_libtool="$withval", use_libtool="no")
730NO_LIBTOOL_ISCLIBS=
731NO_LIBTOOL_DNSLIBS=
732case $use_libtool in
733	yes)
734		AC_MSG_RESULT(yes)
735		AM_PROG_LIBTOOL
736		O=lo
737		A=la
738		LIBTOOL_MKDEP_SED='s;\.o;\.lo;'
739		LIBTOOL_MODE_COMPILE='--mode=compile'
740		LIBTOOL_MODE_INSTALL='--mode=install'
741		LIBTOOL_MODE_LINK='--mode=link'
742		LIBTOOL_MODE_UNINSTALL='--mode=uninstall'
743		INSTALL_LIBRARY='${INSTALL_PROGRAM}'
744		AC_DEFINE([USE_LIBTOOL],[1],[Define if libtool is used for compilation])
745		;;
746	*)
747		AC_MSG_RESULT(no)
748		O=o
749		A=a
750		LIBTOOL=
751		AC_SUBST(LIBTOOL)
752		LIBTOOL_MKDEP_SED=
753		LIBTOOL_MODE_COMPILE=
754		LIBTOOL_MODE_INSTALL=
755		LIBTOOL_MODE_LINK=
756		LIBTOOL_MODE_UNINSTALL=
757		INSTALL_LIBRARY='${INSTALL_DATA}'
758		NO_LIBTOOL_ISCLIBS='${NO_LIBTOOL_ISCLIBS}'
759		NO_LIBTOOL_DNSLIBS='${NO_LIBTOOL_DNSLIBS}'
760		;;
761esac
762AC_SUBST(INSTALL_LIBRARY)
763AC_SUBST(NO_LIBTOOL_ISCLIBS)
764AC_SUBST(NO_LIBTOOL_DNSLIBS)
765
766#
767# Do we want to use pthread rwlock?
768#
769# [pairwise: --enable-pthread-rwlock, --disable-pthread-rwlock]
770AC_ARG_ENABLE([pthread_rwlock],
771	      [AS_HELP_STRING([--enable-pthread-rwlock],
772			      [use pthread rwlock instead of internal rwlock implementation])],
773	      [], [enable_pthread_rwlock=no])
774
775AS_IF([test "$enable_pthread_rwlock" = "yes"],
776      [AC_CHECK_FUNCS([pthread_rwlock_rdlock], [],
777		      [AC_MSG_ERROR([pthread_rwlock_rdlock requested but not found])])
778       AC_DEFINE([USE_PTHREAD_RWLOCK],[1],[Define if you want to use pthread rwlock implementation])
779      ])
780
781CRYPTO=OpenSSL
782
783#
784# OpenSSL/LibreSSL is mandatory
785#
786PKG_CHECK_MODULES([OPENSSL], [libssl libcrypto], [],
787		  [AX_CHECK_OPENSSL([:],[AC_MSG_FAILURE([OpenSSL/LibreSSL not found])])])
788
789AX_SAVE_FLAGS([openssl])
790
791CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
792LIBS="$LIBS $OPENSSL_LIBS"
793
794AC_MSG_CHECKING([for OpenSSL >= 1.0.0 or LibreSSL >= 2.7.0])
795AC_COMPILE_IFELSE(
796    [AC_LANG_PROGRAM([[#include <openssl/opensslv.h>]],
797		     [[#if (!defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER < 0x1000000fL)) || \\
798			   (defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER < 0x02070000fL))
799		       #error OpenSSL >= 1.0.0 or LibreSSL >= 2.7.0 required
800		       #endif
801		      ]])],
802    [AC_MSG_RESULT([yes])],
803    [AC_MSG_FAILURE([not found])])
804
805#
806# Check for functions added in OpenSSL or LibreSSL
807#
808
809AC_CHECK_FUNCS([OPENSSL_init_ssl OPENSSL_init_crypto])
810AC_CHECK_FUNCS([CRYPTO_zalloc])
811AC_CHECK_FUNCS([EVP_CIPHER_CTX_new EVP_CIPHER_CTX_free])
812AC_CHECK_FUNCS([EVP_MD_CTX_new EVP_MD_CTX_free EVP_MD_CTX_reset])
813AC_CHECK_FUNCS([HMAC_CTX_new HMAC_CTX_free HMAC_CTX_reset HMAC_CTX_get_md])
814AC_CHECK_FUNCS([SSL_read_ex SSL_peek_ex SSL_write_ex])
815AC_CHECK_FUNCS([BIO_read_ex BIO_write_ex])
816AC_CHECK_FUNCS([SSL_CTX_up_ref])
817AC_CHECK_FUNCS([SSL_CTX_set_min_proto_version])
818
819#
820# Check for algorithm support in OpenSSL
821#
822
823AC_CHECK_FUNCS([ECDSA_sign ECDSA_verify], [:],
824	       [AC_MSG_FAILURE([ECDSA support in OpenSSL is mandatory.])])
825
826AC_MSG_CHECKING([for ECDSA P-256 support])
827AC_COMPILE_IFELSE(
828    [AC_LANG_PROGRAM([[#include <openssl/evp.h>
829		       #include <openssl/ec.h>]],
830		     [[EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);]])],
831    [AC_MSG_RESULT([yes])],
832    [AC_MSG_FAILURE([not found.  ECDSA P-256 support in OpenSSL is mandatory.])])
833
834AC_MSG_CHECKING([for ECDSA P-384 support])
835AC_COMPILE_IFELSE(
836    [AC_LANG_PROGRAM([[#include <openssl/evp.h>
837		       #include <openssl/ec.h>]],
838		     [[EC_KEY *key = EC_KEY_new_by_curve_name(NID_secp384r1);]])],
839    [AC_MSG_RESULT([yes])],
840    [AC_MSG_FAILURE([not found.  ECDSA P-384 support in OpenSSL is mandatory.])])
841
842AC_MSG_CHECKING([for Ed25519 support])
843AC_COMPILE_IFELSE(
844    [AC_LANG_PROGRAM([[#include <openssl/evp.h>
845		       #include <openssl/ec.h>]],
846		     [[EC_KEY *key = EC_KEY_new_by_curve_name(NID_ED25519);]])],
847    [AC_DEFINE([HAVE_OPENSSL_ED25519], [1], [define if OpenSSL supports Ed25519])
848     AC_MSG_RESULT([yes])],
849    [AC_MSG_RESULT([no])])
850
851AC_MSG_CHECKING([for Ed448 support])
852AC_COMPILE_IFELSE(
853    [AC_LANG_PROGRAM([[#include <openssl/evp.h>
854		       #include <openssl/ec.h>]],
855		     [[EC_KEY *key = EC_KEY_new_by_curve_name(NID_ED448);]])],
856    [AC_DEFINE([HAVE_OPENSSL_ED448], [1], [define if OpenSSL supports Ed448])
857     AC_MSG_RESULT([yes])],
858    [AC_MSG_RESULT([no])])
859
860#
861# Check for OpenSSL SHA-1 support
862#
863AC_CHECK_FUNCS([EVP_sha1], [:],
864	       [AC_MSG_FAILURE([SHA-1 support in OpenSSL is mandatory.])])
865
866#
867# Check for OpenSSL SHA-2 support
868#
869AC_CHECK_FUNCS([EVP_sha224 EVP_sha256 EVP_sha384 EVP_sha512], [:],
870	       [AC_MSG_FAILURE([SHA-2 support in OpenSSL is mandatory.])])
871
872#
873# Check for OpenSSL AES support
874#
875AC_CHECK_FUNCS([EVP_aes_128_ecb EVP_aes_192_ecb EVP_aes_256_ecb], [:],
876	       [AC_MSG_FAILURE([AES support in OpenSSL is mandatory.])])
877
878#
879# Check for OpenSSL 1.1.x/LibreSSL functions
880#
881AC_CHECK_FUNCS([DH_get0_key ECDSA_SIG_get0 RSA_set0_key])
882
883AC_CHECK_FUNCS([TLS_server_method TLS_client_method])
884
885#
886# Check whether FIPS mode is available and whether we should enable it
887#
888# FIPS is not included in pairwise testing as the relevant Docker image
889# does not support FIPS mode.
890#
891# [pairwise: skip]
892AC_ARG_ENABLE([fips-mode],
893	      [AS_HELP_STRING([--enable-fips-mode],
894			      [enable FIPS mode in OpenSSL library [default=no]])],
895	      [], [enable_fips_mode="no"])
896
897AC_MSG_CHECKING([whether to enable FIPS mode in OpenSSL library])
898AS_CASE([$enable_fips_mode],
899	[yes], [AC_MSG_RESULT([yes])
900		AC_CHECK_FUNCS([FIPS_mode],
901			       [], [AC_MSG_FAILURE([OpenSSL FIPS mode requested but not available.])])],
902	[no], [AC_MSG_RESULT([no])])
903
904AX_RESTORE_FLAGS([openssl])
905
906AC_SUBST([OPENSSL_CFLAGS])
907AC_SUBST([OPENSSL_LIBS])
908
909PKCS11_TOOLS=
910PKCS11_TEST=
911PKCS11_MANS=
912#
913# was --enable-native-pkcs11 specified?
914#
915# [pairwise: --enable-native-pkcs11 --with-dlopen, --disable-native-pkcs11 --with-dlopen, --disable-native-pkcs11 --without-dlopen]
916AC_ARG_ENABLE(native-pkcs11,
917	      AS_HELP_STRING([--enable-native-pkcs11],
918			     [use native PKCS11 for public-key crypto [default=no]]),
919	      [:], [enable_native_pkcs11="no"])
920
921AC_MSG_CHECKING([for PKCS11 for Public-Key Cryptography])
922AS_CASE([$enable_native_pkcs11],
923	[no],[AC_MSG_RESULT([no])],
924	[yes],[PKCS11_TOOLS=pkcs11
925	       PKCS11_TEST=pkcs11
926	       PKCS11_MANS='${pkcs11_man8_MANS}'
927	       CRYPTO=pkcs11
928	       AS_IF([$use_threads],
929		     [:],
930		     [AC_MSG_ERROR([PKCS11 requires threading support])])
931	       AC_MSG_RESULT([yes])
932	       AC_CHECK_FUNCS([getpassphrase])
933	      ])
934AC_SUBST([PKCS11_TEST])
935AC_SUBST([PKCS11_TOOLS])
936AC_SUBST([PKCS11_MANS])
937
938AC_SUBST([CRYPTO])
939AS_CASE([$CRYPTO],
940	[pkcs11],[AC_DEFINE([USE_PKCS11], [1], [define if PKCS11 is used for Public-Key Cryptography])],
941	[AC_DEFINE([USE_OPENSSL], [1], [define if OpenSSL is used for Public-Key Cryptography])])
942
943# preparation for automake
944# AM_CONDITIONAL([PKCS11_TOOLS], [test "$with_native_pkcs11" = "yes"])
945
946#
947# was --with-pkcs11 specified?
948#
949# [pairwise: skip]
950AC_ARG_WITH([pkcs11],
951	    [AS_HELP_STRING([--with-pkcs11[=PATH]],
952			    [Build with PKCS11 support [no|path] (PATH is for the PKCS11 provider)])],
953	    [:], [with_pkcs11="undefined"])
954
955AS_CASE([$with_pkcs11],
956	[yes|auto],[AC_MSG_ERROR([--with-pkcs11 needs explicit path to the PKCS11 library])],
957	[no|undefined],[with_pkcs11="undefined"])
958AC_DEFINE_UNQUOTED([PK11_LIB_LOCATION], ["$with_pkcs11"], [define the default PKCS11 library path])
959
960# for PKCS11 benchmarks
961
962have_clock_gt=no
963AC_CHECK_FUNC(clock_gettime,have_clock_gt=yes,)
964if test "no" = "$have_clock_gt"; then
965	AC_CHECK_LIB(rt,clock_gettime,have_clock_gt=rt,)
966fi
967
968if test "no" != "$have_clock_gt"; then
969	AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if clock_gettime is available.])
970fi
971
972if test "rt" = "$have_clock_gt"; then
973	LIBS="-lrt $LIBS"
974fi
975
976AC_MSG_CHECKING(for GSSAPI library)
977
978# [pairwise: --with-gssapi=yes, --with-gssapi=auto, --without-gssapi]
979AC_ARG_WITH(gssapi,
980	    AS_HELP_STRING([--with-gssapi=[PATH|[/path/]krb5-config]],
981			   [Specify path for system-supplied GSSAPI
982				[default=auto]]),
983	    use_gssapi="$withval", use_gssapi="auto")
984
985# first try using krb5-config, if that does not work then fall back to "yes" method.
986
987case "$use_gssapi" in
988*/krb5-config|krb5-config)
989    AC_MSG_RESULT(trying $use_gssapi)
990    if test krb5-config = "$use_gssapi"
991    then
992	AC_PATH_PROG(KRB5_CONFIG, $use_gssapi)
993    else
994	KRB5_CONFIG="$use_gssapi"
995    fi
996    gssapi_cflags=`$KRB5_CONFIG --cflags gssapi krb5`
997    gssapi_libs=`$KRB5_CONFIG --libs gssapi krb5`
998    saved_cppflags="$CPPFLAGS"
999    CPPFLAGS="$gssapi_cflags $CPPFLAGS"
1000    AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h,
1001	[ISC_PLATFORM_GSSAPIHEADER="#define ISC_PLATFORM_GSSAPIHEADER <$ac_header>"])
1002    if test "" = "$ISC_PLATFORM_GSSAPIHEADER"; then
1003	AC_MSG_RESULT([krb5-config: gssapi.h not found])
1004	CPPFLAGS="$saved_cppflags"
1005	use_gssapi="yes"
1006    else
1007	AC_CHECK_HEADERS(krb5/krb5.h krb5.h,
1008	    [ISC_PLATFORM_KRB5HEADER="#define ISC_PLATFORM_KRB5HEADER <$ac_header>"])
1009	if test "" = "$ISC_PLATFORM_KRB5HEADER"; then
1010	    AC_MSG_RESULT([krb5-config: krb5.h not found])
1011	    CPPFLAGS="$saved_cppflags"
1012	    use_gssapi="yes"
1013	else
1014	    CPPFLAGS="$saved_cppflags"
1015	    saved_libs="$LIBS"
1016	    LIBS=$gssapi_libs
1017	    AC_MSG_CHECKING([krb5-config linking as $LIBS])
1018	    AC_TRY_LINK( , [gss_acquire_cred();krb5_init_context()],
1019		gssapi_linked=yes, gssapi_linked=no)
1020	    case $gssapi_linked in
1021		yes) AC_MSG_RESULT([krb5-config: linked]);;
1022		no)  AC_MSG_RESULT([krb5-config: could not determine proper GSSAPI linkage])
1023		    use_gssapi="yes"
1024		    ;;
1025	    esac
1026	    LIBS=$saved_libs
1027	fi
1028    fi
1029    if test "yes" = "$use_gssapi"; then
1030	AC_MSG_CHECKING([for GSSAPI library, non krb5-config method])
1031    fi
1032    ;;
1033esac
1034
1035case "$host" in
1036*darwin*)
1037	if test "yes" = "$use_gssapi" -o "auto" = "$use_gssapi"
1038	then
1039		use_gssapi=framework
1040	fi
1041	;;
1042esac
1043
1044# gssapi is just the framework, we really require kerberos v5, so
1045# look for those headers (the gssapi headers must be there, too)
1046# The problem with this implementation is that it doesn't allow
1047# for the specification of gssapi and krb5 headers in different locations,
1048# which probably ought to be fixed although fixing might raise the issue of
1049# trying to build with incompatible versions of gssapi and krb5.
1050if test "yes" = "$use_gssapi" -o "auto" = "$use_gssapi"
1051then
1052	# first, deal with the obvious
1053	if test \( -f /usr/include/kerberosv5/krb5.h -o \
1054		   -f /usr/include/krb5/krb5.h -o \
1055		   -f /usr/include/krb5.h \)   -a \
1056		\( -f /usr/include/gssapi.h -o \
1057		   -f /usr/include/gssapi/gssapi.h \)
1058	then
1059		use_gssapi=/usr
1060	else
1061	    krb5dirs="/usr/local /usr/local/krb5 /usr/local/kerberosv5 /usr/local/kerberos /usr/pkg /usr/krb5 /usr/kerberosv5 /usr/kerberos /usr"
1062	    for d in $krb5dirs
1063	    do
1064		if test -f $d/include/gssapi/gssapi_krb5.h -o \
1065			-f $d/include/krb5.h
1066		then
1067			if test -f $d/include/gssapi/gssapi.h -o \
1068				-f $d/include/gssapi.h
1069			then
1070				use_gssapi=$d
1071				break
1072			fi
1073		fi
1074	    done
1075	    if test "auto" = "$use_gssapi"
1076	    then
1077		use_gssapi="no"
1078	    fi
1079	fi
1080fi
1081
1082case "$use_gssapi" in
1083	no)
1084		AC_MSG_RESULT(disabled)
1085		USE_GSSAPI=''
1086		;;
1087	yes)
1088		AC_MSG_ERROR([--with-gssapi must specify a path])
1089		;;
1090	*/krb5-config|krb5-config)
1091		USE_GSSAPI='-DGSSAPI'
1092		DST_GSSAPI_INC="$gssapi_cflags"
1093		DNS_GSSAPI_LIBS="$gssapi_libs"
1094		;;
1095	framework)
1096		USE_GSSAPI='-DGSSAPI'
1097		ISC_PLATFORM_GSSAPIHEADER="#define ISC_PLATFORM_GSSAPIHEADER <Kerberos/Kerberos.h>"
1098		ISC_PLATFORM_KRB5HEADER="#define ISC_PLATFORM_KRB5HEADER <Kerberos/Kerberos.h>"
1099		DNS_GSSAPI_LIBS="-framework Kerberos"
1100		AC_MSG_RESULT(framework)
1101		;;
1102
1103	*)
1104		AC_MSG_RESULT(looking in $use_gssapi/lib)
1105		USE_GSSAPI='-DGSSAPI'
1106		saved_cppflags="$CPPFLAGS"
1107		CPPFLAGS="-I$use_gssapi/include $CPPFLAGS"
1108		AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h,
1109		    [ISC_PLATFORM_GSSAPIHEADER="#define ISC_PLATFORM_GSSAPIHEADER <$ac_header>"
1110		     gssapi_hack="#include <$ac_header>"])
1111
1112		if test "" = "$ISC_PLATFORM_GSSAPIHEADER"; then
1113		    AC_MSG_ERROR([gssapi.h not found])
1114		fi
1115
1116		AC_CHECK_HEADERS(gssapi_krb5.h gssapi/gssapi_krb5.h,
1117		    [ISC_PLATFORM_GSSAPI_KRB5_HEADER="#define ISC_PLATFORM_GSSAPI_KRB5_HEADER <$ac_header>"
1118		     gssapi_krb5_hack="#include <$ac_header>"])
1119
1120		AC_CHECK_HEADERS(krb5.h krb5/krb5.h kerberosv5/krb5.h,
1121		    [ISC_PLATFORM_KRB5HEADER="#define ISC_PLATFORM_KRB5HEADER <$ac_header>"
1122		    krb5_hack="#include <$ac_header>"])
1123
1124		if test "" = "$ISC_PLATFORM_KRB5HEADER"; then
1125		    AC_MSG_ERROR([krb5.h not found])
1126		fi
1127
1128		#
1129		# XXXDCL This probably doesn't work right on all systems.
1130		# It will need to be worked on as problems become evident.
1131		#
1132		# Essentially the problems here relate to two different
1133		# areas.  The first area is building with either KTH
1134		# or MIT Kerberos, particularly when both are present on
1135		# the machine.  The other is static versus dynamic linking.
1136		#
1137		# On the KTH vs MIT issue, Both have libkrb5 that can mess
1138		# up the works if one implementation ends up trying to
1139		# use the other's krb.  This is unfortunately a situation
1140		# that very easily arises.
1141		#
1142		# Dynamic linking when the dependency information is built
1143		# into MIT's libgssapi_krb5 or KTH's libgssapi magically makes
1144		# all such problems go away, but when that setup is not
1145		# present, because either the dynamic libraries lack
1146		# dependencies or static linking is being done, then the
1147		# problems start to show up.
1148		saved_libs="$LIBS"
1149		for TRY_LIBS in \
1150		    "-lgssapi_krb5" \
1151		    "-lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err" \
1152		    "-lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lresolv" \
1153		    "-lgssapi" \
1154		    "-lgssapi -lkrb5 -ldes -lcrypt -lasn1 -lroken -lcom_err" \
1155		    "-lgssapi -lkrb5 -lcrypt -lasn1 -lroken -lcom_err" \
1156		    "-lgssapi -lkrb5 -lgssapi_krb5 -lcrypt -lasn1 -lroken -lcom_err" \
1157		    "-lgssapi -lkrb5 -lhx509 -lcrypt -lasn1 -lroken -lcom_err" \
1158		    "-lgss -lkrb5"
1159		do
1160		    # Note that this does not include $saved_libs, because
1161		    # on FreeBSD machines this configure script has added
1162		    # -L/usr/local/lib to LIBS, which can make the
1163		    # -lgssapi_krb5 test succeed with shared libraries even
1164		    # when you are trying to build with KTH in /usr/lib.
1165		    if test "/usr" = "$use_gssapi"
1166		    then
1167			    LIBS="$TRY_LIBS $ISC_OPENSSL_LIBS"
1168		    else
1169			    LIBS="-L$use_gssapi/lib $TRY_LIBS $ISC_OPENSSL_LIBS"
1170		    fi
1171		    AC_MSG_CHECKING(linking as $TRY_LIBS)
1172		    AC_TRY_LINK([
1173#include <sys/types.h>
1174$gssapi_hack
1175$gssapi_krb5_hack
1176$krb5_hack
1177				] , [gss_acquire_cred(NULL, NULL, 0, NULL, 0, NULL, NULL, NULL);krb5_init_context(NULL);
1178#if defined(HAVE_GSSAPI_KRB5_H) || defined(HAVE_GSSAPI_GSSAPI_KRB5_H)
1179gsskrb5_register_acceptor_identity(NULL);
1180#endif],
1181				gssapi_linked=yes, gssapi_linked=no)
1182		    case $gssapi_linked in
1183		    yes) AC_MSG_RESULT(yes); break ;;
1184		    no)  AC_MSG_RESULT(no) ;;
1185		    esac
1186		done
1187
1188		CPPFLAGS="$saved_cppflags"
1189
1190		case $gssapi_linked in
1191		no) AC_MSG_ERROR(could not determine proper GSSAPI linkage) ;;
1192		esac
1193
1194		#
1195		# XXXDCL Major kludge.  Tries to cope with KTH in /usr/lib
1196		# but MIT in /usr/local/lib and trying to build with KTH.
1197		# /usr/local/lib can end up earlier on the link lines.
1198		# Like most kludges, this one is not only inelegant it
1199		# is also likely to be the wrong thing to do at least as
1200		# many times as it is the right thing.  Something better
1201		# needs to be done.
1202		#
1203		if test "/usr" = "$use_gssapi" -a \
1204			-f /usr/local/lib/libkrb5.a; then
1205		    FIX_KTH_VS_MIT=yes
1206		fi
1207
1208		case "$FIX_KTH_VS_MIT" in
1209		yes)
1210		    case "$enable_static_linking" in
1211		    yes) gssapi_lib_suffix=".a"  ;;
1212		    *)   gssapi_lib_suffix=".so" ;;
1213		    esac
1214
1215		    for lib in $LIBS; do
1216			case $lib in
1217			-L*)
1218			    ;;
1219			-l*)
1220			    new_lib=`echo $lib |
1221				     sed -e s%^-l%$use_gssapi/lib/lib% \
1222					 -e s%$%$gssapi_lib_suffix%`
1223			    NEW_LIBS="$NEW_LIBS $new_lib"
1224			    ;;
1225			*)
1226			   AC_MSG_ERROR([KTH vs MIT Kerberos confusion!])
1227			    ;;
1228			esac
1229		    done
1230		    LIBS="$NEW_LIBS"
1231		    ;;
1232		esac
1233
1234		DST_GSSAPI_INC="-I$use_gssapi/include"
1235		DNS_GSSAPI_LIBS="$LIBS"
1236
1237		AC_MSG_RESULT(using GSSAPI from $use_gssapi/lib and $use_gssapi/include)
1238		LIBS="$saved_libs"
1239		;;
1240esac
1241
1242AC_SUBST(ISC_PLATFORM_GSSAPIHEADER)
1243AC_SUBST(ISC_PLATFORM_GSSAPI_KRB5_HEADER)
1244AC_SUBST(ISC_PLATFORM_KRB5HEADER)
1245
1246AC_SUBST(USE_GSSAPI)
1247AC_SUBST(DST_GSSAPI_INC)
1248AC_SUBST(DNS_GSSAPI_LIBS)
1249DNS_CRYPTO_LIBS="$DNS_GSSAPI_LIBS"
1250
1251#
1252# Applications linking with libdns also need to link with these libraries.
1253#
1254
1255AC_SUBST(DNS_CRYPTO_LIBS)
1256
1257#
1258# was --with-lmdb specified?
1259#
1260AC_MSG_CHECKING(for lmdb library)
1261
1262# [pairwise: --with-lmdb=auto, --with-lmdb=yes, --without-lmdb]
1263AC_ARG_WITH(lmdb,
1264	    AS_HELP_STRING([--with-lmdb[=PATH]],
1265			   [build with LMDB library [yes|no|path]]),
1266    use_lmdb="$withval", use_lmdb="auto")
1267
1268have_lmdb=""
1269case "$use_lmdb" in
1270	no)
1271		LMDB_LIBS=""
1272		;;
1273	auto|yes)
1274		for d in /usr /usr/local /opt/local
1275		do
1276			if test -f "${d}/include/lmdb.h"
1277			then
1278				if test ${d} != /usr
1279				then
1280					LMDB_CFLAGS="-I ${d}/include"
1281					LMDB_LIBS="-L${d}/lib"
1282				fi
1283				have_lmdb="yes"
1284			fi
1285		done
1286		;;
1287	*)
1288		if test -f "${use_lmdb}/include/lmdb.h"
1289		then
1290			LMDB_CFLAGS="-I${use_lmdb}/include"
1291			LMDB_LIBS="-L${use_lmdb}/lib"
1292			have_lmdb="yes"
1293		else
1294			AC_MSG_ERROR([$use_lmdb/include/lmdb.h not found.])
1295		fi
1296		;;
1297esac
1298
1299if test "X${have_lmdb}" != "X"
1300then
1301	AC_MSG_RESULT(yes)
1302	AX_SAVE_FLAGS([lmdb])
1303	CFLAGS="$CFLAGS $LMDB_CFLAGS"
1304	LIBS="$LIBS $LMDB_LIBS"
1305	AC_SEARCH_LIBS([mdb_env_create], [lmdb], [],
1306		       [AC_MSG_ERROR([found lmdb include but not library.])
1307			have_lmdb=""])
1308	LMDB_LIBS="$LMDB_LIBS $ac_cv_search_mdb_env_create"
1309	AX_RESTORE_FLAGS([lmdb])
1310elif test "X$use_lmdb" = Xyes
1311then
1312	AC_MSG_ERROR([include/lmdb.h not found.])
1313else
1314	AC_MSG_RESULT(no)
1315fi
1316AC_SUBST([LMDB_CFLAGS])
1317AC_SUBST([LMDB_LIBS])
1318
1319NZD_TOOLS=""
1320NZDSRCS=
1321NZDTARGETS=
1322if test "X${have_lmdb}" != "X"
1323then
1324	AC_DEFINE(HAVE_LMDB, 1, [Define if lmdb was found])
1325	NZD_TOOLS="nzd"
1326	NZDSRCS='${NZDSRCS}'
1327	NZDTARGETS='${NZDTARGETS}'
1328	NZD_MANS='${nzd_man8_MANS}'
1329fi
1330AC_SUBST(NZD_TOOLS)
1331AC_SUBST(NZDSRCS)
1332AC_SUBST(NZDTARGETS)
1333AC_SUBST(NZD_MANS)
1334
1335#
1336# was --with-libxml2 specified?
1337#
1338# [pairwise: --with-libxml2=auto, --with-libxml2=yes, --without-libxml2]
1339AC_ARG_WITH([libxml2],
1340	    [AS_HELP_STRING([--with-libxml2],
1341			    [build with libxml2 library [yes|no|auto] (default is auto)])],
1342	    [], [with_libxml2="auto"])
1343
1344AS_CASE([$with_libxml2],
1345	[no],[],
1346	[auto],[PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.6.0],
1347				  [AC_DEFINE([HAVE_LIBXML2], [1], [Use libxml2 library])],
1348				  [:])],
1349	[yes],[PKG_CHECK_MODULES([LIBXML2], [libxml-2.0 >= 2.6.0],
1350				 [AC_DEFINE([HAVE_LIBXML2], [1], [Use libxml2 library])])],
1351	[AC_MSG_ERROR([Specifying libxml2 installation path is not supported, adjust PKG_CONFIG_PATH instead])])
1352
1353#
1354# DEPRECATED
1355#
1356# [pairwise: skip]
1357AC_ARG_WITH([libjson],
1358	    [AS_HELP_STRING([--with-libjson],
1359			    [deprecated, use --with-json-c])],
1360	    [AC_MSG_WARN([--with-libjson is DEPRECATED and will be removed in a future release, use --with-json-c instead])],
1361	    [with_libjson="detect"])
1362
1363#
1364# was --with-json-c specified?
1365#
1366# [pairwise: --with-json-c=detect, --with-json-c=yes, --without-json-c]
1367AC_ARG_WITH([json-c],
1368	    [AS_HELP_STRING([--with-json-c],
1369			    [build with json-c library [yes|no|detect] (default is detect)])],
1370	    [], [with_json_c="$with_libjson"])
1371
1372AS_CASE([$with_json_c],
1373	[no],[],
1374	[detect],[PKG_CHECK_MODULES([JSON_C], [json-c >= 0.11],
1375				    [AC_DEFINE([HAVE_JSON_C], [1], [Use json-c library])],
1376				    [:])],
1377	[yes],[PKG_CHECK_MODULES([JSON_C], [json-c >= 0.11],
1378				 [AC_DEFINE([HAVE_JSON_C], [1], [Use json-c library])])],
1379	[AC_MSG_ERROR([Specifying json-c installation path is not supported, adjust PKG_CONFIG_PATH instead])]
1380       )
1381
1382AC_SUBST([JSON_C_CFLAGS])
1383AC_SUBST([JSON_C_LIBS])
1384
1385# [pairwise: --with-zlib=auto, --with-zlib=yes, --without-zlib]
1386AC_ARG_WITH([zlib],
1387           [AS_HELP_STRING([--with-zlib],
1388                           [build with zlib for HTTP compression
1389                            [default=yes]])],
1390	   [], with_zlib="auto")
1391
1392AS_CASE([$with_zlib],
1393       [no],[],
1394       [auto],[PKG_CHECK_MODULES([ZLIB], [zlib],
1395                                 [AC_DEFINE([HAVE_ZLIB], [1], [Use zlib library])],
1396                                 [:])],
1397       [yes],[PKG_CHECK_MODULES([ZLIB], [zlib],
1398                                [AC_DEFINE([HAVE_ZLIB], [1], [Use zlib library])])],
1399       [AC_MSG_ERROR([Specifying zlib installation path is not supported, adjust PKG_CONFIG_PATH instead])])
1400AC_SUBST([ZLIB_CFLAGS])
1401AC_SUBST([ZLIB_LIBS])
1402
1403#
1404# In solaris 10, SMF can manage named service
1405#
1406AC_CHECK_LIB(scf, smf_enable_instance)
1407
1408#
1409# Additional compiler settings.
1410#
1411MKDEPCC="$CC"
1412
1413MKDEPCFLAGS="-M"
1414AS_CASE([$host],
1415	[*-solaris*],[
1416	    AS_IF([test "$GCC" != "yes"],
1417		  [MKDEPCFLAGS="-xM"])])
1418
1419AS_IF([test "$GCC" = "yes"],
1420      [STD_CWARNINGS="$STD_CWARNINGS -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -Wpointer-arith -Wno-missing-field-initializers"]
1421      )
1422
1423AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing],
1424		      [STD_CWARNINGS="$STD_CWARNINGS -fno-strict-aliasing"])
1425AX_CHECK_COMPILE_FLAG([-Werror -fno-delete-null-pointer-checks],
1426		      [STC_CWARNINGS="$STD_CWARNINGS -fno-delete-null-pointer-checks"])
1427AS_IF([test "$enable_warn_shadow" = "yes"],
1428      [AX_CHECK_COMPILE_FLAG([-Wshadow],
1429			     [STD_CWARNINGS="$STD_CWARNINGS -Wshadow"])])
1430AS_IF([test "$enable_warn_error" = "yes"],
1431      [AX_CHECK_COMPILE_FLAG([-Werror],
1432			     [STD_CWARNINGS="$STD_CWARNINGS -Werror"])])
1433
1434AC_SUBST([MKDEPCC])
1435AC_SUBST([MKDEPCFLAGS])
1436AC_SUBST([MKDEPPROG])
1437
1438#
1439# -lxnet buys us one big porting headache...  standards, gotta love 'em.
1440#
1441# AC_CHECK_LIB(xnet, socket, ,
1442#    AC_CHECK_LIB(socket, socket)
1443# )
1444#
1445# Use this for now, instead:
1446#
1447case "$host" in
1448	*-linux*)
1449		;;
1450	*)
1451		AC_CHECK_LIB(socket, socket)
1452		AC_CHECK_LIB(nsl, inet_addr)
1453		;;
1454esac
1455
1456#
1457# Work around Solaris's select() limitations.
1458#
1459case "$host" in
1460	*-solaris2.[[89]]|*-solaris2.1?)
1461	AC_DEFINE(FD_SETSIZE, 65536,
1462		  [Solaris hack to get select_large_fdset.])
1463	;;
1464esac
1465
1466#
1467# Purify support
1468#
1469AC_MSG_CHECKING(whether to use purify)
1470
1471# Purify is not included in pairwise testing as that tool is not present
1472# in the relevant Docker image.
1473#
1474# [pairwise: skip]
1475AC_ARG_WITH(purify,
1476	    AS_HELP_STRING([--with-purify[=PATH]],[use Rational purify]),
1477	    use_purify="$withval", use_purify="no")
1478
1479case "$use_purify" in
1480	no)
1481		;;
1482	yes)
1483		AC_PATH_PROG(purify_path, purify, purify)
1484		;;
1485	*)
1486		purify_path="$use_purify"
1487		;;
1488esac
1489
1490case "$use_purify" in
1491	no)
1492		AC_MSG_RESULT(no)
1493		PURIFY=""
1494		;;
1495	*)
1496		if test -f "$purify_path" || test purify = "$purify_path"; then
1497			AC_MSG_RESULT($purify_path)
1498			PURIFYFLAGS="`echo $PURIFYOPTIONS`"
1499			PURIFY="$purify_path $PURIFYFLAGS"
1500		else
1501			AC_MSG_ERROR([$purify_path not found.
1502
1503Please choose the proper path with the following command:
1504
1505    configure --with-purify=PATH
1506])
1507		fi
1508		;;
1509esac
1510
1511AC_SUBST(PURIFY)
1512
1513#
1514# Google/Great Performance Tools CPU Profiler
1515#
1516AC_MSG_CHECKING(whether to use gperftools profiler)
1517
1518# Google/Great Performance Tools CPU Profiler is not included in
1519# pairwise testing as that tool is not present in the relevant Docker
1520# image.
1521#
1522# [pairwise: skip]
1523AC_ARG_WITH(gperftools-profiler,
1524	    AS_HELP_STRING([--with-gperftools-profiler],
1525			   [use gperftools CPU profiler]),
1526	    use_profiler="$withval", use_profiler="no")
1527
1528case $use_profiler in
1529	yes)
1530		AC_MSG_RESULT(yes)
1531		AC_DEFINE([HAVE_GPERFTOOLS_PROFILER], 1,
1532		[Define to use gperftools CPU profiler.])
1533		LIBS="$LIBS -lprofiler"
1534		;;
1535	*)
1536		AC_MSG_RESULT(no)
1537		;;
1538esac
1539
1540#
1541# enable/disable dumping stack backtrace.  Also check if the system supports
1542# glibc-compatible backtrace() function.
1543#
1544# [pairwise: --enable-backtrace, --disable-backtrace]
1545AC_ARG_ENABLE([backtrace],
1546	      [AS_HELP_STRING([--enable-backtrace],
1547			      [log stack backtrace on abort [default=yes]])],
1548	      [], [enable_backtrace="yes"])
1549
1550AS_IF([test "$enable_backtrace" = "yes"],
1551      [AC_DEFINE([USE_BACKTRACE], [1], [define if we can use backtrace])
1552       AC_LINK_IFELSE(
1553	 [AC_LANG_PROGRAM(
1554	    [[#include <execinfo.h>]],
1555	    [[return (backtrace((void **)0, 0));]]
1556	  )],
1557	 [AC_DEFINE([HAVE_LIBCTRACE], [1], [define if system have backtrace function])],
1558	 [AC_LINK_IFELSE(
1559	    [AC_LANG_PROGRAM(
1560	       [[#include <stddef.h>]],
1561	       [[return _Unwind_Backtrace(NULL, NULL);]]
1562	     )],
1563	    [AC_DEFINE([HAVE_UNWIND_BACKTRACE], [1], [define if the compiler supports _Unwind_Backtrace()])]
1564	  )]
1565       )])
1566
1567# [pairwise: --enable-symtable, --disable-symtable]
1568AC_ARG_ENABLE(symtable,
1569	      AS_HELP_STRING([--enable-symtable],
1570			     [use internal symbol table for backtrace
1571			      [all|minimal(default)|none]]),
1572		want_symtable="$enableval",  want_symtable="minimal")
1573case $want_symtable in
1574yes|all|minimal)     # "yes" is a hidden value equivalent to "minimal"
1575	if test "" = "$PERL"
1576	then
1577		AC_MSG_ERROR([Internal symbol table requires perl but no perl is found.
1578Install perl or explicitly disable the feature by --disable-symtable.])
1579	fi
1580	if test "yes" = "$use_libtool"; then
1581		AC_MSG_WARN([Internal symbol table does not work with libtool.  Disabling symbol table.])
1582	else
1583		# we generate the internal symbol table only for those systems
1584		# known to work to avoid unexpected build failure.  Also, warn
1585		# about unsupported systems when the feature is enabled
1586		#  manually.
1587		case $host_os in
1588		freebsd*|netbsd*|openbsd*|linux*|solaris*|darwin*)
1589			MKSYMTBL_PROGRAM="$PERL"
1590			if test "all" = "$want_symtable"; then
1591				ALWAYS_MAKE_SYMTABLE="yes"
1592			fi
1593			;;
1594		*)
1595			if test "yes" = "$want_symtable" -o "all" = "$want_symtable"
1596			then
1597				AC_MSG_WARN([this system is not known to generate internal symbol table safely; disabling it])
1598			fi
1599		esac
1600	fi
1601	;;
1602*)
1603	;;
1604esac
1605AC_SUBST(MKSYMTBL_PROGRAM)
1606AC_SUBST(ALWAYS_MAKE_SYMTABLE)
1607
1608#
1609# File name extension for static archive files, for those few places
1610# where they are treated differently from dynamic ones.
1611#
1612SA=a
1613
1614AC_SUBST(O)
1615AC_SUBST(A)
1616AC_SUBST(SA)
1617AC_SUBST(LIBTOOL_MKDEP_SED)
1618AC_SUBST(LIBTOOL_MODE_COMPILE)
1619AC_SUBST(LIBTOOL_MODE_INSTALL)
1620AC_SUBST(LIBTOOL_MODE_LINK)
1621AC_SUBST(LIBTOOL_MODE_UNINSTALL)
1622
1623BIND9_CO_RULE=".c.$O:"
1624AC_SUBST(BIND9_CO_RULE)
1625
1626#
1627# Here begins a very long section to determine the system's networking
1628# capabilities.  The order of the tests is significant.
1629#
1630
1631#
1632# We do the IPv6 compilation checking after libtool so that we can put
1633# the right suffix on the files.
1634#
1635AC_MSG_CHECKING([for IPv6 structures])
1636AC_COMPILE_IFELSE(
1637  [AC_LANG_PROGRAM(
1638     [[
1639       #include <sys/types.h>
1640       #include <sys/socket.h>
1641       #include <netinet/in.h>
1642     ]],
1643     [[
1644       struct sockaddr_in6 sin6;
1645       struct in6_addr in6;
1646       struct in6_pktinfo in6_pi;
1647       struct sockaddr_storage storage;
1648       in6 = in6addr_any;
1649       in6 = in6addr_loopback;
1650       sin6.sin6_scope_id = 0;
1651       return (0);
1652     ]])],
1653  [AC_MSG_RESULT([yes])],
1654  [AC_MSG_FAILURE([IPv6 support is mandatory])])
1655
1656#
1657# Allow forcibly disabling TCP Fast Open support as autodetection might yield
1658# confusing results on some systems (e.g. FreeBSD; see set_tcp_fastopen()
1659# comment in lib/isc/unix/socket.c).
1660#
1661# [pairwise: --enable-tcp-fastopen, --disable-tcp-fastopen]
1662AC_ARG_ENABLE([tcp_fastopen],
1663	      [AS_HELP_STRING([--disable-tcp-fastopen],
1664			      [disable TCP Fast Open support [default=yes]])],
1665	     [], [enable_tcp_fastopen="yes"])
1666
1667AS_IF([test "$enable_tcp_fastopen" = "yes"],
1668      [AC_DEFINE([ENABLE_TCP_FASTOPEN], [1], [define if you want TCP_FASTOPEN enabled if available])])
1669
1670#
1671# Check for some other useful functions that are not ever-present.
1672#
1673AC_CHECK_FUNCS([strlcpy strlcat])
1674
1675AC_SUBST(READLINE_LIB)
1676
1677# [pairwise: --with-readline=auto, --with-readline=yes, --without-readline]
1678AC_ARG_WITH(readline,
1679	    AS_HELP_STRING([--with-readline[=LIBSPEC]],
1680			   [specify readline library [default auto]]),
1681	    use_readline="$withval", use_readline="auto")
1682case "$use_readline" in
1683no)	;;
1684*)
1685	saved_LIBS="$LIBS"
1686	case "$use_readline" in
1687	yes|auto) try_readline="-ledit"; or_readline="-lreadline" ;;
1688	*) try_readline="$use_readline"
1689	esac
1690	for readline in "$try_readline" $or_readline
1691	do
1692		LIBS="$readline"
1693		AC_MSG_NOTICE(checking for readline with $readline)
1694		AC_CHECK_FUNCS(readline)
1695		if test "yes" = "$ac_cv_func_readline"
1696		then
1697			READLINE_LIB="$readline"
1698			break
1699		fi
1700		for lib in -lterminfo -ltermcap -lncurses -lcurses
1701		do
1702			AC_MSG_NOTICE(checking for readline with $readline $lib)
1703			unset ac_cv_func_readline
1704			LIBS="$readline $lib"
1705			AC_CHECK_FUNCS(readline)
1706			if test "yes" = "$ac_cv_func_readline"
1707			then
1708				READLINE_LIB="$readline $lib"
1709				break
1710			fi
1711		done
1712		if test "yes" = "$ac_cv_func_readline"
1713		then
1714			break
1715		fi
1716	done
1717	if test "auto" != "$use_readline" &&
1718	   test "X$READLINE_LIB" = "X"
1719	then
1720		AC_MSG_ERROR([The readline library was not found.])
1721	fi
1722	LIBS="$saved_LIBS"
1723	;;
1724esac
1725if test "yes" = "$ac_cv_func_readline"
1726then
1727	case "$READLINE_LIB" in
1728	*edit*)
1729		AC_CHECK_HEADERS(editline/readline.h)
1730		AC_CHECK_HEADERS(edit/readline/readline.h)
1731		AC_CHECK_HEADERS(edit/readline/history.h)
1732		;;
1733	esac
1734	AC_CHECK_HEADERS(readline/readline.h)
1735	AC_CHECK_HEADERS(readline/history.h)
1736fi
1737
1738AC_SUBST(DST_EXTRA_OBJS)
1739AC_SUBST(DST_EXTRA_SRCS)
1740
1741#
1742# Security Stuff
1743#
1744# Note it is very recommended to *not* disable chroot(),
1745# this is only because chroot() was made obsolete by Posix.
1746#
1747# [pairwise: --enable-chroot, --disable-chroot]
1748AC_ARG_ENABLE(chroot, AS_HELP_STRING([--disable-chroot], [disable chroot]))
1749case "$enable_chroot" in
1750	yes|'')
1751		AC_CHECK_FUNCS(chroot)
1752		;;
1753	no)
1754		;;
1755esac
1756
1757LIBCAP_LIBS=""
1758AC_MSG_CHECKING([whether to enable Linux capabilities])
1759
1760# [pairwise: --enable-linux-caps, --disable-linux-caps]
1761AC_ARG_ENABLE([linux-caps],
1762	      [AS_HELP_STRING([--disable-linux-caps],
1763			      [disable Linux capabilities])],
1764	      [],
1765	      [AS_CASE([$host],
1766		       [*-linux*],[enable_linux_caps=yes],
1767		       [enable_linux_caps=no])])
1768
1769AS_IF([test "$enable_linux_caps" = "yes"],
1770      [AC_MSG_RESULT([yes])
1771       AC_CHECK_HEADERS([sys/capability.h],
1772			[],
1773			[AC_MSG_ERROR(m4_normalize([sys/capability.h header is required for Linux capabilities support.
1774						    Either install libcap or use --disable-linux-caps.]))])
1775       AX_SAVE_FLAGS([cap])
1776       AC_SEARCH_LIBS([cap_set_proc], [cap],
1777		      [LIBCAP_LIBS="$ac_cv_search_cap_set_proc"],
1778		      [AC_MSG_ERROR(m4_normalize([libcap is required for Linux capabilities support.
1779						  Either install libcap or use --disable-linux-caps.]))])
1780       AX_RESTORE_FLAGS([cap])],
1781      [AC_MSG_RESULT([no])])
1782AC_SUBST([LIBCAP_LIBS])
1783
1784AC_CHECK_HEADERS(sys/un.h,
1785ISC_PLATFORM_HAVESYSUNH="#define ISC_PLATFORM_HAVESYSUNH 1"
1786,
1787ISC_PLATFORM_HAVESYSUNH="#undef ISC_PLATFORM_HAVESYSUNH"
1788)
1789AC_SUBST(ISC_PLATFORM_HAVESYSUNH)
1790
1791case "$host" in
1792*-solaris*)
1793	AC_DEFINE(NEED_SECURE_DIRECTORY, 1,
1794		  [Define if connect does not honour the permission on the UNIX domain socket.])
1795	;;
1796esac
1797
1798#
1799# Time Zone Stuff
1800#
1801AC_CHECK_FUNCS([tzset])
1802
1803AC_MSG_CHECKING(for optarg declaration)
1804AC_TRY_COMPILE([
1805#include <unistd.h>
1806],
1807[optarg = 0;],
1808[AC_MSG_RESULT(yes)],
1809[AC_MSG_RESULT(no)
1810GEN_NEED_OPTARG="-DNEED_OPTARG=1"
1811AC_DEFINE(NEED_OPTARG, 1, [Defined if extern char *optarg is not declared.])])
1812
1813#
1814# Check for nanoseconds in file stats
1815#
1816AC_MSG_CHECKING([for st_mtim.tv_nsec])
1817AC_COMPILE_IFELSE(
1818  [AC_LANG_PROGRAM(
1819     [[#include <sys/fcntl.h>]],
1820     [[struct stat s;
1821       return(s.st_mtim.tv_nsec);
1822      ]])],
1823   [AC_DEFINE([HAVE_STAT_NSEC], [1], [define if struct stat has st_mtim.tv_nsec field])])
1824
1825#
1826# Check for if_nametoindex() for IPv6 scoped addresses support
1827#
1828AC_CHECK_FUNCS([if_nametoindex])
1829
1830AC_CHECK_FUNCS(nanosleep usleep explicit_bzero)
1831
1832ISC_ATOMIC_LIBS=""
1833AC_CHECK_HEADERS(
1834  [stdatomic.h],
1835  [AC_MSG_CHECKING([for memory model aware atomic operations])
1836   AC_COMPILE_IFELSE(
1837     [AC_LANG_PROGRAM(
1838	[[#include <stdatomic.h>]],
1839	[[atomic_int_fast32_t val = 0; atomic_fetch_add_explicit(&val, 1, memory_order_relaxed);]]
1840      )],
1841     [AC_MSG_RESULT([stdatomic.h])
1842      AC_MSG_CHECKING([whether -latomic is needed for 64-bit stdatomic.h functions])
1843      AC_LINK_IFELSE(
1844	[AC_LANG_PROGRAM(
1845	   [[#include <stdatomic.h>]],
1846	   [[atomic_int_fast64_t val = 0; atomic_fetch_add_explicit(&val, 1, memory_order_relaxed);]]
1847	 )],
1848	[AC_MSG_RESULT([no])],
1849	[ISC_ATOMIC_LIBS="-latomic"
1850	 AX_SAVE_FLAGS([atomic])
1851	 LIBS="$LIBS $ISC_ATOMIC_LIBS"
1852	 AC_LINK_IFELSE(
1853	   [AC_LANG_PROGRAM(
1854	      [[#include <stdatomic.h>]],
1855	      [[atomic_int_fast64_t val = 0; atomic_fetch_add_explicit(&val, 1, memory_order_relaxed);]]
1856	    )],
1857	   [AC_MSG_RESULT([yes])],
1858	   [AC_MSG_FAILURE([libatomic needed, but linking with -latomic failed, please fix your toolchain.])])
1859	 AX_RESTORE_FLAGS([atomic])
1860	])
1861     ],
1862     [AC_MSG_FAILURE([stdatomic.h header found, but compilation failed, please fix your toolchain.])]
1863   )],
1864  [AC_MSG_CHECKING([for memory model aware atomic operations])
1865   AC_COMPILE_IFELSE(
1866     [AC_LANG_PROGRAM(
1867	[[#include <inttypes.h>]],
1868	[[int32_t val = 0; __atomic_fetch_add(&val, 1, __ATOMIC_RELAXED);]]
1869      )],
1870     [AC_MSG_RESULT([__atomic builtins])
1871      AC_DEFINE([HAVE___ATOMIC], [1], [define if __atomic builtins are not available])
1872      AC_MSG_CHECKING([whether -latomic is needed for 64-bit __atomic builtins])
1873      AC_LINK_IFELSE(
1874	[AC_LANG_PROGRAM(
1875	   [[#include <inttypes.h>]],
1876	   [[int64_t val = 0; __atomic_fetch_add(&val, 1, __ATOMIC_RELAXED);]]
1877	 )],
1878	[AC_MSG_RESULT([no])],
1879	[ISC_ATOMIC_LIBS="-latomic"
1880	 AX_SAVE_FLAGS([atomic])
1881	 LIBS="$LIBS $ISC_ATOMIC_LIBS"
1882	 AC_LINK_IFELSE(
1883	   [AC_LANG_PROGRAM(
1884	      [[#include <inttypes.h>]],
1885	      [[int64_t val = 0; __atomic_fetch_add(&val, 1, __ATOMIC_RELAXED);]]
1886	    )],
1887	   [AC_MSG_RESULT([yes])],
1888	   [AC_MSG_FAILURE([libatomic needed, but linking with -latomic failed, please fix your toolchain.])])
1889	 AX_RESTORE_FLAGS([atomic])
1890	])
1891     ],
1892     [AC_MSG_RESULT([__sync builtins])
1893     ])
1894  ])
1895LIBS="$LIBS $ISC_ATOMIC_LIBS"
1896
1897AC_CHECK_HEADERS([stdalign.h])
1898
1899AC_CHECK_HEADERS([uchar.h])
1900
1901#
1902# Check for __builtin_unreachable
1903#
1904AC_MSG_CHECKING([compiler support for __builtin_unreachable()])
1905AC_LINK_IFELSE(
1906  [AC_LANG_PROGRAM(
1907     [[]],
1908     [[__builtin_unreachable();]]
1909   )],
1910  [AC_MSG_RESULT([yes])
1911   AC_DEFINE([HAVE_BUILTIN_UNREACHABLE], [1], [define if the compiler supports __builtin_unreachable().])
1912  ],
1913  [AC_MSG_RESULT([no])
1914  ])
1915
1916#
1917# Check for __builtin_expect
1918#
1919AC_MSG_CHECKING([compiler support for __builtin_expect])
1920AC_TRY_LINK(, [
1921	return (__builtin_expect(1, 1) ? 1 : 0);
1922], [
1923	have_builtin_expect=yes
1924	AC_MSG_RESULT(yes)
1925], [
1926	have_builtin_expect=no
1927	AC_MSG_RESULT(no)
1928])
1929if test "yes" = "$have_builtin_expect"; then
1930	AC_DEFINE(HAVE_BUILTIN_EXPECT, 1, [Define to 1 if the compiler supports __builtin_expect.])
1931fi
1932
1933#
1934# Check for __builtin_clz
1935#
1936AC_MSG_CHECKING([compiler support for __builtin_clz])
1937AC_TRY_LINK(, [
1938	return (__builtin_clz(0xff) == 24 ? 1 : 0);
1939], [
1940	have_builtin_clz=yes
1941	AC_MSG_RESULT(yes)
1942], [
1943	have_builtin_clz=no
1944	AC_MSG_RESULT(no)
1945])
1946if test "yes" = "$have_builtin_clz"; then
1947	AC_DEFINE(HAVE_BUILTIN_CLZ, 1, [Define to 1 if the compiler supports __builtin_clz.])
1948fi
1949
1950#
1951# Activate "rrset-order fixed" or not?
1952#
1953# [pairwise: --enable-fixed-rrset, --disable-fixed-rrset]
1954AC_ARG_ENABLE(fixed-rrset,
1955	      AS_HELP_STRING([--enable-fixed-rrset],
1956			     [enable fixed rrset ordering [default=no]]),
1957	      enable_fixed="$enableval", enable_fixed="no")
1958case "$enable_fixed" in
1959	yes)
1960		AC_DEFINE(DNS_RDATASET_FIXED, 1,
1961			  [Define to enable "rrset-order fixed" syntax.])
1962		;;
1963	no)
1964		;;
1965	*)
1966		;;
1967esac
1968
1969#
1970# Activate dnstap?
1971#
1972# [pairwise: --enable-dnstap, --disable-dnstap]
1973AC_ARG_ENABLE(dnstap,
1974	      AS_HELP_STRING([--enable-dnstap],
1975			     [enable dnstap support
1976				(requires fstrm, protobuf-c)]),
1977	      use_dnstap=$enableval, use_dnstap=no)
1978
1979DNSTAP=
1980DNSTAPSRCS=
1981DNSTAPOBJS=
1982DNSTAPTARGETS=
1983if test "x$use_dnstap" != "xno"; then
1984
1985	# [pairwise: skip]
1986	AC_ARG_WITH([protobuf-c],
1987		    AS_HELP_STRING([--with-protobuf-c=path],
1988				   [Path where protobuf-c is installed, for dnstap]), [
1989	    # workaround for protobuf-c includes at old dir
1990	    # before protobuf-c-1.0.0
1991	    if test -f $withval/include/google/protobuf-c/protobuf-c.h
1992	    then
1993		PROTOBUF_C_CFLAGS="-I$withval/include/google"
1994	    else
1995		PROTOBUF_C_CFLAGS="-I$withval/include"
1996	    fi
1997	    PROTOBUF_C_LIBS="-L$withval/lib"
1998	    AC_PATH_PROG([PROTOC_C], [protoc-c], [],
1999			 [$PATH$PATH_SEPARATOR$withval/bin])
2000	], [
2001	    # workaround for protobuf-c includes at old dir
2002	    # before protobuf-c-1.0.0
2003	    if test -f /usr/include/google/protobuf-c/protobuf-c.h
2004	    then
2005		PROTOBUF_C_CFLAGS="-I/usr/include/google"
2006	    else
2007		if test -f /usr/local/include/google/protobuf-c/protobuf-c.h
2008		then
2009		    PROTOBUF_C_CFLAGS="-I/usr/local/include/google"
2010		    PROTOBUF_C_LIBS="-L/usr/local/lib"
2011		elif test -f /opt/local/include/google/protobuf-c/protobuf-c.h
2012		then
2013		    PROTOBUF_C_CFLAGS="-I/opt/local/include/google"
2014		    PROTOBUF_C_LIBS="-L/opt/local/lib"
2015		fi
2016	    fi
2017	    AC_PATH_PROG([PROTOC_C],[protoc-c])
2018	])
2019	if test -z "$PROTOC_C"; then
2020		AC_MSG_ERROR([The protoc-c program was not found.])
2021	fi
2022
2023	# [pairwise: skip]
2024	AC_ARG_WITH([libfstrm], AS_HELP_STRING([--with-libfstrm=path],
2025		    [Path where libfstrm is installed, for dnstap]), [
2026	    FSTRM_CFLAGS="-I$withval/include"
2027	    FSTRM_LIBS="-L$withval/lib"
2028	    AC_PATH_PROG([FSTRM_CAPTURE], [fstrm_capture], [], [$PATH$PATH_SEPARATOR$withval/bin])
2029	],[
2030	    for d in /usr /usr/local /opt/local
2031	    do
2032		if test -f "${d}/include/fstrm.h"
2033		then
2034		    if test ${d} != /usr
2035		    then
2036			FSTRM_CFLAGS="-I${d}/include"
2037			FSTRM_LIBS="-L${d}/lib"
2038		    fi
2039		    have_fstrm="$d"
2040		    break
2041		fi
2042	    done
2043	    if test -z "$have_fstrm"; then
2044		AC_PATH_PROG([FSTRM_CAPTURE], [fstrm_capture])
2045	    else
2046		AC_PATH_PROG([FSTRM_CAPTURE], [fstrm_capture], [], [$PATH$PATH_SEPARATOR$have_fstrm/bin])
2047	    fi
2048	])
2049	AX_SAVE_FLAGS([dnstap])
2050	CFLAGS="$CFLAGS $PROTOBUF_C_CFLAGS $FSTRM_CFLAGS"
2051	LIBS="$LDFLAGS $PROTOBUF_C_LIBS $FSTRM_LIBS"
2052
2053	AC_SEARCH_LIBS([fstrm_iothr_init], [fstrm], [],
2054		       AC_MSG_ERROR([The fstrm library was not found. Please install fstrm!]))
2055	FSTRM_LIBS="$FSTRM_LIBS $ac_cv_search_fstrm_iothr_init"
2056
2057	AC_SEARCH_LIBS([protobuf_c_message_pack], [protobuf-c], [],
2058		       AC_MSG_ERROR([The protobuf-c library was not found. Please install protobuf-c!]))
2059	PROTOBUF_C_LIBS="$PROTOBUF_C_LIBS $ac_cv_search_protobuf_c_message_pack"
2060
2061	AX_RESTORE_FLAGS([dnstap])
2062	AC_DEFINE(HAVE_DNSTAP, 1, [Define to 1 to enable dnstap support])
2063	DNSTAP=dnstap
2064	DNSTAPSRCS='${DNSTAPSRCS}'
2065	DNSTAPOBJS='${DNSTAPOBJS}'
2066	DNSTAPTARGETS='${DNSTAPTARGETS}'
2067	DNSTAP_MANS='${dnstap_man1_MANS}'
2068fi
2069AC_SUBST(DNSTAP)
2070AC_SUBST(DNSTAPSRCS)
2071AC_SUBST(DNSTAPOBJS)
2072AC_SUBST(DNSTAPTARGETS)
2073AC_SUBST(DNSTAP_MANS)
2074AC_SUBST([PROTOBUF_C_CFLAGS])
2075AC_SUBST([PROTOBUF_C_LIBS])
2076AC_SUBST([FSTRM_CFLAGS])
2077AC_SUBST([FSTRM_LIBS])
2078
2079#
2080#  The following sets up how non-blocking i/o is established.
2081#  cygwin and solaris 2.x (x<5) require special handling.
2082#
2083case "$host" in
2084*-cygwin*) AC_DEFINE(PORT_NONBLOCK, O_NDELAY);;
2085*-solaris2.[[01234]])
2086	AC_DEFINE(PORT_NONBLOCK, O_NONBLOCK)
2087	AC_DEFINE(USE_FIONBIO_IOCTL, 1,
2088		  [Defined if you need to use ioctl(FIONBIO) instead a fcntl call to make non-blocking.])
2089	;;
2090*) AC_DEFINE(PORT_NONBLOCK, O_NONBLOCK,
2091	     [Sets which flag to pass to open/fcntl to make non-blocking (O_NDELAY/O_NONBLOCK).])
2092	;;
2093esac
2094#
2095# Solaris 2.5.1 and earlier cannot bind() then connect() a TCP socket.
2096# This prevents the source address being set.
2097#
2098case "$host" in
2099*-solaris2.[[012345]]|*-solaris2.5.1)
2100	AC_DEFINE(BROKEN_TCP_BIND_BEFORE_CONNECT, 1,
2101		  [Define if you cannot bind() before connect() for TCP sockets.])
2102	;;
2103esac
2104#
2105# The following sections deal with tools used for formatting
2106# the documentation.  They are all optional, unless you are
2107# a developer editing the documentation source.
2108#
2109
2110#
2111# The following sections deal with tools used for formatting
2112# the documentation.  They are all optional, unless you are
2113# a developer editing the documentation source.
2114#
2115
2116#
2117# Look for sphinx-build
2118#
2119AC_ARG_VAR([SPHINX_BUILD], [path to sphinx-build binary used to build the documentation])
2120AC_PATH_PROG([SPHINX_BUILD], [sphinx-build], [:])
2121AM_CONDITIONAL([HAVE_SPHINX_BUILD], [test "$SPHINX_BUILD" != ":"])
2122
2123AC_PATH_PROG([XELATEX], [xelatex], [:])
2124AC_PATH_PROG([LATEXMK], [latexmk], [:])
2125AM_CONDITIONAL([HAVE_XELATEX], [test "$XELATEX" != ":" && test "$LATEXMK" != ":"])
2126
2127#
2128# Pull release date from CHANGES file last modification date
2129# for reproducible builds
2130#
2131release_date=`date -r CHANGES +%Y-%m-%d`
2132AC_SUBST([RELEASE_DATE], $release_date)
2133
2134# Don't build the documentation if the sphinx-build is not present
2135PDFTARGET=
2136HTMLTARGET=
2137MANSRCS=
2138AS_IF([test -n "$SPHINX_BUILD"],[
2139	  MANSRCS='$(MANPAGES_IN)'
2140	  HTMLTARGET='html dirhtml'
2141	  AC_PATH_PROGS([PDFLATEX], [pdflatex], [])
2142	  AC_PATH_PROGS([LATEXMK], [latexmk], [])
2143	  AS_IF([test -n "$PDFLATEX" && test -n "$LATEXMK"],[
2144		    PDFTARGET='pdf'
2145		])
2146      ])
2147AC_SUBST([HTMLTARGET])
2148AC_SUBST([PDFTARGET])
2149AC_SUBST([MANSRCS])
2150
2151#
2152# Look for Doxygen
2153#
2154AC_PATH_PROGS([DOXYGEN], [doxygen])
2155AC_SUBST(DOXYGEN)
2156
2157#
2158# Look for curl
2159#
2160
2161AC_PATH_PROG(CURL, curl, curl)
2162AC_SUBST(CURL)
2163
2164#
2165# IDN support using libidn2
2166#
2167
2168LIBIDN2_CFLAGS=
2169LIBIDN2_LDFLAGS=
2170LIBIDN2_LIBS=
2171
2172# [pairwise: --with-libidn2=yes, --without-libidn2]
2173AC_ARG_WITH([libidn2],
2174	    [AS_HELP_STRING([--with-libidn2[=PATH]], [enable IDN support using GNU libidn2 [yes|no(default)|path]])],
2175	    [with_libidn2="$withval"], [with_libidn2="no"])
2176AS_CASE([$with_libidn2],
2177	[yes],	[PKG_CHECK_MODULES([LIBIDN2], [libidn2],
2178				   [AC_DEFINE([HAVE_LIBIDN2], [1], [Define if libidn2 was found])])],
2179	[no],	[],
2180	[*],	[AX_SAVE_FLAGS([libidn2])
2181		 LIBIDN2_CFLAGS="-I$with_libidn2/include"
2182		 LIBIDN2_LDFLAGS="-L$with_libidn2/lib"
2183		 CFLAGS="$LIBIDN2_CFLAGS $CFLAGS"
2184		 CPPFLAGS="$LIBIDN2_CFLAGS $CPPFLAGS"
2185		 LDFLAGS="$LIBIDN2_LDFLAGS $LDFLAGS"
2186		 AC_CHECK_HEADERS([idn2.h],
2187				  [],
2188				  [AC_MSG_ERROR([idn2.h not found])])
2189		 AC_SEARCH_LIBS([idn2_to_ascii_lz], [idn2],
2190				[LIBIDN2_LIBS="$ac_cv_search_idn2_to_ascii_lz"
2191				 AC_DEFINE([HAVE_LIBIDN2], [1], [Define if libidn2 was found])],
2192				[AC_MSG_ERROR([libidn2 requested, but not found])])
2193		AX_RESTORE_FLAGS([libidn2])])
2194AC_SUBST([LIBIDN2_CFLAGS])
2195AC_SUBST([LIBIDN2_LDFLAGS])
2196AC_SUBST([LIBIDN2_LIBS])
2197
2198#
2199# Check whether to build with cmocka unit testing framework
2200#
2201# [pairwise: --with-cmocka=detect, --with-cmocka=yes, --without-cmocka]
2202AC_ARG_WITH([cmocka],
2203	    [AS_HELP_STRING([--with-cmocka=detect],[enable CMocka based tests (default is detect)])],
2204	    [],[with_cmocka=detect])
2205
2206AS_CASE([$with_cmocka],
2207	[no],[],
2208	[detect],[PKG_CHECK_MODULES([CMOCKA], [cmocka >= 1.0.0],
2209				    [AC_DEFINE([HAVE_CMOCKA], [1], [Use CMocka])],
2210				    [with_cmocka=no])],
2211	[yes],[PKG_CHECK_MODULES([CMOCKA], [cmocka >= 1.0.0],
2212				 [AC_DEFINE([HAVE_CMOCKA], [1], [Use CMocka])])],
2213	[AC_MSG_ERROR([Use PKG_CONFIG_PATH to specify path to CMocka library])]
2214       )
2215AC_SUBST([CMOCKA_CFLAGS])
2216AC_SUBST([CMOCKA_LIBS])
2217
2218AC_DEFINE([SKIPPED_TEST_EXIT_CODE], [0], [Exit code for skipped tests])
2219
2220#
2221# Check for kyua execution engine if CMocka was requested
2222# and bail out if execution engine was not found
2223#
2224AC_ARG_VAR([KYUA], [path to kyua execution engine])
2225AS_IF([test "$with_cmocka" != "no"],
2226      [AC_PATH_PROGS([KYUA], [kyua], [])
2227       AS_IF([test -z "$KYUA"],
2228             [AC_MSG_WARN([kyua test execution engine not found])],
2229             [UNITTESTS=tests])])
2230AC_SUBST([KYUA])
2231AC_SUBST([UNITTESTS])
2232
2233#
2234# Check for -Wl,--wrap= support
2235#
2236
2237LD_WRAP_TESTS=false
2238AC_MSG_CHECKING([for linker support for --wrap option])
2239AX_SAVE_FLAGS([wrap])
2240LDFLAGS="-Wl,--wrap,exit"
2241AC_LINK_IFELSE(
2242    [AC_LANG_PROGRAM([[#include <stdlib.h>
2243		       void __real_exit (int status);
2244		       void __wrap_exit (int status) { __real_exit (0); }
2245		      ]],
2246		     [[exit (1);]])],
2247    [LD_WRAP_TESTS=true
2248     AC_DEFINE([LD_WRAP], [1], [define if the linker supports --wrap option])
2249     AC_MSG_RESULT([yes])],
2250    [AC_MSG_RESULT([no])])
2251AX_RESTORE_FLAGS([wrap])
2252
2253AC_SUBST([LD_WRAP_TESTS])
2254
2255#
2256# Check for i18n
2257#
2258AC_CHECK_HEADERS(locale.h)
2259AC_CHECK_FUNCS(setlocale)
2260
2261#
2262# was --with-tuning specified?
2263#
2264# [pairwise: --with-tuning=small, --without-tuning]
2265AC_ARG_WITH([tuning],
2266	    AS_HELP_STRING([--with-tuning=ARG],
2267			   [Specify server tuning (default or small)]),
2268	    [],[with_tuning=no])
2269
2270AS_CASE([$with_tuning],
2271	[small],[AC_MSG_NOTICE(using small system tuning)],
2272	[AC_DEFINE(TUNE_LARGE, 1, [Define to use default system tuning.])
2273	 AC_MSG_NOTICE(using default system tuning)])
2274
2275#
2276# was --enable-querytrace specified?
2277#
2278# [pairwise: --enable-querytrace, --disable-querytrace]
2279AC_ARG_ENABLE(querytrace,
2280	      AS_HELP_STRING([--enable-querytrace],
2281			     [enable very verbose query trace logging
2282				[default=no]]),
2283	      want_querytrace="$enableval", want_querytrace="no")
2284
2285AC_MSG_CHECKING([whether to enable query trace logging])
2286case "$want_querytrace" in
2287yes)
2288	AC_MSG_RESULT(yes)
2289	AC_DEFINE(WANT_QUERYTRACE, 1, [Define to enable very verbose query trace logging.])
2290	;;
2291no)
2292	AC_MSG_RESULT(no)
2293	;;
2294*)
2295	AC_MSG_ERROR("--enable-querytrace requires yes or no")
2296	;;
2297esac
2298
2299#
2300# Was --disable-auto-validation specified?
2301#
2302
2303validation_default=auto
2304
2305# [pairwise: --enable-auto-validation, --disable-auto-validation]
2306AC_ARG_ENABLE(auto-validation,
2307	      AS_HELP_STRING([--enable-auto-validation],
2308			     [turn on DNSSEC validation by default, using the IANA root key [default=yes]]),
2309	      [:],[enable_auto_validation=yes])
2310AS_IF([test "$enable_auto_validation" = "no"],[validation_default=yes])
2311AC_DEFINE_UNQUOTED([VALIDATION_DEFAULT], ["$validation_default"], [the default value of dnssec-validation option])
2312
2313#
2314# Substitutions
2315#
2316AC_SUBST(BIND9_TOP_BUILDDIR)
2317BIND9_TOP_BUILDDIR=`pwd`
2318
2319AC_SUBST(BIND9_ISC_BUILDINCLUDE)
2320AC_SUBST(BIND9_ISCCC_BUILDINCLUDE)
2321AC_SUBST(BIND9_ISCCFG_BUILDINCLUDE)
2322AC_SUBST(BIND9_DNS_BUILDINCLUDE)
2323AC_SUBST(BIND9_NS_BUILDINCLUDE)
2324AC_SUBST(BIND9_BIND9_BUILDINCLUDE)
2325AC_SUBST(BIND9_IRS_BUILDINCLUDE)
2326if test "X$srcdir" != "X"; then
2327	BIND9_ISC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isc/include"
2328	BIND9_ISCCC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isccc/include"
2329	BIND9_ISCCFG_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isccfg/include"
2330	BIND9_DNS_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/dns/include"
2331	BIND9_NS_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/ns/include"
2332	BIND9_BIND9_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/bind9/include"
2333	BIND9_IRS_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/irs/include"
2334else
2335	BIND9_ISC_BUILDINCLUDE=""
2336	BIND9_ISCCC_BUILDINCLUDE=""
2337	BIND9_ISCCFG_BUILDINCLUDE=""
2338	BIND9_DNS_BUILDINCLUDE=""
2339	BIND9_NS_BUILDINCLUDE=""
2340	BIND9_BIND9_BUILDINCLUDE=""
2341	BIND9_IRS_BUILDINCLUDE=""
2342fi
2343
2344AC_SUBST_FILE(BIND9_MAKE_INCLUDES)
2345BIND9_MAKE_INCLUDES=$BIND9_TOP_BUILDDIR/make/includes
2346
2347AC_SUBST_FILE(BIND9_MAKE_RULES)
2348BIND9_MAKE_RULES=$BIND9_TOP_BUILDDIR/make/rules
2349
2350. "$srcdir/version"
2351BIND9_PRODUCT="PRODUCT=\"${PRODUCT}\""
2352AC_SUBST(BIND9_PRODUCT)
2353BIND9_DESCRIPTION="DESCRIPTION=\"${DESCRIPTION}\""
2354AC_SUBST(BIND9_DESCRIPTION)
2355BIND9_VERSION="${MAJORVER}.${MINORVER}${PATCHVER:+.}${PATCHVER}${RELEASETYPE}${RELEASEVER}${EXTENSIONS}"
2356AC_SUBST(BIND9_VERSION)
2357BIND9_MAJOR="MAJOR=${MAJORVER}.${MINORVER}"
2358AC_SUBST(BIND9_MAJOR)
2359BIND9_VERSIONSTRING="${PRODUCT} ${MAJORVER}.${MINORVER}${PATCHVER:+.}${PATCHVER}${RELEASETYPE}${RELEASEVER}${EXTENSIONS}${DESCRIPTION:+ }${DESCRIPTION}"
2360AC_SUBST(BIND9_VERSIONSTRING)
2361
2362BIND9_SRCID="SRCID=unset_id"
2363if test -f "${srcdir}/srcid"; then
2364	. "${srcdir}/srcid"
2365	BIND9_SRCID="SRCID=$SRCID"
2366elif test -d "${srcdir}/.git"; then
2367	BIND9_SRCID="SRCID="`(cd "${srcdir}";git rev-parse --short HEAD)`
2368fi
2369
2370AC_SUBST(BIND9_SRCID)
2371
2372if test -z "$ac_configure_args"; then
2373	BIND9_CONFIGARGS="defaults"
2374else
2375	for a in $ac_configure_args
2376	do
2377		BIND9_CONFIGARGS="$BIND9_CONFIGARGS $a"
2378	done
2379fi
2380BIND9_CONFIGARGS="`echo $BIND9_CONFIGARGS | sed 's/^ //'`"
2381BIND9_CONFIGARGS="CONFIGARGS=${BIND9_CONFIGARGS}"
2382AC_SUBST(BIND9_CONFIGARGS)
2383
2384AC_SUBST_FILE(LIBDNS_MAPAPI)
2385LIBDNS_MAPAPI="$srcdir/lib/dns/mapapi"
2386
2387#
2388# Configure any DLZ drivers.
2389#
2390# If config.dlz.in selects one or more DLZ drivers, it will set
2391# CONTRIB_DLZ to a non-empty value, which will be our clue to
2392# build DLZ drivers in contrib.
2393#
2394# This section has to come after the libtool stuff because it needs to
2395# know how to name the driver object files.
2396#
2397
2398CONTRIB_DLZ=""
2399DLZ_DRIVER_INCLUDES=""
2400DLZ_DRIVER_LIBS=""
2401DLZ_DRIVER_SRCS=""
2402DLZ_DRIVER_OBJS=""
2403DLZ_SYSTEM_TEST=""
2404DLZ_DRIVER_MYSQL_INCLUDES=""
2405DLZ_DRIVER_MYSQL_LIBS=""
2406
2407#
2408# Configure support for building a shared library object
2409#
2410# Even when libtool is available it can't always be relied upon
2411# to build an object that can be dlopen()'ed, but this is necessary
2412# for building the dlzexternal system test, so we'll try it the
2413# old-fashioned way.
2414#
2415SO="so"
2416SO_CFLAGS=""
2417SO_LDFLAGS=""
2418SO_LD=""
2419SO_TARGETS=""
2420SO_STRIP="cat"
2421
2422# [pairwise: skip]
2423AC_ARG_WITH([dlopen],
2424	    AS_HELP_STRING([--with-dlopen=ARG],
2425			   [support dynamically loadable DLZ and DYNDB drivers]),
2426	    [], [with_dlopen="auto"])
2427
2428
2429#
2430# If PIC is disabled, dlopen must also be
2431#
2432AS_IF([test "$pic_mode" = "no"],
2433      [AS_CASE([$with_dlopen],
2434	       [auto],[with_dlopen="no"],
2435	       [yes],[AC_MSG_ERROR([--with-dlopen requires PIC])])])
2436
2437AS_CASE([$with_dlopen],
2438	[auto|yes],[
2439	  # -fsanitize=thread hijacks dlopen and dlclose so use dlsym.
2440	  AC_SEARCH_LIBS([dlsym],[dl])
2441	  AC_CHECK_FUNCS([dlopen dlclose dlsym],
2442			 [with_dlopen="yes"],
2443			 [with_dlopen="no"])
2444	])
2445
2446AS_IF([test "$with_dlopen" = "yes"],
2447      [AS_CASE([$host],
2448	       [*-linux*|*-gnu*],[
2449		 LDFLAGS="${LDFLAGS} -Wl,--export-dynamic"
2450		 SO_CFLAGS="-fPIC"
2451		 SO_LDFLAGS=""
2452		 AS_IF([test "$use_libtool" = "yes"],[
2453			 SO_LDFLAGS="-Xcompiler -shared"
2454			 SO_LD="${CC}"
2455		       ],[
2456			 SO_LDFLAGS="-shared"
2457			 SO_LD="${CC}"
2458		       ])
2459	       ],
2460	       [*-freebsd*|*-openbsd*|*-netbsd*],[
2461		 LDFLAGS="${LDFLAGS} -Wl,-E"
2462		 SO_CFLAGS="-fpic"
2463		 AS_IF([test "$use_libtool" = "yes"],[
2464			 SO_LDFLAGS="-Xcompiler -shared"
2465			 SO_LD="${CC}"
2466		       ],[
2467			 SO_LDFLAGS="-shared"
2468			 SO_LD="${CC}"
2469		       ])
2470	       ],
2471	       [*-darwin*],[
2472		 SO_CFLAGS="-fPIC"
2473                 SO_LD="${CC}"
2474		 AS_IF([test "$use_libtool" = "yes"],[
2475			 SO_LDFLAGS="-Xcompiler -dynamiclib -undefined dynamic_lookup"
2476		       ],[
2477			 SO_LDFLAGS="-dynamiclib -undefined dynamic_lookup"
2478		       ])
2479	       ],
2480	       [*-solaris*],[
2481		 SO_CFLAGS="-KPIC"
2482		 SO_LDFLAGS="-G -z text"
2483		 SO_LD="ld"
2484	       ],
2485	       [ia64-hp-hpux*],[
2486		 SO_CFLAGS="+z"
2487	         SO_LDFLAGS="-b"
2488		 SO_LD="${CC}"
2489	       ],
2490	       [
2491		 SO_CFLAGS="-fPIC"
2492	       ])
2493       AS_IF([test "$GCC" = "yes"],[
2494	       SO_CFLAGS="-fPIC"
2495	       AS_IF([test -z "$SO_LD"],
2496		     [AS_IF([test "$use_libtool" = "yes"],[
2497			      SO_LDFLAGS="-Xcompiler -shared"
2498			      SO_LD="${CC}"
2499			    ],[
2500			      SO_LDFLAGS="-shared"
2501			      SO_LD="${CC}"
2502			    ])
2503		     ])
2504	     ])
2505       # If we still don't know how to make shared objects, don't make any.
2506       AS_IF([test -n "$SO_LD"],
2507	     [SO_TARGETS="\${SO_TARGETS}"
2508	      AC_DEFINE([ISC_DLZ_DLOPEN], [1],
2509			[Define to allow building of objects for dlopen().])
2510	     ])
2511      ])
2512
2513AS_IF([test "$with_dlopen" = "no" -a "$enable_native_pkcs11" = "yes"],
2514      [AC_MSG_ERROR([PKCS11 requires dlopen() support])])
2515
2516CFLAGS="$CFLAGS $SO_CFLAGS"
2517
2518AC_SUBST(SO)
2519AC_SUBST(SO_CFLAGS)
2520AC_SUBST(SO_LDFLAGS)
2521AC_SUBST(SO_LD)
2522AC_SUBST(SO_STRIP)
2523AC_SUBST(SO_TARGETS)
2524
2525#
2526# Response policy rewriting using DNS Response Policy Service (DNSRPS)
2527# interface.
2528#
2529# DNSRPS can be compiled into BIND everywhere with a reasonably
2530# modern C compiler.  It is enabled on systems with dlopen() and librpz.so.
2531#
2532dnsrps_avail=yes
2533AC_MSG_CHECKING([for librpz __attribute__s])
2534AC_COMPILE_IFELSE(
2535  [AC_LANG_PROGRAM(
2536     [[]],
2537     [[
2538       extern void f(char *p __attribute__((unused)), ...)
2539       __attribute__((format(printf,1,2))) __attribute__((__noreturn__));
2540     ]])],
2541  [
2542    librpz_have_attr=yes
2543    AC_DEFINE([LIBRPZ_HAVE_ATTR], [1], [have __attribute__s used in librpz.h])
2544    AC_MSG_RESULT([yes])
2545  ],[
2546    librpz_have_attr=no
2547    AC_MSG_RESULT([no])
2548  ])
2549
2550# DNSRPS is not included in pairwise testing as the librpz library is not
2551# present in the relevant Docker image.
2552#
2553# [pairwise: skip]
2554AC_ARG_ENABLE([dnsrps-dl],
2555	      [AS_HELP_STRING([--enable-dnsrps-dl],
2556			      [DNS Response Policy Service delayed link
2557			       [default=$librpz_dl]])],
2558	      [enable_librpz_dl="$enableval"], [enable_librpz_dl="$with_dlopen"])
2559
2560AS_IF([test "$enable_librpz_dl" = "yes" -a "$with_dlopen" = "no"],
2561      [AC_MSG_ERROR([DNS Response Policy Service delayed link requires dlopen to be enabled])])
2562
2563# [pairwise: skip]
2564AC_ARG_WITH([dnsrps-libname],
2565	    [AS_HELP_STRING([--with-dnsrps-libname],
2566			    [DNSRPS provider library name (librpz.so)])],
2567	    [librpz_name="$withval"], [librpz_name="librpz.so"])
2568
2569# [pairwise: skip]
2570AC_ARG_WITH([dnsrps-dir],
2571	    [AS_HELP_STRING([--with-dnsrps-dir],
2572			    [path to DNSRPS provider library])],
2573	    [librpz_path="$withval/$librpz_name"], [librpz_path="$librpz_name"])
2574AC_DEFINE_UNQUOTED([DNSRPS_LIBRPZ_PATH], ["$librpz_path"],
2575		   [dnsrps $librpz_name])
2576AS_IF([test "$enable_librpz_dl" = "yes"],
2577      [
2578	dnsrps_lib_open=2
2579      ],[
2580	dnsrps_lib_open=1
2581	# Add librpz.so to linked libraries if we are not using dlopen()
2582	AC_SEARCH_LIBS([librpz_client_create], [rpz], [],
2583		[dnsrps_lib_open=0
2584		 dnsrps_avail=no])
2585      ])
2586AC_DEFINE_UNQUOTED([DNSRPS_LIB_OPEN], [$dnsrps_lib_open],
2587		   [0=no DNSRPS  1=static link  2=dlopen()])
2588
2589# [pairwise: skip]
2590AC_ARG_ENABLE([dnsrps],
2591	      AS_HELP_STRING([--enable-dnsrps],
2592			     [enable DNS Response Policy Service API]),
2593	      [enable_dnsrps=$enableval], [enable_dnsrps=no])
2594
2595AS_IF([test "$enable_dnsrps" != "no"],[
2596	AS_IF([test "$dnsrps_avail" != "yes"],
2597	      [AC_MSG_ERROR([dlopen and librpz.so needed for DNSRPS])])
2598	AS_IF([test "$dnsrps_lib_open" = "0"],
2599	      [AC_MSG_ERROR([dlopen and librpz.so needed for DNSRPS])])
2600	AC_DEFINE([USE_DNSRPS], [1], [Enable DNS Response Policy Service API])
2601      ])
2602
2603sinclude(contrib/dlz/config.dlz.in)
2604AC_MSG_CHECKING(contributed DLZ drivers)
2605
2606#
2607# Support for constructor and destructor attributes
2608#
2609AX_GCC_FUNC_ATTRIBUTE([constructor])
2610AX_GCC_FUNC_ATTRIBUTE([destructor])
2611
2612if test -n "$CONTRIB_DLZ"
2613then
2614	AC_MSG_RESULT(yes)
2615	DLZ_DRIVER_RULES=contrib/dlz/drivers/rules
2616	AC_CONFIG_FILES([$DLZ_DRIVER_RULES
2617		contrib/dlz/modules/mysql/Makefile
2618		contrib/dlz/modules/mysqldyn/Makefile])
2619else
2620	AC_MSG_RESULT(no)
2621	DLZ_DRIVER_RULES=/dev/null
2622fi
2623
2624AC_SUBST(CONTRIB_DLZ)
2625AC_SUBST(DLZ_DRIVER_INCLUDES)
2626AC_SUBST(DLZ_DRIVER_LIBS)
2627AC_SUBST(DLZ_DRIVER_SRCS)
2628AC_SUBST(DLZ_DRIVER_OBJS)
2629AC_SUBST(DLZ_SYSTEM_TEST)
2630AC_SUBST(DLZ_DRIVER_MYSQL_INCLUDES)
2631AC_SUBST(DLZ_DRIVER_MYSQL_LIBS)
2632AC_SUBST_FILE(DLZ_DRIVER_RULES)
2633
2634if test "yes" = "$cross_compiling"; then
2635	if test -z "$BUILD_CC"; then
2636		AC_MSG_ERROR([BUILD_CC not set])
2637	fi
2638	BUILD_CFLAGS="$BUILD_CFLAGS"
2639	BUILD_CPPFLAGS="$BUILD_CPPFLAGS"
2640	BUILD_LDFLAGS="$BUILD_LDFLAGS"
2641	BUILD_LIBS="$BUILD_LIBS"
2642else
2643	BUILD_CC="$CC"
2644	BUILD_CFLAGS="$CFLAGS"
2645	BUILD_CPPFLAGS="$CPPFLAGS $GEN_NEED_OPTARG"
2646	BUILD_LDFLAGS="$LDFLAGS"
2647	BUILD_LIBS="$LIBS"
2648fi
2649
2650NEWFLAGS=""
2651for e in $BUILD_LDFLAGS ; do
2652    case $e in
2653	-L*)
2654	    case $host_os in
2655		netbsd*)
2656		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
2657		    NEWFLAGS="$NEWFLAGS $e $ee"
2658		    ;;
2659		freebsd*)
2660		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
2661		    NEWFLAGS="$NEWFLAGS $e $ee"
2662		    ;;
2663		solaris*)
2664		    ee=`echo $e | sed -e 's%^-L%-R%'`
2665		    NEWFLAGS="$NEWFLAGS $e $ee"
2666		    ;;
2667		*)
2668		    NEWFLAGS="$NEWFLAGS $e"
2669		    ;;
2670		esac
2671	    ;;
2672	*)
2673	    NEWFLAGS="$NEWFLAGS $e"
2674	    ;;
2675    esac
2676done
2677BUILD_LDFLAGS="$NEWFLAGS"
2678
2679NEWFLAGS=""
2680for e in $DNS_GSSAPI_LIBS ; do
2681    case $e in
2682	-L*)
2683	    case $host_os in
2684		netbsd*)
2685		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
2686		    NEWFLAGS="$NEWFLAGS $e $ee"
2687		    ;;
2688		freebsd*)
2689		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
2690		    NEWFLAGS="$NEWFLAGS $e $ee"
2691		    ;;
2692		solaris*)
2693		    ee=`echo $e | sed -e 's%^-L%-R%'`
2694		    NEWFLAGS="$NEWFLAGS $e $ee"
2695		    ;;
2696		*)
2697		    NEWFLAGS="$NEWFLAGS $e"
2698		    ;;
2699		esac
2700	    ;;
2701	*)
2702	    NEWFLAGS="$NEWFLAGS $e"
2703	    ;;
2704    esac
2705done
2706DNS_GSSAPI_LIBS="$NEWFLAGS"
2707
2708NEWFLAGS=""
2709for e in $ISC_OPENSSL_LIBS ; do
2710    case $e in
2711	-L*)
2712	    case $host_os in
2713		netbsd*)
2714		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
2715		    NEWFLAGS="$NEWFLAGS $e $ee"
2716		    ;;
2717		freebsd*)
2718		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
2719		    NEWFLAGS="$NEWFLAGS $e $ee"
2720		    ;;
2721		solaris*)
2722		    ee=`echo $e | sed -e 's%^-L%-R%'`
2723		    NEWFLAGS="$NEWFLAGS $e $ee"
2724		    ;;
2725		*)
2726		    NEWFLAGS="$NEWFLAGS $e"
2727		    ;;
2728		esac
2729	    ;;
2730	*)
2731	    NEWFLAGS="$NEWFLAGS $e"
2732	    ;;
2733    esac
2734done
2735ISC_OPENSSL_LIBS="$NEWFLAGS"
2736
2737NEWFLAGS=""
2738for e in $DNS_CRYPTO_LIBS ; do
2739    case $e in
2740	-L*)
2741	    case $host_os in
2742		netbsd*)
2743		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
2744		    NEWFLAGS="$NEWFLAGS $e $ee"
2745		    ;;
2746		freebsd*)
2747		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
2748		    NEWFLAGS="$NEWFLAGS $e $ee"
2749		    ;;
2750		solaris*)
2751		    ee=`echo $e | sed -e 's%^-L%-R%'`
2752		    NEWFLAGS="$NEWFLAGS $e $ee"
2753		    ;;
2754		*)
2755		    NEWFLAGS="$NEWFLAGS $e"
2756		    ;;
2757		esac
2758	    ;;
2759	*)
2760	    NEWFLAGS="$NEWFLAGS $e"
2761	    ;;
2762    esac
2763done
2764DNS_CRYPTO_LIBS="$NEWFLAGS"
2765
2766AC_SUBST(BUILD_CC)
2767AC_SUBST(BUILD_CFLAGS)
2768AC_SUBST(BUILD_CPPFLAGS)
2769AC_SUBST(BUILD_LDFLAGS)
2770AC_SUBST(BUILD_LIBS)
2771
2772#
2773# Commands to run at the end of config.status.
2774# Don't just put these into configure, it won't work right if somebody
2775# runs config.status directly (which autoconf allows).
2776#
2777
2778AC_CONFIG_COMMANDS(
2779	[chmod],
2780	[chmod a+x doc/doxygen/doxygen-input-filter])
2781
2782#
2783# Files to configure.  These are listed here because we used to
2784# specify them as arguments to AC_OUTPUT.  It's (now) ok to move these
2785# elsewhere if there's a good reason for doing so.
2786#
2787
2788AC_CONFIG_FILES([
2789	Makefile
2790	bin/Makefile
2791	bin/check/Makefile
2792	bin/confgen/Makefile
2793	bin/confgen/unix/Makefile
2794	bin/delv/Makefile
2795	bin/dig/Makefile
2796	bin/dnssec/Makefile
2797	bin/named/Makefile
2798	bin/named/unix/Makefile
2799	bin/nsupdate/Makefile
2800	bin/pkcs11/Makefile
2801	bin/plugins/Makefile
2802	bin/python/Makefile
2803	bin/python/dnssec-checkds.py
2804	bin/python/dnssec-coverage.py
2805	bin/python/dnssec-keymgr.py
2806	bin/python/isc/Makefile
2807	bin/python/isc/__init__.py
2808	bin/python/isc/checkds.py
2809	bin/python/isc/coverage.py
2810	bin/python/isc/dnskey.py
2811	bin/python/isc/eventlist.py
2812	bin/python/isc/keydict.py
2813	bin/python/isc/keyevent.py
2814	bin/python/isc/keymgr.py
2815	bin/python/isc/keyseries.py
2816	bin/python/isc/keyzone.py
2817	bin/python/isc/policy.py
2818	bin/python/isc/rndc.py
2819	bin/python/isc/tests/Makefile
2820	bin/python/isc/tests/dnskey_test.py
2821	bin/python/isc/tests/policy_test.py
2822	bin/python/isc/utils.py
2823	bin/rndc/Makefile
2824	bin/tests/Makefile
2825	bin/tests/headerdep_test.sh
2826	bin/tests/optional/Makefile
2827	bin/tests/pkcs11/Makefile
2828	bin/tests/pkcs11/benchmarks/Makefile
2829	bin/tests/system/Makefile
2830	bin/tests/system/conf.sh
2831	bin/tests/system/dlzexternal/Makefile
2832	bin/tests/system/dlzexternal/ns1/dlzs.conf
2833	bin/tests/system/dyndb/Makefile
2834	bin/tests/system/dyndb/driver/Makefile
2835	bin/tests/system/pipelined/Makefile
2836	bin/tests/system/rndc/Makefile
2837	bin/tests/system/rpz/Makefile
2838	bin/tests/system/rsabigexponent/Makefile
2839	bin/tests/system/tkey/Makefile
2840	bin/tools/Makefile
2841	contrib/scripts/check-secure-delegation.pl
2842	contrib/scripts/zone-edit.sh
2843	doc/Makefile
2844	doc/arm/Makefile
2845	doc/doxygen/Doxyfile
2846	doc/doxygen/Makefile
2847	doc/doxygen/doxygen-input-filter
2848	doc/man/Makefile
2849	doc/misc/Makefile
2850	fuzz/Makefile
2851	lib/Makefile
2852	lib/bind9/Makefile
2853	lib/bind9/include/Makefile
2854	lib/bind9/include/bind9/Makefile
2855	lib/dns/Makefile
2856	lib/dns/include/Makefile
2857	lib/dns/include/dns/Makefile
2858	lib/dns/include/dst/Makefile
2859	lib/dns/tests/Makefile
2860	lib/irs/Makefile
2861	lib/irs/include/Makefile
2862	lib/irs/include/irs/Makefile
2863	lib/irs/include/irs/netdb.h
2864	lib/irs/include/irs/platform.h
2865	lib/irs/tests/Makefile
2866	lib/isc/Makefile
2867	lib/isc/include/Makefile
2868	lib/isc/include/isc/Makefile
2869	lib/isc/include/isc/platform.h
2870	lib/isc/include/pk11/Makefile
2871	lib/isc/include/pkcs11/Makefile
2872	lib/isc/netmgr/Makefile
2873	lib/isc/pthreads/Makefile
2874	lib/isc/pthreads/include/Makefile
2875	lib/isc/pthreads/include/isc/Makefile
2876	lib/isc/tests/Makefile
2877	lib/isc/unix/Makefile
2878	lib/isc/unix/include/Makefile
2879	lib/isc/unix/include/isc/Makefile
2880	lib/isccc/Makefile
2881	lib/isccc/include/Makefile
2882	lib/isccc/include/isccc/Makefile
2883	lib/isccc/tests/Makefile
2884	lib/isccfg/Makefile
2885	lib/isccfg/include/Makefile
2886	lib/isccfg/include/isccfg/Makefile
2887	lib/isccfg/tests/Makefile
2888	lib/ns/Makefile
2889	lib/ns/include/Makefile
2890	lib/ns/include/ns/Makefile
2891	lib/ns/tests/Makefile
2892	lib/samples/Makefile
2893	lib/samples/Makefile-postinstall
2894	make/Makefile
2895	make/mkdep
2896	unit/unittest.sh
2897	util/check-make-install
2898])
2899
2900#
2901# Do it
2902#
2903
2904AC_OUTPUT
2905
2906#
2907# Now that the Makefiles exist we can ensure that everything is rebuilt.
2908#
2909# [pairwise: --with-make-clean, --without-make-clean]
2910AC_ARG_WITH(make-clean,
2911	    AS_HELP_STRING([--with-make-clean],
2912			   [run "make clean" at end of configure [yes|no]]),
2913    make_clean="$withval", make_clean="yes")
2914case "$make_clean" in
2915yes)
2916	if test "yes" != "$no_create"
2917	then
2918		if test "yes" = "$silent"
2919		then
2920			make clean > /dev/null
2921		else
2922			make clean
2923		fi
2924	fi
2925	;;
2926esac
2927
2928# [pairwise: --enable-full-report, --disable-full-report]
2929AC_ARG_ENABLE(full-report,
2930	      AS_HELP_STRING([--enable-full-report],
2931			     [report values of all configure options]))
2932
2933report() {
2934    echo "==============================================================================="
2935    echo "Configuration summary:"
2936    echo "-------------------------------------------------------------------------------"
2937    echo "Optional features enabled:"
2938    if test "yes" = "$enable_full_report" -o "standard" = "$with_locktype"; then
2939	echo "    Mutex lock type: $with_locktype"
2940    fi
2941    test "small" = "$with_tuning" && echo "    Small-system tuning (--with-tuning)"
2942    test "no" = "$use_dnstap" || \
2943	    echo "    Allow 'dnstap' packet logging (--enable-dnstap)"
2944    test -z "$MAXMINDDB_LIBS" || echo "    GeoIP2 access control (--enable-geoip)"
2945    test "no" = "$use_gssapi" || echo "    GSS-API (--with-gssapi)"
2946
2947    # these lines are only printed if run with --enable-full-report
2948    if test "yes" = "$enable_full_report"; then
2949	test "no" = "$found_ipv6" || echo "    IPv6 support (--enable-ipv6)"
2950	test "X$PYTHON" = "X" || echo "    Python tools (--with-python)"
2951	test "X$LIBXML2_LIBS" = "X" || echo "    XML statistics (--with-libxml2)"
2952	test "X$JSON_C_LIBS" = "X" || echo "    JSON statistics (--with-json-c): $JSON_C_CFLAGS $JSON_C_LIBS"
2953	test "X$ZLIB_LIBS" = "X" || echo "    HTTP zlib compression (--with-zlib)"
2954	test "X$NZD_TOOLS" = "X" || echo "    LMDB database to store configuration for 'addzone' zones (--with-lmdb)"
2955	test "no" = "$with_libidn2" || echo "    IDN support (--with-libidn2)"
2956    fi
2957
2958    test "yes" = "$enable_dnsrps" && \
2959	echo "    DNS Response Policy Service interface (--enable-dnsrps)"
2960    test "yes" = "$enable_fixed" && \
2961	echo "    Allow 'fixed' rrset-order (--enable-fixed-rrset)"
2962    test "yes" = "$enable_backtrace" && \
2963	echo "    Print backtrace on crash (--enable-backtrace)"
2964    test "minimal" = "$want_symtable" && \
2965	echo "    Use symbol table for backtrace, named only (--enable-symtable)"
2966    test "yes" = "$want_symtable" -o "all" = "$want_symtable" && \
2967	echo "    Use symbol table for backtrace, all binaries (--enable-symtable=all)"
2968    test "no" = "$use_libtool" || echo "    Use GNU libtool (--with-libtool)"
2969    test "yes" = "$want_querytrace" && \
2970	echo "    Very verbose query trace logging (--enable-querytrace)"
2971    test "no" = "$with_cmocka" || echo "    CMocka Unit Testing Framework (--with-cmocka)"
2972
2973    test "auto" = "$validation_default" && echo "    DNSSEC validation active by default (--enable-auto-validation)"
2974
2975    test "$CRYPTO" = "pkcs11" && (
2976	echo "    Using PKCS#11 for Public-Key Cryptography (--with-native-pkcs11)"
2977	echo "    PKCS#11 module (--with-pkcs11): $with_pkcs11"
2978    )
2979
2980    echo "    Dynamically loadable zone (DLZ) drivers:"
2981    test "no" = "$use_dlz_bdb" || \
2982	echo "        Berkeley DB (--with-dlz-bdb)"
2983    test "no" = "$use_dlz_ldap" || \
2984	echo "        LDAP (--with-dlz-ldap)"
2985    test "no" = "$use_dlz_mysql" || \
2986	echo "        MySQL (--with-dlz-mysql)"
2987    test "no" = "$use_dlz_odbc" || \
2988	echo "        ODBC (--with-dlz-odbc)"
2989    test "no" = "$use_dlz_postgres" || \
2990	echo "        Postgres (--with-dlz-postgres)"
2991    test "no" = "$use_dlz_filesystem" || \
2992	echo "        Filesystem (--with-dlz-filesystem)"
2993    test "no" = "$use_dlz_stub" || \
2994	echo "        Stub (--with-dlz-stub)"
2995    test "$use_dlz_bdb $use_dlz_ldap $use_dlz_mysql $use_dlz_odbc $use_dlz_postgres $use_dlz_filesystem $use_dlz_stub" = "no no no no no no no" && echo "        None"
2996
2997    echo "-------------------------------------------------------------------------------"
2998
2999    echo "Features disabled or unavailable on this platform:"
3000    test "no" = "$found_ipv6" && echo "    IPv6 support (--enable-ipv6)"
3001    test "small" = "$with_tuning" || echo "    Small-system tuning (--with-tuning)"
3002
3003    test "no" = "$use_dnstap" && \
3004	    echo "    Allow 'dnstap' packet logging (--enable-dnstap)"
3005    test -z "$MAXMINDDB_LIBS" && echo "    GeoIP2 access control (--enable-geoip)"
3006    test "no" = "$use_gssapi" && echo "    GSS-API (--with-gssapi)"
3007
3008    test "no" = "$enable_dnsrps" && \
3009	echo "    DNS Response Policy Service interface (--enable-dnsrps)"
3010
3011    test "yes" = "$enable_fixed" || \
3012	echo "    Allow 'fixed' rrset-order (--enable-fixed-rrset)"
3013
3014    test "yes" = "$validation_default" && echo "    DNSSEC validation requires configuration (--enablee-auto-validation)"
3015
3016    test "$CRYPTO" = "pkcs11" || (
3017	echo "    Using PKCS#11 for Public-Key Cryptography (--with-native-pkcs11)"
3018    )
3019
3020    test "yes" = "$enable_backtrace" || \
3021	echo "    Print backtrace on crash (--enable-backtrace)"
3022    test "yes" = "$want_querytrace" || \
3023	echo "    Very verbose query trace logging (--enable-querytrace)"
3024
3025    test "yes" = "$use_libtool" || echo "    Use GNU libtool (--with-libtool)"
3026    test "no" = "$with_cmocka" && echo "    CMocka Unit Testing Framework (--with-cmocka)"
3027
3028    test "X$PYTHON" = "X" && echo "    Python tools (--with-python)"
3029    test "X$LIBXML2_LIBS" = "X" && echo "    XML statistics (--with-libxml2)"
3030    test "X$JSON_C_LIBS" = "X" && echo "    JSON statistics (--with-json-c)"
3031    test "X$ZLIB_LIBS" = "X" && echo "    HTTP zlib compression (--with-zlib)"
3032    test "X$NZD_TOOLS" = "X" && echo "    LMDB database to store configuration for 'addzone' zones (--with-lmdb)"
3033    test "no" = "$with_libidn2" && echo "    IDN support (--with-libidn2)"
3034
3035    echo "-------------------------------------------------------------------------------"
3036    echo "Configured paths:"
3037    echo "    prefix: $prefix"
3038    echo "    sysconfdir: $sysconfdir"
3039    echo "    localstatedir: $localstatedir"
3040    echo "-------------------------------------------------------------------------------"
3041    echo "Compiler: $CC"
3042    $CC --version 2>&1 | sed 's/^/    /'
3043
3044    if test "X$ac_unrecognized_opts" != "X"; then
3045	echo "Unrecognized options:"
3046	echo "    $ac_unrecognized_opts"
3047    fi
3048
3049    if test "yes" != "$enable_full_report"; then
3050	echo "-------------------------------------------------------------------------------"
3051	echo "For more detail, use --enable-full-report."
3052    fi
3053    echo "==============================================================================="
3054}
3055
3056if test "yes" != "$silent"; then
3057	report
3058fi
3059
3060# Tell Emacs to edit this file in shell mode.
3061# Local Variables:
3062# mode: sh
3063# End:
3064