2 # Process this file with autoconf to produce a configure script.
4 sinclude(acx_nlnetlabs.m4)
5 sinclude(ax_pthread.m4)
6 sinclude(acx_python.m4)
7 sinclude(ac_pkg_swig.m4)
8 sinclude(dnstap/dnstap.m4)
9 sinclude(dnscrypt/dnscrypt.m4)
11 # must be numbers. ac_defun because of later processing
12 m4_define([VERSION_MAJOR],[1])
13 m4_define([VERSION_MINOR],[9])
14 m4_define([VERSION_MICRO],[6])
15 AC_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)
16 AC_SUBST(UNBOUND_VERSION_MAJOR, [VERSION_MAJOR])
17 AC_SUBST(UNBOUND_VERSION_MINOR, [VERSION_MINOR])
18 AC_SUBST(UNBOUND_VERSION_MICRO, [VERSION_MICRO])
30 # 1.3.0 had 1:0:0 # ub_cancel and -export-symbols.
35 # 1.4.0-snapshots had 1:5:0
36 # 1.4.0 had 1:5:0 (not 2:0:0) # ub_result.why_bogus
50 # and 1.4.13p1 and 1.4.13.p2
52 # 1.4.15 had 3:0:1 # adds ub_version()
57 # 1.4.20 had 4:0:2 # adds libunbound.ttl # but shipped 3:5:1
60 # 1.5.0 had 5:3:3 # adds ub_ctx_add_ta_autr
68 # 1.5.8 had 6:0:4 # adds ub_ctx_set_stub
72 # 1.6.1 had 7:0:5 # ub_callback_t typedef renamed to ub_callback_type
84 # 1.8.0 had 8:0:0 # changes the event callback function signature
88 # 1.9.0 had 9:0:1 # add ub_ctx_set_tls
96 # Current -- the number of the binary API that we're implementing
97 # Revision -- which iteration of the implementation of the binary
98 # API are we supplying?
99 # Age -- How many previous binary API versions do we also
102 # If we release a new version that does not change the binary API,
103 # increment Revision.
105 # If we release a new version that changes the binary API, but does
106 # not break programs compiled against the old binary API, increment
107 # Current and Age. Set Revision to 0, since this is the first
108 # implementation of the new API.
110 # Otherwise, we're changing the binary API and breaking backward
111 # compatibility with old binaries. Increment Current. Set Age to 0,
112 # since we're backward compatible with no previous APIs. Set Revision
114 AC_SUBST(LIBUNBOUND_CURRENT)
115 AC_SUBST(LIBUNBOUND_REVISION)
116 AC_SUBST(LIBUNBOUND_AGE)
119 cmdln="`echo $@ | sed -e 's/\\\\/\\\\\\\\/g' | sed -e 's/"/\\\\"/'g`"
120 AC_DEFINE_UNQUOTED(CONFCMDLINE, ["$cmdln"], [Command line arguments used with configure])
124 if test "$ac_cv_header_minix_config_h" = "yes"; then
125 AC_DEFINE(_NETBSD_SOURCE,1, [Enable for compile on Minix])
129 dnl By default set prefix to /usr/local
136 case "$exec_prefix" in
138 exec_prefix="$prefix"
143 if uname -s 2>&1 | grep MINGW32 >/dev/null; then on_mingw="yes"
145 if echo $host $target | grep mingw32 >/dev/null; then on_mingw="yes"
146 else on_mingw="no"; fi
150 # Determine configuration file
151 # the eval is to evaluate shell expansion twice
152 UNBOUND_SBIN_DIR=`eval echo "${sbindir}"`
153 AC_SUBST(UNBOUND_SBIN_DIR)
154 UNBOUND_SYSCONF_DIR=`eval echo "${sysconfdir}"`
155 AC_SUBST(UNBOUND_SYSCONF_DIR)
156 UNBOUND_LOCALSTATE_DIR=`eval echo "${localstatedir}"`
157 AC_SUBST(UNBOUND_LOCALSTATE_DIR)
158 if test $on_mingw = "no"; then
159 ub_conf_file=`eval echo "${sysconfdir}/unbound/unbound.conf"`
161 ub_conf_file="C:\\Program Files\\Unbound\\service.conf"
163 AC_ARG_WITH([conf_file],
164 AC_HELP_STRING([--with-conf-file=path],
165 [Pathname to the Unbound configuration file]),
166 [ub_conf_file="$withval"])
167 AC_SUBST(ub_conf_file)
168 ACX_ESCAPE_BACKSLASH($ub_conf_file, hdr_config)
169 AC_DEFINE_UNQUOTED(CONFIGFILE, ["$hdr_config"], [Pathname to the Unbound configuration file])
170 ub_conf_dir=`AS_DIRNAME(["$ub_conf_file"])`
171 AC_SUBST(ub_conf_dir)
173 # Determine run, chroot directory and pidfile locations
175 AC_HELP_STRING([--with-run-dir=path],
176 [set default directory to chdir to (by default dir part of cfg file)]),
177 UNBOUND_RUN_DIR="$withval",
178 if test $on_mingw = no; then
179 UNBOUND_RUN_DIR=`dirname "$ub_conf_file"`
184 AC_SUBST(UNBOUND_RUN_DIR)
185 ACX_ESCAPE_BACKSLASH($UNBOUND_RUN_DIR, hdr_run)
186 AC_DEFINE_UNQUOTED(RUN_DIR, ["$hdr_run"], [Directory to chdir to])
188 AC_ARG_WITH(chroot-dir,
189 AC_HELP_STRING([--with-chroot-dir=path],
190 [set default directory to chroot to (by default same as run-dir)]),
191 UNBOUND_CHROOT_DIR="$withval",
192 if test $on_mingw = no; then
193 UNBOUND_CHROOT_DIR="$UNBOUND_RUN_DIR"
195 UNBOUND_CHROOT_DIR=""
198 AC_SUBST(UNBOUND_CHROOT_DIR)
199 ACX_ESCAPE_BACKSLASH($UNBOUND_CHROOT_DIR, hdr_chroot)
200 AC_DEFINE_UNQUOTED(CHROOT_DIR, ["$hdr_chroot"], [Directory to chroot to])
202 AC_ARG_WITH(share-dir,
203 AC_HELP_STRING([--with-share-dir=path],
204 [set default directory with shared data (by default same as share/unbound)]),
205 UNBOUND_SHARE_DIR="$withval",
206 UNBOUND_SHARE_DIR="$UNBOUND_RUN_DIR")
207 AC_SUBST(UNBOUND_SHARE_DIR)
208 AC_DEFINE_UNQUOTED(SHARE_DIR, ["$UNBOUND_SHARE_DIR"], [Shared data])
211 AC_HELP_STRING([--with-pidfile=filename],
212 [set default pathname to unbound pidfile (default run-dir/unbound.pid)]),
213 UNBOUND_PIDFILE="$withval",
214 if test $on_mingw = no; then
215 UNBOUND_PIDFILE="$UNBOUND_RUN_DIR/unbound.pid"
220 AC_SUBST(UNBOUND_PIDFILE)
221 ACX_ESCAPE_BACKSLASH($UNBOUND_PIDFILE, hdr_pid)
222 AC_DEFINE_UNQUOTED(PIDFILE, ["$hdr_pid"], [default pidfile location])
224 AC_ARG_WITH(rootkey-file,
225 AC_HELP_STRING([--with-rootkey-file=filename],
226 [set default pathname to root key file (default run-dir/root.key). This file is read and written.]),
227 UNBOUND_ROOTKEY_FILE="$withval",
228 if test $on_mingw = no; then
229 UNBOUND_ROOTKEY_FILE="$UNBOUND_RUN_DIR/root.key"
231 UNBOUND_ROOTKEY_FILE="C:\\Program Files\\Unbound\\root.key"
234 AC_SUBST(UNBOUND_ROOTKEY_FILE)
235 ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTKEY_FILE, hdr_rkey)
236 AC_DEFINE_UNQUOTED(ROOT_ANCHOR_FILE, ["$hdr_rkey"], [default rootkey location])
238 AC_ARG_WITH(rootcert-file,
239 AC_HELP_STRING([--with-rootcert-file=filename],
240 [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.]),
241 UNBOUND_ROOTCERT_FILE="$withval",
242 if test $on_mingw = no; then
243 UNBOUND_ROOTCERT_FILE="$UNBOUND_RUN_DIR/icannbundle.pem"
245 UNBOUND_ROOTCERT_FILE="C:\\Program Files\\Unbound\\icannbundle.pem"
248 AC_SUBST(UNBOUND_ROOTCERT_FILE)
249 ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTCERT_FILE, hdr_rpem)
250 AC_DEFINE_UNQUOTED(ROOT_CERT_FILE, ["$hdr_rpem"], [default rootcert location])
252 AC_ARG_WITH(username,
253 AC_HELP_STRING([--with-username=user],
254 [set default user that unbound changes to (default user is unbound)]),
255 UNBOUND_USERNAME="$withval",
256 UNBOUND_USERNAME="unbound")
257 AC_SUBST(UNBOUND_USERNAME)
258 AC_DEFINE_UNQUOTED(UB_USERNAME, ["$UNBOUND_USERNAME"], [default username])
260 AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
261 ACX_RSRC_VERSION(wnvs)
262 AC_DEFINE_UNQUOTED(RSRC_PACKAGE_VERSION, [$wnvs], [version number for resource files])
264 # Checks for typedefs, structures, and compiler characteristics.
267 # allow user to override the -g -O2 flags.
269 if test "x$CFLAGS" = "x" ; then
270 ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="$CFLAGS -g"])
271 ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"])
276 ACX_DETERMINE_EXT_FLAGS_UNBOUND
278 # debug mode flags warnings
279 AC_ARG_ENABLE(checking, AC_HELP_STRING([--enable-checking], [Enable warnings, asserts, makefile-dependencies]))
280 AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [same as enable-checking]))
281 if test "$enable_debug" = "yes"; then debug_enabled="$enable_debug";
282 else debug_enabled="$enable_checking"; fi
283 AC_SUBST(debug_enabled)
284 case "$debug_enabled" in
286 ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="$CFLAGS -W"])
287 ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="$CFLAGS -Wall"])
288 ACX_CHECK_COMPILER_FLAG(Wextra, [CFLAGS="$CFLAGS -Wextra"])
289 ACX_CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [CFLAGS="$CFLAGS -Wdeclaration-after-statement"])
290 AC_DEFINE([UNBOUND_DEBUG], [], [define this to enable debug checks.])
296 if test "$default_cflags" = "yes"; then
297 # only when CFLAGS was "" at the start, if the users wants to
298 # override we shouldn't add default cflags, because they wouldn't
299 # be able to turn off these options and set the CFLAGS wanted.
306 ACX_CHECK_FORMAT_ATTRIBUTE
307 ACX_CHECK_UNUSED_ATTRIBUTE
309 AC_DEFUN([CHECK_WEAK_ATTRIBUTE],
310 [AC_REQUIRE([AC_PROG_CC])
311 AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "weak" attribute)
312 AC_CACHE_VAL(ac_cv_c_weak_attribute,
313 [ac_cv_c_weak_attribute=no
316 __attribute__((weak)) void f(int x) { printf("%d", x); }
320 [ac_cv_c_weak_attribute="yes"],
321 [ac_cv_c_weak_attribute="no"])
324 AC_MSG_RESULT($ac_cv_c_weak_attribute)
325 if test $ac_cv_c_weak_attribute = yes; then
326 AC_DEFINE(HAVE_ATTR_WEAK, 1, [Whether the C compiler accepts the "weak" attribute])
327 AC_DEFINE(ATTR_WEAK, [__attribute__((weak))], [apply the weak attribute to a symbol])
329 ])dnl End of CHECK_WEAK_ATTRIBUTE
333 AC_DEFUN([CHECK_NORETURN_ATTRIBUTE],
334 [AC_REQUIRE([AC_PROG_CC])
335 AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "noreturn" attribute)
336 AC_CACHE_VAL(ac_cv_c_noreturn_attribute,
337 [ac_cv_c_noreturn_attribute=no
340 __attribute__((noreturn)) void f(int x) { printf("%d", x); }
344 [ac_cv_c_noreturn_attribute="yes"],
345 [ac_cv_c_noreturn_attribute="no"])
348 AC_MSG_RESULT($ac_cv_c_noreturn_attribute)
349 if test $ac_cv_c_noreturn_attribute = yes; then
350 AC_DEFINE(HAVE_ATTR_NORETURN, 1, [Whether the C compiler accepts the "noreturn" attribute])
351 AC_DEFINE(ATTR_NORETURN, [__attribute__((__noreturn__))], [apply the noreturn attribute to a function that exits the program])
353 ])dnl End of CHECK_NORETURN_ATTRIBUTE
355 CHECK_NORETURN_ATTRIBUTE
357 if test "$srcdir" != "."; then
358 CPPFLAGS="$CPPFLAGS -I$srcdir"
361 AC_DEFUN([ACX_YYLEX_DESTROY], [
362 AC_MSG_CHECKING([for yylex_destroy])
363 if echo %% | $LEX -t 2>&1 | grep yylex_destroy >/dev/null 2>&1; then
364 AC_DEFINE(LEX_HAS_YYLEX_DESTROY, 1, [if lex has yylex_destroy])
366 else AC_MSG_RESULT(no);
371 AC_DEFUN([ACX_YYLEX_OPTION], [
372 AC_MSG_CHECKING([for lex %option])
373 if cat <<EOF | $LEX -t 2>&1 | grep yy_delete_buffer >/dev/null 2>&1; then
378 else AC_MSG_RESULT(no);
384 if test "$LEX" != "" -a "$LEX" != ":"; then
387 if test "$LEX" != "" -a "$LEX" != ":"; then
391 AC_CHECK_PROG(doxygen, doxygen, doxygen)
392 AC_CHECK_TOOL(STRIP, strip)
397 # Checks for header files.
398 AC_CHECK_HEADERS([stdarg.h stdbool.h netinet/in.h netinet/tcp.h sys/param.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],,, [AC_INCLUDES_DEFAULT])
401 # Using own tests for int64* because autoconf builtin only give 32bit.
402 AC_CHECK_TYPE(int8_t, signed char)
403 AC_CHECK_TYPE(int16_t, short)
404 AC_CHECK_TYPE(int32_t, int)
405 AC_CHECK_TYPE(int64_t, long long)
406 AC_CHECK_TYPE(uint8_t, unsigned char)
407 AC_CHECK_TYPE(uint16_t, unsigned short)
408 AC_CHECK_TYPE(uint32_t, unsigned int)
409 AC_CHECK_TYPE(uint64_t, unsigned long long)
411 AC_CHECK_TYPE(ssize_t, int)
420 ACX_CHECK_MEMCMP_SIGNED
422 AC_CHECK_SIZEOF(time_t,,[
424 #ifdef TIME_WITH_SYS_TIME
425 # include <sys/time.h>
428 # ifdef HAVE_SYS_TIME_H
429 # include <sys/time.h>
435 AC_CHECK_SIZEOF(size_t)
437 # add option to disable the evil rpath
439 AC_SUBST(RUNTIME_PATH)
441 # check to see if libraries are needed for these functions.
442 AC_SEARCH_LIBS([inet_pton], [nsl])
443 AC_SEARCH_LIBS([socket], [socket])
445 # check wether strptime also works
446 AC_DEFUN([AC_CHECK_STRPTIME_WORKS],
447 [AC_REQUIRE([AC_PROG_CC])
448 AC_MSG_CHECKING(whether strptime works)
449 if test c${cross_compiling} = cno; then
450 AC_RUN_IFELSE([AC_LANG_SOURCE([[
451 #define _XOPEN_SOURCE 600
453 int main(void) { struct tm tm; char *res;
454 res = 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);
456 res = strptime("20070207111842", "%Y%m%d%H%M%S", &tm);
457 if (!res) return 1; return 0; }
458 ]])] , [eval "ac_cv_c_strptime_works=yes"], [eval "ac_cv_c_strptime_works=no"])
460 eval "ac_cv_c_strptime_works=maybe"
462 AC_MSG_RESULT($ac_cv_c_strptime_works)
463 if test $ac_cv_c_strptime_works = no; then
466 AC_DEFINE_UNQUOTED([STRPTIME_WORKS], 1, [use default strptime.])
470 # check some functions of the OS before linking libs (while still runnable).
476 ACX_CHECK_NONBLOCKING_BROKEN
478 AC_CHECK_FUNCS([strptime],[AC_CHECK_STRPTIME_WORKS],[AC_LIBOBJ([strptime])])
480 # check if we can use SO_REUSEPORT
481 if echo "$host" | $GREP -i -e linux -e dragonfly >/dev/null; then
482 AC_DEFINE(REUSEPORT_DEFAULT, 1, [if REUSEPORT is enabled by default])
484 AC_DEFINE(REUSEPORT_DEFAULT, 0, [if REUSEPORT is enabled by default])
487 # Include systemd.m4 - begin
489 # Include systemd.m4 - end
491 # set memory allocation checking if requested
492 AC_ARG_ENABLE(alloc-checks, AC_HELP_STRING([--enable-alloc-checks],
493 [ enable to memory allocation statistics, for debug purposes ]),
495 AC_ARG_ENABLE(alloc-lite, AC_HELP_STRING([--enable-alloc-lite],
496 [ enable for lightweight alloc assertions, for debug purposes ]),
498 AC_ARG_ENABLE(alloc-nonregional, AC_HELP_STRING([--enable-alloc-nonregional],
499 [ enable nonregional allocs, slow but exposes regional allocations to other memory purifiers, for debug purposes ]),
501 if test x_$enable_alloc_nonregional = x_yes; then
502 AC_DEFINE(UNBOUND_ALLOC_NONREGIONAL, 1, [use malloc not regions, for debug use])
504 if test x_$enable_alloc_checks = x_yes; then
505 AC_DEFINE(UNBOUND_ALLOC_STATS, 1, [use statistics for allocs and frees, for debug use])
506 SLDNS_ALLOCCHECK_EXTRA_OBJ="alloc.lo log.lo"
507 AC_SUBST(SLDNS_ALLOCCHECK_EXTRA_OBJ)
508 ASYNCLOOK_ALLOCCHECK_EXTRA_OBJ="alloc.lo"
509 AC_SUBST(ASYNCLOOK_ALLOCCHECK_EXTRA_OBJ)
511 if test x_$enable_alloc_lite = x_yes; then
512 AC_DEFINE(UNBOUND_ALLOC_LITE, 1, [use to enable lightweight alloc assertions, for debug use])
514 ACX_FUNC_MALLOC([unbound])
518 # check windows threads (we use them, not pthreads, on windows).
519 if test "$on_mingw" = "yes"; then
520 # check windows threads
521 AC_CHECK_HEADERS([windows.h],,, [AC_INCLUDES_DEFAULT])
522 AC_MSG_CHECKING([for CreateThread])
523 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
524 #ifdef HAVE_WINDOWS_H
528 HANDLE t = CreateThread(NULL, 0, NULL, NULL, 0, NULL);
531 AC_DEFINE(HAVE_WINDOWS_THREADS, 1, [Using Windows threads])
537 # not on mingw, check thread libraries.
539 # check for thread library.
540 # check this first, so that the pthread lib does not get linked in via
541 # libssl or libpython, and thus distorts the tests, and we end up using
542 # the non-threadsafe C libraries.
543 AC_ARG_WITH(pthreads, AC_HELP_STRING([--with-pthreads],
544 [use pthreads library, or --without-pthreads to disable threading support.]),
545 [ ],[ withval="yes" ])
547 if test x_$withval != x_no; then
549 AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
550 if test -n "$PTHREAD_LIBS"; then
551 LIBS="$PTHREAD_LIBS $LIBS"
553 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
556 AC_CHECK_TYPES([pthread_spinlock_t, pthread_rwlock_t],,,[#include <pthread.h>])
558 if echo "$CFLAGS" | $GREP -e "-pthread" >/dev/null; then
559 AC_MSG_CHECKING([if -pthread unused during linking])
560 # catch clang warning 'argument unused during compilation'
561 AC_LANG_CONFTEST([AC_LANG_SOURCE(AC_INCLUDES_DEFAULT
563 int main(void) {return 0;}
567 echo "$CC $CFLAGS -c conftest.c -o conftest.o" >&AS_MESSAGE_LOG_FD
568 $CC $CFLAGS -c conftest.c -o conftest.o 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD
571 echo "$CC $CFLAGS -Werror $LDFLAGS $LIBS -o conftest contest.o" >&AS_MESSAGE_LOG_FD
572 $CC $CFLAGS -Werror $LDFLAGS $LIBS -o conftest conftest.o 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD
573 if test $? -ne 0; then
575 CFLAGS=`echo "$CFLAGS" | sed -e 's/-pthread//'`
576 PTHREAD_CFLAGS_ONLY="-pthread"
577 AC_SUBST(PTHREAD_CFLAGS_ONLY)
583 fi # endif cc successful
584 rm -f conftest conftest.c conftest.o
585 fi # endif -pthread in CFLAGS
590 # check solaris thread library
591 AC_ARG_WITH(solaris-threads, AC_HELP_STRING([--with-solaris-threads],
592 [use solaris native thread library.]), [ ],[ withval="no" ])
593 ub_have_sol_threads=no
594 if test x_$withval != x_no; then
595 if test x_$ub_have_pthreads != x_no; then
596 AC_WARN([Have pthreads already, ignoring --with-solaris-threads])
598 AC_SEARCH_LIBS(thr_create, [thread],
600 AC_DEFINE(HAVE_SOLARIS_THREADS, 1, [Using Solaris threads])
602 ACX_CHECK_COMPILER_FLAG(mt, [CFLAGS="$CFLAGS -mt"],
603 [CFLAGS="$CFLAGS -D_REENTRANT"])
604 ub_have_sol_threads=yes
606 AC_ERROR([no solaris threads found.])
611 fi # end of non-mingw check of thread libraries
613 # Check for SYSLOG_FACILITY
614 AC_ARG_WITH(syslog-facility, AC_HELP_STRING([--with-syslog-facility=LOCAL0 - LOCAL7], [ set SYSLOG_FACILITY, default DAEMON ]),
615 [ UNBOUND_SYSLOG_FACILITY="$withval" ], [])
616 case "${UNBOUND_SYSLOG_FACILITY}" in
618 LOCAL[[0-7]]) UNBOUND_SYSLOG_FACILITY="LOG_${UNBOUND_SYSLOG_FACILITY}" ;;
620 *) UNBOUND_SYSLOG_FACILITY="LOG_DAEMON" ;;
623 AC_DEFINE_UNQUOTED(UB_SYSLOG_FACILITY,${UNBOUND_SYSLOG_FACILITY},[the SYSLOG_FACILITY to use, default LOG_DAEMON])
625 # Check for PyUnbound
626 AC_ARG_WITH(pyunbound,
627 AC_HELP_STRING([--with-pyunbound],
628 [build PyUnbound, or --without-pyunbound to skip it. (default=no)]),
629 [], [ withval="no" ])
633 if test x_$withval != x_no; then
634 ub_with_pyunbound=yes
638 # Check for Python module
639 AC_ARG_WITH(pythonmodule,
640 AC_HELP_STRING([--with-pythonmodule],
641 [build Python module, or --without-pythonmodule to disable script engine. (default=no)]),
642 [], [ withval="no" ])
645 if test x_$withval != x_no; then
646 ub_with_pythonmod=yes
650 # Check for Python & SWIG only on PyUnbound or PyModule
651 if test x_$ub_test_python != x_no; then
655 ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS
657 if test ! -z "$PYTHON_VERSION"; then
658 if test `$PYTHON -c "print('$PYTHON_VERSION' >= '2.4.0')"` = "False"; then
659 AC_ERROR([Python version >= 2.4.0 is required])
662 [PY_MAJOR_VERSION="`$PYTHON -c \"import sys; print(sys.version_info[0])\"`"]
663 AC_SUBST(PY_MAJOR_VERSION)
665 AC_DEFINE(HAVE_PYTHON,1,[Define if you have Python libraries and header files.])
666 if test -n "$LIBS"; then
667 LIBS="$PYTHON_LDFLAGS $LIBS"
669 LIBS="$PYTHON_LDFLAGS"
671 if test -n "$CPPFLAGS"; then
672 CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
674 CPPFLAGS="$PYTHON_CPPFLAGS"
677 PKG_CHECK_EXISTS(["python${PY_MAJOR_VERSION}"],
678 [PC_PY_DEPENDENCY="python${PY_MAJOR_VERSION}"],
679 [PC_PY_DEPENDENCY="python"])
680 AC_SUBST(PC_PY_DEPENDENCY)
684 AC_ARG_ENABLE(swig-version-check, AC_HELP_STRING([--disable-swig-version-check], [Disable swig version check to build python modules with older swig even though that is unreliable]))
685 if test "$enable_swig_version_check" = "yes"; then
690 AC_MSG_CHECKING(SWIG)
691 if test ! -x "$SWIG"; then
692 AC_ERROR([failed to find swig tool, install it, or do not build Python module and PyUnbound])
694 AC_DEFINE(HAVE_SWIG, 1, [Define if you have Swig libraries and header files.])
695 AC_SUBST(swig, "$SWIG")
696 AC_MSG_RESULT(present)
698 # If have Python & SWIG
700 if test x_$ub_with_pythonmod != x_no; then
701 AC_DEFINE(WITH_PYTHONMODULE, 1, [Define if you want Python module.])
702 WITH_PYTHONMODULE=yes
703 AC_SUBST(WITH_PYTHONMODULE)
704 PYTHONMOD_OBJ="pythonmod.lo pythonmod_utils.lo"
705 AC_SUBST(PYTHONMOD_OBJ)
706 PYTHONMOD_HEADER='$(srcdir)/pythonmod/pythonmod.h'
707 AC_SUBST(PYTHONMOD_HEADER)
708 PYTHONMOD_INSTALL=pythonmod-install
709 AC_SUBST(PYTHONMOD_INSTALL)
710 PYTHONMOD_UNINSTALL=pythonmod-uninstall
711 AC_SUBST(PYTHONMOD_UNINSTALL)
715 if test x_$ub_with_pyunbound != x_no; then
716 AC_DEFINE(WITH_PYUNBOUND, 1, [Define if you want PyUnbound.])
718 AC_SUBST(WITH_PYUNBOUND)
719 PYUNBOUND_OBJ="libunbound_wrap.lo"
720 AC_SUBST(PYUNBOUND_OBJ)
721 PYUNBOUND_TARGET="_unbound.la"
722 AC_SUBST(PYUNBOUND_TARGET)
723 PYUNBOUND_INSTALL=pyunbound-install
724 AC_SUBST(PYUNBOUND_INSTALL)
725 PYUNBOUND_UNINSTALL=pyunbound-uninstall
726 AC_SUBST(PYUNBOUND_UNINSTALL)
730 AC_MSG_RESULT([*** Python libraries not found, won't build PythonMod or PyUnbound ***])
736 if test "`uname`" = "NetBSD"; then
737 NETBSD_LINTFLAGS='"-D__RENAME(x)=" -D_NETINET_IN_H_'
738 AC_SUBST(NETBSD_LINTFLAGS)
740 CONFIG_DATE=`date +%Y%m%d`
741 AC_SUBST(CONFIG_DATE)
743 # Checks for libraries.
747 AC_ARG_WITH([nss], AC_HELP_STRING([--with-nss=path],
748 [use libnss instead of openssl, installed at path.]),
751 AC_DEFINE(HAVE_NSS, 1, [Use libnss for crypto])
752 if test "$withval" != "" -a "$withval" != "yes"; then
753 CPPFLAGS="$CPPFLAGS -I$withval/include/nss3"
754 LDFLAGS="$LDFLAGS -L$withval/lib"
755 ACX_RUNTIME_PATH_ADD([$withval/lib])
756 CPPFLAGS="-I$withval/include/nspr4 $CPPFLAGS"
758 CPPFLAGS="$CPPFLAGS -I/usr/include/nss3"
759 CPPFLAGS="-I/usr/include/nspr4 $CPPFLAGS"
761 LIBS="$LIBS -lnss3 -lnspr4"
768 AC_ARG_WITH([nettle], AC_HELP_STRING([--with-nettle=path],
769 [use libnettle as crypto library, installed at path.]),
772 AC_DEFINE(HAVE_NETTLE, 1, [Use libnettle for crypto])
773 AC_CHECK_HEADERS([nettle/dsa-compat.h],,, [AC_INCLUDES_DEFAULT])
774 if test "$withval" != "" -a "$withval" != "yes"; then
775 CPPFLAGS="$CPPFLAGS -I$withval/include/nettle"
776 LDFLAGS="$LDFLAGS -L$withval/lib"
777 ACX_RUNTIME_PATH_ADD([$withval/lib])
779 CPPFLAGS="$CPPFLAGS -I/usr/include/nettle"
781 LIBS="$LIBS -lhogweed -lnettle -lgmp"
787 if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then
792 # check if -lcrypt32 is needed because CAPIENG needs that. (on windows)
795 AC_MSG_CHECKING([if libssl needs -lcrypt32])
796 AC_TRY_LINK_FUNC([HMAC_Update], [
802 LIBS="$LIBS -lcrypt32"
805 AC_MSG_CHECKING([for LibreSSL])
806 if grep VERSION_TEXT $ssldir/include/openssl/opensslv.h | grep "LibreSSL" >/dev/null; then
808 AC_DEFINE([HAVE_LIBRESSL], [1], [Define if we have LibreSSL])
809 # libressl provides these compat functions, but they may also be
810 # declared by the OS in libc. See if they have been declared.
811 AC_CHECK_DECLS([strlcpy,strlcat,arc4random,arc4random_uniform])
815 AC_CHECK_HEADERS([openssl/conf.h openssl/engine.h openssl/bn.h openssl/dh.h openssl/dsa.h openssl/rsa.h],,, [AC_INCLUDES_DEFAULT])
816 AC_CHECK_FUNCS([OPENSSL_config EVP_sha1 EVP_sha256 EVP_sha512 FIPS_mode EVP_MD_CTX_new OpenSSL_add_all_digests OPENSSL_init_crypto EVP_cleanup ERR_load_crypto_strings CRYPTO_cleanup_all_ex_data ERR_free_strings RAND_cleanup DSA_SIG_set0 EVP_dss1 EVP_DigestVerify SSL_CTX_set_tlsext_ticket_key_cb EVP_aes_256_cbc EVP_EncryptInit_ex HMAC_Init_ex CRYPTO_THREADID_set_callback])
818 # these check_funcs need -lssl
821 AC_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])
824 AC_CHECK_DECLS([SSL_COMP_get_compression_methods,sk_SSL_COMP_pop_free,SSL_CTX_set_ecdh_auto], [], [], [
826 #ifdef HAVE_OPENSSL_ERR_H
827 #include <openssl/err.h>
830 #ifdef HAVE_OPENSSL_RAND_H
831 #include <openssl/rand.h>
834 #ifdef HAVE_OPENSSL_CONF_H
835 #include <openssl/conf.h>
838 #ifdef HAVE_OPENSSL_ENGINE_H
839 #include <openssl/engine.h>
841 #include <openssl/ssl.h>
842 #include <openssl/evp.h>
845 if test "$ac_cv_func_HMAC_Init_ex" = "yes"; then
846 # check function return type.
847 AC_MSG_CHECKING(the return type of HMAC_Init_ex)
848 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
849 #ifdef HAVE_OPENSSL_ERR_H
850 #include <openssl/err.h>
853 #ifdef HAVE_OPENSSL_RAND_H
854 #include <openssl/rand.h>
857 #ifdef HAVE_OPENSSL_CONF_H
858 #include <openssl/conf.h>
861 #ifdef HAVE_OPENSSL_ENGINE_H
862 #include <openssl/engine.h>
864 #include <openssl/ssl.h>
865 #include <openssl/evp.h>
867 HMAC_CTX* hmac_ctx = NULL;
868 void* hmac_key = NULL;
869 const EVP_MD* digest = NULL;
870 int x = HMAC_Init_ex(hmac_ctx, hmac_key, 32, digest, NULL);
876 AC_DEFINE([HMAC_INIT_EX_RETURNS_VOID], 1, [If HMAC_Init_ex() returns void])
884 AC_ARG_ENABLE(sha1, AC_HELP_STRING([--disable-sha1], [Disable SHA1 RRSIG support, does not disable nsec3 support]))
885 case "$enable_sha1" in
889 AC_DEFINE([USE_SHA1], [1], [Define this to enable SHA1 support.])
894 AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
895 case "$enable_sha2" in
899 AC_DEFINE([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.])
903 AC_ARG_ENABLE(subnet, AC_HELP_STRING([--enable-subnet], [Enable client subnet]))
904 case "$enable_subnet" in
906 AC_DEFINE([CLIENT_SUBNET], [1], [Define this to enable client subnet option.])
907 SUBNET_OBJ="edns-subnet.lo subnetmod.lo addrtree.lo subnet-whitelist.lo"
909 SUBNET_HEADER='$(srcdir)/edns-subnet/subnetmod.h $(srcdir)/edns-subnet/edns-subnet.h $(srcdir)/edns-subnet/subnet-whitelist.h $(srcdir)/edns-subnet/addrtree.h'
910 AC_SUBST(SUBNET_HEADER)
916 # check wether gost also works
917 AC_DEFUN([AC_CHECK_GOST_WORKS],
918 [AC_REQUIRE([AC_PROG_CC])
919 AC_MSG_CHECKING([if GOST works])
920 if test c${cross_compiling} = cno; then
922 if test -n "$ssldir"; then
923 CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib"
925 AC_RUN_IFELSE([AC_LANG_SOURCE([[
927 #include <openssl/ssl.h>
928 #include <openssl/evp.h>
929 #include <openssl/engine.h>
930 #include <openssl/conf.h>
931 /* routine to load gost (from sldns) */
932 int load_gost_id(void)
934 static int gost_id = 0;
935 const EVP_PKEY_ASN1_METHOD* meth;
938 if(gost_id) return gost_id;
940 /* see if configuration loaded gost implementation from other engine*/
941 meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1);
943 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
947 /* see if engine can be loaded already */
948 e = ENGINE_by_id("gost");
950 /* load it ourself, in case statically linked */
951 ENGINE_load_builtin_engines();
952 ENGINE_load_dynamic();
953 e = ENGINE_by_id("gost");
956 /* no gost engine in openssl */
959 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
965 meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1);
972 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
978 unsigned char digest[64]; /* its a 256-bit digest, so uses 32 bytes */
979 const char* str = "Hello world";
980 const unsigned char check[] = {
981 0x40 , 0xed , 0xf8 , 0x56 , 0x5a , 0xc5 , 0x36 , 0xe1 ,
982 0x33 , 0x7c , 0x7e , 0x87 , 0x62 , 0x1c , 0x42 , 0xe0 ,
983 0x17 , 0x1b , 0x5e , 0xce , 0xa8 , 0x46 , 0x65 , 0x4d ,
984 0x8d , 0x3e , 0x22 , 0x9b , 0xe1 , 0x30 , 0x19 , 0x9d
986 OPENSSL_config(NULL);
987 (void)load_gost_id();
988 md = EVP_get_digestbyname("md_gost94");
990 memset(digest, 0, sizeof(digest));
991 ctx = EVP_MD_CTX_create();
993 if(!EVP_DigestInit_ex(ctx, md, NULL)) return 3;
994 if(!EVP_DigestUpdate(ctx, str, 10)) return 4;
995 if(!EVP_DigestFinal_ex(ctx, digest, NULL)) return 5;
996 /* uncomment to see the hash calculated.
999 printf(" %2.2x", (int)digest[i]);
1002 if(memcmp(digest, check, sizeof(check)) != 0)
1006 ]])] , [eval "ac_cv_c_gost_works=yes"], [eval "ac_cv_c_gost_works=no"])
1009 eval "ac_cv_c_gost_works=maybe"
1011 AC_MSG_RESULT($ac_cv_c_gost_works)
1014 AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support]))
1016 if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then
1017 case "$enable_gost" in
1021 AC_CHECK_FUNC(EVP_PKEY_set_type_str, [:],[AC_MSG_ERROR([OpenSSL 1.0.0 is needed for GOST support])])
1022 AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([OpenSSL does not support ECC, needed for GOST support])])
1024 if test "$ac_cv_c_gost_works" != no; then
1026 AC_DEFINE([USE_GOST], [1], [Define this to enable GOST support.])
1030 fi dnl !USE_NSS && !USE_NETTLE
1032 AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support]))
1034 case "$enable_ecdsa" in
1038 if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then
1039 AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade or rerun with --disable-ecdsa])])
1040 AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade or rerun with --disable-ecdsa])])
1041 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
1042 #include <openssl/evp.h>
1044 # see if OPENSSL 1.0.0 or later (has EVP MD and Verify independency)
1045 AC_MSG_CHECKING([if openssl supports SHA2 and ECDSA with EVP])
1046 if grep OPENSSL_VERSION_TEXT $ssldir/include/openssl/opensslv.h | grep "OpenSSL" >/dev/null; then
1047 if grep OPENSSL_VERSION_NUMBER $ssldir/include/openssl/opensslv.h | grep 0x0 >/dev/null; then
1049 AC_DEFINE_UNQUOTED([USE_ECDSA_EVP_WORKAROUND], [1], [Define this to enable an EVP workaround for older openssl])
1051 AC_MSG_RESULT([yes])
1054 # not OpenSSL, thus likely LibreSSL, which supports it
1055 AC_MSG_RESULT([yes])
1058 # we now know we have ECDSA and the required curves.
1059 AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
1064 AC_ARG_ENABLE(dsa, AC_HELP_STRING([--disable-dsa], [Disable DSA support]))
1066 case "$enable_dsa" in
1070 # detect if DSA is supported, and turn it off if not.
1071 if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then
1072 AC_CHECK_FUNC(DSA_SIG_new, [
1073 AC_CHECK_TYPE(DSA_SIG*, [
1074 AC_DEFINE_UNQUOTED([USE_DSA], [1], [Define this to enable DSA support.])
1075 ], [if test "x$enable_dsa" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support DSA and you used --enable-dsa.])
1078 #ifdef HAVE_OPENSSL_ERR_H
1079 #include <openssl/err.h>
1082 #ifdef HAVE_OPENSSL_RAND_H
1083 #include <openssl/rand.h>
1086 #ifdef HAVE_OPENSSL_CONF_H
1087 #include <openssl/conf.h>
1090 #ifdef HAVE_OPENSSL_ENGINE_H
1091 #include <openssl/engine.h>
1094 ], [if test "x$enable_dsa" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support DSA and you used --enable-dsa.])
1097 AC_DEFINE_UNQUOTED([USE_DSA], [1], [Define this to enable DSA support.])
1102 AC_ARG_ENABLE(ed25519, AC_HELP_STRING([--disable-ed25519], [Disable ED25519 support]))
1104 case "$enable_ed25519" in
1108 if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then
1109 AC_CHECK_DECLS([NID_ED25519], [
1111 ], [ if test "x$enable_ed25519" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support ED25519 and you used --enable-ed25519.])
1112 fi ], [AC_INCLUDES_DEFAULT
1113 #include <openssl/evp.h>
1116 if test $USE_NETTLE = "yes"; then
1117 AC_CHECK_HEADERS([nettle/eddsa.h], use_ed25519="yes",, [AC_INCLUDES_DEFAULT])
1119 if test $use_ed25519 = "yes"; then
1120 AC_DEFINE_UNQUOTED([USE_ED25519], [1], [Define this to enable ED25519 support.])
1125 AC_ARG_ENABLE(ed448, AC_HELP_STRING([--disable-ed448], [Disable ED448 support]))
1127 case "$enable_ed448" in
1131 if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then
1132 AC_CHECK_DECLS([NID_ED448], [
1134 ], [ if test "x$enable_ed448" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support ED448 and you used --enable-ed448.])
1135 fi ], [AC_INCLUDES_DEFAULT
1136 #include <openssl/evp.h>
1139 if test $use_ed448 = "yes"; then
1140 AC_DEFINE_UNQUOTED([USE_ED448], [1], [Define this to enable ED448 support.])
1145 AC_ARG_ENABLE(event-api, AC_HELP_STRING([--enable-event-api], [Enable (experimental) pluggable event base libunbound API installed to unbound-event.h]))
1146 case "$enable_event_api" in
1148 AC_SUBST(UNBOUND_EVENT_INSTALL, [unbound-event-install])
1149 AC_SUBST(UNBOUND_EVENT_UNINSTALL, [unbound-event-uninstall])
1155 AC_ARG_ENABLE(tfo-client, AC_HELP_STRING([--enable-tfo-client], [Enable TCP Fast Open for client mode]))
1156 case "$enable_tfo_client" in
1159 Linux) AC_CHECK_DECL([MSG_FASTOPEN], [AC_MSG_WARN([Check the platform specific TFO kernel parameters are correctly configured to support client mode TFO])],
1160 [AC_MSG_ERROR([TCP Fast Open is not available for client mode: please rerun without --enable-tfo-client])],
1161 [AC_INCLUDES_DEFAULT
1162 #include <netinet/tcp.h>
1164 AC_DEFINE_UNQUOTED([USE_MSG_FASTOPEN], [1], [Define this to enable client TCP Fast Open.])
1166 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])],
1167 [AC_MSG_ERROR([TCP Fast Open is not available for client mode: please rerun without --enable-tfo-client])],
1168 [AC_INCLUDES_DEFAULT
1169 #include <sys/socket.h>
1171 AC_DEFINE_UNQUOTED([USE_OSX_MSG_FASTOPEN], [1], [Define this to enable client TCP Fast Open.])
1179 AC_ARG_ENABLE(tfo-server, AC_HELP_STRING([--enable-tfo-server], [Enable TCP Fast Open for server mode]))
1180 case "$enable_tfo_server" in
1182 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
1183 #include <netinet/tcp.h>
1185 AC_DEFINE_UNQUOTED([USE_TCP_FASTOPEN], [1], [Define this to enable server TCP Fast Open.])
1191 # check for libevent
1192 AC_ARG_WITH(libevent, AC_HELP_STRING([--with-libevent=pathname],
1193 [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.]),
1194 [ ],[ withval="no" ])
1195 if test x_$withval = x_yes -o x_$withval != x_no; then
1196 AC_MSG_CHECKING(for libevent)
1197 if test x_$withval = x_ -o x_$withval = x_yes; then
1198 withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr"
1200 for dir in $withval; do
1202 if test -f "$dir/include/event.h" -o -f "$dir/include/event2/event.h"; then
1203 found_libevent="yes"
1204 dnl assume /usr is in default path.
1205 if test "$thedir" != "/usr"; then
1206 CPPFLAGS="$CPPFLAGS -I$thedir/include"
1211 if test x_$found_libevent != x_yes; then
1212 if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then
1213 # libevent source directory
1214 AC_MSG_RESULT(found in $thedir)
1215 CPPFLAGS="$CPPFLAGS -I$thedir -I$thedir/include"
1217 BAK_LDFLAGS="$LDFLAGS"
1218 # remove evdns from linking
1219 mkdir build >/dev/null 2>&1
1220 mkdir build/libevent >/dev/null 2>&1
1221 mkdir build/libevent/.libs >/dev/null 2>&1
1222 ev_files_o=`ls $thedir/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o`
1223 ev_files_lo=`ls $thedir/*.lo | grep -v evdns\.lo | grep -v bufferevent_openssl\.lo`
1224 ev_files_libso=`ls $thedir/.libs/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o`
1225 cp $ev_files_o build/libevent
1226 cp $ev_files_lo build/libevent
1227 cp $ev_files_libso build/libevent/.libs
1228 LATE_LDFLAGS="build/libevent/*.lo -lm"
1229 LDFLAGS="build/libevent/*.o $LDFLAGS -lm"
1231 AC_MSG_ERROR([Cannot find the libevent library in $withval
1232 You can restart ./configure --with-libevent=no to use a builtin alternative.
1233 Please note that this alternative is not as capable as libevent when using
1234 large outgoing port ranges. ])
1237 AC_MSG_RESULT(found in $thedir)
1238 dnl if event2 exists and no event lib in dir itself, use subdir
1239 if test ! -f $thedir/lib/libevent.a -a ! -f $thedir/lib/libevent.so -a -d "$thedir/lib/event2"; then
1240 LDFLAGS="$LDFLAGS -L$thedir/lib/event2"
1241 ACX_RUNTIME_PATH_ADD([$thedir/lib/event2])
1243 dnl assume /usr is in default path, do not add "".
1244 if test "$thedir" != "/usr" -a "$thedir" != ""; then
1245 LDFLAGS="$LDFLAGS -L$thedir/lib"
1246 ACX_RUNTIME_PATH_ADD([$thedir/lib])
1250 # check for library used by libevent after 1.3c
1251 AC_SEARCH_LIBS([clock_gettime], [rt])
1253 # is the event.h header libev or libevent?
1254 AC_CHECK_HEADERS([event.h],,, [AC_INCLUDES_DEFAULT])
1255 AC_CHECK_DECL(EV_VERSION_MAJOR, [
1256 AC_SEARCH_LIBS(event_set, [ev])
1258 AC_SEARCH_LIBS(event_set, [event])
1259 ],[AC_INCLUDES_DEFAULT
1262 AC_CHECK_FUNCS([event_base_free]) # only in libevent 1.2 and later
1263 AC_CHECK_FUNCS([event_base_once]) # only in libevent 1.4.1 and later
1264 AC_CHECK_FUNCS([event_base_new]) # only in libevent 1.4.1 and later
1265 AC_CHECK_FUNCS([event_base_get_method]) # only in libevent 1.4.3 and later
1266 AC_CHECK_FUNCS([ev_loop]) # only in libev. (tested on 3.51)
1267 AC_CHECK_FUNCS([ev_default_loop]) # only in libev. (tested on 4.00)
1268 AC_CHECK_FUNCS([event_assign]) # in libevent, for thread-safety
1269 AC_CHECK_DECLS([evsignal_assign], [], [], [AC_INCLUDES_DEFAULT
1273 # include "event2/event.h"
1276 PC_LIBEVENT_DEPENDENCY="libevent"
1277 AC_SUBST(PC_LIBEVENT_DEPENDENCY)
1278 if test -n "$BAK_LDFLAGS_SET"; then
1279 LDFLAGS="$BAK_LDFLAGS"
1282 AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events])
1285 # check for libexpat
1286 AC_ARG_WITH(libexpat, AC_HELP_STRING([--with-libexpat=path],
1287 [specify explicit path for libexpat.]),
1288 [ ],[ withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" ])
1289 AC_MSG_CHECKING(for libexpat)
1291 for dir in $withval ; do
1292 if test -f "$dir/include/expat.h"; then
1293 found_libexpat="yes"
1294 dnl assume /usr is in default path.
1295 if test "$dir" != "/usr"; then
1296 CPPFLAGS="$CPPFLAGS -I$dir/include"
1297 LDFLAGS="$LDFLAGS -L$dir/lib"
1299 AC_MSG_RESULT(found in $dir)
1303 if test x_$found_libexpat != x_yes; then
1304 AC_ERROR([Could not find libexpat, expat.h])
1306 AC_CHECK_HEADERS([expat.h],,, [AC_INCLUDES_DEFAULT])
1307 AC_CHECK_DECLS([XML_StopParser], [], [], [AC_INCLUDES_DEFAULT
1311 # hiredis (redis C client for cachedb)
1312 AC_ARG_WITH(libhiredis, AC_HELP_STRING([--with-libhiredis=path],
1313 [specify explicit path for libhiredis.]),
1314 [ ],[ withval="no" ])
1315 found_libhiredis="no"
1316 if test x_$withval = x_yes -o x_$withval != x_no; then
1317 AC_MSG_CHECKING(for libhiredis)
1318 if test x_$withval = x_ -o x_$withval = x_yes; then
1319 withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr"
1321 for dir in $withval ; do
1322 if test -f "$dir/include/hiredis/hiredis.h"; then
1323 found_libhiredis="yes"
1324 dnl assume /usr is in default path.
1325 if test "$dir" != "/usr"; then
1326 CPPFLAGS="$CPPFLAGS -I$dir/include"
1327 LDFLAGS="$LDFLAGS -L$dir/lib"
1329 AC_MSG_RESULT(found in $dir)
1330 AC_DEFINE([USE_REDIS], [1], [Define this to use hiredis client.])
1331 LIBS="$LIBS -lhiredis"
1335 if test x_$found_libhiredis != x_yes; then
1336 AC_ERROR([Could not find libhiredis, hiredis.h])
1338 AC_CHECK_HEADERS([hiredis/hiredis.h],,, [AC_INCLUDES_DEFAULT])
1339 AC_CHECK_DECLS([redisConnect], [], [], [AC_INCLUDES_DEFAULT
1340 #include <hiredis/hiredis.h>
1344 # set static linking for uninstalled libraries if requested
1347 AC_ARG_ENABLE(static-exe, AC_HELP_STRING([--enable-static-exe],
1348 [ enable to compile executables statically against (event) uninstalled libs, for debug purposes ]),
1350 if test x_$enable_static_exe = x_yes; then
1352 if test "$on_mingw" = yes; then
1353 staticexe="-all-static"
1354 # for static compile, include gdi32 and zlib here.
1355 if echo $LIBS | grep 'lgdi32' >/dev/null; then
1358 LIBS="$LIBS -lgdi32"
1364 # set full static linking if requested
1365 AC_ARG_ENABLE(fully-static, AC_HELP_STRING([--enable-fully-static],
1366 [ enable to compile fully static ]),
1368 if test x_$enable_fully_static = x_yes; then
1369 staticexe="-all-static"
1370 if test "$on_mingw" = yes; then
1371 # for static compile, include gdi32 and zlib here.
1372 if echo $LIBS | grep 'lgdi32' >/dev/null; then
1375 LIBS="$LIBS -lgdi32"
1381 # set lock checking if requested
1382 AC_ARG_ENABLE(lock_checks, AC_HELP_STRING([--enable-lock-checks],
1383 [ enable to check lock and unlock calls, for debug purposes ]),
1385 if test x_$enable_lock_checks = x_yes; then
1386 AC_DEFINE(ENABLE_LOCK_CHECKS, 1, [Define if you want to use debug lock checking (slow).])
1387 CHECKLOCK_OBJ="checklocks.lo"
1388 AC_SUBST(CHECKLOCK_OBJ)
1391 ACX_CHECK_GETADDRINFO_WITH_INCLUDES
1392 if test "$USE_WINSOCK" = 1; then
1393 AC_DEFINE(UB_ON_WINDOWS, 1, [Use win32 resources and API])
1394 AC_CHECK_HEADERS([iphlpapi.h],,, [AC_INCLUDES_DEFAULT
1395 #include <windows.h>
1397 AC_CHECK_TOOL(WINDRES, windres)
1398 LIBS="$LIBS -liphlpapi -lcrypt32"
1399 WINAPPS="unbound-service-install.exe unbound-service-remove.exe anchor-update.exe"
1401 WIN_DAEMON_SRC="winrc/win_svc.c winrc/w_inst.c"
1402 AC_SUBST(WIN_DAEMON_SRC)
1403 WIN_DAEMON_OBJ="win_svc.lo w_inst.lo"
1404 AC_SUBST(WIN_DAEMON_OBJ)
1405 WIN_DAEMON_OBJ_LINK="rsrc_unbound.o"
1406 AC_SUBST(WIN_DAEMON_OBJ_LINK)
1407 WIN_HOST_OBJ_LINK="rsrc_unbound_host.o"
1408 AC_SUBST(WIN_HOST_OBJ_LINK)
1409 WIN_UBANCHOR_OBJ_LINK="rsrc_unbound_anchor.o log.lo locks.lo"
1410 AC_SUBST(WIN_UBANCHOR_OBJ_LINK)
1411 WIN_CONTROL_OBJ_LINK="rsrc_unbound_control.o"
1412 AC_SUBST(WIN_CONTROL_OBJ_LINK)
1413 WIN_CHECKCONF_OBJ_LINK="rsrc_unbound_checkconf.o"
1414 AC_SUBST(WIN_CHECKCONF_OBJ_LINK)
1416 if test $ac_cv_func_getaddrinfo = no; then
1417 AC_LIBOBJ([fake-rfc2553])
1419 # check after getaddrinfo for its libraries
1420 ACX_FUNC_IOCTLSOCKET
1422 # see if daemon(3) exists, and if it is deprecated.
1423 AC_CHECK_FUNCS([daemon])
1424 if test $ac_cv_func_daemon = yes; then
1425 ACX_FUNC_DEPRECATED([daemon], [(void)daemon(0, 0);], [
1430 AC_CHECK_MEMBERS([struct sockaddr_un.sun_len],,,[
1432 #ifdef HAVE_SYS_UN_H
1436 AC_CHECK_MEMBERS([struct in_pktinfo.ipi_spec_dst],,,[
1438 #if HAVE_SYS_PARAM_H
1439 #include <sys/param.h>
1442 #ifdef HAVE_SYS_SOCKET_H
1443 #include <sys/socket.h>
1446 #ifdef HAVE_SYS_UIO_H
1447 #include <sys/uio.h>
1450 #ifdef HAVE_NETINET_IN_H
1451 #include <netinet/in.h>
1454 #ifdef HAVE_NETINET_TCP_H
1455 #include <netinet/tcp.h>
1458 #ifdef HAVE_ARPA_INET_H
1459 #include <arpa/inet.h>
1462 #ifdef HAVE_WINSOCK2_H
1463 #include <winsock2.h>
1466 #ifdef HAVE_WS2TCPIP_H
1467 #include <ws2tcpip.h>
1470 AC_SEARCH_LIBS([setusercontext], [util])
1471 AC_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])
1472 AC_CHECK_FUNCS([setresuid],,[AC_CHECK_FUNCS([setreuid])])
1473 AC_CHECK_FUNCS([setresgid],,[AC_CHECK_FUNCS([setregid])])
1475 # check if setreuid en setregid fail, on MacOSX10.4(darwin8).
1476 if echo $target_os | grep darwin8 > /dev/null; then
1477 AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work])
1479 AC_CHECK_DECLS([inet_pton,inet_ntop], [], [], [
1481 #ifdef HAVE_NETINET_IN_H
1482 #include <netinet/in.h>
1485 #ifdef HAVE_NETINET_TCP_H
1486 #include <netinet/tcp.h>
1489 #ifdef HAVE_ARPA_INET_H
1490 #include <arpa/inet.h>
1493 #ifdef HAVE_WINSOCK2_H
1494 #include <winsock2.h>
1497 #ifdef HAVE_WS2TCPIP_H
1498 #include <ws2tcpip.h>
1501 AC_REPLACE_FUNCS(inet_aton)
1502 AC_REPLACE_FUNCS(inet_pton)
1503 AC_REPLACE_FUNCS(inet_ntop)
1504 AC_REPLACE_FUNCS(snprintf)
1505 # test if snprintf return the proper length
1506 if test "x$ac_cv_func_snprintf" = xyes; then
1507 if test c${cross_compiling} = cno; then
1508 AC_MSG_CHECKING([for correct snprintf return value])
1509 AC_RUN_IFELSE([AC_LANG_SOURCE(AC_INCLUDES_DEFAULT
1511 int main(void) { return !(snprintf(NULL, 0, "test") == 4); }
1512 ]])], [AC_MSG_RESULT(yes)], [
1514 AC_DEFINE([SNPRINTF_RET_BROKEN], [], [define if (v)snprintf does not return length needed, (but length used)])
1519 AC_REPLACE_FUNCS(strlcat)
1520 AC_REPLACE_FUNCS(strlcpy)
1521 AC_REPLACE_FUNCS(memmove)
1522 AC_REPLACE_FUNCS(gmtime_r)
1523 AC_REPLACE_FUNCS(isblank)
1524 AC_REPLACE_FUNCS(explicit_bzero)
1525 dnl without CTIME, ARC4-functions and without reallocarray.
1526 LIBOBJ_WITHOUT_CTIMEARC4="$LIBOBJS"
1527 AC_SUBST(LIBOBJ_WITHOUT_CTIMEARC4)
1528 AC_MSG_CHECKING([for reallocarray])
1529 AC_LINK_IFELSE([AC_LANG_SOURCE(AC_INCLUDES_DEFAULT
1531 #ifndef _OPENBSD_SOURCE
1532 #define _OPENBSD_SOURCE 1
1536 void* p = reallocarray(NULL, 10, 100);
1540 ]])], [AC_MSG_RESULT(yes)
1541 AC_DEFINE(HAVE_REALLOCARRAY, 1, [If we have reallocarray(3)])
1544 AC_LIBOBJ(reallocarray)
1546 AC_CHECK_DECLS([reallocarray])
1547 if test "$USE_NSS" = "no"; then
1548 AC_REPLACE_FUNCS(arc4random)
1549 AC_REPLACE_FUNCS(arc4random_uniform)
1550 if test "$ac_cv_func_arc4random" = "no"; then
1551 AC_LIBOBJ(arc4_lock)
1552 AC_CHECK_FUNCS([getentropy],,[
1553 if test "$USE_WINSOCK" = 1; then
1554 AC_LIBOBJ(getentropy_win)
1558 AC_LIBOBJ(getentropy_osx)
1560 *solaris*|*sunos*|SunOS)
1561 AC_LIBOBJ(getentropy_solaris)
1562 AC_CHECK_HEADERS([sys/sha2.h],, [
1563 AC_CHECK_FUNCS([SHA512_Update],,[
1566 ], [AC_INCLUDES_DEFAULT])
1567 if test "$ac_cv_header_sys_sha2_h" = "yes"; then
1568 # this lib needed for sha2 on solaris
1571 AC_SEARCH_LIBS([clock_gettime], [rt])
1574 AC_LIBOBJ(getentropy_freebsd)
1577 AC_LIBOBJ(getentropy_linux)
1578 AC_CHECK_FUNCS([SHA512_Update],,[
1579 AC_DEFINE([COMPAT_SHA512], [1], [Do sha512 definitions in config.h])
1582 AC_CHECK_HEADERS([sys/sysctl.h],,, [AC_INCLUDES_DEFAULT])
1583 AC_CHECK_FUNCS([getauxval])
1584 AC_SEARCH_LIBS([clock_gettime], [rt])
1591 LIBOBJ_WITHOUT_CTIME="$LIBOBJS"
1592 AC_SUBST(LIBOBJ_WITHOUT_CTIME)
1593 AC_REPLACE_FUNCS(ctime_r)
1594 AC_REPLACE_FUNCS(strsep)
1596 AC_ARG_ENABLE(allsymbols, AC_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]))
1597 case "$enable_allsymbols" in
1599 COMMON_OBJ_ALL_SYMBOLS=""
1601 EXTRALINK="-L. -L.libs -lunbound"
1602 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])
1605 COMMON_OBJ_ALL_SYMBOLS='$(COMMON_OBJ)'
1606 UBSYMS='-export-symbols $(srcdir)/libunbound/ubsyms.def'
1610 AC_SUBST(COMMON_OBJ_ALL_SYMBOLS)
1613 if test x_$enable_lock_checks = x_yes; then
1614 UBSYMS="-export-symbols clubsyms.def"
1615 cp ${srcdir}/libunbound/ubsyms.def clubsyms.def
1616 echo lock_protect >> clubsyms.def
1617 echo lock_unprotect >> clubsyms.def
1618 echo lock_get_mem >> clubsyms.def
1619 echo checklock_start >> clubsyms.def
1620 echo checklock_stop >> clubsyms.def
1621 echo checklock_lock >> clubsyms.def
1622 echo checklock_unlock >> clubsyms.def
1623 echo checklock_init >> clubsyms.def
1624 echo checklock_thrcreate >> clubsyms.def
1625 echo checklock_thrjoin >> clubsyms.def
1628 # check for dnstap if requested
1629 dt_DNSTAP([$UNBOUND_RUN_DIR/dnstap.sock],
1631 AC_DEFINE([USE_DNSTAP], [1], [Define to 1 to enable dnstap support])
1632 AC_SUBST([ENABLE_DNSTAP], [1])
1634 AC_SUBST([opt_dnstap_socket_path])
1635 ACX_ESCAPE_BACKSLASH($opt_dnstap_socket_path, hdr_dnstap_socket_path)
1636 AC_DEFINE_UNQUOTED(DNSTAP_SOCKET_PATH,
1637 ["$hdr_dnstap_socket_path"], [default dnstap socket path])
1639 AC_SUBST([DNSTAP_SRC], ["dnstap/dnstap.c dnstap/dnstap.pb-c.c"])
1640 AC_SUBST([DNSTAP_OBJ], ["dnstap.lo dnstap.pb-c.lo"])
1643 AC_SUBST([ENABLE_DNSTAP], [0])
1647 # check for dnscrypt if requested
1649 AC_DEFINE([USE_DNSCRYPT], [1], [Define to 1 to enable dnscrypt support])
1650 AC_SUBST([ENABLE_DNSCRYPT], [1])
1652 AC_SUBST([DNSCRYPT_SRC], ["dnscrypt/dnscrypt.c"])
1653 AC_SUBST([DNSCRYPT_OBJ], ["dnscrypt.lo"])
1656 AC_SUBST([ENABLE_DNSCRYPT], [0])
1660 # check for cachedb if requested
1661 AC_ARG_ENABLE(cachedb, AC_HELP_STRING([--enable-cachedb], [enable cachedb module that can use external cache storage]))
1662 # turn on cachedb when hiredis support is enabled.
1663 if test "$found_libhiredis" = "yes"; then enable_cachedb="yes"; fi
1664 case "$enable_cachedb" in
1666 AC_DEFINE([USE_CACHEDB], [1], [Define to 1 to use cachedb support])
1673 # check for ipsecmod if requested
1674 AC_ARG_ENABLE(ipsecmod, AC_HELP_STRING([--enable-ipsecmod], [Enable ipsecmod module that facilitates opportunistic IPsec]))
1675 case "$enable_ipsecmod" in
1677 AC_DEFINE([USE_IPSECMOD], [1], [Define to 1 to use ipsecmod support.])
1678 IPSECMOD_OBJ="ipsecmod.lo ipsecmod-whitelist.lo"
1679 AC_SUBST(IPSECMOD_OBJ)
1680 IPSECMOD_HEADER='$(srcdir)/ipsecmod/ipsecmod.h $(srcdir)/ipsecmod/ipsecmod-whitelist.h'
1681 AC_SUBST(IPSECMOD_HEADER)
1688 # check for ipset if requested
1689 AC_ARG_ENABLE(ipset, AC_HELP_STRING([--enable-ipset], [enable ipset module]))
1690 case "$enable_ipset" in
1692 AC_DEFINE([USE_IPSET], [1], [Define to 1 to use ipset support])
1693 IPSET_SRC="ipset/ipset.c"
1695 IPSET_OBJ="ipset.lo"
1699 AC_ARG_WITH(libmnl, AC_HELP_STRING([--with-libmnl=path],
1700 [specify explicit path for libmnl.]),
1701 [ ],[ withval="yes" ])
1703 AC_MSG_CHECKING(for libmnl)
1704 if test x_$withval = x_ -o x_$withval = x_yes; then
1705 withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr"
1707 for dir in $withval ; do
1708 if test -f "$dir/include/libmnl/libmnl.h"; then
1710 dnl assume /usr is in default path.
1711 if test "$dir" != "/usr"; then
1712 CPPFLAGS="$CPPFLAGS -I$dir/include"
1713 LDFLAGS="$LDFLAGS -L$dir/lib"
1715 AC_MSG_RESULT(found in $dir)
1720 if test x_$found_libmnl != x_yes; then
1721 AC_ERROR([Could not find libmnl, libmnl.h])
1729 AC_MSG_CHECKING([if ${MAKE:-make} supports $< with implicit rule in scope])
1730 # on openBSD, the implicit rule make $< work.
1731 # on Solaris, it does not work ($? is changed sources, $^ lists dependencies).
1733 cat >conftest.make <<EOF
1736 conftest.lo foo.lo bla.lo:
1737 if test -f "\$<"; then touch \$@; fi
1741 if test -f "\$<"; then touch \$@; fi
1743 conftest.lo: conftest.dir/conftest.c
1746 touch conftest.dir/conftest.c
1747 rm -f conftest.lo conftest.c
1748 ${MAKE:-make} -f conftest.make >/dev/null
1749 rm -f conftest.make conftest.c conftest.dir/conftest.c
1751 if test ! -f conftest.lo; then
1753 SOURCEDETERMINE='echo "$^" | awk "-F " "{print \$$1;}" > .source'
1754 SOURCEFILE='`cat .source`'
1761 AC_SUBST(SOURCEDETERMINE)
1762 AC_SUBST(SOURCEFILE)
1764 # see if we want to build the library or everything
1765 ALLTARGET="alltargets"
1766 INSTALLTARGET="install-all"
1767 AC_ARG_WITH(libunbound-only, AC_HELP_STRING([--with-libunbound-only],
1768 [do not build daemon and tool programs]),
1770 if test "$withval" = "yes"; then
1772 INSTALLTARGET="install-lib"
1775 if test $ALLTARGET = "alltargets"; then
1776 if test $USE_NSS = "yes"; then
1777 AC_ERROR([--with-nss can only be used in combination with --with-libunbound-only.])
1779 if test $USE_NETTLE = "yes"; then
1780 AC_ERROR([--with-nettle can only be used in combination with --with-libunbound-only.])
1785 AC_SUBST(INSTALLTARGET)
1788 if test -n "$LATE_LDFLAGS"; then
1789 LDFLAGS="$LATE_LDFLAGS $LDFLAGS"
1791 # remove start spaces
1792 LDFLAGS=`echo "$LDFLAGS"|sed -e 's/^ *//'`
1793 LIBS=`echo "$LIBS"|sed -e 's/^ *//'`
1795 AC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [10240], [Define to the maximum message length to pass to syslog.])
1798 dnl this must be first AH_CONFIG, to define the flags before any includes.
1799 AHX_CONFIG_EXT_FLAGS
1803 #ifndef _OPENBSD_SOURCE
1804 #define _OPENBSD_SOURCE 1
1807 #ifndef UNBOUND_DEBUG
1813 /** Use small-ldns codebase */
1816 # define LDNS_BUILD_CONFIG_HAVE_SSL 1
1829 #ifdef HAVE_STDARG_H
1833 #ifdef HAVE_STDINT_H
1839 #if HAVE_SYS_PARAM_H
1840 #include <sys/param.h>
1843 #ifdef HAVE_SYS_SOCKET_H
1844 #include <sys/socket.h>
1847 #ifdef HAVE_SYS_UIO_H
1848 #include <sys/uio.h>
1851 #ifdef HAVE_NETINET_IN_H
1852 #include <netinet/in.h>
1855 #ifdef HAVE_NETINET_TCP_H
1856 #include <netinet/tcp.h>
1859 #ifdef HAVE_ARPA_INET_H
1860 #include <arpa/inet.h>
1863 #ifdef HAVE_WINSOCK2_H
1864 #include <winsock2.h>
1867 #ifdef HAVE_WS2TCPIP_H
1868 #include <ws2tcpip.h>
1872 #define ARG_LL "%ll"
1874 #define ARG_LL "%I64"
1878 #define AF_LOCAL AF_UNIX
1882 AHX_CONFIG_FORMAT_ATTRIBUTE
1883 AHX_CONFIG_UNUSED_ATTRIBUTE
1885 AHX_CONFIG_MAXHOSTNAMELEN
1886 #if !defined(HAVE_SNPRINTF) || defined(SNPRINTF_RET_BROKEN)
1887 #define snprintf snprintf_unbound
1888 #define vsnprintf vsnprintf_unbound
1890 int snprintf (char *str, size_t count, const char *fmt, ...);
1891 int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
1892 #endif /* HAVE_SNPRINTF or SNPRINTF_RET_BROKEN */
1893 AHX_CONFIG_INET_PTON(unbound)
1894 AHX_CONFIG_INET_NTOP(unbound)
1895 AHX_CONFIG_INET_ATON(unbound)
1896 AHX_CONFIG_MEMMOVE(unbound)
1897 AHX_CONFIG_STRLCAT(unbound)
1898 AHX_CONFIG_STRLCPY(unbound)
1899 AHX_CONFIG_GMTIME_R(unbound)
1900 AHX_CONFIG_REALLOCARRAY(unbound)
1901 AHX_CONFIG_W32_SLEEP
1902 AHX_CONFIG_W32_USLEEP
1903 AHX_CONFIG_W32_RANDOM
1904 AHX_CONFIG_W32_SRANDOM
1905 AHX_CONFIG_W32_FD_SET_T
1906 AHX_CONFIG_IPV6_MIN_MTU
1907 AHX_MEMCMP_BROKEN(unbound)
1910 #ifndef HAVE_CTIME_R
1911 #define ctime_r unbound_ctime_r
1912 char *ctime_r(const time_t *timep, char *buf);
1916 #define strsep unbound_strsep
1917 char *strsep(char **stringp, const char *delim);
1920 #ifndef HAVE_ISBLANK
1921 #define isblank unbound_isblank
1925 #ifndef HAVE_EXPLICIT_BZERO
1926 #define explicit_bzero unbound_explicit_bzero
1927 void explicit_bzero(void* buf, size_t len);
1930 #if defined(HAVE_INET_NTOP) && !HAVE_DECL_INET_NTOP
1931 const char *inet_ntop(int af, const void *src, char *dst, size_t size);
1934 #if defined(HAVE_INET_PTON) && !HAVE_DECL_INET_PTON
1935 int inet_pton(int af, const char* src, void* dst);
1938 #if !defined(HAVE_STRPTIME) || !defined(STRPTIME_WORKS)
1939 #define strptime unbound_strptime
1941 char *strptime(const char *s, const char *format, struct tm *tm);
1944 #if !HAVE_DECL_REALLOCARRAY
1945 void *reallocarray(void *ptr, size_t nmemb, size_t size);
1948 #ifdef HAVE_LIBRESSL
1949 # if !HAVE_DECL_STRLCPY
1950 size_t strlcpy(char *dst, const char *src, size_t siz);
1952 # if !HAVE_DECL_STRLCAT
1953 size_t strlcat(char *dst, const char *src, size_t siz);
1955 # if !HAVE_DECL_ARC4RANDOM && defined(HAVE_ARC4RANDOM)
1956 uint32_t arc4random(void);
1958 # if !HAVE_DECL_ARC4RANDOM_UNIFORM && defined(HAVE_ARC4RANDOM_UNIFORM)
1959 uint32_t arc4random_uniform(uint32_t upper_bound);
1961 #endif /* HAVE_LIBRESSL */
1962 #ifndef HAVE_ARC4RANDOM
1963 int getentropy(void* buf, size_t len);
1964 uint32_t arc4random(void);
1965 void arc4random_buf(void* buf, size_t n);
1966 void _ARC4_LOCK(void);
1967 void _ARC4_UNLOCK(void);
1968 void _ARC4_LOCK_DESTROY(void);
1970 #ifndef HAVE_ARC4RANDOM_UNIFORM
1971 uint32_t arc4random_uniform(uint32_t upper_bound);
1973 #ifdef COMPAT_SHA512
1974 #ifndef SHA512_DIGEST_LENGTH
1975 #define SHA512_BLOCK_LENGTH 128
1976 #define SHA512_DIGEST_LENGTH 64
1977 #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
1978 typedef struct _SHA512_CTX {
1980 uint64_t bitcount[2];
1981 uint8_t buffer[SHA512_BLOCK_LENGTH];
1983 #endif /* SHA512_DIGEST_LENGTH */
1984 void SHA512_Init(SHA512_CTX*);
1985 void SHA512_Update(SHA512_CTX*, void*, size_t);
1986 void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
1987 unsigned char *SHA512(void* data, unsigned int data_len, unsigned char *digest);
1988 #endif /* COMPAT_SHA512 */
1992 #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))
1993 /* using version of libevent that is not threadsafe. */
1994 # define LIBEVENT_SIGNAL_PROBLEM 1
1997 #ifndef CHECKED_INET6
1998 # define CHECKED_INET6
2002 # define AF_INET6 28
2004 #endif /* CHECKED_INET6 */
2006 #ifndef HAVE_GETADDRINFO
2007 struct sockaddr_storage;
2008 #include "compat/fake-rfc2553.h"
2011 #ifdef UNBOUND_ALLOC_STATS
2012 # define malloc(s) unbound_stat_malloc_log(s, __FILE__, __LINE__, __func__)
2013 # define calloc(n,s) unbound_stat_calloc_log(n, s, __FILE__, __LINE__, __func__)
2014 # define free(p) unbound_stat_free_log(p, __FILE__, __LINE__, __func__)
2015 # define realloc(p,s) unbound_stat_realloc_log(p, s, __FILE__, __LINE__, __func__)
2016 void *unbound_stat_malloc(size_t size);
2017 void *unbound_stat_calloc(size_t nmemb, size_t size);
2018 void unbound_stat_free(void *ptr);
2019 void *unbound_stat_realloc(void *ptr, size_t size);
2020 void *unbound_stat_malloc_log(size_t size, const char* file, int line,
2022 void *unbound_stat_calloc_log(size_t nmemb, size_t size, const char* file,
2023 int line, const char* func);
2024 void unbound_stat_free_log(void *ptr, const char* file, int line,
2026 void *unbound_stat_realloc_log(void *ptr, size_t size, const char* file,
2027 int line, const char* func);
2028 #elif defined(UNBOUND_ALLOC_LITE)
2029 # include "util/alloc.h"
2030 #endif /* UNBOUND_ALLOC_LITE and UNBOUND_ALLOC_STATS */
2032 /** default port for DNS traffic. */
2033 #define UNBOUND_DNS_PORT 53
2034 /** default port for DNS over TLS traffic. */
2035 #define UNBOUND_DNS_OVER_TLS_PORT 853
2036 /** default port for unbound control traffic, registered port with IANA,
2037 ub-dns-control 8953/tcp unbound dns nameserver control */
2038 #define UNBOUND_CONTROL_PORT 8953
2039 /** the version of unbound-control that this software implements */
2040 #define UNBOUND_CONTROL_VERSION 1
2044 dnl if we build from source tree, the man pages need @date@ and @version@
2045 dnl if this is a distro tarball, that was already done by makedist.sh
2046 AC_SUBST(version, [VERSION_MAJOR.VERSION_MINOR.VERSION_MICRO])
2047 AC_SUBST(date, [`date +'%b %e, %Y'`])
2049 AC_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])
2050 AC_CONFIG_HEADER([config.h])