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