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