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