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