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