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