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