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