xref: /freebsd/contrib/unbound/configure.ac (revision be771a7b7f4580a30d99e41a5bb1b93a385a119d)
1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3AC_PREREQ([2.56])
4sinclude(acx_nlnetlabs.m4)
5sinclude(ax_build_date_epoch.m4)
6sinclude(ax_pthread.m4)
7sinclude(acx_python.m4)
8sinclude(ax_pkg_swig.m4)
9sinclude(dnstap/dnstap.m4)
10sinclude(dnscrypt/dnscrypt.m4)
11
12# must be numbers. ac_defun because of later processing
13m4_define([VERSION_MAJOR],[1])
14m4_define([VERSION_MINOR],[23])
15m4_define([VERSION_MICRO],[0])
16AC_INIT([unbound],m4_defn([VERSION_MAJOR]).m4_defn([VERSION_MINOR]).m4_defn([VERSION_MICRO]),[unbound-bugs@nlnetlabs.nl or https://github.com/NLnetLabs/unbound/issues],[unbound])
17AC_SUBST(UNBOUND_VERSION_MAJOR, [VERSION_MAJOR])
18AC_SUBST(UNBOUND_VERSION_MINOR, [VERSION_MINOR])
19AC_SUBST(UNBOUND_VERSION_MICRO, [VERSION_MICRO])
20
21LIBUNBOUND_CURRENT=9
22LIBUNBOUND_REVISION=31
23LIBUNBOUND_AGE=1
24# 1.0.0 had 0:12:0
25# 1.0.1 had 0:13:0
26# 1.0.2 had 0:14:0
27# 1.1.0 had 0:15:0
28# 1.1.1 had 0:16:0
29# 1.2.0 had 0:17:0
30# 1.2.1 had 0:18:0
31# 1.3.0 had 1:0:0   # ub_cancel and -export-symbols.
32# 1.3.1 had 1:1:0
33# 1.3.2 had 1:2:0
34# 1.3.3 had 1:3:0
35# 1.3.4 had 1:4:0
36# 1.4.0-snapshots had 1:5:0
37# 1.4.0 had 1:5:0 (not 2:0:0)   # ub_result.why_bogus
38# 1.4.1 had 2:1:0
39# 1.4.2 had 2:2:0
40# 1.4.3 had 2:3:0
41# 1.4.4 had 2:4:0
42# 1.4.5 had 2:5:0
43# 1.4.6 had 2:6:0
44# 1.4.7 had 2:7:0
45# 1.4.8 had 2:8:0
46# 1.4.9 had 2:9:0
47# 1.4.10 had 2:10:0
48# 1.4.11 had 2:11:0
49# 1.4.12 had 2:12:0
50# 1.4.13 had 2:13:0
51# and 1.4.13p1 and 1.4.13.p2
52# 1.4.14 had 2:14:0
53# 1.4.15 had 3:0:1 # adds ub_version()
54# 1.4.16 had 3:1:1
55# 1.4.17 had 3:2:1
56# 1.4.18 had 3:3:1
57# 1.4.19 had 3:4:1
58# 1.4.20 had 4:0:2 # adds libunbound.ttl # but shipped 3:5:1
59# 1.4.21 had 4:1:2
60# 1.4.22 had 4:1:2
61# 1.5.0 had 5:3:3 # adds ub_ctx_add_ta_autr
62# 1.5.1 had 5:3:3
63# 1.5.2 had 5:5:3
64# 1.5.3 had 5:6:3
65# 1.5.4 had 5:7:3
66# 1.5.5 had 5:8:3
67# 1.5.6 had 5:9:3
68# 1.5.7 had 5:10:3
69# 1.5.8 had 6:0:4 # adds ub_ctx_set_stub
70# 1.5.9 had 6:1:4
71# 1.5.10 had 6:2:4
72# 1.6.0 had 6:3:4
73# 1.6.1 had 7:0:5 # ub_callback_t typedef renamed to ub_callback_type
74# 1.6.2 had 7:1:5
75# 1.6.3 had 7:2:5
76# 1.6.4 had 7:3:5
77# 1.6.5 had 7:4:5
78# 1.6.6 had 7:5:5
79# 1.6.7 had 7:6:5
80# 1.6.8 had 7:7:5
81# 1.7.0 had 7:8:5
82# 1.7.1 had 7:9:5
83# 1.7.2 had 7:10:5
84# 1.7.3 had 7:11:5
85# 1.8.0 had 8:0:0 # changes the event callback function signature
86# 1.8.1 had 8:1:0
87# 1.8.2 had 8:2:0
88# 1.8.3 had 8:3:0
89# 1.9.0 had 9:0:1 # add ub_ctx_set_tls
90# 1.9.1 had 9:1:1
91# 1.9.2 had 9:2:1
92# 1.9.3 had 9:3:1
93# 1.9.4 had 9:4:1
94# 1.9.5 had 9:5:1
95# 1.9.6 had 9:6:1
96# 1.10.0 had 9:7:1
97# 1.10.1 had 9:8:1
98# 1.11.0 had 9:9:1
99# 1.12.0 had 9:10:1
100# 1.13.0 had 9:11:1
101# 1.13.1 had 9:12:1
102# 1.13.2 had 9:13:1
103# 1.14.0 had 9:14:1
104# 1.15.0 had 9:15:1
105# 1.16.0 had 9:16:1
106# 1.16.1 had 9:17:1
107# 1.16.2 had 9:18:1
108# 1.16.3 had 9:19:1
109# 1.17.0 had 9:20:1
110# 1.17.1 had 9:21:1
111# 1.18.0 had 9:22:1
112# 1.19.0 had 9:23:1
113# 1.19.1 had 9:24:1
114# 1.19.2 had 9:25:1
115# 1.19.3 had 9:26:1
116# 1.20.0 had 9:27:1
117# 1.21.0 had 9:28:1
118# 1.21.1 had 9:29:1
119# 1.22.0 had 9:30:1
120# 1.23.0 had 9:31:1
121
122#   Current  -- the number of the binary API that we're implementing
123#   Revision -- which iteration of the implementation of the binary
124#               API are we supplying?
125#   Age      -- How many previous binary API versions do we also
126#               support?
127#
128# If we release a new version that does not change the binary API,
129# increment Revision.
130#
131# If we release a new version that changes the binary API, but does
132# not break programs compiled against the old binary API, increment
133# Current and Age.  Set Revision to 0, since this is the first
134# implementation of the new API.
135#
136# Otherwise, we're changing the binary API and breaking backward
137# compatibility with old binaries.  Increment Current.  Set Age to 0,
138# since we're backward compatible with no previous APIs.  Set Revision
139# to 0 too.
140AC_SUBST(LIBUNBOUND_CURRENT)
141AC_SUBST(LIBUNBOUND_REVISION)
142AC_SUBST(LIBUNBOUND_AGE)
143
144
145cmdln="`echo $@ | sed -e 's/\\\\/\\\\\\\\/g' | sed -e 's/"/\\\\"/'g`"
146AC_DEFINE_UNQUOTED(CONFCMDLINE, ["$cmdln"], [Command line arguments used with configure])
147
148CFLAGS="$CFLAGS"
149AC_USE_SYSTEM_EXTENSIONS
150if test "$ac_cv_header_minix_config_h" = "yes"; then
151	AC_DEFINE(_NETBSD_SOURCE,1, [Enable for compile on Minix])
152fi
153
154dnl
155dnl By default set prefix to /usr/local
156dnl
157case "$prefix" in
158        NONE)
159		prefix="/usr/local"
160        ;;
161esac
162case "$exec_prefix" in
163        NONE)
164		exec_prefix="$prefix"
165        ;;
166esac
167
168# are we on MinGW?
169if uname -s 2>&1 | grep MINGW >/dev/null; then on_mingw="yes"
170else
171	if echo $host | grep mingw >/dev/null; then on_mingw="yes"
172	else on_mingw="no"; fi
173fi
174
175#
176# Determine configuration file
177# the eval is to evaluate shell expansion twice
178UNBOUND_SBIN_DIR=`eval echo "${sbindir}"`
179AC_SUBST(UNBOUND_SBIN_DIR)
180UNBOUND_SYSCONF_DIR=`eval echo "${sysconfdir}"`
181AC_SUBST(UNBOUND_SYSCONF_DIR)
182UNBOUND_LOCALSTATE_DIR=`eval echo "${localstatedir}"`
183AC_SUBST(UNBOUND_LOCALSTATE_DIR)
184if test $on_mingw = "no"; then
185  ub_conf_file=`eval echo "${sysconfdir}/unbound/unbound.conf"`
186else
187  ub_conf_file="C:\\Program Files\\Unbound\\service.conf"
188fi
189AC_ARG_WITH([conf_file],
190        AS_HELP_STRING([--with-conf-file=path],[Pathname to the Unbound configuration file]),
191	[ub_conf_file="$withval"])
192AC_SUBST(ub_conf_file)
193ACX_ESCAPE_BACKSLASH($ub_conf_file, hdr_config)
194AC_DEFINE_UNQUOTED(CONFIGFILE, ["$hdr_config"], [Pathname to the Unbound configuration file])
195ub_conf_dir=`AS_DIRNAME(["$ub_conf_file"])`
196AC_SUBST(ub_conf_dir)
197
198# Determine run, chroot directory and pidfile locations
199AC_ARG_WITH(run-dir,
200    AS_HELP_STRING([--with-run-dir=path],[set default directory to chdir to (by default dir part of cfg file)]),
201    UNBOUND_RUN_DIR="$withval",
202if test $on_mingw = no; then
203    UNBOUND_RUN_DIR=`dirname "$ub_conf_file"`
204else
205    UNBOUND_RUN_DIR=""
206fi
207)
208AC_SUBST(UNBOUND_RUN_DIR)
209ACX_ESCAPE_BACKSLASH($UNBOUND_RUN_DIR, hdr_run)
210AC_DEFINE_UNQUOTED(RUN_DIR, ["$hdr_run"], [Directory to chdir to])
211
212AC_ARG_WITH(chroot-dir,
213    AS_HELP_STRING([--with-chroot-dir=path],[set default directory to chroot to (by default same as run-dir)]),
214    UNBOUND_CHROOT_DIR="$withval",
215if test $on_mingw = no; then
216    UNBOUND_CHROOT_DIR="$UNBOUND_RUN_DIR"
217else
218    UNBOUND_CHROOT_DIR=""
219fi
220)
221AC_SUBST(UNBOUND_CHROOT_DIR)
222ACX_ESCAPE_BACKSLASH($UNBOUND_CHROOT_DIR, hdr_chroot)
223AC_DEFINE_UNQUOTED(CHROOT_DIR, ["$hdr_chroot"], [Directory to chroot to])
224
225AC_ARG_WITH(share-dir,
226    AS_HELP_STRING([--with-share-dir=path],[set default directory with shared data (by default same as share/unbound)]),
227    UNBOUND_SHARE_DIR="$withval",
228    UNBOUND_SHARE_DIR="$UNBOUND_RUN_DIR")
229AC_SUBST(UNBOUND_SHARE_DIR)
230AC_DEFINE_UNQUOTED(SHARE_DIR, ["$UNBOUND_SHARE_DIR"], [Shared data])
231
232AC_ARG_WITH(pidfile,
233    AS_HELP_STRING([--with-pidfile=filename],[set default pathname to unbound pidfile (default run-dir/unbound.pid)]),
234    UNBOUND_PIDFILE="$withval",
235if test $on_mingw = no; then
236    UNBOUND_PIDFILE="$UNBOUND_RUN_DIR/unbound.pid"
237else
238    UNBOUND_PIDFILE=""
239fi
240)
241AC_SUBST(UNBOUND_PIDFILE)
242ACX_ESCAPE_BACKSLASH($UNBOUND_PIDFILE, hdr_pid)
243AC_DEFINE_UNQUOTED(PIDFILE, ["$hdr_pid"], [default pidfile location])
244
245AC_ARG_WITH(rootkey-file,
246    AS_HELP_STRING([--with-rootkey-file=filename],[set default pathname to root key file (default run-dir/root.key). This file is read and written.]),
247    UNBOUND_ROOTKEY_FILE="$withval",
248if test $on_mingw = no; then
249    UNBOUND_ROOTKEY_FILE="$UNBOUND_RUN_DIR/root.key"
250else
251    UNBOUND_ROOTKEY_FILE="C:\\Program Files\\Unbound\\root.key"
252fi
253)
254AC_SUBST(UNBOUND_ROOTKEY_FILE)
255ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTKEY_FILE, hdr_rkey)
256AC_DEFINE_UNQUOTED(ROOT_ANCHOR_FILE, ["$hdr_rkey"], [default rootkey location])
257
258AC_ARG_WITH(rootcert-file,
259    AS_HELP_STRING([--with-rootcert-file=filename],[set default pathname to root update certificate file (default run-dir/icannbundle.pem).  This file need not exist if you are content with the builtin.]),
260    UNBOUND_ROOTCERT_FILE="$withval",
261if test $on_mingw = no; then
262    UNBOUND_ROOTCERT_FILE="$UNBOUND_RUN_DIR/icannbundle.pem"
263else
264    UNBOUND_ROOTCERT_FILE="C:\\Program Files\\Unbound\\icannbundle.pem"
265fi
266)
267AC_SUBST(UNBOUND_ROOTCERT_FILE)
268ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTCERT_FILE, hdr_rpem)
269AC_DEFINE_UNQUOTED(ROOT_CERT_FILE, ["$hdr_rpem"], [default rootcert location])
270
271AC_ARG_WITH(username,
272    AS_HELP_STRING([--with-username=user],[set default user that unbound changes to (default user is unbound)]),
273    UNBOUND_USERNAME="$withval",
274    UNBOUND_USERNAME="unbound")
275AC_SUBST(UNBOUND_USERNAME)
276AC_DEFINE_UNQUOTED(UB_USERNAME, ["$UNBOUND_USERNAME"], [default username])
277
278AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
279ACX_RSRC_VERSION(wnvs)
280AC_DEFINE_UNQUOTED(RSRC_PACKAGE_VERSION, [$wnvs], [version number for resource files])
281
282# Check for 'grep -e' program, here, since ACX_CHECK_FLTO needs that.
283AC_PROG_GREP
284
285# Checks for typedefs, structures, and compiler characteristics.
286AC_C_CONST
287AC_LANG([C])
288# allow user to override the -g -O2 flags.
289default_cflags=no
290if test "x$CFLAGS" = "x" ; then
291ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="$CFLAGS -g"])
292ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"])
293default_cflags=yes
294fi
295m4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_STDC])
296ACX_DEPFLAG
297ACX_DETERMINE_EXT_FLAGS_UNBOUND
298
299# debug mode flags warnings
300AC_ARG_ENABLE(checking, AS_HELP_STRING([--enable-checking],[Enable warnings, asserts, makefile-dependencies]))
301AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],[same as enable-checking]))
302if test "$enable_debug" = "yes"; then debug_enabled="$enable_debug";
303else debug_enabled="$enable_checking"; fi
304AC_SUBST(debug_enabled)
305case "$debug_enabled" in
306        yes)
307		ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="$CFLAGS -W"])
308		ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="$CFLAGS -Wall"])
309		ACX_CHECK_COMPILER_FLAG(Wextra, [CFLAGS="$CFLAGS -Wextra"])
310		ACX_CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [CFLAGS="$CFLAGS -Wdeclaration-after-statement"])
311		AC_DEFINE([UNBOUND_DEBUG], [], [define this to enable debug checks.])
312		;;
313	no|*)
314		# nothing to do.
315		;;
316esac
317if test "$default_cflags" = "yes"; then
318	# only when CFLAGS was "" at the start, if the users wants to
319	# override we shouldn't add default cflags, because they wouldn't
320	# be able to turn off these options and set the CFLAGS wanted.
321	ACX_CHECK_FLTO
322	ACX_CHECK_PIE
323	ACX_CHECK_RELRO_NOW
324fi
325
326AC_C_INLINE
327ACX_CHECK_FORMAT_ATTRIBUTE
328ACX_CHECK_UNUSED_ATTRIBUTE
329
330AC_DEFUN([CHECK_WEAK_ATTRIBUTE],
331[AC_REQUIRE([AC_PROG_CC])
332AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "weak" attribute)
333AC_CACHE_VAL(ac_cv_c_weak_attribute,
334[ac_cv_c_weak_attribute=no
335AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h>
336__attribute__((weak)) void f(int x) { printf("%d", x); }
337]], [[
338   f(1);
339]])],[ac_cv_c_weak_attribute="yes"],[ac_cv_c_weak_attribute="no"])
340])
341
342AC_MSG_RESULT($ac_cv_c_weak_attribute)
343if test $ac_cv_c_weak_attribute = yes; then
344  AC_DEFINE(HAVE_ATTR_WEAK, 1, [Whether the C compiler accepts the "weak" attribute])
345  AC_DEFINE(ATTR_WEAK, [__attribute__((weak))], [apply the weak attribute to a symbol])
346else
347  AC_DEFINE(ATTR_WEAK,[], [apply the weak attribute to a symbol])
348fi
349])dnl End of CHECK_WEAK_ATTRIBUTE
350
351CHECK_WEAK_ATTRIBUTE
352
353AC_DEFUN([CHECK_NORETURN_ATTRIBUTE],
354[AC_REQUIRE([AC_PROG_CC])
355AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "noreturn" attribute)
356AC_CACHE_VAL(ac_cv_c_noreturn_attribute,
357[ac_cv_c_noreturn_attribute=no
358AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h>
359__attribute__((noreturn)) void f(int x) { printf("%d", x); }
360]], [[
361   f(1);
362]])],[ac_cv_c_noreturn_attribute="yes"],[ac_cv_c_noreturn_attribute="no"])
363])
364
365AC_MSG_RESULT($ac_cv_c_noreturn_attribute)
366if test $ac_cv_c_noreturn_attribute = yes; then
367  AC_DEFINE(HAVE_ATTR_NORETURN, 1, [Whether the C compiler accepts the "noreturn" attribute])
368  AC_DEFINE(ATTR_NORETURN, [__attribute__((__noreturn__))], [apply the noreturn attribute to a function that exits the program])
369else
370  AC_DEFINE(ATTR_NORETURN,[], [apply the noreturn attribute to a function that exits the program])
371fi
372])dnl End of CHECK_NORETURN_ATTRIBUTE
373
374CHECK_NORETURN_ATTRIBUTE
375
376AC_DEFUN([CHECK_FALLTHROUGH_ATTRIBUTE],
377[AC_REQUIRE([AC_PROG_CC])
378AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "fallthrough" attribute)
379BAKCFLAGS="$CFLAGS"
380CFLAGS="$CFLAGS -Werror"
381AC_CACHE_VAL(ac_cv_c_fallthrough_attribute,
382[ac_cv_c_fallthrough_attribute=no
383AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h>
384void f(int x) {
385	int y = 0;
386	switch(x) {
387	case 1:
388		y = 1;
389		__attribute__((fallthrough));
390		/* fallthrough */
391	case 2:
392		y++;
393		break;
394	case 3:
395		y = 3;
396		break;
397	}
398	printf("%d", y);
399}
400]], [[
401   f(1);
402]])],[ac_cv_c_fallthrough_attribute="yes"],[ac_cv_c_fallthrough_attribute="no"])
403])
404CFLAGS="$BAKCFLAGS"
405
406AC_MSG_RESULT($ac_cv_c_fallthrough_attribute)
407if test $ac_cv_c_fallthrough_attribute = yes; then
408  AC_DEFINE(HAVE_ATTR_FALLTHROUGH, 1, [Whether the C compiler accepts the "fallthrough" attribute])
409  AC_DEFINE(ATTR_FALLTHROUGH, [__attribute__((fallthrough));], [apply the fallthrough attribute.])
410else
411  AC_DEFINE(ATTR_FALLTHROUGH,[], [apply the fallthrough attribute.])
412fi
413])dnl End of CHECK_FALLTHROUGH_ATTRIBUTE
414
415CHECK_FALLTHROUGH_ATTRIBUTE
416
417if test "$srcdir" != "."; then
418	CPPFLAGS="$CPPFLAGS -I$srcdir"
419fi
420
421AC_DEFUN([ACX_YYLEX_DESTROY], [
422	AC_MSG_CHECKING([for yylex_destroy])
423	if echo %% | $LEX -t 2>&1 | grep yylex_destroy >/dev/null 2>&1; then
424		AC_DEFINE(LEX_HAS_YYLEX_DESTROY, 1, [if lex has yylex_destroy])
425		AC_MSG_RESULT(yes)
426	else AC_MSG_RESULT(no);
427		LEX=":"
428	fi
429])
430
431AC_DEFUN([ACX_YYLEX_OPTION], [
432	AC_MSG_CHECKING([for lex %option])
433	if cat <<EOF | $LEX -t 2>&1 | grep yy_delete_buffer >/dev/null 2>&1; then
434%option nounput
435%%
436EOF
437		AC_MSG_RESULT(yes)
438	else AC_MSG_RESULT(no);
439		LEX=":"
440	fi
441])
442
443AC_PROG_LEX([noyywrap])
444if test "$LEX" != "" -a "$LEX" != ":"; then
445ACX_YYLEX_DESTROY
446fi
447if test "$LEX" != "" -a "$LEX" != ":"; then
448ACX_YYLEX_OPTION
449fi
450if test "$LEX" = "" -o "$LEX" = ":"; then
451	if test ! -f util/configlexer.c; then
452		AC_MSG_ERROR([no lex and no util/configlexer.c: need flex and bison to compile from source repository.])
453	fi
454fi
455AC_PROG_YACC
456if test "$YACC" = "" -o "$YACC" = ":"; then
457	if test ! -f util/configparser.c; then
458		AC_MSG_ERROR([no yacc and no util/configparser.c: need flex and bison to compile from source repository.])
459	fi
460fi
461AC_CHECK_PROG(doxygen, doxygen, doxygen)
462AC_CHECK_TOOL(STRIP, strip)
463ACX_LIBTOOL_C_ONLY
464
465# pkg-config is only needed for these options, do not require it otherwise
466if test "$enable_systemd" = "yes" -o "$enable_dnstap" = "yes" -o "$with_pyunbound" = "yes" -o "$with_pythonmod" = "yes"; then
467PKG_PROG_PKG_CONFIG
468fi
469
470# Checks for header files.
471AC_CHECK_HEADERS([stdarg.h stdbool.h netinet/in.h netinet/tcp.h sys/param.h sys/select.h sys/socket.h sys/un.h sys/uio.h sys/resource.h arpa/inet.h syslog.h netdb.h sys/wait.h pwd.h glob.h grp.h login_cap.h winsock2.h ws2tcpip.h endian.h sys/endian.h libkern/OSByteOrder.h sys/ipc.h sys/shm.h ifaddrs.h poll.h],,, [AC_INCLUDES_DEFAULT])
472# net/if.h portability for Darwin see:
473# https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Header-Portability.html
474AC_CHECK_HEADERS([net/if.h],,, [
475#include <stdio.h>
476#ifdef STDC_HEADERS
477# include <stdlib.h>
478# include <stddef.h>
479#else
480# ifdef HAVE_STDLIB_H
481#  include <stdlib.h>
482# endif
483#endif
484#ifdef HAVE_SYS_SOCKET_H
485# include <sys/socket.h>
486#endif
487])
488
489# Check for Apple header. This uncovers TARGET_OS_IPHONE, TARGET_OS_TV or TARGET_OS_WATCH
490AC_CHECK_HEADERS([TargetConditionals.h],,, [AC_INCLUDES_DEFAULT])
491AC_CHECK_HEADERS([netioapi.h],,, [AC_INCLUDES_DEFAULT
492#if HAVE_SYS_PARAM_H
493#include <sys/param.h>
494#endif
495
496#ifdef HAVE_SYS_SOCKET_H
497#include <sys/socket.h>
498#endif
499
500#ifdef HAVE_SYS_UIO_H
501#include <sys/uio.h>
502#endif
503
504#ifdef HAVE_NETINET_IN_H
505#include <netinet/in.h>
506#endif
507
508#ifdef HAVE_NETINET_TCP_H
509#include <netinet/tcp.h>
510#endif
511
512#ifdef HAVE_ARPA_INET_H
513#include <arpa/inet.h>
514#endif
515
516#ifdef HAVE_WINSOCK2_H
517#include <winsock2.h>
518#endif
519
520#ifdef HAVE_WS2TCPIP_H
521#include <ws2tcpip.h>
522#endif
523])
524
525# Check for Linux timestamping headers
526AC_CHECK_HEADERS([linux/net_tstamp.h],,, [AC_INCLUDES_DEFAULT])
527AC_CHECK_HEADERS([stdatomic.h],,, [AC_INCLUDES_DEFAULT])
528
529# check for types.
530# Using own tests for int64* because autoconf builtin only give 32bit.
531AC_CHECK_TYPE(int8_t, signed char)
532AC_CHECK_TYPE(int16_t, short)
533AC_CHECK_TYPE(int32_t, int)
534AC_CHECK_TYPE(int64_t, long long)
535AC_CHECK_TYPE(uint8_t, unsigned char)
536AC_CHECK_TYPE(uint16_t, unsigned short)
537AC_CHECK_TYPE(uint32_t, unsigned int)
538AC_CHECK_TYPE(uint64_t, unsigned long long)
539AC_TYPE_SIZE_T
540AC_CHECK_TYPE(ssize_t, int)
541AC_TYPE_UID_T
542AC_TYPE_PID_T
543AC_TYPE_OFF_T
544ACX_TYPE_U_CHAR
545ACX_TYPE_RLIM_T
546ACX_TYPE_SOCKLEN_T
547ACX_TYPE_IN_ADDR_T
548ACX_TYPE_IN_PORT_T
549ACX_CHECK_MEMCMP_SIGNED
550
551AC_CHECK_SIZEOF(time_t,,[
552AC_INCLUDES_DEFAULT
553#ifdef TIME_WITH_SYS_TIME
554# include <sys/time.h>
555# include <time.h>
556#else
557# ifdef HAVE_SYS_TIME_H
558#  include <sys/time.h>
559# else
560#  include <time.h>
561# endif
562#endif
563])
564AC_CHECK_SIZEOF(size_t)
565
566# add option to disable the evil rpath
567ACX_ARG_RPATH
568AC_SUBST(RUNTIME_PATH)
569
570# check to see if libraries are needed for these functions.
571AC_SEARCH_LIBS([inet_pton], [nsl])
572AC_SEARCH_LIBS([socket], [socket])
573
574# check whether strptime also works
575AC_DEFUN([AC_CHECK_STRPTIME_WORKS],
576[AC_REQUIRE([AC_PROG_CC])
577AC_MSG_CHECKING(whether strptime works)
578if test c${cross_compiling} = cno; then
579AC_RUN_IFELSE([AC_LANG_SOURCE([[
580#define _XOPEN_SOURCE 600
581#include <time.h>
582int main(void) { struct tm tm; char *res;
583res = strptime("2010-07-15T00:00:00+00:00", "%t%Y%t-%t%m%t-%t%d%tT%t%H%t:%t%M%t:%t%S%t", &tm);
584if (!res) return 2;
585res = strptime("20070207111842", "%Y%m%d%H%M%S", &tm);
586if (!res) return 1; return 0; }
587]])] , [eval "ac_cv_c_strptime_works=yes"], [eval "ac_cv_c_strptime_works=no"],
588[eval "ac_cv_c_strptime_works=maybe"])
589else
590eval "ac_cv_c_strptime_works=maybe"
591fi
592AC_MSG_RESULT($ac_cv_c_strptime_works)
593if test $ac_cv_c_strptime_works = no; then
594AC_LIBOBJ(strptime)
595else
596AC_DEFINE_UNQUOTED([STRPTIME_WORKS], 1, [use default strptime.])
597fi
598])dnl
599
600# check some functions of the OS before linking libs (while still runnable).
601AC_FUNC_CHOWN
602AC_FUNC_FORK
603AC_DEFINE(RETSIGTYPE,void,[Return type of signal handlers, but autoconf 2.70 says 'your code may safely assume C89 semantics that RETSIGTYPE is void.'])
604AC_FUNC_FSEEKO
605ACX_SYS_LARGEFILE
606ACX_CHECK_NONBLOCKING_BROKEN
607ACX_MKDIR_ONE_ARG
608AC_CHECK_FUNCS([strptime],[AC_CHECK_STRPTIME_WORKS],[AC_LIBOBJ([strptime])])
609
610# check if we can use SO_REUSEPORT
611reuseport_default=0
612if echo "$host" | $GREP -i -e linux >/dev/null; then reuseport_default=1; fi
613if echo "$host" | $GREP -i -e dragonfly >/dev/null; then reuseport_default=1; fi
614if test "$reuseport_default" = 1; then
615	AC_DEFINE(REUSEPORT_DEFAULT, 1, [if REUSEPORT is enabled by default])
616else
617	AC_DEFINE(REUSEPORT_DEFAULT, 0, [if REUSEPORT is enabled by default])
618fi
619
620# Include systemd.m4 - begin
621sinclude(systemd.m4)
622# Include systemd.m4 - end
623
624# set memory allocation checking if requested
625AC_ARG_ENABLE(alloc-checks, AS_HELP_STRING([--enable-alloc-checks],[ enable to memory allocation statistics, for debug purposes ]),
626	, )
627AC_ARG_ENABLE(alloc-lite, AS_HELP_STRING([--enable-alloc-lite],[ enable for lightweight alloc assertions, for debug purposes ]),
628	, )
629AC_ARG_ENABLE(alloc-nonregional, AS_HELP_STRING([--enable-alloc-nonregional],[ enable nonregional allocs, slow but exposes regional allocations to other memory purifiers, for debug purposes ]),
630	, )
631if test x_$enable_alloc_nonregional = x_yes; then
632	AC_DEFINE(UNBOUND_ALLOC_NONREGIONAL, 1, [use malloc not regions, for debug use])
633fi
634if test x_$enable_alloc_checks = x_yes; then
635	AC_DEFINE(UNBOUND_ALLOC_STATS, 1, [use statistics for allocs and frees, for debug use])
636	SLDNS_ALLOCCHECK_EXTRA_OBJ="alloc.lo log.lo"
637	AC_SUBST(SLDNS_ALLOCCHECK_EXTRA_OBJ)
638	ASYNCLOOK_ALLOCCHECK_EXTRA_OBJ="alloc.lo"
639	AC_SUBST(ASYNCLOOK_ALLOCCHECK_EXTRA_OBJ)
640else
641	if test x_$enable_alloc_lite = x_yes; then
642		AC_DEFINE(UNBOUND_ALLOC_LITE, 1, [use to enable lightweight alloc assertions, for debug use])
643	else
644		ACX_FUNC_MALLOC([unbound])
645	fi
646fi
647
648# check windows threads (we use them, not pthreads, on windows).
649if test "$on_mingw" = "yes"; then
650# check windows threads
651	AC_CHECK_HEADERS([windows.h],,, [AC_INCLUDES_DEFAULT])
652	AC_MSG_CHECKING([for CreateThread])
653	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
654#ifdef HAVE_WINDOWS_H
655#include <windows.h>
656#endif
657], [
658	HANDLE t = CreateThread(NULL, 0, NULL, NULL, 0, NULL);
659])],
660	AC_MSG_RESULT(yes)
661	AC_DEFINE(HAVE_WINDOWS_THREADS, 1, [Using Windows threads])
662,
663	AC_MSG_RESULT(no)
664)
665
666else
667# not on mingw, check thread libraries.
668
669# check for thread library.
670# check this first, so that the pthread lib does not get linked in via
671# libssl or libpython, and thus distorts the tests, and we end up using
672# the non-threadsafe C libraries.
673AC_ARG_WITH(pthreads, AS_HELP_STRING([--with-pthreads],[use pthreads library, or --without-pthreads to disable threading support.]),
674 [ ],[ withval="yes" ])
675ub_have_pthreads=no
676if test x_$withval != x_no; then
677	AX_PTHREAD([
678		AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
679		if test -n "$PTHREAD_LIBS"; then
680		  LIBS="$PTHREAD_LIBS $LIBS"
681		fi
682		CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
683		CC="$PTHREAD_CC"
684		ub_have_pthreads=yes
685		AC_CHECK_TYPES([pthread_spinlock_t, pthread_rwlock_t],,,[#include <pthread.h>])
686		AC_CHECK_SIZEOF([unsigned long])
687		AC_CHECK_SIZEOF(pthread_t)
688
689		if echo "$CFLAGS" | $GREP -e "-pthread" >/dev/null; then
690		AC_MSG_CHECKING([if -pthread unused during linking])
691		# catch clang warning 'argument unused during compilation'
692		AC_LANG_CONFTEST([AC_LANG_SOURCE(AC_INCLUDES_DEFAULT
693[[
694int main(void) {return 0;}
695]])])
696		pthread_unused="yes"
697		# first compile
698		echo "$CC $CFLAGS -c conftest.c -o conftest.o" >&AS_MESSAGE_LOG_FD
699		$CC $CFLAGS -c conftest.c -o conftest.o 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD
700		if test $? = 0; then
701			# then link
702			echo "$CC $CFLAGS -Werror $LDFLAGS $LIBS -o conftest contest.o" >&AS_MESSAGE_LOG_FD
703			$CC $CFLAGS -Werror $LDFLAGS $LIBS -o conftest conftest.o 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD
704			if test $? -ne 0; then
705				AC_MSG_RESULT(yes)
706				CFLAGS=`echo "$CFLAGS" | sed -e 's/-pthread//'`
707				PTHREAD_CFLAGS_ONLY="-pthread"
708				AC_SUBST(PTHREAD_CFLAGS_ONLY)
709			else
710				AC_MSG_RESULT(no)
711			fi
712		else
713			AC_MSG_RESULT(no)
714		fi # endif cc successful
715		rm -f conftest conftest.c conftest.o
716		fi # endif -pthread in CFLAGS
717
718		])
719fi
720
721# check solaris thread library
722AC_ARG_WITH(solaris-threads, AS_HELP_STRING([--with-solaris-threads],[use solaris native thread library.]), [ ],[ withval="no" ])
723ub_have_sol_threads=no
724if test x_$withval != x_no; then
725	if test x_$ub_have_pthreads != x_no; then
726	    AC_MSG_WARN([Have pthreads already, ignoring --with-solaris-threads])
727	else
728	AC_SEARCH_LIBS(thr_create, [thread],
729	[
730    		AC_DEFINE(HAVE_SOLARIS_THREADS, 1, [Using Solaris threads])
731
732		ACX_CHECK_COMPILER_FLAG(mt, [CFLAGS="$CFLAGS -mt"],
733			[CFLAGS="$CFLAGS -D_REENTRANT"])
734		ub_have_sol_threads=yes
735	] , [
736		AC_MSG_ERROR([no solaris threads found.])
737	])
738	fi
739fi
740
741fi # end of non-mingw check of thread libraries
742
743# Check for SYSLOG_FACILITY
744AC_ARG_WITH(syslog-facility, AS_HELP_STRING([--with-syslog-facility=LOCAL0 - LOCAL7],[ set SYSLOG_FACILITY, default DAEMON ]),
745	[ UNBOUND_SYSLOG_FACILITY="$withval" ], [])
746case "${UNBOUND_SYSLOG_FACILITY}" in
747
748  LOCAL[[0-7]]) UNBOUND_SYSLOG_FACILITY="LOG_${UNBOUND_SYSLOG_FACILITY}" ;;
749
750           *) UNBOUND_SYSLOG_FACILITY="LOG_DAEMON" ;;
751
752esac
753AC_DEFINE_UNQUOTED(UB_SYSLOG_FACILITY,${UNBOUND_SYSLOG_FACILITY},[the SYSLOG_FACILITY to use, default LOG_DAEMON])
754
755# Check for dynamic library module
756AC_ARG_WITH(dynlibmodule,
757   AS_HELP_STRING([--with-dynlibmodule],[build dynamic library module, or --without-dynlibmodule to disable it. (default=no)]),
758   [], [ withval="no" ])
759
760if test x_$withval != x_no; then
761  AC_DEFINE(WITH_DYNLIBMODULE, 1, [Define if you want dynlib module.])
762  WITH_DYNLIBMODULE=yes
763  AC_SUBST(WITH_DYNLIBMODULE)
764  DYNLIBMOD_OBJ="dynlibmod.lo"
765  AC_SUBST(DYNLIBMOD_OBJ)
766  DYNLIBMOD_HEADER='$(srcdir)/dynlibmod/dynlibmod.h'
767  AC_SUBST(DYNLIBMOD_HEADER)
768  if test $on_mingw = "no"; then
769    # link with -ldl if not already there, for all executables because
770    # dlopen call is in the dynlib module.  For unbound executable, also
771    # export symbols.
772    AC_SEARCH_LIBS([dlopen], [dl])
773    DYNLIBMOD_EXTRALIBS="-export-dynamic"
774  else
775    DYNLIBMOD_EXTRALIBS="-Wl,--export-all-symbols,--out-implib,libunbound.dll.a"
776  fi
777  AC_SUBST(DYNLIBMOD_EXTRALIBS)
778fi
779
780# Check for PyUnbound
781AC_ARG_WITH(pyunbound,
782   AS_HELP_STRING([--with-pyunbound],[build PyUnbound, or --without-pyunbound to skip it. (default=no)]),
783   [], [ withval="no" ])
784
785ub_test_python=no
786ub_with_pyunbound=no
787if test x_$withval != x_no; then
788   ub_with_pyunbound=yes
789   ub_test_python=yes
790fi
791
792# Check for Python module
793AC_ARG_WITH(pythonmodule,
794   AS_HELP_STRING([--with-pythonmodule],[build Python module, or --without-pythonmodule to disable script engine. (default=no)]),
795   [], [ withval="no" ])
796
797ub_with_pythonmod=no
798if test x_$withval != x_no; then
799   ub_with_pythonmod=yes
800   ub_test_python=yes
801fi
802
803# Check for Python & SWIG only on PyUnbound or PyModule
804if test x_$ub_test_python != x_no; then
805
806   # Check for Python
807   ub_have_python=no
808   ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS
809   AC_PYTHON_DEVEL
810   if test ! -z "$PYTHON_VERSION"; then
811	badversion="no"
812	if test "$PYTHON_VERSION_MAJOR" -lt 2; then
813		badversion="yes"
814	fi
815	if test "$PYTHON_VERSION_MAJOR" -eq 2 -a "$PYTHON_VERSION_MINOR" -lt 4; then
816		badversion="yes"
817	fi
818	if test "$badversion" = "yes"; then
819		AC_MSG_ERROR([Python version >= 2.4.0 is required])
820	fi
821
822      [PY_MAJOR_VERSION="`$PYTHON -c \"import sys; print(sys.version_info[0])\"`"]
823      AC_SUBST(PY_MAJOR_VERSION)
824      # Have Python
825      AC_DEFINE(HAVE_PYTHON,1,[Define if you have Python libraries and header files.])
826      if test x_$ub_with_pythonmod != x_no; then
827        if test -n "$LIBS"; then
828          LIBS="$PYTHON_LDFLAGS $LIBS"
829        else
830          LIBS="$PYTHON_LDFLAGS"
831        fi
832      fi
833      PYTHON_LIBS="$PYTHON_LDFLAGS"
834      AC_SUBST(PYTHON_LIBS)
835      if test -n "$CPPFLAGS"; then
836        CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
837      else
838        CPPFLAGS="$PYTHON_CPPFLAGS"
839      fi
840      if test "$PYTHON_LIBDIR" != "/usr/lib" -a "$PYTHON_LIBDIR" != "" -a "$PYTHON_LIBDIR" != "/usr/lib64"; then
841        ACX_RUNTIME_PATH_ADD([$PYTHON_LIBDIR])
842      fi
843      ub_have_python=yes
844      PKG_CHECK_EXISTS(["python${PY_MAJOR_VERSION}"],
845                       [PC_PY_DEPENDENCY="python${PY_MAJOR_VERSION}"],
846                       [PC_PY_DEPENDENCY="python"])
847      AC_SUBST(PC_PY_DEPENDENCY)
848
849      # Check for SWIG
850      ub_have_swig=no
851      AC_ARG_ENABLE(swig-version-check, AS_HELP_STRING([--disable-swig-version-check],[Disable swig version check to build python modules with older swig even though that is unreliable]))
852      if test "$enable_swig_version_check" = "yes"; then
853      	AX_PKG_SWIG(2.0.1)
854      else
855      	AX_PKG_SWIG
856      fi
857      AC_MSG_CHECKING(SWIG)
858      if test ! -x "$SWIG"; then
859         AC_MSG_ERROR([failed to find swig tool, install it, or do not build Python module and PyUnbound])
860      else
861         AC_DEFINE(HAVE_SWIG, 1, [Define if you have Swig libraries and header files.])
862         AC_SUBST(swig, "$SWIG")
863         AC_MSG_RESULT(present)
864
865         # If have Python & SWIG
866         # Declare PythonMod
867         if test x_$ub_with_pythonmod != x_no; then
868            AC_DEFINE(WITH_PYTHONMODULE, 1, [Define if you want Python module.])
869            WITH_PYTHONMODULE=yes
870            AC_SUBST(WITH_PYTHONMODULE)
871	    PYTHONMOD_OBJ="pythonmod.lo pythonmod_utils.lo"
872	    AC_SUBST(PYTHONMOD_OBJ)
873	    PYTHONMOD_HEADER='$(srcdir)/pythonmod/pythonmod.h'
874	    AC_SUBST(PYTHONMOD_HEADER)
875	    PYTHONMOD_INSTALL=pythonmod-install
876	    AC_SUBST(PYTHONMOD_INSTALL)
877	    PYTHONMOD_UNINSTALL=pythonmod-uninstall
878	    AC_SUBST(PYTHONMOD_UNINSTALL)
879         fi
880
881         # Declare PyUnbound
882         if test x_$ub_with_pyunbound != x_no; then
883            AC_DEFINE(WITH_PYUNBOUND, 1, [Define if you want PyUnbound.])
884            WITH_PYUNBOUND=yes
885            AC_SUBST(WITH_PYUNBOUND)
886	    PYUNBOUND_OBJ="libunbound_wrap.lo"
887	    AC_SUBST(PYUNBOUND_OBJ)
888	    PYUNBOUND_TARGET="_unbound.la"
889	    AC_SUBST(PYUNBOUND_TARGET)
890	    PYUNBOUND_INSTALL=pyunbound-install
891	    AC_SUBST(PYUNBOUND_INSTALL)
892	    PYUNBOUND_UNINSTALL=pyunbound-uninstall
893	    AC_SUBST(PYUNBOUND_UNINSTALL)
894         fi
895      fi
896   else
897      AC_MSG_RESULT([*** Python libraries not found, won't build PythonMod or PyUnbound ***])
898      ub_with_pyunbound=no
899      ub_with_pythonmod=no
900   fi
901fi
902
903if test "`uname`" = "NetBSD"; then
904	NETBSD_LINTFLAGS='"-D__RENAME(x)=" -D_NETINET_IN_H_'
905	AC_SUBST(NETBSD_LINTFLAGS)
906fi
907
908if test "`uname`" = "Linux"; then
909	# splint cannot parse modern c99 header files
910	GCC_DOCKER_LINTFLAGS='-syntax'
911	AC_SUBST(GCC_DOCKER_LINTFLAGS)
912fi
913AX_BUILD_DATE_EPOCH(CONFIG_DATE, [%Y%m%d])
914AC_ARG_VAR(SOURCE_DATE_EPOCH, [If it is set, it uses the value of that variable instead of the current time as the build timestamp. The format is a unix timestamp. This enables reproducible build output.])
915AC_SUBST(CONFIG_DATE)
916
917# Checks for libraries.
918
919# libnss
920USE_NSS="no"
921AC_ARG_WITH([nss], AS_HELP_STRING([--with-nss=path],[use libnss instead of openssl, installed at path.]),
922	[
923	USE_NSS="yes"
924	AC_DEFINE(HAVE_NSS, 1, [Use libnss for crypto])
925	if test "$withval" != "" -a "$withval" != "yes"; then
926		CPPFLAGS="$CPPFLAGS -I$withval/include/nss3"
927		LDFLAGS="$LDFLAGS -L$withval/lib"
928		ACX_RUNTIME_PATH_ADD([$withval/lib])
929		CPPFLAGS="-I$withval/include/nspr4 $CPPFLAGS"
930	else
931		CPPFLAGS="$CPPFLAGS -I/usr/include/nss3"
932		CPPFLAGS="-I/usr/include/nspr4 $CPPFLAGS"
933	fi
934        LIBS="$LIBS -lnss3 -lnspr4"
935	SSLLIB=""
936	PC_CRYPTO_DEPENDENCY="nss nspr"
937	AC_SUBST(PC_CRYPTO_DEPENDENCY)
938	]
939)
940
941# libnettle
942USE_NETTLE="no"
943AC_ARG_WITH([nettle], AS_HELP_STRING([--with-nettle=path],[use libnettle as crypto library, installed at path.]),
944	[
945	USE_NETTLE="yes"
946	AC_DEFINE(HAVE_NETTLE, 1, [Use libnettle for crypto])
947	AC_CHECK_HEADERS([nettle/dsa-compat.h],,, [AC_INCLUDES_DEFAULT])
948	if test "$withval" != "" -a "$withval" != "yes"; then
949		CPPFLAGS="$CPPFLAGS -I$withval/include/nettle"
950		LDFLAGS="$LDFLAGS -L$withval/lib"
951		ACX_RUNTIME_PATH_ADD([$withval/lib])
952	else
953		CPPFLAGS="$CPPFLAGS -I/usr/include/nettle"
954	fi
955        LIBS="$LIBS -lhogweed -lnettle -lgmp"
956	SSLLIB=""
957	PC_CRYPTO_DEPENDENCY="hogweed nettle"
958	AC_SUBST(PC_CRYPTO_DEPENDENCY)
959	]
960)
961
962# openssl
963if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then
964ACX_WITH_SSL
965ACX_LIB_SSL
966SSLLIB="-lssl"
967
968PC_CRYPTO_DEPENDENCY=""
969AC_SUBST(PC_CRYPTO_DEPENDENCY)
970
971# check if -lcrypt32 is needed because CAPIENG needs that. (on windows)
972BAKLIBS="$LIBS"
973LIBS="-lssl $LIBS"
974AC_MSG_CHECKING([if libssl needs -lcrypt32])
975AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
976	int EVP_sha256(void);
977	(void)EVP_sha256();
978]])], [
979	AC_MSG_RESULT([no])
980	LIBS="$BAKLIBS"
981], [
982	AC_MSG_RESULT([yes])
983	LIBS="$BAKLIBS"
984	LIBS="$LIBS -lcrypt32"
985])
986
987AC_MSG_CHECKING([for LibreSSL])
988if grep VERSION_TEXT $ssldir_include/openssl/opensslv.h | grep "LibreSSL" >/dev/null; then
989	AC_MSG_RESULT([yes])
990	AC_DEFINE([HAVE_LIBRESSL], [1], [Define if we have LibreSSL])
991	# libressl provides these compat functions, but they may also be
992	# declared by the OS in libc.  See if they have been declared.
993	AC_CHECK_DECLS([strlcpy,strlcat,arc4random,arc4random_uniform])
994else
995	AC_MSG_RESULT([no])
996fi
997AC_CHECK_HEADERS([openssl/conf.h openssl/engine.h openssl/bn.h openssl/dh.h openssl/dsa.h openssl/rsa.h openssl/core_names.h openssl/param_build.h],,, [AC_INCLUDES_DEFAULT])
998AC_CHECK_FUNCS([OPENSSL_config EVP_sha1 EVP_sha256 EVP_sha512 FIPS_mode EVP_default_properties_is_fips_enabled EVP_MD_CTX_new OpenSSL_add_all_digests OPENSSL_init_crypto EVP_cleanup ENGINE_cleanup ERR_load_crypto_strings CRYPTO_cleanup_all_ex_data ERR_free_strings RAND_cleanup DSA_SIG_set0 EVP_dss1 EVP_DigestVerify EVP_aes_256_cbc EVP_EncryptInit_ex HMAC_Init_ex CRYPTO_THREADID_set_callback EVP_MAC_CTX_set_params OSSL_PARAM_BLD_new BIO_set_callback_ex SSL_CTX_set_tmp_ecdh])
999
1000# these check_funcs need -lssl
1001BAKLIBS="$LIBS"
1002LIBS="-lssl $LIBS"
1003AC_CHECK_FUNCS([OPENSSL_init_ssl SSL_CTX_set_security_level SSL_set1_host SSL_get0_peername X509_VERIFY_PARAM_set1_host SSL_CTX_set_ciphersuites SSL_CTX_set_tlsext_ticket_key_evp_cb SSL_CTX_set_alpn_select_cb SSL_get0_alpn_selected SSL_CTX_set_alpn_protos SSL_get1_peer_certificate])
1004LIBS="$BAKLIBS"
1005
1006AC_CHECK_DECLS([SSL_COMP_get_compression_methods,sk_SSL_COMP_pop_free,SSL_CTX_set_ecdh_auto], [], [], [
1007AC_INCLUDES_DEFAULT
1008#ifdef HAVE_OPENSSL_ERR_H
1009#include <openssl/err.h>
1010#endif
1011
1012#ifdef HAVE_OPENSSL_RAND_H
1013#include <openssl/rand.h>
1014#endif
1015
1016#ifdef HAVE_OPENSSL_CONF_H
1017#include <openssl/conf.h>
1018#endif
1019
1020#ifdef HAVE_OPENSSL_ENGINE_H
1021#include <openssl/engine.h>
1022#endif
1023#include <openssl/ssl.h>
1024#include <openssl/evp.h>
1025])
1026
1027if test "$ac_cv_func_HMAC_Init_ex" = "yes"; then
1028# check function return type.
1029AC_MSG_CHECKING(the return type of HMAC_Init_ex)
1030AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1031#ifdef HAVE_OPENSSL_ERR_H
1032#include <openssl/err.h>
1033#endif
1034
1035#ifdef HAVE_OPENSSL_RAND_H
1036#include <openssl/rand.h>
1037#endif
1038
1039#ifdef HAVE_OPENSSL_CONF_H
1040#include <openssl/conf.h>
1041#endif
1042
1043#ifdef HAVE_OPENSSL_ENGINE_H
1044#include <openssl/engine.h>
1045#endif
1046#include <openssl/ssl.h>
1047#include <openssl/evp.h>
1048], [
1049	HMAC_CTX* hmac_ctx = NULL;
1050	void* hmac_key = NULL;
1051	const EVP_MD* digest = NULL;
1052	int x = HMAC_Init_ex(hmac_ctx, hmac_key, 32, digest, NULL);
1053	(void)x;
1054])], [
1055	AC_MSG_RESULT(int)
1056], [
1057	AC_MSG_RESULT(void)
1058	AC_DEFINE([HMAC_INIT_EX_RETURNS_VOID], 1, [If HMAC_Init_ex() returns void])
1059])
1060fi
1061
1062fi
1063AC_SUBST(SSLLIB)
1064
1065# libbsd
1066AC_ARG_WITH([libbsd], AS_HELP_STRING([--with-libbsd],[Use portable libbsd functions]), [
1067	AC_CHECK_HEADERS([bsd/string.h bsd/stdlib.h],,, [AC_INCLUDES_DEFAULT])
1068	if test "x$ac_cv_header_bsd_string_h" = xyes -a "x$ac_cv_header_bsd_stdlib_h" = xyes; then
1069		for func in strlcpy strlcat arc4random arc4random_uniform reallocarray; do
1070			AC_SEARCH_LIBS([$func], [bsd], [
1071				AC_DEFINE(HAVE_LIBBSD, 1, [Use portable libbsd functions])
1072				PC_LIBBSD_DEPENDENCY=libbsd
1073				AC_SUBST(PC_LIBBSD_DEPENDENCY)
1074			])
1075		done
1076	fi
1077])
1078
1079AC_ARG_ENABLE(sha1, AS_HELP_STRING([--disable-sha1],[Disable SHA1 RRSIG support, does not disable nsec3 support]))
1080case "$enable_sha1" in
1081	no)
1082	;;
1083	yes|*)
1084	AC_DEFINE([USE_SHA1], [1], [Define this to enable SHA1 support.])
1085	;;
1086esac
1087
1088
1089AC_ARG_ENABLE(sha2, AS_HELP_STRING([--disable-sha2],[Disable SHA256 and SHA512 RRSIG support]))
1090case "$enable_sha2" in
1091	no)
1092	;;
1093	yes|*)
1094	AC_DEFINE([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.])
1095	;;
1096esac
1097
1098AC_ARG_ENABLE(subnet, AS_HELP_STRING([--enable-subnet],[Enable client subnet]))
1099case "$enable_subnet" in
1100	yes)
1101	AC_DEFINE([CLIENT_SUBNET], [1], [Define this to enable client subnet option.])
1102	SUBNET_OBJ="edns-subnet.lo subnetmod.lo addrtree.lo subnet-whitelist.lo"
1103	AC_SUBST(SUBNET_OBJ)
1104	SUBNET_HEADER='$(srcdir)/edns-subnet/subnetmod.h $(srcdir)/edns-subnet/edns-subnet.h $(srcdir)/edns-subnet/subnet-whitelist.h $(srcdir)/edns-subnet/addrtree.h'
1105	AC_SUBST(SUBNET_HEADER)
1106	;;
1107	no|*)
1108	;;
1109esac
1110
1111# check whether gost also works
1112AC_DEFUN([AC_CHECK_GOST_WORKS],
1113[AC_REQUIRE([AC_PROG_CC])
1114AC_MSG_CHECKING([if GOST works])
1115if test c${cross_compiling} = cno; then
1116BAKCFLAGS="$CFLAGS"
1117if test -n "$ssldir"; then
1118	CFLAGS="$CFLAGS -Wl,-rpath,$ssldir_lib"
1119fi
1120AC_RUN_IFELSE([AC_LANG_SOURCE([[
1121#include <string.h>
1122#include <openssl/ssl.h>
1123#include <openssl/evp.h>
1124#include <openssl/engine.h>
1125#include <openssl/conf.h>
1126/* routine to load gost (from sldns) */
1127int load_gost_id(void)
1128{
1129	static int gost_id = 0;
1130	const EVP_PKEY_ASN1_METHOD* meth;
1131	ENGINE* e;
1132
1133	if(gost_id) return gost_id;
1134
1135	/* see if configuration loaded gost implementation from other engine*/
1136	meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1);
1137	if(meth) {
1138		EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
1139		return gost_id;
1140	}
1141
1142	/* see if engine can be loaded already */
1143	e = ENGINE_by_id("gost");
1144	if(!e) {
1145		/* load it ourself, in case statically linked */
1146		ENGINE_load_builtin_engines();
1147		ENGINE_load_dynamic();
1148		e = ENGINE_by_id("gost");
1149	}
1150	if(!e) {
1151		/* no gost engine in openssl */
1152		return 0;
1153	}
1154	if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
1155		ENGINE_finish(e);
1156		ENGINE_free(e);
1157		return 0;
1158	}
1159
1160	meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1);
1161	if(!meth) {
1162		/* algo not found */
1163		ENGINE_finish(e);
1164		ENGINE_free(e);
1165		return 0;
1166	}
1167	EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
1168	return gost_id;
1169}
1170int main(void) {
1171	EVP_MD_CTX* ctx;
1172	const EVP_MD* md;
1173	unsigned char digest[64]; /* its a 256-bit digest, so uses 32 bytes */
1174	const char* str = "Hello world";
1175	const unsigned char check[] = {
1176		0x40 , 0xed , 0xf8 , 0x56 , 0x5a , 0xc5 , 0x36 , 0xe1 ,
1177		0x33 , 0x7c , 0x7e , 0x87 , 0x62 , 0x1c , 0x42 , 0xe0 ,
1178		0x17 , 0x1b , 0x5e , 0xce , 0xa8 , 0x46 , 0x65 , 0x4d ,
1179		0x8d , 0x3e , 0x22 , 0x9b , 0xe1 , 0x30 , 0x19 , 0x9d
1180	};
1181	OPENSSL_config(NULL);
1182	(void)load_gost_id();
1183	md = EVP_get_digestbyname("md_gost94");
1184	if(!md) return 1;
1185	memset(digest, 0, sizeof(digest));
1186	ctx = EVP_MD_CTX_create();
1187	if(!ctx) return 2;
1188	if(!EVP_DigestInit_ex(ctx, md, NULL)) return 3;
1189	if(!EVP_DigestUpdate(ctx, str, 10)) return 4;
1190	if(!EVP_DigestFinal_ex(ctx, digest, NULL)) return 5;
1191	/* uncomment to see the hash calculated.
1192		{int i;
1193		for(i=0; i<32; i++)
1194			printf(" %2.2x", (int)digest[i]);
1195		printf("\n");}
1196	*/
1197	if(memcmp(digest, check, sizeof(check)) != 0)
1198		return 6;
1199	return 0;
1200}
1201]])] , [eval "ac_cv_c_gost_works=yes"], [eval "ac_cv_c_gost_works=no"],
1202[eval "ac_cv_c_gost_works=maybe"])
1203CFLAGS="$BAKCFLAGS"
1204else
1205eval "ac_cv_c_gost_works=maybe"
1206fi
1207AC_MSG_RESULT($ac_cv_c_gost_works)
1208])dnl
1209
1210AC_ARG_ENABLE(gost, AS_HELP_STRING([--disable-gost],[Disable GOST support]))
1211use_gost="no"
1212if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then
1213case "$enable_gost" in
1214	no)
1215	;;
1216	*)
1217	AC_CHECK_FUNC(EVP_PKEY_set_type_str, [:],[AC_MSG_ERROR([OpenSSL 1.0.0 is needed for GOST support])])
1218	AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([OpenSSL does not support ECC, needed for GOST support])])
1219	AC_CHECK_GOST_WORKS
1220	if test "$ac_cv_c_gost_works" != no; then
1221		use_gost="yes"
1222		AC_DEFINE([USE_GOST], [1], [Define this to enable GOST support.])
1223	fi
1224	;;
1225esac
1226fi dnl !USE_NSS && !USE_NETTLE
1227
1228AC_ARG_ENABLE(ecdsa, AS_HELP_STRING([--disable-ecdsa],[Disable ECDSA support]))
1229use_ecdsa="no"
1230case "$enable_ecdsa" in
1231    no)
1232      ;;
1233    *)
1234      if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then
1235	      AC_CHECK_FUNC(EVP_PKEY_fromdata, [
1236	          # with EVP_PKEY_fromdata, check if EC is not disabled
1237	          AC_CHECK_DECL([OPENSSL_NO_EC], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade or rerun with --disable-ecdsa])
1238		  ], [], [AC_INCLUDES_DEFAULT
1239#include <openssl/evp.h>
1240		  ])
1241		], [
1242		  # without EVP_PKEY_fromdata, older openssl, check for support
1243		  AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade or rerun with --disable-ecdsa])])
1244		  AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade or rerun with --disable-ecdsa])])
1245		])
1246	      AC_CHECK_DECLS([NID_X9_62_prime256v1, NID_secp384r1], [], [AC_MSG_ERROR([OpenSSL does not support the ECDSA curves: please upgrade or rerun with --disable-ecdsa])], [AC_INCLUDES_DEFAULT
1247#include <openssl/evp.h>
1248	      ])
1249	      # see if OPENSSL 1.0.0 or later (has EVP MD and Verify independency)
1250	      AC_MSG_CHECKING([if openssl supports SHA2 and ECDSA with EVP])
1251	      if grep OPENSSL_VERSION_TEXT $ssldir_include/openssl/opensslv.h | grep "OpenSSL" >/dev/null; then
1252		if grep OPENSSL_VERSION_NUMBER $ssldir_include/openssl/opensslv.h | grep 0x0 >/dev/null; then
1253		  AC_MSG_RESULT([no])
1254		  AC_DEFINE_UNQUOTED([USE_ECDSA_EVP_WORKAROUND], [1], [Define this to enable an EVP workaround for older openssl])
1255		else
1256		  AC_MSG_RESULT([yes])
1257		fi
1258	      else
1259		# not OpenSSL, thus likely LibreSSL, which supports it
1260		AC_MSG_RESULT([yes])
1261	      fi
1262      fi
1263      # we now know we have ECDSA and the required curves.
1264      AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
1265      use_ecdsa="yes"
1266      ;;
1267esac
1268
1269AC_ARG_ENABLE(dsa, AS_HELP_STRING([--disable-dsa],[Disable DSA support]))
1270use_dsa="no"
1271case "$enable_dsa" in
1272    yes)
1273      # detect if DSA is supported, and turn it off if not.
1274      if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then
1275      AC_CHECK_FUNC(DSA_SIG_new, [
1276      AC_CHECK_TYPE(DSA_SIG*, [
1277      AC_DEFINE_UNQUOTED([USE_DSA], [1], [Define this to enable DSA support.])
1278      ], [if test "x$enable_dsa" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support DSA and you used --enable-dsa.])
1279               fi ], [
1280AC_INCLUDES_DEFAULT
1281#ifdef HAVE_OPENSSL_ERR_H
1282#include <openssl/err.h>
1283#endif
1284
1285#ifdef HAVE_OPENSSL_RAND_H
1286#include <openssl/rand.h>
1287#endif
1288
1289#ifdef HAVE_OPENSSL_CONF_H
1290#include <openssl/conf.h>
1291#endif
1292
1293#ifdef HAVE_OPENSSL_ENGINE_H
1294#include <openssl/engine.h>
1295#endif
1296      ])
1297      ], [if test "x$enable_dsa" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support DSA and you used --enable-dsa.])
1298               fi ])
1299      else
1300      AC_DEFINE_UNQUOTED([USE_DSA], [1], [Define this to enable DSA support.])
1301      fi
1302      ;;
1303    *)
1304      # disable dsa by default, RFC 8624 section 3.1, validators MUST NOT
1305      # support DSA for DNSSEC Validation.
1306      ;;
1307esac
1308
1309AC_ARG_WITH(deprecate-rsa-1024, AS_HELP_STRING([--with-deprecate-rsa-1024],[Deprecate RSA 1024 bit length, makes that an unsupported key, for use when OpenSSL FIPS refuses 1024 bit verification]))
1310if test "$with_deprecate_rsa_1024" = "yes"; then
1311	AC_DEFINE([DEPRECATE_RSA_1024], [1], [Deprecate RSA 1024 bit length, makes that an unsupported key])
1312fi
1313
1314AC_ARG_ENABLE(ed25519, AS_HELP_STRING([--disable-ed25519],[Disable ED25519 support]))
1315use_ed25519="no"
1316case "$enable_ed25519" in
1317    no)
1318      ;;
1319    *)
1320      if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then
1321	      AC_CHECK_DECLS([NID_ED25519], [
1322      		use_ed25519="yes"
1323	      ], [ if test "x$enable_ed25519" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support ED25519 and you used --enable-ed25519.])
1324	      	fi ], [AC_INCLUDES_DEFAULT
1325#include <openssl/evp.h>
1326	      ])
1327      fi
1328      if test $USE_NETTLE = "yes"; then
1329		AC_CHECK_HEADERS([nettle/eddsa.h], use_ed25519="yes",, [AC_INCLUDES_DEFAULT])
1330      fi
1331      if test $use_ed25519 = "yes"; then
1332      		AC_DEFINE_UNQUOTED([USE_ED25519], [1], [Define this to enable ED25519 support.])
1333      fi
1334      ;;
1335esac
1336
1337AC_ARG_ENABLE(ed448, AS_HELP_STRING([--disable-ed448],[Disable ED448 support]))
1338use_ed448="no"
1339case "$enable_ed448" in
1340    no)
1341      ;;
1342    *)
1343      if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then
1344	      AC_CHECK_DECLS([NID_ED448], [
1345      		use_ed448="yes"
1346	      ], [ if test "x$enable_ed448" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support ED448 and you used --enable-ed448.])
1347	      	fi ], [AC_INCLUDES_DEFAULT
1348#include <openssl/evp.h>
1349	      ])
1350      fi
1351      if test $use_ed448 = "yes"; then
1352      		AC_DEFINE_UNQUOTED([USE_ED448], [1], [Define this to enable ED448 support.])
1353      fi
1354      ;;
1355esac
1356
1357AC_ARG_ENABLE(event-api, AS_HELP_STRING([--enable-event-api],[Enable (experimental) pluggable event base libunbound API installed to unbound-event.h]))
1358case "$enable_event_api" in
1359    yes)
1360      AC_SUBST(UNBOUND_EVENT_INSTALL, [unbound-event-install])
1361      AC_SUBST(UNBOUND_EVENT_UNINSTALL, [unbound-event-uninstall])
1362      ;;
1363    *)
1364      ;;
1365esac
1366
1367AC_ARG_ENABLE(tfo-client, AS_HELP_STRING([--enable-tfo-client],[Enable TCP Fast Open for client mode]))
1368case "$enable_tfo_client" in
1369	yes)
1370		case "$host_os" in
1371			linux*) AC_CHECK_DECL([MSG_FASTOPEN], [AC_MSG_WARN([Check the platform specific TFO kernel parameters are correctly configured to support client mode TFO])],
1372				[AC_MSG_ERROR([TCP Fast Open is not available for client mode: please rerun without --enable-tfo-client])],
1373				[AC_INCLUDES_DEFAULT
1374#include <netinet/tcp.h>
1375])
1376				AC_DEFINE_UNQUOTED([USE_MSG_FASTOPEN], [1], [Define this to enable client TCP Fast Open.])
1377				;;
1378			darwin*) AC_CHECK_DECL([CONNECT_RESUME_ON_READ_WRITE], [AC_MSG_WARN([Check the platform specific TFO kernel parameters are correctly configured to support client mode TFO])],
1379				[AC_MSG_ERROR([TCP Fast Open is not available for client mode: please rerun without --enable-tfo-client])],
1380				[AC_INCLUDES_DEFAULT
1381#include <sys/socket.h>
1382])
1383				AC_DEFINE_UNQUOTED([USE_OSX_MSG_FASTOPEN], [1], [Define this to enable client TCP Fast Open.])
1384				;;
1385		esac
1386		;;
1387	no|*)
1388		;;
1389esac
1390
1391AC_ARG_ENABLE(tfo-server, AS_HELP_STRING([--enable-tfo-server],[Enable TCP Fast Open for server mode]))
1392case "$enable_tfo_server" in
1393	yes)
1394	      AC_CHECK_DECL([TCP_FASTOPEN], [AC_MSG_WARN([Check the platform specific TFO kernel parameters are correctly configured to support server mode TFO])], [AC_MSG_ERROR([TCP Fast Open is not available for server mode: please rerun without --enable-tfo-server])], [AC_INCLUDES_DEFAULT
1395#include <netinet/tcp.h>
1396	      ])
1397		AC_DEFINE_UNQUOTED([USE_TCP_FASTOPEN], [1], [Define this to enable server TCP Fast Open.])
1398		;;
1399	no|*)
1400		;;
1401esac
1402
1403# check for libevent
1404AC_ARG_WITH(libevent, AS_HELP_STRING([--with-libevent=pathname],[use libevent (will check /usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr  or you can specify an explicit path). Slower, but allows use of large outgoing port ranges.]),
1405    [ ],[ with_libevent="no" ])
1406if test "x_$with_libevent" != x_no; then
1407        AC_DEFINE([USE_LIBEVENT], [1], [Define if you enable libevent])
1408        AC_MSG_CHECKING(for libevent)
1409        if test "x_$with_libevent" = x_ -o "x_$with_libevent" = x_yes; then
1410            with_libevent="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr"
1411        fi
1412        for dir in $with_libevent; do
1413            thedir="$dir"
1414            if test -f "$dir/include/event.h" -o -f "$dir/include/event2/event.h"; then
1415                found_libevent="yes"
1416				dnl assume /usr is in default path.
1417				if test "$thedir" != "/usr"; then
1418				    CPPFLAGS="$CPPFLAGS -I$thedir/include"
1419				fi
1420				break;
1421		    fi
1422        done
1423        if test x_$found_libevent != x_yes; then
1424		if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then
1425			# libevent source directory
1426			AC_MSG_RESULT(found in $thedir)
1427			CPPFLAGS="$CPPFLAGS -I$thedir -I$thedir/include"
1428			BAK_LDFLAGS_SET="1"
1429			BAK_LDFLAGS="$LDFLAGS"
1430			# remove evdns from linking
1431			mkdir build >/dev/null 2>&1
1432			mkdir build/libevent >/dev/null 2>&1
1433			mkdir build/libevent/.libs >/dev/null 2>&1
1434			ev_files_o=`ls $thedir/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o`
1435			ev_files_lo=`ls $thedir/*.lo | grep -v evdns\.lo | grep -v bufferevent_openssl\.lo`
1436			ev_files_libso=`ls $thedir/.libs/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o`
1437			cp $ev_files_o build/libevent
1438			cp $ev_files_lo build/libevent
1439			cp $ev_files_libso build/libevent/.libs
1440			LATE_LDFLAGS="build/libevent/*.lo -lm"
1441			LDFLAGS="build/libevent/*.o $LDFLAGS -lm"
1442		else
1443            AC_MSG_ERROR([Cannot find the libevent library in $with_libevent
1444You can restart ./configure --with-libevent=no to use a builtin alternative.
1445Please note that this alternative is not as capable as libevent when using
1446large outgoing port ranges.  ])
1447		fi
1448        else
1449            AC_MSG_RESULT(found in $thedir)
1450	    dnl if event2 exists and no event lib in dir itself, use subdir
1451	    if test ! -f $thedir/lib/libevent.a -a ! -f $thedir/lib/libevent.so -a -d "$thedir/lib/event2"; then
1452		    LDFLAGS="$LDFLAGS -L$thedir/lib/event2"
1453		    ACX_RUNTIME_PATH_ADD([$thedir/lib/event2])
1454	    else
1455		    dnl assume /usr is in default path, do not add "".
1456		    if test "$thedir" != "/usr" -a "$thedir" != ""; then
1457			LDFLAGS="$LDFLAGS -L$thedir/lib"
1458			ACX_RUNTIME_PATH_ADD([$thedir/lib])
1459		    fi
1460	    fi
1461        fi
1462	# check for library used by libevent after 1.3c
1463	AC_SEARCH_LIBS([clock_gettime], [rt])
1464
1465	# is the event.h header libev or libevent?
1466	AC_CHECK_HEADERS([event.h],,, [AC_INCLUDES_DEFAULT])
1467	AC_CHECK_DECL(EV_VERSION_MAJOR, [
1468		AC_SEARCH_LIBS(event_set, [ev])
1469	],[
1470		AC_SEARCH_LIBS(event_set, [event])
1471	],[AC_INCLUDES_DEFAULT
1472#include <event.h>
1473	])
1474	AC_CHECK_FUNCS([event_base_free]) # only in libevent 1.2 and later
1475	AC_CHECK_FUNCS([event_base_once]) # only in libevent 1.4.1 and later
1476	AC_CHECK_FUNCS([event_base_new]) # only in libevent 1.4.1 and later
1477	AC_CHECK_FUNCS([event_base_get_method]) # only in libevent 1.4.3 and later
1478	AC_CHECK_FUNCS([ev_loop]) # only in libev. (tested on 3.51)
1479	AC_CHECK_FUNCS([ev_default_loop]) # only in libev. (tested on 4.00)
1480	AC_CHECK_FUNCS([event_assign]) # in libevent, for thread-safety
1481	AC_CHECK_DECLS([evsignal_assign], [], [], [AC_INCLUDES_DEFAULT
1482#ifdef HAVE_EVENT_H
1483#  include <event.h>
1484#else
1485#  include "event2/event.h"
1486#endif
1487	])
1488        PC_LIBEVENT_DEPENDENCY="libevent"
1489        AC_SUBST(PC_LIBEVENT_DEPENDENCY)
1490	if test -n "$BAK_LDFLAGS_SET"; then
1491		LDFLAGS="$BAK_LDFLAGS"
1492	fi
1493else
1494	AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events])
1495fi
1496
1497# check for libexpat
1498AC_ARG_WITH(libexpat, AS_HELP_STRING([--with-libexpat=path],[specify explicit path for libexpat.]),
1499    [ ],[ withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" ])
1500AC_MSG_CHECKING(for libexpat)
1501found_libexpat="no"
1502for dir in $withval ; do
1503            if test -f "$dir/include/expat.h"; then
1504		found_libexpat="yes"
1505		dnl assume /usr is in default path.
1506		if test "$dir" != "/usr"; then
1507                    CPPFLAGS="$CPPFLAGS -I$dir/include"
1508		    LDFLAGS="$LDFLAGS -L$dir/lib"
1509		fi
1510            	AC_MSG_RESULT(found in $dir)
1511                break;
1512            fi
1513done
1514if test x_$found_libexpat != x_yes; then
1515	AC_MSG_ERROR([Could not find libexpat, expat.h])
1516fi
1517AC_CHECK_HEADERS([expat.h],,, [AC_INCLUDES_DEFAULT])
1518AC_CHECK_DECLS([XML_StopParser], [], [], [AC_INCLUDES_DEFAULT
1519#include <expat.h>
1520])
1521
1522# hiredis (redis C client for cachedb)
1523AC_ARG_WITH(libhiredis, AS_HELP_STRING([--with-libhiredis=path],[specify explicit path for libhiredis.]),
1524    [ ],[ withval="no" ])
1525found_libhiredis="no"
1526if test x_$withval = x_yes -o x_$withval != x_no; then
1527   AC_MSG_CHECKING(for libhiredis)
1528   if test x_$withval = x_ -o x_$withval = x_yes; then
1529            withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr"
1530   fi
1531   for dir in $withval ; do
1532            if test -f "$dir/include/hiredis/hiredis.h"; then
1533		found_libhiredis="yes"
1534		dnl assume /usr is in default path.
1535		if test "$dir" != "/usr"; then
1536                    CPPFLAGS="$CPPFLAGS -I$dir/include"
1537		    LDFLAGS="$LDFLAGS -L$dir/lib"
1538		fi
1539		AC_MSG_RESULT(found in $dir)
1540		AC_DEFINE([USE_REDIS], [1], [Define this to use hiredis client.])
1541		LIBS="$LIBS -lhiredis"
1542                break;
1543            fi
1544    done
1545    if test x_$found_libhiredis != x_yes; then
1546	AC_MSG_ERROR([Could not find libhiredis, hiredis.h])
1547    fi
1548    AC_CHECK_HEADERS([hiredis/hiredis.h],,, [AC_INCLUDES_DEFAULT])
1549    AC_CHECK_DECLS([redisConnect], [], [], [AC_INCLUDES_DEFAULT
1550    #include <hiredis/hiredis.h>
1551    ])
1552fi
1553
1554# nghttp2
1555AC_ARG_WITH(libnghttp2, AS_HELP_STRING([--with-libnghttp2=path],[specify explicit path for libnghttp2.]),
1556    [ ],[ withval="no" ])
1557found_libnghttp2="no"
1558if test x_$withval = x_yes -o x_$withval != x_no; then
1559   AC_MSG_CHECKING(for libnghttp2)
1560   if test x_$withval = x_ -o x_$withval = x_yes; then
1561            withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr"
1562   fi
1563   for dir in $withval ; do
1564            if test -f "$dir/include/nghttp2/nghttp2.h"; then
1565		found_libnghttp2="yes"
1566		dnl assume /usr is in default path.
1567		if test "$dir" != "/usr"; then
1568                    CPPFLAGS="$CPPFLAGS -I$dir/include"
1569		    LDFLAGS="$LDFLAGS -L$dir/lib"
1570		fi
1571		AC_MSG_RESULT(found in $dir)
1572		AC_DEFINE([HAVE_NGHTTP2], [1], [Define this to use nghttp2 client.])
1573		LIBS="$LIBS -lnghttp2"
1574                break;
1575            fi
1576    done
1577    if test x_$found_libnghttp2 != x_yes; then
1578	AC_MSG_ERROR([Could not find libnghttp2, nghttp2.h])
1579    fi
1580    AC_CHECK_HEADERS([nghttp2/nghttp2.h],,, [AC_INCLUDES_DEFAULT])
1581    AC_CHECK_DECLS([nghttp2_session_server_new], [], [], [AC_INCLUDES_DEFAULT
1582    #include <nghttp2/nghttp2.h>
1583    ])
1584fi
1585
1586# ngtcp2
1587AC_ARG_WITH(libngtcp2, AS_HELP_STRING([--with-libngtcp2=path],[specify explicit path for libngtcp2, for QUIC.]),
1588    [ ],[ withval="no" ])
1589found_libngtcp2="no"
1590if test x_$withval = x_yes -o x_$withval != x_no; then
1591   AC_MSG_CHECKING(for libngtcp2)
1592   if test x_$withval = x_ -o x_$withval = x_yes; then
1593            withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr"
1594   fi
1595   for dir in $withval ; do
1596            if test -f "$dir/include/ngtcp2/ngtcp2.h"; then
1597		found_libngtcp2="yes"
1598		dnl assume /usr is in default path.
1599		if test "$dir" != "/usr"; then
1600                    CPPFLAGS="$CPPFLAGS -I$dir/include"
1601		    LDFLAGS="$LDFLAGS -L$dir/lib"
1602		fi
1603		AC_MSG_RESULT(found in $dir)
1604		AC_DEFINE([HAVE_NGTCP2], [1], [Define this to use ngtcp2.])
1605		LIBS="$LIBS -lngtcp2"
1606                break;
1607            fi
1608    done
1609    if test x_$found_libngtcp2 != x_yes; then
1610	AC_MSG_ERROR([Could not find libngtcp2, ngtcp2.h])
1611    fi
1612    AC_CHECK_HEADERS([ngtcp2/ngtcp2.h ngtcp2/ngtcp2_crypto_openssl.h ngtcp2/ngtcp2_crypto_quictls.h],,, [AC_INCLUDES_DEFAULT])
1613    AC_CHECK_DECLS([ngtcp2_conn_server_new], [], [], [AC_INCLUDES_DEFAULT
1614    #include <ngtcp2/ngtcp2.h>
1615    ])
1616    AC_CHECK_DECLS([ngtcp2_crypto_encrypt_cb], [], [], [AC_INCLUDES_DEFAULT
1617    #include <ngtcp2/ngtcp2_crypto.h>
1618    ])
1619    AC_CHECK_LIB([ngtcp2_crypto_openssl], [ngtcp2_crypto_encrypt_cb], [ LIBS="$LIBS -lngtcp2_crypto_openssl" ])
1620    AC_CHECK_LIB([ngtcp2_crypto_quictls], [ngtcp2_crypto_encrypt_cb], [ LIBS="$LIBS -lngtcp2_crypto_quictls" ])
1621    AC_CHECK_FUNCS([ngtcp2_crypto_encrypt_cb ngtcp2_ccerr_default ngtcp2_conn_in_closing_period ngtcp2_conn_in_draining_period ngtcp2_conn_get_max_local_streams_uni ngtcp2_crypto_quictls_from_ossl_encryption_level ngtcp2_crypto_quictls_configure_server_context ngtcp2_crypto_quictls_configure_client_context ngtcp2_conn_get_num_scid ngtcp2_conn_tls_early_data_rejected ngtcp2_conn_encode_0rtt_transport_params])
1622    AC_CHECK_FUNCS([SSL_is_quic], [], [AC_MSG_ERROR([No QUIC support detected in OpenSSL. Need OpenSSL version with QUIC support to enable DNS over QUIC with libngtcp2.])])
1623    AC_CHECK_TYPES([struct ngtcp2_version_cid, ngtcp2_encryption_level],,,[AC_INCLUDES_DEFAULT
1624    #include <ngtcp2/ngtcp2.h>
1625    ])
1626    AC_CHECK_MEMBERS([struct ngtcp2_pkt_hd.tokenlen, struct ngtcp2_settings.tokenlen, struct ngtcp2_settings.max_tx_udp_payload_size, struct ngtcp2_transport_params.original_dcid_present],,,[AC_INCLUDES_DEFAULT
1627    #include <ngtcp2/ngtcp2.h>
1628    ])
1629
1630    AC_MSG_CHECKING([whether ngtcp2_conn_shutdown_stream has 4 arguments])
1631    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1632#include <ngtcp2/ngtcp2.h>
1633    ],[
1634	(void)ngtcp2_conn_shutdown_stream(NULL, 0, 0, 0);
1635    ])],[
1636	AC_MSG_RESULT(yes)
1637	AC_DEFINE(HAVE_NGTCP2_CONN_SHUTDOWN_STREAM4, 1, [Define if ngtcp2_conn_shutdown_stream has 4 arguments.])
1638    ],[
1639	AC_MSG_RESULT(no)
1640    ])
1641
1642fi
1643
1644# set static linking for uninstalled libraries if requested
1645AC_SUBST(staticexe)
1646staticexe=""
1647AC_ARG_ENABLE(static-exe, AS_HELP_STRING([--enable-static-exe],[ enable to compile executables statically against (event) uninstalled libs, for debug purposes ]),
1648	, )
1649if test x_$enable_static_exe = x_yes; then
1650	staticexe="-static"
1651	if test "$on_mingw" = yes; then
1652		staticexe="-all-static"
1653		# for static compile, include gdi32 and zlib here.
1654		if echo "$LIBS" | grep 'lgdi32' >/dev/null; then
1655			:
1656		else
1657			LIBS="$LIBS -lgdi32"
1658		fi
1659		AC_CHECK_LIB([z], [compress], [ LIBS="$LIBS -lz" ])
1660		if echo "$LIBS" | grep -e "libssp.a" -e "lssp" >/dev/null; then
1661			:
1662		else
1663			LIBS="$LIBS -l:libssp.a"
1664		fi
1665	fi
1666fi
1667
1668# set full static linking if requested
1669AC_ARG_ENABLE(fully-static, AS_HELP_STRING([--enable-fully-static],[ enable to compile fully static ]),
1670	, )
1671if test x_$enable_fully_static = x_yes; then
1672	staticexe="-all-static"
1673	if test "$on_mingw" = yes; then
1674		# for static compile, include gdi32 and zlib here.
1675		if echo $LIBS | grep 'lgdi32' >/dev/null; then
1676			:
1677		else
1678			LIBS="$LIBS -lgdi32"
1679		fi
1680		AC_CHECK_LIB([z], [compress], [ LIBS="$LIBS -lz" ])
1681		if echo "$LIBS" | grep -e "libssp.a" -e "lssp" >/dev/null; then
1682			:
1683		else
1684			LIBS="$LIBS -l:libssp.a"
1685		fi
1686	fi
1687fi
1688
1689# set lock checking if requested
1690AC_ARG_ENABLE(lock_checks, AS_HELP_STRING([--enable-lock-checks],[ enable to check lock and unlock calls, for debug purposes ]),
1691	, )
1692if test x_$enable_lock_checks = x_yes; then
1693	AC_DEFINE(ENABLE_LOCK_CHECKS, 1, [Define if you want to use debug lock checking (slow).])
1694	CHECKLOCK_OBJ="checklocks.lo"
1695	AC_SUBST(CHECKLOCK_OBJ)
1696fi
1697
1698ACX_CHECK_GETADDRINFO_WITH_INCLUDES
1699if test "$USE_WINSOCK" = 1; then
1700	AC_DEFINE(UB_ON_WINDOWS, 1, [Use win32 resources and API])
1701	AC_CHECK_HEADERS([iphlpapi.h],,, [AC_INCLUDES_DEFAULT
1702#include <windows.h>
1703	])
1704	AC_CHECK_TOOL(WINDRES, windres)
1705	if echo "$LIBS" | grep crypt32 >/dev/null; then
1706		LIBS="$LIBS -liphlpapi"
1707	else
1708		LIBS="$LIBS -liphlpapi -lcrypt32"
1709	fi
1710	WINAPPS="unbound-service-install.exe unbound-service-remove.exe anchor-update.exe"
1711	AC_SUBST(WINAPPS)
1712	WIN_DAEMON_SRC="winrc/win_svc.c winrc/w_inst.c"
1713	AC_SUBST(WIN_DAEMON_SRC)
1714	WIN_DAEMON_OBJ="win_svc.lo w_inst.lo"
1715	AC_SUBST(WIN_DAEMON_OBJ)
1716	WIN_DAEMON_OBJ_LINK="rsrc_unbound.o"
1717	AC_SUBST(WIN_DAEMON_OBJ_LINK)
1718	WIN_HOST_OBJ_LINK="rsrc_unbound_host.o"
1719	AC_SUBST(WIN_HOST_OBJ_LINK)
1720	WIN_UBANCHOR_OBJ_LINK="rsrc_unbound_anchor.o log.lo locks.lo"
1721	AC_SUBST(WIN_UBANCHOR_OBJ_LINK)
1722	WIN_CONTROL_OBJ_LINK="rsrc_unbound_control.o"
1723	AC_SUBST(WIN_CONTROL_OBJ_LINK)
1724	WIN_CHECKCONF_OBJ_LINK="rsrc_unbound_checkconf.o"
1725	AC_SUBST(WIN_CHECKCONF_OBJ_LINK)
1726	AC_DEFINE(__USE_MINGW_ANSI_STDIO, 1, [defined to use gcc ansi snprintf and sscanf that understands %lld when compiled for windows.])
1727fi
1728if test $ac_cv_func_getaddrinfo = no; then
1729	AC_LIBOBJ([fake-rfc2553])
1730fi
1731# check after getaddrinfo for its libraries
1732ACX_FUNC_IOCTLSOCKET
1733
1734# see if daemon(3) exists, and if it is deprecated.
1735AC_CHECK_FUNCS([daemon])
1736if test $ac_cv_func_daemon = yes; then
1737	ACX_FUNC_DEPRECATED([daemon], [(void)daemon(0, 0);], [
1738#include <stdlib.h>
1739#include <unistd.h>
1740])
1741fi
1742
1743AC_CHECK_MEMBERS([struct sockaddr_un.sun_len],,,[
1744AC_INCLUDES_DEFAULT
1745#ifdef HAVE_SYS_UN_H
1746#include <sys/un.h>
1747#endif
1748])
1749AC_CHECK_MEMBERS([struct in_pktinfo.ipi_spec_dst],,,[
1750AC_INCLUDES_DEFAULT
1751#if HAVE_SYS_PARAM_H
1752#include <sys/param.h>
1753#endif
1754
1755#ifdef HAVE_SYS_SOCKET_H
1756#include <sys/socket.h>
1757#endif
1758
1759#ifdef HAVE_SYS_UIO_H
1760#include <sys/uio.h>
1761#endif
1762
1763#ifdef HAVE_NETINET_IN_H
1764#include <netinet/in.h>
1765#endif
1766
1767#ifdef HAVE_NETINET_TCP_H
1768#include <netinet/tcp.h>
1769#endif
1770
1771#ifdef HAVE_ARPA_INET_H
1772#include <arpa/inet.h>
1773#endif
1774
1775#ifdef HAVE_WINSOCK2_H
1776#include <winsock2.h>
1777#endif
1778
1779#ifdef HAVE_WS2TCPIP_H
1780#include <ws2tcpip.h>
1781#endif
1782])
1783
1784AC_MSG_CHECKING([for htobe64])
1785AC_LINK_IFELSE([AC_LANG_PROGRAM([
1786#include <stdio.h>
1787#ifdef HAVE_ENDIAN_H
1788#  include <endian.h>
1789#endif
1790#ifdef HAVE_SYS_ENDIAN_H
1791#  include <sys/endian.h>
1792#endif
1793], [unsigned long long x = htobe64(0); printf("%u", (unsigned)x);])],
1794  AC_MSG_RESULT(yes)
1795  AC_DEFINE(HAVE_HTOBE64, 1, [If we have htobe64]),
1796  AC_MSG_RESULT(no))
1797
1798AC_MSG_CHECKING([for be64toh])
1799AC_LINK_IFELSE([AC_LANG_PROGRAM([
1800#include <stdio.h>
1801#ifdef HAVE_ENDIAN_H
1802#  include <endian.h>
1803#endif
1804#ifdef HAVE_SYS_ENDIAN_H
1805#  include <sys/endian.h>
1806#endif
1807], [unsigned long long x = be64toh(0); printf("%u", (unsigned)x);])],
1808  AC_MSG_RESULT(yes)
1809  AC_DEFINE(HAVE_BE64TOH, 1, [If we have be64toh]),
1810  AC_MSG_RESULT(no))
1811
1812AC_SEARCH_LIBS([setusercontext], [util])
1813AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam endpwent getrlimit setrlimit setsid chroot kill chown sleep usleep random srandom recvmsg sendmsg writev socketpair glob initgroups strftime localtime_r setusercontext _beginthreadex endservent endprotoent fsync shmget accept4 getifaddrs if_nametoindex poll gettid])
1814AC_CHECK_FUNCS([setresuid],,[AC_CHECK_FUNCS([setreuid])])
1815AC_CHECK_FUNCS([setresgid],,[AC_CHECK_FUNCS([setregid])])
1816
1817# check if setreuid en setregid fail, on MacOSX10.4(darwin8).
1818if echo $host_os | grep darwin8 > /dev/null; then
1819	AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work])
1820fi
1821
1822AC_MSG_CHECKING([for atomic_store])
1823AC_LINK_IFELSE([AC_LANG_PROGRAM(AC_INCLUDES_DEFAULT [[
1824#ifdef HAVE_STDATOMIC_H
1825#include <stdatomic.h>
1826#endif
1827]], [[
1828	int newvar = 5, var = 0;
1829	atomic_store((_Atomic int*)&var, newvar);
1830	newvar = 0;
1831	/* condition to use the variables. */
1832	if(var == newvar) return 1;
1833]])], [
1834	AC_MSG_RESULT(yes)
1835	AC_DEFINE(HAVE_LINK_ATOMIC_STORE, 1, [If we have atomic_store])
1836], [
1837	AC_MSG_RESULT([no])
1838])
1839
1840AC_CHECK_DECLS([inet_pton,inet_ntop], [], [], [
1841AC_INCLUDES_DEFAULT
1842#ifdef HAVE_NETINET_IN_H
1843#include <netinet/in.h>
1844#endif
1845
1846#ifdef HAVE_NETINET_TCP_H
1847#include <netinet/tcp.h>
1848#endif
1849
1850#ifdef HAVE_ARPA_INET_H
1851#include <arpa/inet.h>
1852#endif
1853
1854#ifdef HAVE_WINSOCK2_H
1855#include <winsock2.h>
1856#endif
1857
1858#ifdef HAVE_WS2TCPIP_H
1859#include <ws2tcpip.h>
1860#endif
1861])
1862AC_REPLACE_FUNCS(inet_aton)
1863AC_REPLACE_FUNCS(inet_pton)
1864AC_REPLACE_FUNCS(inet_ntop)
1865AC_REPLACE_FUNCS(snprintf)
1866# test if snprintf return the proper length
1867if test "x$ac_cv_func_snprintf" = xyes; then
1868    if test c${cross_compiling} = cno; then
1869	AC_MSG_CHECKING([for correct snprintf return value])
1870	AC_RUN_IFELSE([AC_LANG_SOURCE(AC_INCLUDES_DEFAULT
1871[[
1872int main(void) { return !(snprintf(NULL, 0, "test") == 4); }
1873]])], [AC_MSG_RESULT(yes)], [
1874		AC_MSG_RESULT(no)
1875		AC_DEFINE([SNPRINTF_RET_BROKEN], [], [define if (v)snprintf does not return length needed, (but length used)])
1876		AC_LIBOBJ(snprintf)
1877	  ], [AC_MSG_RESULT(maybe)])
1878    fi
1879fi
1880AC_REPLACE_FUNCS(strlcat)
1881AC_REPLACE_FUNCS(strlcpy)
1882AC_REPLACE_FUNCS(memmove)
1883AC_REPLACE_FUNCS(gmtime_r)
1884AC_REPLACE_FUNCS(isblank)
1885AC_REPLACE_FUNCS(explicit_bzero)
1886dnl without CTIME, ARC4-functions and without reallocarray.
1887LIBOBJ_WITHOUT_CTIMEARC4="$LIBOBJS"
1888AC_SUBST(LIBOBJ_WITHOUT_CTIMEARC4)
1889AC_MSG_CHECKING([for reallocarray])
1890AC_LINK_IFELSE([AC_LANG_SOURCE(AC_INCLUDES_DEFAULT
1891[[
1892#ifndef _OPENBSD_SOURCE
1893#define _OPENBSD_SOURCE 1
1894#endif
1895#include <stdlib.h>
1896int main(void) {
1897	void* p = reallocarray(NULL, 10, 100);
1898	free(p);
1899	return 0;
1900}
1901]])], [AC_MSG_RESULT(yes)
1902	AC_DEFINE(HAVE_REALLOCARRAY, 1, [If we have reallocarray(3)])
1903], [
1904	AC_MSG_RESULT(no)
1905	AC_LIBOBJ(reallocarray)
1906])
1907AC_CHECK_DECLS([reallocarray])
1908if test "$USE_NSS" = "no"; then
1909	AC_REPLACE_FUNCS(arc4random)
1910	AC_REPLACE_FUNCS(arc4random_uniform)
1911	if test "$ac_cv_func_arc4random" = "no"; then
1912		AC_LIBOBJ(arc4_lock)
1913		AC_CHECK_FUNCS([getentropy],,[
1914		    if test "$USE_WINSOCK" = 1; then
1915			AC_LIBOBJ(getentropy_win)
1916		    else
1917			case "$host" in
1918			Darwin|*darwin*)
1919				AC_LIBOBJ(getentropy_osx)
1920			;;
1921			*solaris*|*sunos*|SunOS)
1922				AC_LIBOBJ(getentropy_solaris)
1923				AC_CHECK_HEADERS([sys/sha2.h],, [
1924					AC_CHECK_FUNCS([SHA512_Update],,[
1925						AC_LIBOBJ(sha512)
1926					])
1927				], [AC_INCLUDES_DEFAULT])
1928				if test "$ac_cv_header_sys_sha2_h" = "yes"; then
1929					# this lib needed for sha2 on solaris
1930					LIBS="$LIBS -lmd"
1931				fi
1932				AC_SEARCH_LIBS([clock_gettime], [rt])
1933			;;
1934			*freebsd*|*FreeBSD)
1935				AC_LIBOBJ(getentropy_freebsd)
1936			;;
1937			*linux*|Linux|*)
1938				AC_LIBOBJ(getentropy_linux)
1939				AC_CHECK_FUNCS([SHA512_Update],,[
1940					AC_DEFINE([COMPAT_SHA512], [1], [Do sha512 definitions in config.h])
1941					AC_LIBOBJ(sha512)
1942				])
1943				AC_CHECK_HEADERS([sys/sysctl.h],,, [AC_INCLUDES_DEFAULT])
1944				AC_CHECK_FUNCS([getauxval])
1945				AC_SEARCH_LIBS([clock_gettime], [rt])
1946			;;
1947			esac
1948		    fi
1949		])
1950	fi
1951fi
1952LIBOBJ_WITHOUT_CTIME="$LIBOBJS"
1953AC_SUBST(LIBOBJ_WITHOUT_CTIME)
1954AC_REPLACE_FUNCS(ctime_r)
1955AC_REPLACE_FUNCS(strsep)
1956
1957AC_ARG_ENABLE(allsymbols, AS_HELP_STRING([--enable-allsymbols],[export all symbols from libunbound and link binaries to it, smaller install size but libunbound export table is polluted by internal symbols]))
1958case "$enable_allsymbols" in
1959	yes)
1960	COMMON_OBJ_ALL_SYMBOLS=""
1961	UBSYMS=""
1962	EXTRALINK="libunbound.la"
1963	AC_DEFINE(EXPORT_ALL_SYMBOLS, 1, [Define this if you enabled-allsymbols from libunbound to link binaries to it for smaller install size, but the libunbound export table is polluted by internal symbols])
1964	;;
1965	no|*)
1966	COMMON_OBJ_ALL_SYMBOLS='$(COMMON_OBJ)'
1967	UBSYMS='-export-symbols $(srcdir)/libunbound/ubsyms.def'
1968	EXTRALINK=""
1969	;;
1970esac
1971AC_SUBST(COMMON_OBJ_ALL_SYMBOLS)
1972AC_SUBST(EXTRALINK)
1973AC_SUBST(UBSYMS)
1974if test x_$enable_lock_checks = x_yes; then
1975	UBSYMS="-export-symbols clubsyms.def"
1976	cp ${srcdir}/libunbound/ubsyms.def clubsyms.def
1977	echo lock_protect >> clubsyms.def
1978	echo lock_protect_place >> clubsyms.def
1979	echo lock_unprotect >> clubsyms.def
1980	echo lock_get_mem >> clubsyms.def
1981	echo checklock_start >> clubsyms.def
1982	echo checklock_stop >> clubsyms.def
1983	echo checklock_set_output_name >> clubsyms.def
1984	echo checklock_lock >> clubsyms.def
1985	echo checklock_unlock >> clubsyms.def
1986	echo checklock_init >> clubsyms.def
1987	echo checklock_thrcreate >> clubsyms.def
1988	echo checklock_thrjoin >> clubsyms.def
1989fi
1990
1991# check for dnstap if requested
1992dt_DNSTAP([$UNBOUND_RUN_DIR/dnstap.sock],
1993    [
1994        AC_DEFINE([USE_DNSTAP], [1], [Define to 1 to enable dnstap support])
1995        AC_SUBST([ENABLE_DNSTAP], [1])
1996
1997        AC_SUBST([opt_dnstap_socket_path])
1998        ACX_ESCAPE_BACKSLASH($opt_dnstap_socket_path, hdr_dnstap_socket_path)
1999        AC_DEFINE_UNQUOTED(DNSTAP_SOCKET_PATH,
2000            ["$hdr_dnstap_socket_path"], [default dnstap socket path])
2001	AC_SUBST(DNSTAP_SOCKET_PATH,["$hdr_dnstap_socket_path"])
2002	AC_SUBST(DNSTAP_SOCKET_TESTBIN,['unbound-dnstap-socket$(EXEEXT)'])
2003        AC_SUBST([DNSTAP_SRC], ["dnstap/dnstap.c dnstap/dnstap.pb-c.c dnstap/dnstap_fstrm.c dnstap/dtstream.c"])
2004        AC_SUBST([DNSTAP_OBJ], ["dnstap.lo dnstap.pb-c.lo dnstap_fstrm.lo dtstream.lo"])
2005    ],
2006    [
2007        AC_SUBST([ENABLE_DNSTAP], [0])
2008    ]
2009)
2010
2011# check for dnscrypt if requested
2012dnsc_DNSCRYPT([
2013        AC_DEFINE([USE_DNSCRYPT], [1], [Define to 1 to enable dnscrypt support])
2014        AC_SUBST([ENABLE_DNSCRYPT], [1])
2015
2016        AC_SUBST([DNSCRYPT_SRC], ["dnscrypt/dnscrypt.c"])
2017        AC_SUBST([DNSCRYPT_OBJ], ["dnscrypt.lo"])
2018    ],
2019    [
2020        AC_SUBST([ENABLE_DNSCRYPT], [0])
2021    ]
2022)
2023
2024# check for cachedb if requested
2025AC_ARG_ENABLE(cachedb, AS_HELP_STRING([--enable-cachedb],[enable cachedb module that can use external cache storage]))
2026# turn on cachedb when hiredis support is enabled.
2027if test "$found_libhiredis" = "yes"; then enable_cachedb="yes"; fi
2028case "$enable_cachedb" in
2029    yes)
2030    	AC_DEFINE([USE_CACHEDB], [1], [Define to 1 to use cachedb support])
2031	AC_SUBST([CACHEDB_SRC], ["cachedb/cachedb.c cachedb/redis.c"])
2032	AC_SUBST([CACHEDB_OBJ], ["cachedb.lo redis.lo"])
2033    	;;
2034    no|*)
2035    	# nothing
2036    	;;
2037esac
2038
2039# check for ipsecmod if requested
2040AC_ARG_ENABLE(ipsecmod, AS_HELP_STRING([--enable-ipsecmod],[Enable ipsecmod module that facilitates opportunistic IPsec]))
2041case "$enable_ipsecmod" in
2042	yes)
2043		AC_DEFINE([USE_IPSECMOD], [1], [Define to 1 to use ipsecmod support.])
2044		IPSECMOD_OBJ="ipsecmod.lo ipsecmod-whitelist.lo"
2045		AC_SUBST(IPSECMOD_OBJ)
2046		IPSECMOD_HEADER='$(srcdir)/ipsecmod/ipsecmod.h $(srcdir)/ipsecmod/ipsecmod-whitelist.h'
2047		AC_SUBST(IPSECMOD_HEADER)
2048		;;
2049	no|*)
2050		# nothing
2051		;;
2052esac
2053
2054# check for ipset if requested
2055AC_ARG_ENABLE(ipset, AS_HELP_STRING([--enable-ipset],[enable ipset module]))
2056case "$enable_ipset" in
2057    yes)
2058		AC_DEFINE([USE_IPSET], [1], [Define to 1 to use ipset support])
2059		IPSET_SRC="ipset/ipset.c"
2060		AC_SUBST(IPSET_SRC)
2061		IPSET_OBJ="ipset.lo"
2062		AC_SUBST(IPSET_OBJ)
2063
2064		# BSD's pf
2065		AC_CHECK_HEADERS([net/pfvar.h], [], [
2066		    # mnl
2067		    AC_ARG_WITH(libmnl, AS_HELP_STRING([--with-libmnl=path],[specify explicit path for libmnl.]),
2068			[ ],[ withval="yes" ])
2069		    found_libmnl="no"
2070		    AC_MSG_CHECKING(for libmnl)
2071		    if test x_$withval = x_ -o x_$withval = x_yes; then
2072			withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr"
2073		    fi
2074		    for dir in $withval ; do
2075			if test -f "$dir/include/libmnl/libmnl.h" -o -f "$dir/include/libmnl/libmnl/libmnl.h"; then
2076				found_libmnl="yes"
2077				dnl assume /usr is in default path.
2078				extralibmnl=""
2079				if test -f "$dir/include/libmnl/libmnl/libmnl.h"; then
2080					extralibmnl="/libmnl"
2081				fi
2082				if test "$dir" != "/usr" -o -n "$extralibmnl"; then
2083					CPPFLAGS="$CPPFLAGS -I$dir/include$extralibmnl"
2084				fi
2085				if test "$dir" != "/usr"; then
2086					LDFLAGS="$LDFLAGS -L$dir/lib"
2087				fi
2088				AC_MSG_RESULT(found in $dir)
2089				LIBS="$LIBS -lmnl"
2090				break;
2091			fi
2092		    done
2093		    if test x_$found_libmnl != x_yes; then
2094			  AC_MSG_ERROR([Could not find libmnl, libmnl.h])
2095		    fi
2096		], [
2097		  #include <netinet/in.h>
2098		  #include <net/if.h>
2099		])
2100		;;
2101    no|*)
2102    	# nothing
2103		;;
2104esac
2105AC_ARG_ENABLE(explicit-port-randomisation, AS_HELP_STRING([--disable-explicit-port-randomisation],[disable explicit source port randomisation and rely on the kernel to provide random source ports]))
2106case "$enable_explicit_port_randomisation" in
2107	no)
2108		AC_DEFINE([DISABLE_EXPLICIT_PORT_RANDOMISATION], [1], [Define this to enable kernel based UDP source port randomization.])
2109		;;
2110	yes|*)
2111		;;
2112esac
2113
2114if echo "$host" | $GREP -i -e linux >/dev/null; then
2115	AC_ARG_ENABLE(linux-ip-local-port-range, AS_HELP_STRING([--enable-linux-ip-local-port-range], [Define this to enable use of /proc/sys/net/ipv4/ip_local_port_range as a default outgoing port range. This is only for the libunbound on Linux and does not affect unbound resolving daemon itself. This may severely limit the number of available outgoing ports and thus decrease randomness. Define this only when the target system restricts (e.g. some of SELinux enabled distributions) the use of non-ephemeral ports.]))
2116	case "$enable_linux_ip_local_port_range" in
2117		yes)
2118			AC_DEFINE([USE_LINUX_IP_LOCAL_PORT_RANGE], [1], [Define this to enable use of /proc/sys/net/ipv4/ip_local_port_range as a default outgoing port range. This is only for the libunbound on Linux and does not affect unbound resolving daemon itself. This may severely limit the number of available outgoing ports and thus decrease randomness. Define this only when the target system restricts (e.g. some of SELinux enabled distributions) the use of non-ephemeral ports.])
2119			;;
2120		no|*)
2121			;;
2122	esac
2123fi
2124
2125
2126AC_MSG_CHECKING([if ${MAKE:-make} supports $< with implicit rule in scope])
2127# on openBSD, the implicit rule make $< work.
2128# on Solaris, it does not work ($? is changed sources, $^ lists dependencies).
2129# gmake works.
2130cat >conftest.make <<EOF
2131all:	conftest.lo
2132
2133conftest.lo foo.lo bla.lo:
2134	if test -f "\$<"; then touch \$@; fi
2135
2136.SUFFIXES: .lo
2137.c.lo:
2138	if test -f "\$<"; then touch \$@; fi
2139
2140conftest.lo:        conftest.dir/conftest.c
2141EOF
2142mkdir conftest.dir
2143touch conftest.dir/conftest.c
2144rm -f conftest.lo conftest.c
2145${MAKE:-make} -f conftest.make >/dev/null
2146rm -f conftest.make conftest.c conftest.dir/conftest.c
2147rm -rf conftest.dir
2148if test ! -f conftest.lo; then
2149	AC_MSG_RESULT(no)
2150	SOURCEDETERMINE='echo "$^" | awk "-F " "{print \$$1;}" > .source'
2151	SOURCEFILE='`cat .source`'
2152else
2153	AC_MSG_RESULT(yes)
2154	SOURCEDETERMINE=':'
2155	SOURCEFILE='$<'
2156fi
2157rm -f conftest.lo
2158AC_SUBST(SOURCEDETERMINE)
2159AC_SUBST(SOURCEFILE)
2160
2161# see if we want to build the library or everything
2162ALLTARGET="alltargets"
2163INSTALLTARGET="install-all"
2164AC_ARG_WITH(libunbound-only, AS_HELP_STRING([--with-libunbound-only],[do not build daemon and tool programs]),
2165	[
2166	if test "$withval" = "yes"; then
2167		ALLTARGET="lib"
2168		INSTALLTARGET="install-lib"
2169	fi
2170])
2171if test $ALLTARGET = "alltargets"; then
2172	if test $USE_NSS = "yes"; then
2173		AC_MSG_ERROR([--with-nss can only be used in combination with --with-libunbound-only.])
2174	fi
2175	if test $USE_NETTLE = "yes"; then
2176		AC_MSG_ERROR([--with-nettle can only be used in combination with --with-libunbound-only.])
2177	fi
2178fi
2179
2180AC_SUBST(ALLTARGET)
2181AC_SUBST(INSTALLTARGET)
2182
2183ACX_STRIP_EXT_FLAGS
2184if test -n "$LATE_LDFLAGS"; then
2185  LDFLAGS="$LATE_LDFLAGS $LDFLAGS"
2186fi
2187# remove start spaces
2188LDFLAGS=`echo "$LDFLAGS"|sed -e 's/^ *//'`
2189LIBS=`echo "$LIBS"|sed -e 's/^ *//'`
2190
2191AC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [10240], [Define to the maximum message length to pass to syslog.])
2192
2193AH_BOTTOM(
2194dnl this must be first AH_CONFIG, to define the flags before any includes.
2195AHX_CONFIG_EXT_FLAGS
2196
2197dnl includes
2198[
2199#ifndef _OPENBSD_SOURCE
2200#define _OPENBSD_SOURCE 1
2201#endif
2202
2203#ifndef UNBOUND_DEBUG
2204# ifndef NDEBUG
2205#  define NDEBUG
2206# endif
2207#endif
2208
2209/** Use small-ldns codebase */
2210#define USE_SLDNS 1
2211#ifdef HAVE_SSL
2212#  define LDNS_BUILD_CONFIG_HAVE_SSL 1
2213#endif
2214
2215#include <stdio.h>
2216#include <string.h>
2217#include <unistd.h>
2218#include <assert.h>
2219
2220#if STDC_HEADERS
2221#include <stdlib.h>
2222#include <stddef.h>
2223#endif
2224
2225#ifdef HAVE_STDARG_H
2226#include <stdarg.h>
2227#endif
2228
2229#ifdef HAVE_STDINT_H
2230#include <stdint.h>
2231#endif
2232
2233#include <errno.h>
2234
2235#if HAVE_SYS_PARAM_H
2236#include <sys/param.h>
2237#endif
2238
2239#ifdef HAVE_SYS_SOCKET_H
2240#include <sys/socket.h>
2241#endif
2242
2243#ifdef HAVE_SYS_UIO_H
2244#include <sys/uio.h>
2245#endif
2246
2247#ifdef HAVE_NETINET_IN_H
2248#include <netinet/in.h>
2249#endif
2250
2251#ifdef HAVE_NETINET_TCP_H
2252#include <netinet/tcp.h>
2253#endif
2254
2255#ifdef HAVE_ARPA_INET_H
2256#include <arpa/inet.h>
2257#endif
2258
2259#ifdef HAVE_WINSOCK2_H
2260#include <winsock2.h>
2261#endif
2262
2263#ifdef HAVE_WS2TCPIP_H
2264#include <ws2tcpip.h>
2265#endif
2266
2267#if !defined(USE_WINSOCK) || !defined(HAVE_SNPRINTF) || defined(SNPRINTF_RET_BROKEN) || defined(__USE_MINGW_ANSI_STDIO)
2268#define ARG_LL "%ll"
2269#else
2270#define ARG_LL "%I64"
2271#endif
2272
2273#ifndef AF_LOCAL
2274#define AF_LOCAL AF_UNIX
2275#endif
2276]
2277
2278AHX_CONFIG_FORMAT_ATTRIBUTE
2279AHX_CONFIG_UNUSED_ATTRIBUTE
2280AHX_CONFIG_FSEEKO
2281AHX_CONFIG_MAXHOSTNAMELEN
2282#if !defined(HAVE_SNPRINTF) || defined(SNPRINTF_RET_BROKEN)
2283#define snprintf snprintf_unbound
2284#define vsnprintf vsnprintf_unbound
2285#include <stdarg.h>
2286int snprintf (char *str, size_t count, const char *fmt, ...);
2287int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
2288#endif /* HAVE_SNPRINTF or SNPRINTF_RET_BROKEN */
2289AHX_CONFIG_INET_PTON(unbound)
2290AHX_CONFIG_INET_NTOP(unbound)
2291AHX_CONFIG_INET_ATON(unbound)
2292AHX_CONFIG_MEMMOVE(unbound)
2293AHX_CONFIG_STRLCAT(unbound)
2294AHX_CONFIG_STRLCPY(unbound)
2295AHX_CONFIG_GMTIME_R(unbound)
2296AHX_CONFIG_REALLOCARRAY(unbound)
2297AHX_CONFIG_W32_SLEEP
2298AHX_CONFIG_W32_USLEEP
2299AHX_CONFIG_W32_RANDOM
2300AHX_CONFIG_W32_SRANDOM
2301AHX_CONFIG_W32_FD_SET_T
2302AHX_CONFIG_IPV6_MIN_MTU
2303AHX_MEMCMP_BROKEN(unbound)
2304
2305[
2306#ifndef HAVE_CTIME_R
2307#define ctime_r unbound_ctime_r
2308char *ctime_r(const time_t *timep, char *buf);
2309#endif
2310
2311#ifndef HAVE_STRSEP
2312#define strsep unbound_strsep
2313char *strsep(char **stringp, const char *delim);
2314#endif
2315
2316#ifndef HAVE_ISBLANK
2317#define isblank unbound_isblank
2318int isblank(int c);
2319#endif
2320
2321#ifndef HAVE_EXPLICIT_BZERO
2322#define explicit_bzero unbound_explicit_bzero
2323void explicit_bzero(void* buf, size_t len);
2324#endif
2325
2326#if defined(HAVE_INET_NTOP) && !HAVE_DECL_INET_NTOP
2327const char *inet_ntop(int af, const void *src, char *dst, size_t size);
2328#endif
2329
2330#if defined(HAVE_INET_PTON) && !HAVE_DECL_INET_PTON
2331int inet_pton(int af, const char* src, void* dst);
2332#endif
2333
2334#if !defined(HAVE_STRPTIME) || !defined(STRPTIME_WORKS)
2335#define strptime unbound_strptime
2336struct tm;
2337char *strptime(const char *s, const char *format, struct tm *tm);
2338#endif
2339
2340#if !HAVE_DECL_REALLOCARRAY
2341void *reallocarray(void *ptr, size_t nmemb, size_t size);
2342#endif
2343
2344#ifdef HAVE_LIBBSD
2345#include <bsd/string.h>
2346#include <bsd/stdlib.h>
2347#endif
2348
2349#ifdef HAVE_LIBRESSL
2350#  if !HAVE_DECL_STRLCPY
2351size_t strlcpy(char *dst, const char *src, size_t siz);
2352#  endif
2353#  if !HAVE_DECL_STRLCAT
2354size_t strlcat(char *dst, const char *src, size_t siz);
2355#  endif
2356#  if !HAVE_DECL_ARC4RANDOM && defined(HAVE_ARC4RANDOM)
2357uint32_t arc4random(void);
2358#  endif
2359#  if !HAVE_DECL_ARC4RANDOM_UNIFORM && defined(HAVE_ARC4RANDOM_UNIFORM)
2360uint32_t arc4random_uniform(uint32_t upper_bound);
2361#  endif
2362#endif /* HAVE_LIBRESSL */
2363#ifndef HAVE_ARC4RANDOM
2364int getentropy(void* buf, size_t len);
2365uint32_t arc4random(void);
2366void arc4random_buf(void* buf, size_t n);
2367void _ARC4_LOCK(void);
2368void _ARC4_UNLOCK(void);
2369void _ARC4_LOCK_DESTROY(void);
2370#endif
2371#ifndef HAVE_ARC4RANDOM_UNIFORM
2372uint32_t arc4random_uniform(uint32_t upper_bound);
2373#endif
2374#ifdef COMPAT_SHA512
2375#ifndef SHA512_DIGEST_LENGTH
2376#define SHA512_BLOCK_LENGTH		128
2377#define SHA512_DIGEST_LENGTH		64
2378#define SHA512_DIGEST_STRING_LENGTH	(SHA512_DIGEST_LENGTH * 2 + 1)
2379typedef struct _SHA512_CTX {
2380	uint64_t	state[8];
2381	uint64_t	bitcount[2];
2382	uint8_t	buffer[SHA512_BLOCK_LENGTH];
2383} SHA512_CTX;
2384#endif /* SHA512_DIGEST_LENGTH */
2385void SHA512_Init(SHA512_CTX*);
2386void SHA512_Update(SHA512_CTX*, void*, size_t);
2387void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
2388unsigned char *SHA512(void* data, unsigned int data_len, unsigned char *digest);
2389#endif /* COMPAT_SHA512 */
2390
2391
2392
2393#if defined(HAVE_EVENT_H) && !defined(HAVE_EVENT_BASE_ONCE) && !(defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP)) && (defined(HAVE_PTHREAD) || defined(HAVE_SOLARIS_THREADS))
2394   /* using version of libevent that is not threadsafe. */
2395#  define LIBEVENT_SIGNAL_PROBLEM 1
2396#endif
2397
2398#ifndef CHECKED_INET6
2399#  define CHECKED_INET6
2400#  ifdef AF_INET6
2401#    define INET6
2402#  else
2403#    define AF_INET6        28
2404#  endif
2405#endif /* CHECKED_INET6 */
2406
2407#ifndef HAVE_GETADDRINFO
2408struct sockaddr_storage;
2409#include "compat/fake-rfc2553.h"
2410#endif
2411
2412#ifdef UNBOUND_ALLOC_STATS
2413#  define malloc(s) unbound_stat_malloc_log(s, __FILE__, __LINE__, __func__)
2414#  define calloc(n,s) unbound_stat_calloc_log(n, s, __FILE__, __LINE__, __func__)
2415#  define free(p) unbound_stat_free_log(p, __FILE__, __LINE__, __func__)
2416#  define realloc(p,s) unbound_stat_realloc_log(p, s, __FILE__, __LINE__, __func__)
2417#  define strdup(s) unbound_stat_strdup_log(s, __FILE__, __LINE__, __func__)
2418#ifdef HAVE_REALLOCARRAY
2419#  define reallocarray(p,n,s) unbound_stat_reallocarray_log(p, n, s, __FILE__, __LINE__, __func__)
2420#endif
2421void *unbound_stat_malloc(size_t size);
2422void *unbound_stat_calloc(size_t nmemb, size_t size);
2423void unbound_stat_free(void *ptr);
2424void *unbound_stat_realloc(void *ptr, size_t size);
2425void *unbound_stat_malloc_log(size_t size, const char* file, int line,
2426	const char* func);
2427void *unbound_stat_calloc_log(size_t nmemb, size_t size, const char* file,
2428	int line, const char* func);
2429void unbound_stat_free_log(void *ptr, const char* file, int line,
2430	const char* func);
2431void *unbound_stat_realloc_log(void *ptr, size_t size, const char* file,
2432	int line, const char* func);
2433void *unbound_stat_reallocarray_log(void *ptr, size_t nmemb, size_t size,
2434	const char* file, int line, const char* func);
2435char *unbound_stat_strdup_log(const char *s, const char* file, int line,
2436	const char* func);
2437#elif defined(UNBOUND_ALLOC_LITE)
2438#  include "util/alloc.h"
2439#endif /* UNBOUND_ALLOC_LITE and UNBOUND_ALLOC_STATS */
2440
2441/** default port for DNS traffic. */
2442#define UNBOUND_DNS_PORT 53
2443/** default port for DNS over TLS traffic. */
2444#define UNBOUND_DNS_OVER_TLS_PORT 853
2445/** default port for DNS over HTTPS traffic. */
2446#define UNBOUND_DNS_OVER_HTTPS_PORT 443
2447/** default port for DNS over QUIC traffic. */
2448#define UNBOUND_DNS_OVER_QUIC_PORT 853
2449/** default port for unbound control traffic, registered port with IANA,
2450    ub-dns-control  8953/tcp    unbound dns nameserver control */
2451#define UNBOUND_CONTROL_PORT 8953
2452/** the version of unbound-control that this software implements */
2453#define UNBOUND_CONTROL_VERSION 1
2454
2455])
2456
2457dnl if we build from source tree, the man pages need @date@ and @version@
2458dnl if this is a distro tarball, that was already done by makedist.sh
2459AC_SUBST(version, [VERSION_MAJOR.VERSION_MINOR.VERSION_MICRO])
2460AX_BUILD_DATE_EPOCH(date, [[%b %e, %Y]])
2461AC_SUBST(date)
2462
2463AC_CONFIG_FILES([Makefile doc/example.conf doc/libunbound.3 doc/unbound.8 doc/unbound-anchor.8 doc/unbound-checkconf.8 doc/unbound.conf.5 doc/unbound-control.8 doc/unbound-host.1 smallapp/unbound-control-setup.sh dnstap/dnstap_config.h dnscrypt/dnscrypt_config.h contrib/libunbound.pc contrib/unbound.socket contrib/unbound.service contrib/unbound_portable.service])
2464AC_CONFIG_HEADERS([config.h])
2465AC_OUTPUT
2466