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