1933707f3Ssthen# -*- Autoconf -*- 2933707f3Ssthen# Process this file with autoconf to produce a configure script. 39982a05dSsthenAC_PREREQ([2.56]) 4933707f3Ssthensinclude(acx_nlnetlabs.m4) 5e9c7b4efSsthensinclude(ax_pthread.m4) 6933707f3Ssthensinclude(acx_python.m4) 72bdc0ed1Ssthensinclude(ax_pkg_swig.m4) 8e10d3884Sbradsinclude(dnstap/dnstap.m4) 92be9e038Ssthensinclude(dnscrypt/dnscrypt.m4) 10933707f3Ssthen 11e9c7b4efSsthen# must be numbers. ac_defun because of later processing 12e9c7b4efSsthenm4_define([VERSION_MAJOR],[1]) 1398bc733bSsthenm4_define([VERSION_MINOR],[21]) 14*bdcafcd9Ssthenm4_define([VERSION_MICRO],[1]) 159982a05dSsthenAC_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]) 16e9c7b4efSsthenAC_SUBST(UNBOUND_VERSION_MAJOR, [VERSION_MAJOR]) 17e9c7b4efSsthenAC_SUBST(UNBOUND_VERSION_MINOR, [VERSION_MINOR]) 18e9c7b4efSsthenAC_SUBST(UNBOUND_VERSION_MICRO, [VERSION_MICRO]) 19933707f3Ssthen 20f6b99bafSsthenLIBUNBOUND_CURRENT=9 21*bdcafcd9SsthenLIBUNBOUND_REVISION=29 22f6b99bafSsthenLIBUNBOUND_AGE=1 23933707f3Ssthen# 1.0.0 had 0:12:0 24933707f3Ssthen# 1.0.1 had 0:13:0 25933707f3Ssthen# 1.0.2 had 0:14:0 26933707f3Ssthen# 1.1.0 had 0:15:0 27933707f3Ssthen# 1.1.1 had 0:16:0 28933707f3Ssthen# 1.2.0 had 0:17:0 29933707f3Ssthen# 1.2.1 had 0:18:0 30933707f3Ssthen# 1.3.0 had 1:0:0 # ub_cancel and -export-symbols. 31933707f3Ssthen# 1.3.1 had 1:1:0 32933707f3Ssthen# 1.3.2 had 1:2:0 33933707f3Ssthen# 1.3.3 had 1:3:0 34933707f3Ssthen# 1.3.4 had 1:4:0 35933707f3Ssthen# 1.4.0-snapshots had 1:5:0 36933707f3Ssthen# 1.4.0 had 1:5:0 (not 2:0:0) # ub_result.why_bogus 37933707f3Ssthen# 1.4.1 had 2:1:0 38933707f3Ssthen# 1.4.2 had 2:2:0 39933707f3Ssthen# 1.4.3 had 2:3:0 40933707f3Ssthen# 1.4.4 had 2:4:0 41933707f3Ssthen# 1.4.5 had 2:5:0 42933707f3Ssthen# 1.4.6 had 2:6:0 43933707f3Ssthen# 1.4.7 had 2:7:0 44933707f3Ssthen# 1.4.8 had 2:8:0 45933707f3Ssthen# 1.4.9 had 2:9:0 46933707f3Ssthen# 1.4.10 had 2:10:0 47933707f3Ssthen# 1.4.11 had 2:11:0 48933707f3Ssthen# 1.4.12 had 2:12:0 49933707f3Ssthen# 1.4.13 had 2:13:0 50933707f3Ssthen# and 1.4.13p1 and 1.4.13.p2 51933707f3Ssthen# 1.4.14 had 2:14:0 52933707f3Ssthen# 1.4.15 had 3:0:1 # adds ub_version() 53933707f3Ssthen# 1.4.16 had 3:1:1 54163a4143Ssthen# 1.4.17 had 3:2:1 55cebdf579Ssthen# 1.4.18 had 3:3:1 56e9c7b4efSsthen# 1.4.19 had 3:4:1 57e9c7b4efSsthen# 1.4.20 had 4:0:2 # adds libunbound.ttl # but shipped 3:5:1 58e9c7b4efSsthen# 1.4.21 had 4:1:2 59e10d3884Sbrad# 1.4.22 had 4:1:2 60e10d3884Sbrad# 1.5.0 had 5:3:3 # adds ub_ctx_add_ta_autr 6131f127bbSsthen# 1.5.1 had 5:3:3 6231f127bbSsthen# 1.5.2 had 5:5:3 63a58bff56Ssthen# 1.5.3 had 5:6:3 64a58bff56Ssthen# 1.5.4 had 5:7:3 65a961b961Ssthen# 1.5.5 had 5:8:3 66a961b961Ssthen# 1.5.6 had 5:9:3 6724893edcSsthen# 1.5.7 had 5:10:3 6832e31f52Ssthen# 1.5.8 had 6:0:4 # adds ub_ctx_set_stub 692ee382b6Ssthen# 1.5.9 had 6:1:4 7077079be7Ssthen# 1.5.10 had 6:2:4 7177079be7Ssthen# 1.6.0 had 6:3:4 7277079be7Ssthen# 1.6.1 had 7:0:5 # ub_callback_t typedef renamed to ub_callback_type 732be9e038Ssthen# 1.6.2 had 7:1:5 742be9e038Ssthen# 1.6.3 had 7:2:5 752be9e038Ssthen# 1.6.4 had 7:3:5 760990ddf5Ssthen# 1.6.5 had 7:4:5 777191de28Ssthen# 1.6.6 had 7:5:5 78bdfc4d55Sflorian# 1.6.7 had 7:6:5 79bdfc4d55Sflorian# 1.6.8 had 7:7:5 80938a3a5eSflorian# 1.7.0 had 7:8:5 8120237c55Ssthen# 1.7.1 had 7:9:5 8220237c55Ssthen# 1.7.2 had 7:10:5 8320237c55Ssthen# 1.7.3 had 7:11:5 84452a1548Ssthen# 1.8.0 had 8:0:0 # changes the event callback function signature 85452a1548Ssthen# 1.8.1 had 8:1:0 863150e5f6Ssthen# 1.8.2 had 8:2:0 87feddb4c1Ssthen# 1.8.3 had 8:3:0 88c3b38330Ssthen# 1.9.0 had 9:0:1 # add ub_ctx_set_tls 89c3b38330Ssthen# 1.9.1 had 9:1:1 90550cf4a9Ssthen# 1.9.2 had 9:2:1 918240c1b9Ssthen# 1.9.3 had 9:3:1 929effb331Ssthen# 1.9.4 had 9:4:1 93ebf5bb73Ssthen# 1.9.5 had 9:5:1 94ebf5bb73Ssthen# 1.9.6 had 9:6:1 95eaf2578eSsthen# 1.10.0 had 9:7:1 9606a13c09Ssthen# 1.10.1 had 9:8:1 97a3167c07Ssthen# 1.11.0 had 9:9:1 982c144df0Ssthen# 1.12.0 had 9:10:1 99eba819a2Ssthen# 1.13.0 had 9:11:1 1009982a05dSsthen# 1.13.1 had 9:12:1 101191f22c6Ssthen# 1.13.2 had 9:13:1 102e21c60efSsthen# 1.14.0 had 9:14:1 103e21c60efSsthen# 1.15.0 had 9:15:1 1040bdb4f62Ssthen# 1.16.0 had 9:16:1 105d1e2768aSsthen# 1.16.1 had 9:17:1 106d1e2768aSsthen# 1.16.2 had 9:18:1 1077dd170e2Ssthen# 1.16.3 had 9:19:1 10845872187Ssthen# 1.17.0 had 9:20:1 1098b7325afSsthen# 1.17.1 had 9:21:1 1108b7325afSsthen# 1.18.0 had 9:22:1 111d896b962Ssthen# 1.19.0 had 9:23:1 112d896b962Ssthen# 1.19.1 had 9:24:1 113d896b962Ssthen# 1.19.2 had 9:25:1 114f46c52bfSsthen# 1.19.3 had 9:26:1 1152bdc0ed1Ssthen# 1.20.0 had 9:27:1 11698bc733bSsthen# 1.21.0 had 9:28:1 117*bdcafcd9Ssthen# 1.21.1 had 9:29:1 118933707f3Ssthen 119933707f3Ssthen# Current -- the number of the binary API that we're implementing 120933707f3Ssthen# Revision -- which iteration of the implementation of the binary 121933707f3Ssthen# API are we supplying? 122933707f3Ssthen# Age -- How many previous binary API versions do we also 123933707f3Ssthen# support? 124933707f3Ssthen# 125933707f3Ssthen# If we release a new version that does not change the binary API, 126933707f3Ssthen# increment Revision. 127933707f3Ssthen# 128933707f3Ssthen# If we release a new version that changes the binary API, but does 129933707f3Ssthen# not break programs compiled against the old binary API, increment 130933707f3Ssthen# Current and Age. Set Revision to 0, since this is the first 131933707f3Ssthen# implementation of the new API. 132933707f3Ssthen# 133bdfc4d55Sflorian# Otherwise, we're changing the binary API and breaking backward 134933707f3Ssthen# compatibility with old binaries. Increment Current. Set Age to 0, 135933707f3Ssthen# since we're backward compatible with no previous APIs. Set Revision 136933707f3Ssthen# to 0 too. 137933707f3SsthenAC_SUBST(LIBUNBOUND_CURRENT) 138933707f3SsthenAC_SUBST(LIBUNBOUND_REVISION) 139933707f3SsthenAC_SUBST(LIBUNBOUND_AGE) 140933707f3Ssthen 1418240c1b9Ssthen 1428240c1b9Ssthencmdln="`echo $@ | sed -e 's/\\\\/\\\\\\\\/g' | sed -e 's/"/\\\\"/'g`" 1438240c1b9SsthenAC_DEFINE_UNQUOTED(CONFCMDLINE, ["$cmdln"], [Command line arguments used with configure]) 1448240c1b9Ssthen 145933707f3SsthenCFLAGS="$CFLAGS" 1469982a05dSsthenAC_USE_SYSTEM_EXTENSIONS 1470b68ff31Ssthenif test "$ac_cv_header_minix_config_h" = "yes"; then 1480b68ff31Ssthen AC_DEFINE(_NETBSD_SOURCE,1, [Enable for compile on Minix]) 1490b68ff31Ssthenfi 150933707f3Ssthen 151933707f3Ssthendnl 152933707f3Ssthendnl By default set prefix to /usr/local 153933707f3Ssthendnl 154933707f3Ssthencase "$prefix" in 155933707f3Ssthen NONE) 156933707f3Ssthen prefix="/usr/local" 157933707f3Ssthen ;; 158933707f3Ssthenesac 1592be9e038Ssthencase "$exec_prefix" in 1602be9e038Ssthen NONE) 1612be9e038Ssthen exec_prefix="$prefix" 1622be9e038Ssthen ;; 1632be9e038Ssthenesac 164933707f3Ssthen 165933707f3Ssthen# are we on MinGW? 166191f22c6Ssthenif uname -s 2>&1 | grep MINGW >/dev/null; then on_mingw="yes" 167933707f3Ssthenelse 168191f22c6Ssthen if echo $host | grep mingw >/dev/null; then on_mingw="yes" 169933707f3Ssthen else on_mingw="no"; fi 170933707f3Ssthenfi 171933707f3Ssthen 172933707f3Ssthen# 173933707f3Ssthen# Determine configuration file 174933707f3Ssthen# the eval is to evaluate shell expansion twice 1752be9e038SsthenUNBOUND_SBIN_DIR=`eval echo "${sbindir}"` 1762be9e038SsthenAC_SUBST(UNBOUND_SBIN_DIR) 1772be9e038SsthenUNBOUND_SYSCONF_DIR=`eval echo "${sysconfdir}"` 1782be9e038SsthenAC_SUBST(UNBOUND_SYSCONF_DIR) 1792be9e038SsthenUNBOUND_LOCALSTATE_DIR=`eval echo "${localstatedir}"` 1802be9e038SsthenAC_SUBST(UNBOUND_LOCALSTATE_DIR) 181933707f3Ssthenif test $on_mingw = "no"; then 182933707f3Ssthen ub_conf_file=`eval echo "${sysconfdir}/unbound/unbound.conf"` 183933707f3Ssthenelse 1842be9e038Ssthen ub_conf_file="C:\\Program Files\\Unbound\\service.conf" 185933707f3Ssthenfi 186933707f3SsthenAC_ARG_WITH([conf_file], 1879982a05dSsthen AS_HELP_STRING([--with-conf-file=path],[Pathname to the Unbound configuration file]), 188933707f3Ssthen [ub_conf_file="$withval"]) 189933707f3SsthenAC_SUBST(ub_conf_file) 190933707f3SsthenACX_ESCAPE_BACKSLASH($ub_conf_file, hdr_config) 191933707f3SsthenAC_DEFINE_UNQUOTED(CONFIGFILE, ["$hdr_config"], [Pathname to the Unbound configuration file]) 1928306b374Ssthenub_conf_dir=`AS_DIRNAME(["$ub_conf_file"])` 1938306b374SsthenAC_SUBST(ub_conf_dir) 194933707f3Ssthen 195933707f3Ssthen# Determine run, chroot directory and pidfile locations 196933707f3SsthenAC_ARG_WITH(run-dir, 1979982a05dSsthen AS_HELP_STRING([--with-run-dir=path],[set default directory to chdir to (by default dir part of cfg file)]), 198933707f3Ssthen UNBOUND_RUN_DIR="$withval", 199933707f3Ssthenif test $on_mingw = no; then 200933707f3Ssthen UNBOUND_RUN_DIR=`dirname "$ub_conf_file"` 201933707f3Ssthenelse 202933707f3Ssthen UNBOUND_RUN_DIR="" 203933707f3Ssthenfi 204933707f3Ssthen) 205933707f3SsthenAC_SUBST(UNBOUND_RUN_DIR) 206933707f3SsthenACX_ESCAPE_BACKSLASH($UNBOUND_RUN_DIR, hdr_run) 207933707f3SsthenAC_DEFINE_UNQUOTED(RUN_DIR, ["$hdr_run"], [Directory to chdir to]) 208933707f3Ssthen 209933707f3SsthenAC_ARG_WITH(chroot-dir, 2109982a05dSsthen AS_HELP_STRING([--with-chroot-dir=path],[set default directory to chroot to (by default same as run-dir)]), 211933707f3Ssthen UNBOUND_CHROOT_DIR="$withval", 212933707f3Ssthenif test $on_mingw = no; then 213933707f3Ssthen UNBOUND_CHROOT_DIR="$UNBOUND_RUN_DIR" 214933707f3Ssthenelse 215933707f3Ssthen UNBOUND_CHROOT_DIR="" 216933707f3Ssthenfi 217933707f3Ssthen) 218933707f3SsthenAC_SUBST(UNBOUND_CHROOT_DIR) 219d4d89bb1SsthenACX_ESCAPE_BACKSLASH($UNBOUND_CHROOT_DIR, hdr_chroot) 220933707f3SsthenAC_DEFINE_UNQUOTED(CHROOT_DIR, ["$hdr_chroot"], [Directory to chroot to]) 221933707f3Ssthen 222933707f3SsthenAC_ARG_WITH(share-dir, 2239982a05dSsthen AS_HELP_STRING([--with-share-dir=path],[set default directory with shared data (by default same as share/unbound)]), 224933707f3Ssthen UNBOUND_SHARE_DIR="$withval", 225933707f3Ssthen UNBOUND_SHARE_DIR="$UNBOUND_RUN_DIR") 226933707f3SsthenAC_SUBST(UNBOUND_SHARE_DIR) 227933707f3SsthenAC_DEFINE_UNQUOTED(SHARE_DIR, ["$UNBOUND_SHARE_DIR"], [Shared data]) 228933707f3Ssthen 229933707f3SsthenAC_ARG_WITH(pidfile, 2309982a05dSsthen AS_HELP_STRING([--with-pidfile=filename],[set default pathname to unbound pidfile (default run-dir/unbound.pid)]), 231933707f3Ssthen UNBOUND_PIDFILE="$withval", 232933707f3Ssthenif test $on_mingw = no; then 233933707f3Ssthen UNBOUND_PIDFILE="$UNBOUND_RUN_DIR/unbound.pid" 234933707f3Ssthenelse 235933707f3Ssthen UNBOUND_PIDFILE="" 236933707f3Ssthenfi 237933707f3Ssthen) 238933707f3SsthenAC_SUBST(UNBOUND_PIDFILE) 239933707f3SsthenACX_ESCAPE_BACKSLASH($UNBOUND_PIDFILE, hdr_pid) 240933707f3SsthenAC_DEFINE_UNQUOTED(PIDFILE, ["$hdr_pid"], [default pidfile location]) 241933707f3Ssthen 242933707f3SsthenAC_ARG_WITH(rootkey-file, 2439982a05dSsthen 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.]), 244933707f3Ssthen UNBOUND_ROOTKEY_FILE="$withval", 245933707f3Ssthenif test $on_mingw = no; then 246933707f3Ssthen UNBOUND_ROOTKEY_FILE="$UNBOUND_RUN_DIR/root.key" 247933707f3Ssthenelse 2482be9e038Ssthen UNBOUND_ROOTKEY_FILE="C:\\Program Files\\Unbound\\root.key" 249933707f3Ssthenfi 250933707f3Ssthen) 251933707f3SsthenAC_SUBST(UNBOUND_ROOTKEY_FILE) 252933707f3SsthenACX_ESCAPE_BACKSLASH($UNBOUND_ROOTKEY_FILE, hdr_rkey) 253933707f3SsthenAC_DEFINE_UNQUOTED(ROOT_ANCHOR_FILE, ["$hdr_rkey"], [default rootkey location]) 254933707f3Ssthen 255933707f3SsthenAC_ARG_WITH(rootcert-file, 2569982a05dSsthen 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.]), 257933707f3Ssthen UNBOUND_ROOTCERT_FILE="$withval", 258933707f3Ssthenif test $on_mingw = no; then 259933707f3Ssthen UNBOUND_ROOTCERT_FILE="$UNBOUND_RUN_DIR/icannbundle.pem" 260933707f3Ssthenelse 2612be9e038Ssthen UNBOUND_ROOTCERT_FILE="C:\\Program Files\\Unbound\\icannbundle.pem" 262933707f3Ssthenfi 263933707f3Ssthen) 264933707f3SsthenAC_SUBST(UNBOUND_ROOTCERT_FILE) 265933707f3SsthenACX_ESCAPE_BACKSLASH($UNBOUND_ROOTCERT_FILE, hdr_rpem) 266933707f3SsthenAC_DEFINE_UNQUOTED(ROOT_CERT_FILE, ["$hdr_rpem"], [default rootcert location]) 267933707f3Ssthen 268933707f3SsthenAC_ARG_WITH(username, 2699982a05dSsthen AS_HELP_STRING([--with-username=user],[set default user that unbound changes to (default user is unbound)]), 270933707f3Ssthen UNBOUND_USERNAME="$withval", 271933707f3Ssthen UNBOUND_USERNAME="unbound") 272933707f3SsthenAC_SUBST(UNBOUND_USERNAME) 273933707f3SsthenAC_DEFINE_UNQUOTED(UB_USERNAME, ["$UNBOUND_USERNAME"], [default username]) 274933707f3Ssthen 275933707f3SsthenAC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled]) 276933707f3SsthenACX_RSRC_VERSION(wnvs) 277933707f3SsthenAC_DEFINE_UNQUOTED(RSRC_PACKAGE_VERSION, [$wnvs], [version number for resource files]) 278933707f3Ssthen 2792bdc0ed1Ssthen# Check for 'grep -e' program, here, since ACX_CHECK_FLTO needs that. 2802bdc0ed1SsthenAC_PROG_GREP 2812bdc0ed1Ssthen 282933707f3Ssthen# Checks for typedefs, structures, and compiler characteristics. 283933707f3SsthenAC_C_CONST 2849982a05dSsthenAC_LANG([C]) 285cebdf579Ssthen# allow user to override the -g -O2 flags. 286bdfc4d55Sfloriandefault_cflags=no 287cebdf579Ssthenif test "x$CFLAGS" = "x" ; then 288cebdf579SsthenACX_CHECK_COMPILER_FLAG(g, [CFLAGS="$CFLAGS -g"]) 289cebdf579SsthenACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"]) 290bdfc4d55Sfloriandefault_cflags=yes 291cebdf579Ssthenfi 292d896b962Ssthenm4_version_prereq([2.70], [AC_PROG_CC], [AC_PROG_CC_STDC]) 293933707f3SsthenACX_DEPFLAG 294933707f3SsthenACX_DETERMINE_EXT_FLAGS_UNBOUND 295933707f3Ssthen 296933707f3Ssthen# debug mode flags warnings 2979982a05dSsthenAC_ARG_ENABLE(checking, AS_HELP_STRING([--enable-checking],[Enable warnings, asserts, makefile-dependencies])) 2989982a05dSsthenAC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],[same as enable-checking])) 299933707f3Ssthenif test "$enable_debug" = "yes"; then debug_enabled="$enable_debug"; 300933707f3Ssthenelse debug_enabled="$enable_checking"; fi 301933707f3SsthenAC_SUBST(debug_enabled) 302933707f3Ssthencase "$debug_enabled" in 303933707f3Ssthen yes) 304933707f3Ssthen ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="$CFLAGS -W"]) 305933707f3Ssthen ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="$CFLAGS -Wall"]) 306933707f3Ssthen ACX_CHECK_COMPILER_FLAG(Wextra, [CFLAGS="$CFLAGS -Wextra"]) 307933707f3Ssthen ACX_CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [CFLAGS="$CFLAGS -Wdeclaration-after-statement"]) 308933707f3Ssthen AC_DEFINE([UNBOUND_DEBUG], [], [define this to enable debug checks.]) 309933707f3Ssthen ;; 310933707f3Ssthen no|*) 311933707f3Ssthen # nothing to do. 312933707f3Ssthen ;; 313933707f3Ssthenesac 314bdfc4d55Sflorianif test "$default_cflags" = "yes"; then 315bdfc4d55Sflorian # only when CFLAGS was "" at the start, if the users wants to 316bdfc4d55Sflorian # override we shouldn't add default cflags, because they wouldn't 317bdfc4d55Sflorian # be able to turn off these options and set the CFLAGS wanted. 318933707f3Ssthen ACX_CHECK_FLTO 319a961b961Ssthen ACX_CHECK_PIE 320a961b961Ssthen ACX_CHECK_RELRO_NOW 321bdfc4d55Sflorianfi 322933707f3Ssthen 323933707f3SsthenAC_C_INLINE 324933707f3SsthenACX_CHECK_FORMAT_ATTRIBUTE 325933707f3SsthenACX_CHECK_UNUSED_ATTRIBUTE 326933707f3Ssthen 3272ee382b6SsthenAC_DEFUN([CHECK_WEAK_ATTRIBUTE], 3282ee382b6Ssthen[AC_REQUIRE([AC_PROG_CC]) 3292ee382b6SsthenAC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "weak" attribute) 3302ee382b6SsthenAC_CACHE_VAL(ac_cv_c_weak_attribute, 3312ee382b6Ssthen[ac_cv_c_weak_attribute=no 3329982a05dSsthenAC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> 3332ee382b6Ssthen__attribute__((weak)) void f(int x) { printf("%d", x); } 3349982a05dSsthen]], [[ 3352ee382b6Ssthen f(1); 3369982a05dSsthen]])],[ac_cv_c_weak_attribute="yes"],[ac_cv_c_weak_attribute="no"]) 3372ee382b6Ssthen]) 3382ee382b6Ssthen 3392ee382b6SsthenAC_MSG_RESULT($ac_cv_c_weak_attribute) 3402ee382b6Ssthenif test $ac_cv_c_weak_attribute = yes; then 3412ee382b6Ssthen AC_DEFINE(HAVE_ATTR_WEAK, 1, [Whether the C compiler accepts the "weak" attribute]) 342452a1548Ssthen AC_DEFINE(ATTR_WEAK, [__attribute__((weak))], [apply the weak attribute to a symbol]) 34398bc733bSsthenelse 34498bc733bSsthen AC_DEFINE(ATTR_WEAK,[], [apply the weak attribute to a symbol]) 3452ee382b6Ssthenfi 3462ee382b6Ssthen])dnl End of CHECK_WEAK_ATTRIBUTE 3472ee382b6Ssthen 3482ee382b6SsthenCHECK_WEAK_ATTRIBUTE 3492ee382b6Ssthen 350452a1548SsthenAC_DEFUN([CHECK_NORETURN_ATTRIBUTE], 351452a1548Ssthen[AC_REQUIRE([AC_PROG_CC]) 352452a1548SsthenAC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "noreturn" attribute) 353452a1548SsthenAC_CACHE_VAL(ac_cv_c_noreturn_attribute, 354452a1548Ssthen[ac_cv_c_noreturn_attribute=no 3559982a05dSsthenAC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> 356452a1548Ssthen__attribute__((noreturn)) void f(int x) { printf("%d", x); } 3579982a05dSsthen]], [[ 358452a1548Ssthen f(1); 3599982a05dSsthen]])],[ac_cv_c_noreturn_attribute="yes"],[ac_cv_c_noreturn_attribute="no"]) 360452a1548Ssthen]) 361452a1548Ssthen 362452a1548SsthenAC_MSG_RESULT($ac_cv_c_noreturn_attribute) 363452a1548Ssthenif test $ac_cv_c_noreturn_attribute = yes; then 364452a1548Ssthen AC_DEFINE(HAVE_ATTR_NORETURN, 1, [Whether the C compiler accepts the "noreturn" attribute]) 365452a1548Ssthen AC_DEFINE(ATTR_NORETURN, [__attribute__((__noreturn__))], [apply the noreturn attribute to a function that exits the program]) 36698bc733bSsthenelse 36798bc733bSsthen AC_DEFINE(ATTR_NORETURN,[], [apply the noreturn attribute to a function that exits the program]) 368452a1548Ssthenfi 369452a1548Ssthen])dnl End of CHECK_NORETURN_ATTRIBUTE 370452a1548Ssthen 371452a1548SsthenCHECK_NORETURN_ATTRIBUTE 372452a1548Ssthen 37398bc733bSsthenAC_DEFUN([CHECK_FALLTHROUGH_ATTRIBUTE], 37498bc733bSsthen[AC_REQUIRE([AC_PROG_CC]) 37598bc733bSsthenAC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "fallthrough" attribute) 37698bc733bSsthenBAKCFLAGS="$CFLAGS" 37798bc733bSsthenCFLAGS="$CFLAGS -Werror" 37898bc733bSsthenAC_CACHE_VAL(ac_cv_c_fallthrough_attribute, 37998bc733bSsthen[ac_cv_c_fallthrough_attribute=no 38098bc733bSsthenAC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> 38198bc733bSsthenvoid f(int x) { 38298bc733bSsthen int y = 0; 38398bc733bSsthen switch(x) { 38498bc733bSsthen case 1: 38598bc733bSsthen y = 1; 38698bc733bSsthen __attribute__((fallthrough)); 38798bc733bSsthen /* fallthrough */ 38898bc733bSsthen case 2: 38998bc733bSsthen y++; 39098bc733bSsthen break; 39198bc733bSsthen case 3: 39298bc733bSsthen y = 3; 39398bc733bSsthen break; 39498bc733bSsthen } 39598bc733bSsthen printf("%d", y); 39698bc733bSsthen} 39798bc733bSsthen]], [[ 39898bc733bSsthen f(1); 39998bc733bSsthen]])],[ac_cv_c_fallthrough_attribute="yes"],[ac_cv_c_fallthrough_attribute="no"]) 40098bc733bSsthen]) 40198bc733bSsthenCFLAGS="$BAKCFLAGS" 40298bc733bSsthen 40398bc733bSsthenAC_MSG_RESULT($ac_cv_c_fallthrough_attribute) 40498bc733bSsthenif test $ac_cv_c_fallthrough_attribute = yes; then 40598bc733bSsthen AC_DEFINE(HAVE_ATTR_FALLTHROUGH, 1, [Whether the C compiler accepts the "fallthrough" attribute]) 40698bc733bSsthen AC_DEFINE(ATTR_FALLTHROUGH, [__attribute__((fallthrough));], [apply the fallthrough attribute.]) 40798bc733bSsthenelse 40898bc733bSsthen AC_DEFINE(ATTR_FALLTHROUGH,[], [apply the fallthrough attribute.]) 40998bc733bSsthenfi 41098bc733bSsthen])dnl End of CHECK_FALLTHROUGH_ATTRIBUTE 41198bc733bSsthen 41298bc733bSsthenCHECK_FALLTHROUGH_ATTRIBUTE 41398bc733bSsthen 414933707f3Ssthenif test "$srcdir" != "."; then 415933707f3Ssthen CPPFLAGS="$CPPFLAGS -I$srcdir" 416933707f3Ssthenfi 417933707f3Ssthen 418933707f3SsthenAC_DEFUN([ACX_YYLEX_DESTROY], [ 419933707f3Ssthen AC_MSG_CHECKING([for yylex_destroy]) 420933707f3Ssthen if echo %% | $LEX -t 2>&1 | grep yylex_destroy >/dev/null 2>&1; then 421933707f3Ssthen AC_DEFINE(LEX_HAS_YYLEX_DESTROY, 1, [if lex has yylex_destroy]) 422933707f3Ssthen AC_MSG_RESULT(yes) 4232308e98cSsthen else AC_MSG_RESULT(no); 4242308e98cSsthen LEX=":" 4252308e98cSsthen fi 4262308e98cSsthen]) 4272308e98cSsthen 4282308e98cSsthenAC_DEFUN([ACX_YYLEX_OPTION], [ 4292308e98cSsthen AC_MSG_CHECKING([for lex %option]) 4302308e98cSsthen if cat <<EOF | $LEX -t 2>&1 | grep yy_delete_buffer >/dev/null 2>&1; then 4312308e98cSsthen%option nounput 4322308e98cSsthen%% 4332308e98cSsthenEOF 4342308e98cSsthen AC_MSG_RESULT(yes) 4352308e98cSsthen else AC_MSG_RESULT(no); 4362308e98cSsthen LEX=":" 4372308e98cSsthen fi 438933707f3Ssthen]) 439933707f3Ssthen 4409982a05dSsthenAC_PROG_LEX([noyywrap]) 4412308e98cSsthenif test "$LEX" != "" -a "$LEX" != ":"; then 442933707f3SsthenACX_YYLEX_DESTROY 4432308e98cSsthenfi 4442308e98cSsthenif test "$LEX" != "" -a "$LEX" != ":"; then 4452308e98cSsthenACX_YYLEX_OPTION 4462308e98cSsthenfi 4478b7325afSsthenif test "$LEX" = "" -o "$LEX" = ":"; then 4488b7325afSsthen if test ! -f util/configlexer.c; then 4498b7325afSsthen AC_MSG_ERROR([no lex and no util/configlexer.c: need flex and bison to compile from source repository.]) 4508b7325afSsthen fi 4518b7325afSsthenfi 452933707f3SsthenAC_PROG_YACC 4538b7325afSsthenif test "$YACC" = "" -o "$YACC" = ":"; then 4548b7325afSsthen if test ! -f util/configparser.c; then 4558b7325afSsthen AC_MSG_ERROR([no yacc and no util/configparser.c: need flex and bison to compile from source repository.]) 4568b7325afSsthen fi 4578b7325afSsthenfi 458933707f3SsthenAC_CHECK_PROG(doxygen, doxygen, doxygen) 459933707f3SsthenAC_CHECK_TOOL(STRIP, strip) 460933707f3SsthenACX_LIBTOOL_C_ONLY 461933707f3Ssthen 462191f22c6Ssthen# pkg-config is only needed for these options, do not require it otherwise 463f46c52bfSsthenif test "$enable_systemd" = "yes" -o "$enable_dnstap" = "yes" -o "$with_pyunbound" = "yes" -o "$with_pythonmod" = "yes"; then 464c3b38330SsthenPKG_PROG_PKG_CONFIG 465191f22c6Ssthenfi 466c3b38330Ssthen 467933707f3Ssthen# Checks for header files. 46845872187SsthenAC_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]) 469eba819a2Ssthen# net/if.h portability for Darwin see: 470eba819a2Ssthen# https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Header-Portability.html 471eba819a2SsthenAC_CHECK_HEADERS([net/if.h],,, [ 472eba819a2Ssthen#include <stdio.h> 473eba819a2Ssthen#ifdef STDC_HEADERS 474eba819a2Ssthen# include <stdlib.h> 475eba819a2Ssthen# include <stddef.h> 476eba819a2Ssthen#else 477eba819a2Ssthen# ifdef HAVE_STDLIB_H 478eba819a2Ssthen# include <stdlib.h> 479eba819a2Ssthen# endif 480eba819a2Ssthen#endif 481eba819a2Ssthen#ifdef HAVE_SYS_SOCKET_H 482eba819a2Ssthen# include <sys/socket.h> 483eba819a2Ssthen#endif 484eba819a2Ssthen]) 485933707f3Ssthen 486a3167c07Ssthen# Check for Apple header. This uncovers TARGET_OS_IPHONE, TARGET_OS_TV or TARGET_OS_WATCH 487191f22c6SsthenAC_CHECK_HEADERS([TargetConditionals.h],,, [AC_INCLUDES_DEFAULT]) 488e21c60efSsthenAC_CHECK_HEADERS([netioapi.h],,, [AC_INCLUDES_DEFAULT 489e21c60efSsthen#if HAVE_SYS_PARAM_H 490e21c60efSsthen#include <sys/param.h> 491e21c60efSsthen#endif 492e21c60efSsthen 493e21c60efSsthen#ifdef HAVE_SYS_SOCKET_H 494e21c60efSsthen#include <sys/socket.h> 495e21c60efSsthen#endif 496e21c60efSsthen 497e21c60efSsthen#ifdef HAVE_SYS_UIO_H 498e21c60efSsthen#include <sys/uio.h> 499e21c60efSsthen#endif 500e21c60efSsthen 501e21c60efSsthen#ifdef HAVE_NETINET_IN_H 502e21c60efSsthen#include <netinet/in.h> 503e21c60efSsthen#endif 504e21c60efSsthen 505e21c60efSsthen#ifdef HAVE_NETINET_TCP_H 506e21c60efSsthen#include <netinet/tcp.h> 507e21c60efSsthen#endif 508e21c60efSsthen 509e21c60efSsthen#ifdef HAVE_ARPA_INET_H 510e21c60efSsthen#include <arpa/inet.h> 511e21c60efSsthen#endif 512e21c60efSsthen 513e21c60efSsthen#ifdef HAVE_WINSOCK2_H 514e21c60efSsthen#include <winsock2.h> 515e21c60efSsthen#endif 516e21c60efSsthen 517e21c60efSsthen#ifdef HAVE_WS2TCPIP_H 518e21c60efSsthen#include <ws2tcpip.h> 519e21c60efSsthen#endif 520e21c60efSsthen]) 521a3167c07Ssthen 5228b7325afSsthen# Check for Linux timestamping headers 5238b7325afSsthenAC_CHECK_HEADERS([linux/net_tstamp.h],,, [AC_INCLUDES_DEFAULT]) 5248b7325afSsthen 525933707f3Ssthen# check for types. 526933707f3Ssthen# Using own tests for int64* because autoconf builtin only give 32bit. 527933707f3SsthenAC_CHECK_TYPE(int8_t, signed char) 528933707f3SsthenAC_CHECK_TYPE(int16_t, short) 529933707f3SsthenAC_CHECK_TYPE(int32_t, int) 530933707f3SsthenAC_CHECK_TYPE(int64_t, long long) 531933707f3SsthenAC_CHECK_TYPE(uint8_t, unsigned char) 532933707f3SsthenAC_CHECK_TYPE(uint16_t, unsigned short) 533933707f3SsthenAC_CHECK_TYPE(uint32_t, unsigned int) 534933707f3SsthenAC_CHECK_TYPE(uint64_t, unsigned long long) 535933707f3SsthenAC_TYPE_SIZE_T 536933707f3SsthenAC_CHECK_TYPE(ssize_t, int) 537933707f3SsthenAC_TYPE_UID_T 538933707f3SsthenAC_TYPE_PID_T 539933707f3SsthenAC_TYPE_OFF_T 540933707f3SsthenACX_TYPE_U_CHAR 541933707f3SsthenACX_TYPE_RLIM_T 542933707f3SsthenACX_TYPE_SOCKLEN_T 543933707f3SsthenACX_TYPE_IN_ADDR_T 544933707f3SsthenACX_TYPE_IN_PORT_T 545933707f3SsthenACX_CHECK_MEMCMP_SIGNED 546933707f3Ssthen 5470b68ff31SsthenAC_CHECK_SIZEOF(time_t,,[ 5480b68ff31SsthenAC_INCLUDES_DEFAULT 5490b68ff31Ssthen#ifdef TIME_WITH_SYS_TIME 5500b68ff31Ssthen# include <sys/time.h> 5510b68ff31Ssthen# include <time.h> 5520b68ff31Ssthen#else 5530b68ff31Ssthen# ifdef HAVE_SYS_TIME_H 5540b68ff31Ssthen# include <sys/time.h> 5550b68ff31Ssthen# else 5560b68ff31Ssthen# include <time.h> 5570b68ff31Ssthen# endif 5580b68ff31Ssthen#endif 5590b68ff31Ssthen]) 560ebf5bb73SsthenAC_CHECK_SIZEOF(size_t) 5610b68ff31Ssthen 562933707f3Ssthen# add option to disable the evil rpath 563933707f3SsthenACX_ARG_RPATH 564933707f3SsthenAC_SUBST(RUNTIME_PATH) 565933707f3Ssthen 566933707f3Ssthen# check to see if libraries are needed for these functions. 567933707f3SsthenAC_SEARCH_LIBS([inet_pton], [nsl]) 568933707f3SsthenAC_SEARCH_LIBS([socket], [socket]) 569933707f3Ssthen 570e21c60efSsthen# check whether strptime also works 571933707f3SsthenAC_DEFUN([AC_CHECK_STRPTIME_WORKS], 572933707f3Ssthen[AC_REQUIRE([AC_PROG_CC]) 573933707f3SsthenAC_MSG_CHECKING(whether strptime works) 574933707f3Ssthenif test c${cross_compiling} = cno; then 575933707f3SsthenAC_RUN_IFELSE([AC_LANG_SOURCE([[ 576e10d3884Sbrad#define _XOPEN_SOURCE 600 577933707f3Ssthen#include <time.h> 578933707f3Ssthenint main(void) { struct tm tm; char *res; 579933707f3Ssthenres = 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); 580933707f3Ssthenif (!res) return 2; 581933707f3Ssthenres = strptime("20070207111842", "%Y%m%d%H%M%S", &tm); 582933707f3Ssthenif (!res) return 1; return 0; } 583d896b962Ssthen]])] , [eval "ac_cv_c_strptime_works=yes"], [eval "ac_cv_c_strptime_works=no"], 584d896b962Ssthen[eval "ac_cv_c_strptime_works=maybe"]) 585933707f3Ssthenelse 586933707f3Sstheneval "ac_cv_c_strptime_works=maybe" 587933707f3Ssthenfi 588933707f3SsthenAC_MSG_RESULT($ac_cv_c_strptime_works) 589933707f3Ssthenif test $ac_cv_c_strptime_works = no; then 590933707f3SsthenAC_LIBOBJ(strptime) 591933707f3Ssthenelse 592933707f3SsthenAC_DEFINE_UNQUOTED([STRPTIME_WORKS], 1, [use default strptime.]) 593933707f3Ssthenfi 594933707f3Ssthen])dnl 595933707f3Ssthen 596933707f3Ssthen# check some functions of the OS before linking libs (while still runnable). 597933707f3SsthenAC_FUNC_CHOWN 598933707f3SsthenAC_FUNC_FORK 5999982a05dSsthenAC_DEFINE(RETSIGTYPE,void,[Return type of signal handlers, but autoconf 2.70 says 'your code may safely assume C89 semantics that RETSIGTYPE is void.']) 600933707f3SsthenAC_FUNC_FSEEKO 601933707f3SsthenACX_SYS_LARGEFILE 602933707f3SsthenACX_CHECK_NONBLOCKING_BROKEN 603933707f3SsthenACX_MKDIR_ONE_ARG 604933707f3SsthenAC_CHECK_FUNCS([strptime],[AC_CHECK_STRPTIME_WORKS],[AC_LIBOBJ([strptime])]) 605933707f3Ssthen 6063150e5f6Ssthen# check if we can use SO_REUSEPORT 607191f22c6Ssthenreuseport_default=0 608191f22c6Ssthenif echo "$host" | $GREP -i -e linux >/dev/null; then reuseport_default=1; fi 609191f22c6Ssthenif echo "$host" | $GREP -i -e dragonfly >/dev/null; then reuseport_default=1; fi 610191f22c6Ssthenif test "$reuseport_default" = 1; then 6113150e5f6Ssthen AC_DEFINE(REUSEPORT_DEFAULT, 1, [if REUSEPORT is enabled by default]) 6123150e5f6Ssthenelse 6133150e5f6Ssthen AC_DEFINE(REUSEPORT_DEFAULT, 0, [if REUSEPORT is enabled by default]) 6143150e5f6Ssthenfi 6153150e5f6Ssthen 6168240c1b9Ssthen# Include systemd.m4 - begin 6178240c1b9Ssthensinclude(systemd.m4) 6188240c1b9Ssthen# Include systemd.m4 - end 6198240c1b9Ssthen 620933707f3Ssthen# set memory allocation checking if requested 6219982a05dSsthenAC_ARG_ENABLE(alloc-checks, AS_HELP_STRING([--enable-alloc-checks],[ enable to memory allocation statistics, for debug purposes ]), 622933707f3Ssthen , ) 6239982a05dSsthenAC_ARG_ENABLE(alloc-lite, AS_HELP_STRING([--enable-alloc-lite],[ enable for lightweight alloc assertions, for debug purposes ]), 624933707f3Ssthen , ) 6259982a05dSsthenAC_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 ]), 626933707f3Ssthen , ) 627933707f3Ssthenif test x_$enable_alloc_nonregional = x_yes; then 628933707f3Ssthen AC_DEFINE(UNBOUND_ALLOC_NONREGIONAL, 1, [use malloc not regions, for debug use]) 629933707f3Ssthenfi 630933707f3Ssthenif test x_$enable_alloc_checks = x_yes; then 631933707f3Ssthen AC_DEFINE(UNBOUND_ALLOC_STATS, 1, [use statistics for allocs and frees, for debug use]) 632ebf5bb73Ssthen SLDNS_ALLOCCHECK_EXTRA_OBJ="alloc.lo log.lo" 633ebf5bb73Ssthen AC_SUBST(SLDNS_ALLOCCHECK_EXTRA_OBJ) 634ebf5bb73Ssthen ASYNCLOOK_ALLOCCHECK_EXTRA_OBJ="alloc.lo" 635ebf5bb73Ssthen AC_SUBST(ASYNCLOOK_ALLOCCHECK_EXTRA_OBJ) 636933707f3Ssthenelse 637933707f3Ssthen if test x_$enable_alloc_lite = x_yes; then 638933707f3Ssthen AC_DEFINE(UNBOUND_ALLOC_LITE, 1, [use to enable lightweight alloc assertions, for debug use]) 639933707f3Ssthen else 640933707f3Ssthen ACX_FUNC_MALLOC([unbound]) 641933707f3Ssthen fi 642933707f3Ssthenfi 643933707f3Ssthen 644933707f3Ssthen# check windows threads (we use them, not pthreads, on windows). 645933707f3Ssthenif test "$on_mingw" = "yes"; then 646933707f3Ssthen# check windows threads 647933707f3Ssthen AC_CHECK_HEADERS([windows.h],,, [AC_INCLUDES_DEFAULT]) 648933707f3Ssthen AC_MSG_CHECKING([for CreateThread]) 649933707f3Ssthen AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ 650933707f3Ssthen#ifdef HAVE_WINDOWS_H 651933707f3Ssthen#include <windows.h> 652933707f3Ssthen#endif 653933707f3Ssthen], [ 654933707f3Ssthen HANDLE t = CreateThread(NULL, 0, NULL, NULL, 0, NULL); 655933707f3Ssthen])], 656933707f3Ssthen AC_MSG_RESULT(yes) 657933707f3Ssthen AC_DEFINE(HAVE_WINDOWS_THREADS, 1, [Using Windows threads]) 658933707f3Ssthen, 659933707f3Ssthen AC_MSG_RESULT(no) 660933707f3Ssthen) 661933707f3Ssthen 662933707f3Ssthenelse 663933707f3Ssthen# not on mingw, check thread libraries. 664933707f3Ssthen 665933707f3Ssthen# check for thread library. 666933707f3Ssthen# check this first, so that the pthread lib does not get linked in via 667933707f3Ssthen# libssl or libpython, and thus distorts the tests, and we end up using 668933707f3Ssthen# the non-threadsafe C libraries. 6699982a05dSsthenAC_ARG_WITH(pthreads, AS_HELP_STRING([--with-pthreads],[use pthreads library, or --without-pthreads to disable threading support.]), 670933707f3Ssthen [ ],[ withval="yes" ]) 671933707f3Ssthenub_have_pthreads=no 672933707f3Ssthenif test x_$withval != x_no; then 673e9c7b4efSsthen AX_PTHREAD([ 674933707f3Ssthen AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]) 6757191de28Ssthen if test -n "$PTHREAD_LIBS"; then 676933707f3Ssthen LIBS="$PTHREAD_LIBS $LIBS" 6777191de28Ssthen fi 678933707f3Ssthen CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 679933707f3Ssthen CC="$PTHREAD_CC" 680933707f3Ssthen ub_have_pthreads=yes 681933707f3Ssthen AC_CHECK_TYPES([pthread_spinlock_t, pthread_rwlock_t],,,[#include <pthread.h>]) 68245872187Ssthen AC_CHECK_SIZEOF([unsigned long]) 68345872187Ssthen AC_CHECK_SIZEOF(pthread_t) 68432e31f52Ssthen 68532e31f52Ssthen if echo "$CFLAGS" | $GREP -e "-pthread" >/dev/null; then 68632e31f52Ssthen AC_MSG_CHECKING([if -pthread unused during linking]) 68732e31f52Ssthen # catch clang warning 'argument unused during compilation' 68832e31f52Ssthen AC_LANG_CONFTEST([AC_LANG_SOURCE(AC_INCLUDES_DEFAULT 68932e31f52Ssthen[[ 69032e31f52Ssthenint main(void) {return 0;} 69132e31f52Ssthen]])]) 69232e31f52Ssthen pthread_unused="yes" 69332e31f52Ssthen # first compile 69432e31f52Ssthen echo "$CC $CFLAGS -c conftest.c -o conftest.o" >&AS_MESSAGE_LOG_FD 69532e31f52Ssthen $CC $CFLAGS -c conftest.c -o conftest.o 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD 69632e31f52Ssthen if test $? = 0; then 69732e31f52Ssthen # then link 69832e31f52Ssthen echo "$CC $CFLAGS -Werror $LDFLAGS $LIBS -o conftest contest.o" >&AS_MESSAGE_LOG_FD 69932e31f52Ssthen $CC $CFLAGS -Werror $LDFLAGS $LIBS -o conftest conftest.o 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD 70032e31f52Ssthen if test $? -ne 0; then 70132e31f52Ssthen AC_MSG_RESULT(yes) 70232e31f52Ssthen CFLAGS=`echo "$CFLAGS" | sed -e 's/-pthread//'` 70332e31f52Ssthen PTHREAD_CFLAGS_ONLY="-pthread" 70432e31f52Ssthen AC_SUBST(PTHREAD_CFLAGS_ONLY) 70532e31f52Ssthen else 70632e31f52Ssthen AC_MSG_RESULT(no) 70732e31f52Ssthen fi 70832e31f52Ssthen else 70932e31f52Ssthen AC_MSG_RESULT(no) 71032e31f52Ssthen fi # endif cc successful 71132e31f52Ssthen rm -f conftest conftest.c conftest.o 71232e31f52Ssthen fi # endif -pthread in CFLAGS 71332e31f52Ssthen 714933707f3Ssthen ]) 715933707f3Ssthenfi 716933707f3Ssthen 717933707f3Ssthen# check solaris thread library 7189982a05dSsthenAC_ARG_WITH(solaris-threads, AS_HELP_STRING([--with-solaris-threads],[use solaris native thread library.]), [ ],[ withval="no" ]) 719933707f3Ssthenub_have_sol_threads=no 720933707f3Ssthenif test x_$withval != x_no; then 721933707f3Ssthen if test x_$ub_have_pthreads != x_no; then 7229982a05dSsthen AC_MSG_WARN([Have pthreads already, ignoring --with-solaris-threads]) 723933707f3Ssthen else 724933707f3Ssthen AC_SEARCH_LIBS(thr_create, [thread], 725933707f3Ssthen [ 726933707f3Ssthen AC_DEFINE(HAVE_SOLARIS_THREADS, 1, [Using Solaris threads]) 727933707f3Ssthen 728933707f3Ssthen ACX_CHECK_COMPILER_FLAG(mt, [CFLAGS="$CFLAGS -mt"], 729933707f3Ssthen [CFLAGS="$CFLAGS -D_REENTRANT"]) 730933707f3Ssthen ub_have_sol_threads=yes 731933707f3Ssthen ] , [ 7329982a05dSsthen AC_MSG_ERROR([no solaris threads found.]) 733933707f3Ssthen ]) 734933707f3Ssthen fi 735933707f3Ssthenfi 736933707f3Ssthen 737933707f3Ssthenfi # end of non-mingw check of thread libraries 738933707f3Ssthen 739ebf5bb73Ssthen# Check for SYSLOG_FACILITY 7409982a05dSsthenAC_ARG_WITH(syslog-facility, AS_HELP_STRING([--with-syslog-facility=LOCAL0 - LOCAL7],[ set SYSLOG_FACILITY, default DAEMON ]), 741ebf5bb73Ssthen [ UNBOUND_SYSLOG_FACILITY="$withval" ], []) 742ebf5bb73Ssthencase "${UNBOUND_SYSLOG_FACILITY}" in 743ebf5bb73Ssthen 744ebf5bb73Ssthen LOCAL[[0-7]]) UNBOUND_SYSLOG_FACILITY="LOG_${UNBOUND_SYSLOG_FACILITY}" ;; 745ebf5bb73Ssthen 746ebf5bb73Ssthen *) UNBOUND_SYSLOG_FACILITY="LOG_DAEMON" ;; 747ebf5bb73Ssthen 748ebf5bb73Ssthenesac 749ebf5bb73SsthenAC_DEFINE_UNQUOTED(UB_SYSLOG_FACILITY,${UNBOUND_SYSLOG_FACILITY},[the SYSLOG_FACILITY to use, default LOG_DAEMON]) 750ebf5bb73Ssthen 751a3167c07Ssthen# Check for dynamic library module 752a3167c07SsthenAC_ARG_WITH(dynlibmodule, 7539982a05dSsthen AS_HELP_STRING([--with-dynlibmodule],[build dynamic library module, or --without-dynlibmodule to disable it. (default=no)]), 754a3167c07Ssthen [], [ withval="no" ]) 755a3167c07Ssthen 756a3167c07Ssthenif test x_$withval != x_no; then 757a3167c07Ssthen AC_DEFINE(WITH_DYNLIBMODULE, 1, [Define if you want dynlib module.]) 758a3167c07Ssthen WITH_DYNLIBMODULE=yes 759a3167c07Ssthen AC_SUBST(WITH_DYNLIBMODULE) 760a3167c07Ssthen DYNLIBMOD_OBJ="dynlibmod.lo" 761a3167c07Ssthen AC_SUBST(DYNLIBMOD_OBJ) 762a3167c07Ssthen DYNLIBMOD_HEADER='$(srcdir)/dynlibmod/dynlibmod.h' 763a3167c07Ssthen AC_SUBST(DYNLIBMOD_HEADER) 764a3167c07Ssthen if test $on_mingw = "no"; then 7659982a05dSsthen # link with -ldl if not already there, for all executables because 7669982a05dSsthen # dlopen call is in the dynlib module. For unbound executable, also 7679982a05dSsthen # export symbols. 7689982a05dSsthen AC_SEARCH_LIBS([dlopen], [dl]) 7699982a05dSsthen DYNLIBMOD_EXTRALIBS="-export-dynamic" 770a3167c07Ssthen else 7719982a05dSsthen DYNLIBMOD_EXTRALIBS="-Wl,--export-all-symbols,--out-implib,libunbound.dll.a" 772a3167c07Ssthen fi 773a3167c07Ssthen AC_SUBST(DYNLIBMOD_EXTRALIBS) 774a3167c07Ssthenfi 775a3167c07Ssthen 776933707f3Ssthen# Check for PyUnbound 777933707f3SsthenAC_ARG_WITH(pyunbound, 7789982a05dSsthen AS_HELP_STRING([--with-pyunbound],[build PyUnbound, or --without-pyunbound to skip it. (default=no)]), 779933707f3Ssthen [], [ withval="no" ]) 780933707f3Ssthen 781933707f3Ssthenub_test_python=no 782933707f3Ssthenub_with_pyunbound=no 783933707f3Ssthenif test x_$withval != x_no; then 784933707f3Ssthen ub_with_pyunbound=yes 785933707f3Ssthen ub_test_python=yes 786933707f3Ssthenfi 787933707f3Ssthen 788933707f3Ssthen# Check for Python module 789933707f3SsthenAC_ARG_WITH(pythonmodule, 7909982a05dSsthen AS_HELP_STRING([--with-pythonmodule],[build Python module, or --without-pythonmodule to disable script engine. (default=no)]), 791933707f3Ssthen [], [ withval="no" ]) 792933707f3Ssthen 793933707f3Ssthenub_with_pythonmod=no 794933707f3Ssthenif test x_$withval != x_no; then 795933707f3Ssthen ub_with_pythonmod=yes 796933707f3Ssthen ub_test_python=yes 797933707f3Ssthenfi 798933707f3Ssthen 799933707f3Ssthen# Check for Python & SWIG only on PyUnbound or PyModule 800933707f3Ssthenif test x_$ub_test_python != x_no; then 801933707f3Ssthen 802933707f3Ssthen # Check for Python 803933707f3Ssthen ub_have_python=no 804933707f3Ssthen ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS 805933707f3Ssthen AC_PYTHON_DEVEL 806933707f3Ssthen if test ! -z "$PYTHON_VERSION"; then 8078b7325afSsthen badversion="no" 8088b7325afSsthen if test "$PYTHON_VERSION_MAJOR" -lt 2; then 8098b7325afSsthen badversion="yes" 8108b7325afSsthen fi 8118b7325afSsthen if test "$PYTHON_VERSION_MAJOR" -eq 2 -a "$PYTHON_VERSION_MINOR" -lt 4; then 8128b7325afSsthen badversion="yes" 8138b7325afSsthen fi 8148b7325afSsthen if test "$badversion" = "yes"; then 8159982a05dSsthen AC_MSG_ERROR([Python version >= 2.4.0 is required]) 816933707f3Ssthen fi 817933707f3Ssthen 818a961b961Ssthen [PY_MAJOR_VERSION="`$PYTHON -c \"import sys; print(sys.version_info[0])\"`"] 819a58bff56Ssthen AC_SUBST(PY_MAJOR_VERSION) 820933707f3Ssthen # Have Python 821933707f3Ssthen AC_DEFINE(HAVE_PYTHON,1,[Define if you have Python libraries and header files.]) 822e21c60efSsthen if test x_$ub_with_pythonmod != x_no; then 8237191de28Ssthen if test -n "$LIBS"; then 824933707f3Ssthen LIBS="$PYTHON_LDFLAGS $LIBS" 8257191de28Ssthen else 8267191de28Ssthen LIBS="$PYTHON_LDFLAGS" 8277191de28Ssthen fi 828e21c60efSsthen fi 829e21c60efSsthen PYTHON_LIBS="$PYTHON_LDFLAGS" 830e21c60efSsthen AC_SUBST(PYTHON_LIBS) 8317191de28Ssthen if test -n "$CPPFLAGS"; then 832933707f3Ssthen CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS" 8337191de28Ssthen else 8347191de28Ssthen CPPFLAGS="$PYTHON_CPPFLAGS" 8357191de28Ssthen fi 836a3167c07Ssthen if test "$PYTHON_LIBDIR" != "/usr/lib" -a "$PYTHON_LIBDIR" != "" -a "$PYTHON_LIBDIR" != "/usr/lib64"; then 837a3167c07Ssthen ACX_RUNTIME_PATH_ADD([$PYTHON_LIBDIR]) 838a3167c07Ssthen fi 839933707f3Ssthen ub_have_python=yes 8402308e98cSsthen PKG_CHECK_EXISTS(["python${PY_MAJOR_VERSION}"], 8412308e98cSsthen [PC_PY_DEPENDENCY="python${PY_MAJOR_VERSION}"], 8422308e98cSsthen [PC_PY_DEPENDENCY="python"]) 84377079be7Ssthen AC_SUBST(PC_PY_DEPENDENCY) 844933707f3Ssthen 845933707f3Ssthen # Check for SWIG 846933707f3Ssthen ub_have_swig=no 8479982a05dSsthen 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])) 848938a3a5eSflorian if test "$enable_swig_version_check" = "yes"; then 8492bdc0ed1Ssthen AX_PKG_SWIG(2.0.1) 850938a3a5eSflorian else 8512bdc0ed1Ssthen AX_PKG_SWIG 852938a3a5eSflorian fi 853933707f3Ssthen AC_MSG_CHECKING(SWIG) 854933707f3Ssthen if test ! -x "$SWIG"; then 8559982a05dSsthen AC_MSG_ERROR([failed to find swig tool, install it, or do not build Python module and PyUnbound]) 856933707f3Ssthen else 857933707f3Ssthen AC_DEFINE(HAVE_SWIG, 1, [Define if you have Swig libraries and header files.]) 858933707f3Ssthen AC_SUBST(swig, "$SWIG") 859933707f3Ssthen AC_MSG_RESULT(present) 860933707f3Ssthen 861933707f3Ssthen # If have Python & SWIG 862933707f3Ssthen # Declare PythonMod 863933707f3Ssthen if test x_$ub_with_pythonmod != x_no; then 864933707f3Ssthen AC_DEFINE(WITH_PYTHONMODULE, 1, [Define if you want Python module.]) 865933707f3Ssthen WITH_PYTHONMODULE=yes 866933707f3Ssthen AC_SUBST(WITH_PYTHONMODULE) 867933707f3Ssthen PYTHONMOD_OBJ="pythonmod.lo pythonmod_utils.lo" 868933707f3Ssthen AC_SUBST(PYTHONMOD_OBJ) 869163a4143Ssthen PYTHONMOD_HEADER='$(srcdir)/pythonmod/pythonmod.h' 870c8d6334aSsthen AC_SUBST(PYTHONMOD_HEADER) 871933707f3Ssthen PYTHONMOD_INSTALL=pythonmod-install 872933707f3Ssthen AC_SUBST(PYTHONMOD_INSTALL) 873933707f3Ssthen PYTHONMOD_UNINSTALL=pythonmod-uninstall 874933707f3Ssthen AC_SUBST(PYTHONMOD_UNINSTALL) 875933707f3Ssthen fi 876933707f3Ssthen 877933707f3Ssthen # Declare PyUnbound 878933707f3Ssthen if test x_$ub_with_pyunbound != x_no; then 879933707f3Ssthen AC_DEFINE(WITH_PYUNBOUND, 1, [Define if you want PyUnbound.]) 880933707f3Ssthen WITH_PYUNBOUND=yes 881933707f3Ssthen AC_SUBST(WITH_PYUNBOUND) 882933707f3Ssthen PYUNBOUND_OBJ="libunbound_wrap.lo" 883933707f3Ssthen AC_SUBST(PYUNBOUND_OBJ) 884933707f3Ssthen PYUNBOUND_TARGET="_unbound.la" 885933707f3Ssthen AC_SUBST(PYUNBOUND_TARGET) 886933707f3Ssthen PYUNBOUND_INSTALL=pyunbound-install 887933707f3Ssthen AC_SUBST(PYUNBOUND_INSTALL) 888933707f3Ssthen PYUNBOUND_UNINSTALL=pyunbound-uninstall 889933707f3Ssthen AC_SUBST(PYUNBOUND_UNINSTALL) 890933707f3Ssthen fi 891933707f3Ssthen fi 892933707f3Ssthen else 893933707f3Ssthen AC_MSG_RESULT([*** Python libraries not found, won't build PythonMod or PyUnbound ***]) 894933707f3Ssthen ub_with_pyunbound=no 895933707f3Ssthen ub_with_pythonmod=no 896933707f3Ssthen fi 897933707f3Ssthenfi 898933707f3Ssthen 899933707f3Ssthenif test "`uname`" = "NetBSD"; then 900933707f3Ssthen NETBSD_LINTFLAGS='"-D__RENAME(x)=" -D_NETINET_IN_H_' 901933707f3Ssthen AC_SUBST(NETBSD_LINTFLAGS) 902933707f3Ssthenfi 903e21c60efSsthen 904e21c60efSsthenif test "`uname`" = "Linux"; then 905e21c60efSsthen # splint cannot parse modern c99 header files 906e21c60efSsthen GCC_DOCKER_LINTFLAGS='-syntax' 907e21c60efSsthen AC_SUBST(GCC_DOCKER_LINTFLAGS) 908e21c60efSsthenfi 909933707f3SsthenCONFIG_DATE=`date +%Y%m%d` 910933707f3SsthenAC_SUBST(CONFIG_DATE) 911933707f3Ssthen 912933707f3Ssthen# Checks for libraries. 913cebdf579Ssthen 914cebdf579Ssthen# libnss 915cebdf579SsthenUSE_NSS="no" 9169982a05dSsthenAC_ARG_WITH([nss], AS_HELP_STRING([--with-nss=path],[use libnss instead of openssl, installed at path.]), 917cebdf579Ssthen [ 918cebdf579Ssthen USE_NSS="yes" 919cebdf579Ssthen AC_DEFINE(HAVE_NSS, 1, [Use libnss for crypto]) 920e9c7b4efSsthen if test "$withval" != "" -a "$withval" != "yes"; then 921e9c7b4efSsthen CPPFLAGS="$CPPFLAGS -I$withval/include/nss3" 922cebdf579Ssthen LDFLAGS="$LDFLAGS -L$withval/lib" 923cebdf579Ssthen ACX_RUNTIME_PATH_ADD([$withval/lib]) 924cebdf579Ssthen CPPFLAGS="-I$withval/include/nspr4 $CPPFLAGS" 925cebdf579Ssthen else 926e9c7b4efSsthen CPPFLAGS="$CPPFLAGS -I/usr/include/nss3" 927cebdf579Ssthen CPPFLAGS="-I/usr/include/nspr4 $CPPFLAGS" 928cebdf579Ssthen fi 929cebdf579Ssthen LIBS="$LIBS -lnss3 -lnspr4" 93024893edcSsthen SSLLIB="" 931eaf2578eSsthen PC_CRYPTO_DEPENDENCY="nss nspr" 932eaf2578eSsthen AC_SUBST(PC_CRYPTO_DEPENDENCY) 93324893edcSsthen ] 93424893edcSsthen) 93524893edcSsthen 93624893edcSsthen# libnettle 93724893edcSsthenUSE_NETTLE="no" 9389982a05dSsthenAC_ARG_WITH([nettle], AS_HELP_STRING([--with-nettle=path],[use libnettle as crypto library, installed at path.]), 93924893edcSsthen [ 94024893edcSsthen USE_NETTLE="yes" 94124893edcSsthen AC_DEFINE(HAVE_NETTLE, 1, [Use libnettle for crypto]) 94277079be7Ssthen AC_CHECK_HEADERS([nettle/dsa-compat.h],,, [AC_INCLUDES_DEFAULT]) 94324893edcSsthen if test "$withval" != "" -a "$withval" != "yes"; then 94424893edcSsthen CPPFLAGS="$CPPFLAGS -I$withval/include/nettle" 94524893edcSsthen LDFLAGS="$LDFLAGS -L$withval/lib" 94624893edcSsthen ACX_RUNTIME_PATH_ADD([$withval/lib]) 94724893edcSsthen else 94824893edcSsthen CPPFLAGS="$CPPFLAGS -I/usr/include/nettle" 94924893edcSsthen fi 95024893edcSsthen LIBS="$LIBS -lhogweed -lnettle -lgmp" 95124893edcSsthen SSLLIB="" 952eaf2578eSsthen PC_CRYPTO_DEPENDENCY="hogweed nettle" 953eaf2578eSsthen AC_SUBST(PC_CRYPTO_DEPENDENCY) 954cebdf579Ssthen ] 955cebdf579Ssthen) 956cebdf579Ssthen 957cebdf579Ssthen# openssl 95824893edcSsthenif test $USE_NSS = "no" -a $USE_NETTLE = "no"; then 959933707f3SsthenACX_WITH_SSL 960933707f3SsthenACX_LIB_SSL 96124893edcSsthenSSLLIB="-lssl" 96277079be7Ssthen 963e21c60efSsthenPC_CRYPTO_DEPENDENCY="" 964eaf2578eSsthenAC_SUBST(PC_CRYPTO_DEPENDENCY) 965eaf2578eSsthen 96677079be7Ssthen# check if -lcrypt32 is needed because CAPIENG needs that. (on windows) 96777079be7SsthenBAKLIBS="$LIBS" 96877079be7SsthenLIBS="-lssl $LIBS" 96977079be7SsthenAC_MSG_CHECKING([if libssl needs -lcrypt32]) 9709982a05dSsthenAC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ 9719982a05dSsthen int EVP_sha256(void); 9729982a05dSsthen (void)EVP_sha256(); 9739982a05dSsthen]])], [ 97477079be7Ssthen AC_MSG_RESULT([no]) 97577079be7Ssthen LIBS="$BAKLIBS" 97677079be7Ssthen], [ 97777079be7Ssthen AC_MSG_RESULT([yes]) 97877079be7Ssthen LIBS="$BAKLIBS" 97977079be7Ssthen LIBS="$LIBS -lcrypt32" 98077079be7Ssthen]) 98177079be7Ssthen 982e10d3884SbradAC_MSG_CHECKING([for LibreSSL]) 983e21c60efSsthenif grep VERSION_TEXT $ssldir_include/openssl/opensslv.h | grep "LibreSSL" >/dev/null; then 984e10d3884Sbrad AC_MSG_RESULT([yes]) 985e10d3884Sbrad AC_DEFINE([HAVE_LIBRESSL], [1], [Define if we have LibreSSL]) 986e10d3884Sbrad # libressl provides these compat functions, but they may also be 987e10d3884Sbrad # declared by the OS in libc. See if they have been declared. 988ebf5bb73Ssthen AC_CHECK_DECLS([strlcpy,strlcat,arc4random,arc4random_uniform]) 989e10d3884Sbradelse 990e10d3884Sbrad AC_MSG_RESULT([no]) 991e10d3884Sbradfi 992191f22c6SsthenAC_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]) 99398bc733bSsthenAC_CHECK_FUNCS([OPENSSL_config EVP_sha1 EVP_sha256 EVP_sha512 FIPS_mode EVP_default_properties_is_fips_enabled EVP_MD_CTX_new OpenSSL_add_all_digests OPENSSL_init_crypto EVP_cleanup ENGINE_cleanup ERR_load_crypto_strings CRYPTO_cleanup_all_ex_data ERR_free_strings RAND_cleanup DSA_SIG_set0 EVP_dss1 EVP_DigestVerify EVP_aes_256_cbc EVP_EncryptInit_ex HMAC_Init_ex CRYPTO_THREADID_set_callback EVP_MAC_CTX_set_params OSSL_PARAM_BLD_new BIO_set_callback_ex SSL_CTX_set_tmp_ecdh]) 99477079be7Ssthen 99577079be7Ssthen# these check_funcs need -lssl 99677079be7SsthenBAKLIBS="$LIBS" 99777079be7SsthenLIBS="-lssl $LIBS" 998191f22c6SsthenAC_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]) 99977079be7SsthenLIBS="$BAKLIBS" 100077079be7Ssthen 1001a961b961SsthenAC_CHECK_DECLS([SSL_COMP_get_compression_methods,sk_SSL_COMP_pop_free,SSL_CTX_set_ecdh_auto], [], [], [ 1002933707f3SsthenAC_INCLUDES_DEFAULT 1003933707f3Ssthen#ifdef HAVE_OPENSSL_ERR_H 1004933707f3Ssthen#include <openssl/err.h> 1005933707f3Ssthen#endif 1006933707f3Ssthen 1007933707f3Ssthen#ifdef HAVE_OPENSSL_RAND_H 1008933707f3Ssthen#include <openssl/rand.h> 1009933707f3Ssthen#endif 1010933707f3Ssthen 1011933707f3Ssthen#ifdef HAVE_OPENSSL_CONF_H 1012933707f3Ssthen#include <openssl/conf.h> 1013933707f3Ssthen#endif 1014933707f3Ssthen 1015933707f3Ssthen#ifdef HAVE_OPENSSL_ENGINE_H 1016933707f3Ssthen#include <openssl/engine.h> 1017933707f3Ssthen#endif 1018933707f3Ssthen#include <openssl/ssl.h> 1019933707f3Ssthen#include <openssl/evp.h> 1020933707f3Ssthen]) 1021ebf5bb73Ssthen 1022ebf5bb73Ssthenif test "$ac_cv_func_HMAC_Init_ex" = "yes"; then 1023ebf5bb73Ssthen# check function return type. 1024ebf5bb73SsthenAC_MSG_CHECKING(the return type of HMAC_Init_ex) 1025ebf5bb73SsthenAC_COMPILE_IFELSE([AC_LANG_PROGRAM([ 1026ebf5bb73Ssthen#ifdef HAVE_OPENSSL_ERR_H 1027ebf5bb73Ssthen#include <openssl/err.h> 1028ebf5bb73Ssthen#endif 1029ebf5bb73Ssthen 1030ebf5bb73Ssthen#ifdef HAVE_OPENSSL_RAND_H 1031ebf5bb73Ssthen#include <openssl/rand.h> 1032ebf5bb73Ssthen#endif 1033ebf5bb73Ssthen 1034ebf5bb73Ssthen#ifdef HAVE_OPENSSL_CONF_H 1035ebf5bb73Ssthen#include <openssl/conf.h> 1036ebf5bb73Ssthen#endif 1037ebf5bb73Ssthen 1038ebf5bb73Ssthen#ifdef HAVE_OPENSSL_ENGINE_H 1039ebf5bb73Ssthen#include <openssl/engine.h> 1040ebf5bb73Ssthen#endif 1041ebf5bb73Ssthen#include <openssl/ssl.h> 1042ebf5bb73Ssthen#include <openssl/evp.h> 1043ebf5bb73Ssthen], [ 1044ebf5bb73Ssthen HMAC_CTX* hmac_ctx = NULL; 1045ebf5bb73Ssthen void* hmac_key = NULL; 1046ebf5bb73Ssthen const EVP_MD* digest = NULL; 1047ebf5bb73Ssthen int x = HMAC_Init_ex(hmac_ctx, hmac_key, 32, digest, NULL); 1048ebf5bb73Ssthen (void)x; 1049ebf5bb73Ssthen])], [ 1050ebf5bb73Ssthen AC_MSG_RESULT(int) 1051ebf5bb73Ssthen], [ 1052ebf5bb73Ssthen AC_MSG_RESULT(void) 1053ebf5bb73Ssthen AC_DEFINE([HMAC_INIT_EX_RETURNS_VOID], 1, [If HMAC_Init_ex() returns void]) 1054ebf5bb73Ssthen]) 1055ebf5bb73Ssthenfi 1056ebf5bb73Ssthen 1057cebdf579Ssthenfi 105824893edcSsthenAC_SUBST(SSLLIB) 1059cebdf579Ssthen 1060eaf2578eSsthen# libbsd 10619982a05dSsthenAC_ARG_WITH([libbsd], AS_HELP_STRING([--with-libbsd],[Use portable libbsd functions]), [ 1062eaf2578eSsthen AC_CHECK_HEADERS([bsd/string.h bsd/stdlib.h],,, [AC_INCLUDES_DEFAULT]) 1063eaf2578eSsthen if test "x$ac_cv_header_bsd_string_h" = xyes -a "x$ac_cv_header_bsd_stdlib_h" = xyes; then 1064eaf2578eSsthen for func in strlcpy strlcat arc4random arc4random_uniform reallocarray; do 1065eaf2578eSsthen AC_SEARCH_LIBS([$func], [bsd], [ 1066eaf2578eSsthen AC_DEFINE(HAVE_LIBBSD, 1, [Use portable libbsd functions]) 1067eaf2578eSsthen PC_LIBBSD_DEPENDENCY=libbsd 1068eaf2578eSsthen AC_SUBST(PC_LIBBSD_DEPENDENCY) 1069eaf2578eSsthen ]) 1070eaf2578eSsthen done 1071eaf2578eSsthen fi 1072eaf2578eSsthen]) 1073933707f3Ssthen 10749982a05dSsthenAC_ARG_ENABLE(sha1, AS_HELP_STRING([--disable-sha1],[Disable SHA1 RRSIG support, does not disable nsec3 support])) 10752be9e038Ssthencase "$enable_sha1" in 10762be9e038Ssthen no) 10772be9e038Ssthen ;; 10782be9e038Ssthen yes|*) 10792be9e038Ssthen AC_DEFINE([USE_SHA1], [1], [Define this to enable SHA1 support.]) 10802be9e038Ssthen ;; 10812be9e038Ssthenesac 10822be9e038Ssthen 10832be9e038Ssthen 10849982a05dSsthenAC_ARG_ENABLE(sha2, AS_HELP_STRING([--disable-sha2],[Disable SHA256 and SHA512 RRSIG support])) 1085933707f3Ssthencase "$enable_sha2" in 1086933707f3Ssthen no) 1087933707f3Ssthen ;; 1088933707f3Ssthen yes|*) 1089933707f3Ssthen AC_DEFINE([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.]) 1090933707f3Ssthen ;; 1091933707f3Ssthenesac 1092933707f3Ssthen 10939982a05dSsthenAC_ARG_ENABLE(subnet, AS_HELP_STRING([--enable-subnet],[Enable client subnet])) 10942be9e038Ssthencase "$enable_subnet" in 10952be9e038Ssthen yes) 10962be9e038Ssthen AC_DEFINE([CLIENT_SUBNET], [1], [Define this to enable client subnet option.]) 10972be9e038Ssthen SUBNET_OBJ="edns-subnet.lo subnetmod.lo addrtree.lo subnet-whitelist.lo" 10982be9e038Ssthen AC_SUBST(SUBNET_OBJ) 10992be9e038Ssthen SUBNET_HEADER='$(srcdir)/edns-subnet/subnetmod.h $(srcdir)/edns-subnet/edns-subnet.h $(srcdir)/edns-subnet/subnet-whitelist.h $(srcdir)/edns-subnet/addrtree.h' 11002be9e038Ssthen AC_SUBST(SUBNET_HEADER) 11012be9e038Ssthen ;; 11022be9e038Ssthen no|*) 11032be9e038Ssthen ;; 11042be9e038Ssthenesac 11052be9e038Ssthen 1106e21c60efSsthen# check whether gost also works 1107933707f3SsthenAC_DEFUN([AC_CHECK_GOST_WORKS], 1108933707f3Ssthen[AC_REQUIRE([AC_PROG_CC]) 1109933707f3SsthenAC_MSG_CHECKING([if GOST works]) 1110933707f3Ssthenif test c${cross_compiling} = cno; then 1111933707f3SsthenBAKCFLAGS="$CFLAGS" 1112933707f3Ssthenif test -n "$ssldir"; then 1113e21c60efSsthen CFLAGS="$CFLAGS -Wl,-rpath,$ssldir_lib" 1114933707f3Ssthenfi 1115933707f3SsthenAC_RUN_IFELSE([AC_LANG_SOURCE([[ 1116933707f3Ssthen#include <string.h> 1117933707f3Ssthen#include <openssl/ssl.h> 1118933707f3Ssthen#include <openssl/evp.h> 1119933707f3Ssthen#include <openssl/engine.h> 1120933707f3Ssthen#include <openssl/conf.h> 11210b68ff31Ssthen/* routine to load gost (from sldns) */ 1122933707f3Ssthenint load_gost_id(void) 1123933707f3Ssthen{ 1124933707f3Ssthen static int gost_id = 0; 1125933707f3Ssthen const EVP_PKEY_ASN1_METHOD* meth; 1126933707f3Ssthen ENGINE* e; 1127933707f3Ssthen 1128933707f3Ssthen if(gost_id) return gost_id; 1129933707f3Ssthen 1130933707f3Ssthen /* see if configuration loaded gost implementation from other engine*/ 1131933707f3Ssthen meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1); 1132933707f3Ssthen if(meth) { 1133933707f3Ssthen EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); 1134933707f3Ssthen return gost_id; 1135933707f3Ssthen } 1136933707f3Ssthen 1137933707f3Ssthen /* see if engine can be loaded already */ 1138933707f3Ssthen e = ENGINE_by_id("gost"); 1139933707f3Ssthen if(!e) { 1140933707f3Ssthen /* load it ourself, in case statically linked */ 1141933707f3Ssthen ENGINE_load_builtin_engines(); 1142933707f3Ssthen ENGINE_load_dynamic(); 1143933707f3Ssthen e = ENGINE_by_id("gost"); 1144933707f3Ssthen } 1145933707f3Ssthen if(!e) { 1146933707f3Ssthen /* no gost engine in openssl */ 1147933707f3Ssthen return 0; 1148933707f3Ssthen } 1149933707f3Ssthen if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) { 1150933707f3Ssthen ENGINE_finish(e); 1151933707f3Ssthen ENGINE_free(e); 1152933707f3Ssthen return 0; 1153933707f3Ssthen } 1154933707f3Ssthen 1155933707f3Ssthen meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1); 1156933707f3Ssthen if(!meth) { 1157933707f3Ssthen /* algo not found */ 1158933707f3Ssthen ENGINE_finish(e); 1159933707f3Ssthen ENGINE_free(e); 1160933707f3Ssthen return 0; 1161933707f3Ssthen } 1162933707f3Ssthen EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); 1163933707f3Ssthen return gost_id; 1164933707f3Ssthen} 1165933707f3Ssthenint main(void) { 1166933707f3Ssthen EVP_MD_CTX* ctx; 1167933707f3Ssthen const EVP_MD* md; 1168933707f3Ssthen unsigned char digest[64]; /* its a 256-bit digest, so uses 32 bytes */ 1169933707f3Ssthen const char* str = "Hello world"; 1170933707f3Ssthen const unsigned char check[] = { 1171933707f3Ssthen 0x40 , 0xed , 0xf8 , 0x56 , 0x5a , 0xc5 , 0x36 , 0xe1 , 1172933707f3Ssthen 0x33 , 0x7c , 0x7e , 0x87 , 0x62 , 0x1c , 0x42 , 0xe0 , 1173933707f3Ssthen 0x17 , 0x1b , 0x5e , 0xce , 0xa8 , 0x46 , 0x65 , 0x4d , 1174933707f3Ssthen 0x8d , 0x3e , 0x22 , 0x9b , 0xe1 , 0x30 , 0x19 , 0x9d 1175933707f3Ssthen }; 1176933707f3Ssthen OPENSSL_config(NULL); 1177933707f3Ssthen (void)load_gost_id(); 1178933707f3Ssthen md = EVP_get_digestbyname("md_gost94"); 1179933707f3Ssthen if(!md) return 1; 1180933707f3Ssthen memset(digest, 0, sizeof(digest)); 1181933707f3Ssthen ctx = EVP_MD_CTX_create(); 1182933707f3Ssthen if(!ctx) return 2; 1183933707f3Ssthen if(!EVP_DigestInit_ex(ctx, md, NULL)) return 3; 1184933707f3Ssthen if(!EVP_DigestUpdate(ctx, str, 10)) return 4; 1185933707f3Ssthen if(!EVP_DigestFinal_ex(ctx, digest, NULL)) return 5; 1186933707f3Ssthen /* uncomment to see the hash calculated. 1187933707f3Ssthen {int i; 1188933707f3Ssthen for(i=0; i<32; i++) 1189933707f3Ssthen printf(" %2.2x", (int)digest[i]); 1190933707f3Ssthen printf("\n");} 1191933707f3Ssthen */ 1192933707f3Ssthen if(memcmp(digest, check, sizeof(check)) != 0) 1193933707f3Ssthen return 6; 1194933707f3Ssthen return 0; 1195933707f3Ssthen} 1196d896b962Ssthen]])] , [eval "ac_cv_c_gost_works=yes"], [eval "ac_cv_c_gost_works=no"], 1197d896b962Ssthen[eval "ac_cv_c_gost_works=maybe"]) 1198933707f3SsthenCFLAGS="$BAKCFLAGS" 1199933707f3Ssthenelse 1200933707f3Sstheneval "ac_cv_c_gost_works=maybe" 1201933707f3Ssthenfi 1202933707f3SsthenAC_MSG_RESULT($ac_cv_c_gost_works) 1203933707f3Ssthen])dnl 1204933707f3Ssthen 12059982a05dSsthenAC_ARG_ENABLE(gost, AS_HELP_STRING([--disable-gost],[Disable GOST support])) 1206933707f3Ssthenuse_gost="no" 120724893edcSsthenif test $USE_NSS = "no" -a $USE_NETTLE = "no"; then 1208933707f3Ssthencase "$enable_gost" in 1209933707f3Ssthen no) 1210933707f3Ssthen ;; 1211933707f3Ssthen *) 1212933707f3Ssthen AC_CHECK_FUNC(EVP_PKEY_set_type_str, [:],[AC_MSG_ERROR([OpenSSL 1.0.0 is needed for GOST support])]) 1213933707f3Ssthen AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([OpenSSL does not support ECC, needed for GOST support])]) 1214933707f3Ssthen AC_CHECK_GOST_WORKS 1215cebdf579Ssthen if test "$ac_cv_c_gost_works" != no; then 1216933707f3Ssthen use_gost="yes" 1217933707f3Ssthen AC_DEFINE([USE_GOST], [1], [Define this to enable GOST support.]) 1218933707f3Ssthen fi 1219933707f3Ssthen ;; 1220933707f3Ssthenesac 122124893edcSsthenfi dnl !USE_NSS && !USE_NETTLE 1222933707f3Ssthen 12239982a05dSsthenAC_ARG_ENABLE(ecdsa, AS_HELP_STRING([--disable-ecdsa],[Disable ECDSA support])) 1224163a4143Ssthenuse_ecdsa="no" 1225163a4143Ssthencase "$enable_ecdsa" in 1226163a4143Ssthen no) 1227163a4143Ssthen ;; 1228163a4143Ssthen *) 122924893edcSsthen if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then 123098bc733bSsthen AC_CHECK_FUNC(EVP_PKEY_fromdata, [ 123198bc733bSsthen # with EVP_PKEY_fromdata, check if EC is not disabled 123298bc733bSsthen AC_CHECK_DECL([OPENSSL_NO_EC], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade or rerun with --disable-ecdsa]) 123398bc733bSsthen ], [], [AC_INCLUDES_DEFAULT 123498bc733bSsthen#include <openssl/evp.h> 123598bc733bSsthen ]) 123698bc733bSsthen ], [ 123798bc733bSsthen # without EVP_PKEY_fromdata, older openssl, check for support 1238163a4143Ssthen AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade or rerun with --disable-ecdsa])]) 1239163a4143Ssthen AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade or rerun with --disable-ecdsa])]) 124098bc733bSsthen ]) 1241163a4143Ssthen 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 1242163a4143Ssthen#include <openssl/evp.h> 1243163a4143Ssthen ]) 1244163a4143Ssthen # see if OPENSSL 1.0.0 or later (has EVP MD and Verify independency) 1245163a4143Ssthen AC_MSG_CHECKING([if openssl supports SHA2 and ECDSA with EVP]) 1246e21c60efSsthen if grep OPENSSL_VERSION_TEXT $ssldir_include/openssl/opensslv.h | grep "OpenSSL" >/dev/null; then 1247e21c60efSsthen if grep OPENSSL_VERSION_NUMBER $ssldir_include/openssl/opensslv.h | grep 0x0 >/dev/null; then 1248163a4143Ssthen AC_MSG_RESULT([no]) 1249163a4143Ssthen AC_DEFINE_UNQUOTED([USE_ECDSA_EVP_WORKAROUND], [1], [Define this to enable an EVP workaround for older openssl]) 1250163a4143Ssthen else 1251163a4143Ssthen AC_MSG_RESULT([yes]) 1252163a4143Ssthen fi 1253e10d3884Sbrad else 1254e10d3884Sbrad # not OpenSSL, thus likely LibreSSL, which supports it 1255e10d3884Sbrad AC_MSG_RESULT([yes]) 1256e10d3884Sbrad fi 1257cebdf579Ssthen fi 1258163a4143Ssthen # we now know we have ECDSA and the required curves. 1259163a4143Ssthen AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.]) 1260163a4143Ssthen use_ecdsa="yes" 1261163a4143Ssthen ;; 1262163a4143Ssthenesac 1263163a4143Ssthen 12649982a05dSsthenAC_ARG_ENABLE(dsa, AS_HELP_STRING([--disable-dsa],[Disable DSA support])) 12652ee382b6Ssthenuse_dsa="no" 126677079be7Ssthencase "$enable_dsa" in 1267eaf2578eSsthen yes) 12682ee382b6Ssthen # detect if DSA is supported, and turn it off if not. 12697191de28Ssthen if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then 127077079be7Ssthen AC_CHECK_FUNC(DSA_SIG_new, [ 1271938a3a5eSflorian AC_CHECK_TYPE(DSA_SIG*, [ 12722ee382b6Ssthen AC_DEFINE_UNQUOTED([USE_DSA], [1], [Define this to enable DSA support.]) 12732ee382b6Ssthen ], [if test "x$enable_dsa" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support DSA and you used --enable-dsa.]) 1274938a3a5eSflorian fi ], [ 1275938a3a5eSflorianAC_INCLUDES_DEFAULT 1276938a3a5eSflorian#ifdef HAVE_OPENSSL_ERR_H 1277938a3a5eSflorian#include <openssl/err.h> 1278938a3a5eSflorian#endif 1279938a3a5eSflorian 1280938a3a5eSflorian#ifdef HAVE_OPENSSL_RAND_H 1281938a3a5eSflorian#include <openssl/rand.h> 1282938a3a5eSflorian#endif 1283938a3a5eSflorian 1284938a3a5eSflorian#ifdef HAVE_OPENSSL_CONF_H 1285938a3a5eSflorian#include <openssl/conf.h> 1286938a3a5eSflorian#endif 1287938a3a5eSflorian 1288938a3a5eSflorian#ifdef HAVE_OPENSSL_ENGINE_H 1289938a3a5eSflorian#include <openssl/engine.h> 1290938a3a5eSflorian#endif 1291938a3a5eSflorian ]) 1292938a3a5eSflorian ], [if test "x$enable_dsa" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support DSA and you used --enable-dsa.]) 12932ee382b6Ssthen fi ]) 12947191de28Ssthen else 12957191de28Ssthen AC_DEFINE_UNQUOTED([USE_DSA], [1], [Define this to enable DSA support.]) 12967191de28Ssthen fi 12972ee382b6Ssthen ;; 1298eaf2578eSsthen *) 1299eaf2578eSsthen # disable dsa by default, RFC 8624 section 3.1, validators MUST NOT 1300eaf2578eSsthen # support DSA for DNSSEC Validation. 1301eaf2578eSsthen ;; 13022ee382b6Ssthenesac 13032ee382b6Ssthen 1304191f22c6SsthenAC_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])) 1305191f22c6Ssthenif test "$with_deprecate_rsa_1024" = "yes"; then 1306191f22c6Ssthen AC_DEFINE([DEPRECATE_RSA_1024], [1], [Deprecate RSA 1024 bit length, makes that an unsupported key]) 1307191f22c6Ssthenfi 1308191f22c6Ssthen 13099982a05dSsthenAC_ARG_ENABLE(ed25519, AS_HELP_STRING([--disable-ed25519],[Disable ED25519 support])) 13102be9e038Ssthenuse_ed25519="no" 13112be9e038Ssthencase "$enable_ed25519" in 13122be9e038Ssthen no) 13132be9e038Ssthen ;; 13142be9e038Ssthen *) 13152be9e038Ssthen if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then 13162be9e038Ssthen AC_CHECK_DECLS([NID_ED25519], [ 13172be9e038Ssthen use_ed25519="yes" 13182be9e038Ssthen ], [ if test "x$enable_ed25519" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support ED25519 and you used --enable-ed25519.]) 13192be9e038Ssthen fi ], [AC_INCLUDES_DEFAULT 13202be9e038Ssthen#include <openssl/evp.h> 13212be9e038Ssthen ]) 13222be9e038Ssthen fi 13237191de28Ssthen if test $USE_NETTLE = "yes"; then 13247191de28Ssthen AC_CHECK_HEADERS([nettle/eddsa.h], use_ed25519="yes",, [AC_INCLUDES_DEFAULT]) 13257191de28Ssthen fi 13267191de28Ssthen if test $use_ed25519 = "yes"; then 13277191de28Ssthen AC_DEFINE_UNQUOTED([USE_ED25519], [1], [Define this to enable ED25519 support.]) 13287191de28Ssthen fi 13292be9e038Ssthen ;; 13302be9e038Ssthenesac 13312ee382b6Ssthen 13329982a05dSsthenAC_ARG_ENABLE(ed448, AS_HELP_STRING([--disable-ed448],[Disable ED448 support])) 133320237c55Ssthenuse_ed448="no" 133420237c55Ssthencase "$enable_ed448" in 133520237c55Ssthen no) 133620237c55Ssthen ;; 133720237c55Ssthen *) 133820237c55Ssthen if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then 133920237c55Ssthen AC_CHECK_DECLS([NID_ED448], [ 134020237c55Ssthen use_ed448="yes" 134120237c55Ssthen ], [ if test "x$enable_ed448" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support ED448 and you used --enable-ed448.]) 134220237c55Ssthen fi ], [AC_INCLUDES_DEFAULT 134320237c55Ssthen#include <openssl/evp.h> 134420237c55Ssthen ]) 134520237c55Ssthen fi 134620237c55Ssthen if test $use_ed448 = "yes"; then 134720237c55Ssthen AC_DEFINE_UNQUOTED([USE_ED448], [1], [Define this to enable ED448 support.]) 134820237c55Ssthen fi 134920237c55Ssthen ;; 135020237c55Ssthenesac 135120237c55Ssthen 13529982a05dSsthenAC_ARG_ENABLE(event-api, AS_HELP_STRING([--enable-event-api],[Enable (experimental) pluggable event base libunbound API installed to unbound-event.h])) 13530b68ff31Ssthencase "$enable_event_api" in 13540b68ff31Ssthen yes) 13552ee382b6Ssthen AC_SUBST(UNBOUND_EVENT_INSTALL, [unbound-event-install]) 13562ee382b6Ssthen AC_SUBST(UNBOUND_EVENT_UNINSTALL, [unbound-event-uninstall]) 13570b68ff31Ssthen ;; 13580b68ff31Ssthen *) 13590b68ff31Ssthen ;; 13600b68ff31Ssthenesac 13610b68ff31Ssthen 13629982a05dSsthenAC_ARG_ENABLE(tfo-client, AS_HELP_STRING([--enable-tfo-client],[Enable TCP Fast Open for client mode])) 136377079be7Ssthencase "$enable_tfo_client" in 136477079be7Ssthen yes) 1365191f22c6Ssthen case "$host_os" in 1366191f22c6Ssthen linux*) AC_CHECK_DECL([MSG_FASTOPEN], [AC_MSG_WARN([Check the platform specific TFO kernel parameters are correctly configured to support client mode TFO])], 136777079be7Ssthen [AC_MSG_ERROR([TCP Fast Open is not available for client mode: please rerun without --enable-tfo-client])], 136877079be7Ssthen [AC_INCLUDES_DEFAULT 136977079be7Ssthen#include <netinet/tcp.h> 137077079be7Ssthen]) 137177079be7Ssthen AC_DEFINE_UNQUOTED([USE_MSG_FASTOPEN], [1], [Define this to enable client TCP Fast Open.]) 137277079be7Ssthen ;; 1373191f22c6Ssthen 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])], 137477079be7Ssthen [AC_MSG_ERROR([TCP Fast Open is not available for client mode: please rerun without --enable-tfo-client])], 137577079be7Ssthen [AC_INCLUDES_DEFAULT 137677079be7Ssthen#include <sys/socket.h> 137777079be7Ssthen]) 137877079be7Ssthen AC_DEFINE_UNQUOTED([USE_OSX_MSG_FASTOPEN], [1], [Define this to enable client TCP Fast Open.]) 137977079be7Ssthen ;; 138077079be7Ssthen esac 138177079be7Ssthen ;; 138277079be7Ssthen no|*) 138377079be7Ssthen ;; 138477079be7Ssthenesac 138577079be7Ssthen 13869982a05dSsthenAC_ARG_ENABLE(tfo-server, AS_HELP_STRING([--enable-tfo-server],[Enable TCP Fast Open for server mode])) 138777079be7Ssthencase "$enable_tfo_server" in 138877079be7Ssthen yes) 138977079be7Ssthen 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 139077079be7Ssthen#include <netinet/tcp.h> 139177079be7Ssthen ]) 139277079be7Ssthen AC_DEFINE_UNQUOTED([USE_TCP_FASTOPEN], [1], [Define this to enable server TCP Fast Open.]) 139377079be7Ssthen ;; 139477079be7Ssthen no|*) 139577079be7Ssthen ;; 139677079be7Ssthenesac 139777079be7Ssthen 1398933707f3Ssthen# check for libevent 13999982a05dSsthenAC_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.]), 1400a3167c07Ssthen [ ],[ with_libevent="no" ]) 1401a3167c07Ssthenif test "x_$with_libevent" != x_no; then 1402a3167c07Ssthen AC_DEFINE([USE_LIBEVENT], [1], [Define if you enable libevent]) 1403933707f3Ssthen AC_MSG_CHECKING(for libevent) 1404a3167c07Ssthen if test "x_$with_libevent" = x_ -o "x_$with_libevent" = x_yes; then 1405a3167c07Ssthen with_libevent="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" 1406933707f3Ssthen fi 1407a3167c07Ssthen for dir in $with_libevent; do 1408933707f3Ssthen thedir="$dir" 14090b68ff31Ssthen if test -f "$dir/include/event.h" -o -f "$dir/include/event2/event.h"; then 1410933707f3Ssthen found_libevent="yes" 1411933707f3Ssthen dnl assume /usr is in default path. 1412933707f3Ssthen if test "$thedir" != "/usr"; then 1413933707f3Ssthen CPPFLAGS="$CPPFLAGS -I$thedir/include" 1414933707f3Ssthen fi 1415933707f3Ssthen break; 1416933707f3Ssthen fi 1417933707f3Ssthen done 1418933707f3Ssthen if test x_$found_libevent != x_yes; then 1419933707f3Ssthen if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then 1420933707f3Ssthen # libevent source directory 1421933707f3Ssthen AC_MSG_RESULT(found in $thedir) 1422933707f3Ssthen CPPFLAGS="$CPPFLAGS -I$thedir -I$thedir/include" 1423933707f3Ssthen BAK_LDFLAGS_SET="1" 1424933707f3Ssthen BAK_LDFLAGS="$LDFLAGS" 1425933707f3Ssthen # remove evdns from linking 1426933707f3Ssthen mkdir build >/dev/null 2>&1 1427933707f3Ssthen mkdir build/libevent >/dev/null 2>&1 1428933707f3Ssthen mkdir build/libevent/.libs >/dev/null 2>&1 1429933707f3Ssthen ev_files_o=`ls $thedir/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o` 1430933707f3Ssthen ev_files_lo=`ls $thedir/*.lo | grep -v evdns\.lo | grep -v bufferevent_openssl\.lo` 1431933707f3Ssthen ev_files_libso=`ls $thedir/.libs/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o` 1432933707f3Ssthen cp $ev_files_o build/libevent 1433933707f3Ssthen cp $ev_files_lo build/libevent 1434933707f3Ssthen cp $ev_files_libso build/libevent/.libs 1435933707f3Ssthen LATE_LDFLAGS="build/libevent/*.lo -lm" 1436933707f3Ssthen LDFLAGS="build/libevent/*.o $LDFLAGS -lm" 1437933707f3Ssthen else 1438a3167c07Ssthen AC_MSG_ERROR([Cannot find the libevent library in $with_libevent 1439933707f3SsthenYou can restart ./configure --with-libevent=no to use a builtin alternative. 1440933707f3SsthenPlease note that this alternative is not as capable as libevent when using 1441933707f3Ssthenlarge outgoing port ranges. ]) 1442933707f3Ssthen fi 1443933707f3Ssthen else 1444933707f3Ssthen AC_MSG_RESULT(found in $thedir) 14450b68ff31Ssthen dnl if event2 exists and no event lib in dir itself, use subdir 14460b68ff31Ssthen if test ! -f $thedir/lib/libevent.a -a ! -f $thedir/lib/libevent.so -a -d "$thedir/lib/event2"; then 14470b68ff31Ssthen LDFLAGS="$LDFLAGS -L$thedir/lib/event2" 14480b68ff31Ssthen ACX_RUNTIME_PATH_ADD([$thedir/lib/event2]) 14490b68ff31Ssthen else 1450933707f3Ssthen dnl assume /usr is in default path, do not add "". 1451933707f3Ssthen if test "$thedir" != "/usr" -a "$thedir" != ""; then 1452933707f3Ssthen LDFLAGS="$LDFLAGS -L$thedir/lib" 1453933707f3Ssthen ACX_RUNTIME_PATH_ADD([$thedir/lib]) 1454933707f3Ssthen fi 1455933707f3Ssthen fi 14560b68ff31Ssthen fi 1457933707f3Ssthen # check for library used by libevent after 1.3c 1458933707f3Ssthen AC_SEARCH_LIBS([clock_gettime], [rt]) 1459933707f3Ssthen 1460933707f3Ssthen # is the event.h header libev or libevent? 1461933707f3Ssthen AC_CHECK_HEADERS([event.h],,, [AC_INCLUDES_DEFAULT]) 1462933707f3Ssthen AC_CHECK_DECL(EV_VERSION_MAJOR, [ 1463933707f3Ssthen AC_SEARCH_LIBS(event_set, [ev]) 1464933707f3Ssthen ],[ 1465933707f3Ssthen AC_SEARCH_LIBS(event_set, [event]) 1466933707f3Ssthen ],[AC_INCLUDES_DEFAULT 1467933707f3Ssthen#include <event.h> 1468933707f3Ssthen ]) 1469933707f3Ssthen AC_CHECK_FUNCS([event_base_free]) # only in libevent 1.2 and later 1470933707f3Ssthen AC_CHECK_FUNCS([event_base_once]) # only in libevent 1.4.1 and later 1471933707f3Ssthen AC_CHECK_FUNCS([event_base_new]) # only in libevent 1.4.1 and later 1472933707f3Ssthen AC_CHECK_FUNCS([event_base_get_method]) # only in libevent 1.4.3 and later 1473933707f3Ssthen AC_CHECK_FUNCS([ev_loop]) # only in libev. (tested on 3.51) 1474933707f3Ssthen AC_CHECK_FUNCS([ev_default_loop]) # only in libev. (tested on 4.00) 1475550cf4a9Ssthen AC_CHECK_FUNCS([event_assign]) # in libevent, for thread-safety 1476550cf4a9Ssthen AC_CHECK_DECLS([evsignal_assign], [], [], [AC_INCLUDES_DEFAULT 1477550cf4a9Ssthen#ifdef HAVE_EVENT_H 1478550cf4a9Ssthen# include <event.h> 1479550cf4a9Ssthen#else 1480550cf4a9Ssthen# include "event2/event.h" 1481550cf4a9Ssthen#endif 1482550cf4a9Ssthen ]) 148377079be7Ssthen PC_LIBEVENT_DEPENDENCY="libevent" 148477079be7Ssthen AC_SUBST(PC_LIBEVENT_DEPENDENCY) 1485933707f3Ssthen if test -n "$BAK_LDFLAGS_SET"; then 1486933707f3Ssthen LDFLAGS="$BAK_LDFLAGS" 1487933707f3Ssthen fi 1488933707f3Ssthenelse 1489933707f3Ssthen AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events]) 1490933707f3Ssthenfi 1491933707f3Ssthen 1492933707f3Ssthen# check for libexpat 14939982a05dSsthenAC_ARG_WITH(libexpat, AS_HELP_STRING([--with-libexpat=path],[specify explicit path for libexpat.]), 1494933707f3Ssthen [ ],[ withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" ]) 1495933707f3SsthenAC_MSG_CHECKING(for libexpat) 1496933707f3Ssthenfound_libexpat="no" 1497933707f3Ssthenfor dir in $withval ; do 1498933707f3Ssthen if test -f "$dir/include/expat.h"; then 1499933707f3Ssthen found_libexpat="yes" 1500933707f3Ssthen dnl assume /usr is in default path. 1501933707f3Ssthen if test "$dir" != "/usr"; then 1502933707f3Ssthen CPPFLAGS="$CPPFLAGS -I$dir/include" 1503933707f3Ssthen LDFLAGS="$LDFLAGS -L$dir/lib" 1504933707f3Ssthen fi 1505933707f3Ssthen AC_MSG_RESULT(found in $dir) 1506933707f3Ssthen break; 1507933707f3Ssthen fi 1508933707f3Ssthendone 1509933707f3Ssthenif test x_$found_libexpat != x_yes; then 15109982a05dSsthen AC_MSG_ERROR([Could not find libexpat, expat.h]) 1511933707f3Ssthenfi 1512933707f3SsthenAC_CHECK_HEADERS([expat.h],,, [AC_INCLUDES_DEFAULT]) 151324893edcSsthenAC_CHECK_DECLS([XML_StopParser], [], [], [AC_INCLUDES_DEFAULT 151424893edcSsthen#include <expat.h> 151524893edcSsthen]) 1516933707f3Ssthen 151720237c55Ssthen# hiredis (redis C client for cachedb) 15189982a05dSsthenAC_ARG_WITH(libhiredis, AS_HELP_STRING([--with-libhiredis=path],[specify explicit path for libhiredis.]), 151920237c55Ssthen [ ],[ withval="no" ]) 152020237c55Ssthenfound_libhiredis="no" 152120237c55Ssthenif test x_$withval = x_yes -o x_$withval != x_no; then 15222308e98cSsthen AC_MSG_CHECKING(for libhiredis) 152320237c55Ssthen if test x_$withval = x_ -o x_$withval = x_yes; then 152420237c55Ssthen withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" 152520237c55Ssthen fi 152620237c55Ssthen for dir in $withval ; do 152720237c55Ssthen if test -f "$dir/include/hiredis/hiredis.h"; then 152820237c55Ssthen found_libhiredis="yes" 152920237c55Ssthen dnl assume /usr is in default path. 153020237c55Ssthen if test "$dir" != "/usr"; then 153120237c55Ssthen CPPFLAGS="$CPPFLAGS -I$dir/include" 153220237c55Ssthen LDFLAGS="$LDFLAGS -L$dir/lib" 153320237c55Ssthen fi 153420237c55Ssthen AC_MSG_RESULT(found in $dir) 153520237c55Ssthen AC_DEFINE([USE_REDIS], [1], [Define this to use hiredis client.]) 153620237c55Ssthen LIBS="$LIBS -lhiredis" 153720237c55Ssthen break; 153820237c55Ssthen fi 153920237c55Ssthen done 154020237c55Ssthen if test x_$found_libhiredis != x_yes; then 15419982a05dSsthen AC_MSG_ERROR([Could not find libhiredis, hiredis.h]) 154220237c55Ssthen fi 154320237c55Ssthen AC_CHECK_HEADERS([hiredis/hiredis.h],,, [AC_INCLUDES_DEFAULT]) 154420237c55Ssthen AC_CHECK_DECLS([redisConnect], [], [], [AC_INCLUDES_DEFAULT 154520237c55Ssthen #include <hiredis/hiredis.h> 154620237c55Ssthen ]) 154720237c55Ssthenfi 154820237c55Ssthen 15492c144df0Ssthen# nghttp2 15509982a05dSsthenAC_ARG_WITH(libnghttp2, AS_HELP_STRING([--with-libnghttp2=path],[specify explicit path for libnghttp2.]), 15512c144df0Ssthen [ ],[ withval="no" ]) 15522c144df0Ssthenfound_libnghttp2="no" 15532c144df0Ssthenif test x_$withval = x_yes -o x_$withval != x_no; then 15542c144df0Ssthen AC_MSG_CHECKING(for libnghttp2) 15552c144df0Ssthen if test x_$withval = x_ -o x_$withval = x_yes; then 15562c144df0Ssthen withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" 15572c144df0Ssthen fi 15582c144df0Ssthen for dir in $withval ; do 15592c144df0Ssthen if test -f "$dir/include/nghttp2/nghttp2.h"; then 15602c144df0Ssthen found_libnghttp2="yes" 15612c144df0Ssthen dnl assume /usr is in default path. 15622c144df0Ssthen if test "$dir" != "/usr"; then 15632c144df0Ssthen CPPFLAGS="$CPPFLAGS -I$dir/include" 15642c144df0Ssthen LDFLAGS="$LDFLAGS -L$dir/lib" 15652c144df0Ssthen fi 15662c144df0Ssthen AC_MSG_RESULT(found in $dir) 15672c144df0Ssthen AC_DEFINE([HAVE_NGHTTP2], [1], [Define this to use nghttp2 client.]) 15682c144df0Ssthen LIBS="$LIBS -lnghttp2" 15692c144df0Ssthen break; 15702c144df0Ssthen fi 15712c144df0Ssthen done 15722c144df0Ssthen if test x_$found_libnghttp2 != x_yes; then 15739982a05dSsthen AC_MSG_ERROR([Could not find libnghttp2, nghttp2.h]) 15742c144df0Ssthen fi 15752c144df0Ssthen AC_CHECK_HEADERS([nghttp2/nghttp2.h],,, [AC_INCLUDES_DEFAULT]) 15762c144df0Ssthen AC_CHECK_DECLS([nghttp2_session_server_new], [], [], [AC_INCLUDES_DEFAULT 15772c144df0Ssthen #include <nghttp2/nghttp2.h> 15782c144df0Ssthen ]) 15792c144df0Ssthenfi 15802c144df0Ssthen 1581ebf5bb73Ssthen# set static linking for uninstalled libraries if requested 1582933707f3SsthenAC_SUBST(staticexe) 1583933707f3Ssthenstaticexe="" 15849982a05dSsthenAC_ARG_ENABLE(static-exe, AS_HELP_STRING([--enable-static-exe],[ enable to compile executables statically against (event) uninstalled libs, for debug purposes ]), 1585933707f3Ssthen , ) 1586933707f3Ssthenif test x_$enable_static_exe = x_yes; then 1587933707f3Ssthen staticexe="-static" 1588933707f3Ssthen if test "$on_mingw" = yes; then 1589933707f3Ssthen staticexe="-all-static" 159077079be7Ssthen # for static compile, include gdi32 and zlib here. 1591f46c52bfSsthen if echo "$LIBS" | grep 'lgdi32' >/dev/null; then 15927191de28Ssthen : 15937191de28Ssthen else 15947191de28Ssthen LIBS="$LIBS -lgdi32" 15957191de28Ssthen fi 1596d1e2768aSsthen AC_CHECK_LIB([z], [compress], [ LIBS="$LIBS -lz" ]) 1597f46c52bfSsthen if echo "$LIBS" | grep -e "libssp.a" -e "lssp" >/dev/null; then 1598f46c52bfSsthen : 1599f46c52bfSsthen else 16009982a05dSsthen LIBS="$LIBS -l:libssp.a" 1601933707f3Ssthen fi 1602933707f3Ssthen fi 1603f46c52bfSsthenfi 160477079be7Ssthen 1605ebf5bb73Ssthen# set full static linking if requested 16069982a05dSsthenAC_ARG_ENABLE(fully-static, AS_HELP_STRING([--enable-fully-static],[ enable to compile fully static ]), 1607ebf5bb73Ssthen , ) 1608ebf5bb73Ssthenif test x_$enable_fully_static = x_yes; then 1609ebf5bb73Ssthen staticexe="-all-static" 1610ebf5bb73Ssthen if test "$on_mingw" = yes; then 1611ebf5bb73Ssthen # for static compile, include gdi32 and zlib here. 1612ebf5bb73Ssthen if echo $LIBS | grep 'lgdi32' >/dev/null; then 1613ebf5bb73Ssthen : 1614ebf5bb73Ssthen else 1615ebf5bb73Ssthen LIBS="$LIBS -lgdi32" 1616ebf5bb73Ssthen fi 1617d1e2768aSsthen AC_CHECK_LIB([z], [compress], [ LIBS="$LIBS -lz" ]) 1618f46c52bfSsthen if echo "$LIBS" | grep -e "libssp.a" -e "lssp" >/dev/null; then 1619f46c52bfSsthen : 1620f46c52bfSsthen else 16219982a05dSsthen LIBS="$LIBS -l:libssp.a" 1622ebf5bb73Ssthen fi 1623ebf5bb73Ssthen fi 1624f46c52bfSsthenfi 1625ebf5bb73Ssthen 1626933707f3Ssthen# set lock checking if requested 16279982a05dSsthenAC_ARG_ENABLE(lock_checks, AS_HELP_STRING([--enable-lock-checks],[ enable to check lock and unlock calls, for debug purposes ]), 1628933707f3Ssthen , ) 1629933707f3Ssthenif test x_$enable_lock_checks = x_yes; then 1630933707f3Ssthen AC_DEFINE(ENABLE_LOCK_CHECKS, 1, [Define if you want to use debug lock checking (slow).]) 1631933707f3Ssthen CHECKLOCK_OBJ="checklocks.lo" 1632933707f3Ssthen AC_SUBST(CHECKLOCK_OBJ) 1633933707f3Ssthenfi 1634933707f3Ssthen 1635933707f3SsthenACX_CHECK_GETADDRINFO_WITH_INCLUDES 1636933707f3Ssthenif test "$USE_WINSOCK" = 1; then 1637933707f3Ssthen AC_DEFINE(UB_ON_WINDOWS, 1, [Use win32 resources and API]) 1638933707f3Ssthen AC_CHECK_HEADERS([iphlpapi.h],,, [AC_INCLUDES_DEFAULT 1639933707f3Ssthen#include <windows.h> 1640933707f3Ssthen ]) 1641933707f3Ssthen AC_CHECK_TOOL(WINDRES, windres) 1642f46c52bfSsthen if echo "$LIBS" | grep crypt32 >/dev/null; then 1643f46c52bfSsthen LIBS="$LIBS -liphlpapi" 1644f46c52bfSsthen else 164520237c55Ssthen LIBS="$LIBS -liphlpapi -lcrypt32" 1646f46c52bfSsthen fi 1647933707f3Ssthen WINAPPS="unbound-service-install.exe unbound-service-remove.exe anchor-update.exe" 1648933707f3Ssthen AC_SUBST(WINAPPS) 1649933707f3Ssthen WIN_DAEMON_SRC="winrc/win_svc.c winrc/w_inst.c" 1650933707f3Ssthen AC_SUBST(WIN_DAEMON_SRC) 1651933707f3Ssthen WIN_DAEMON_OBJ="win_svc.lo w_inst.lo" 1652933707f3Ssthen AC_SUBST(WIN_DAEMON_OBJ) 1653933707f3Ssthen WIN_DAEMON_OBJ_LINK="rsrc_unbound.o" 1654933707f3Ssthen AC_SUBST(WIN_DAEMON_OBJ_LINK) 1655933707f3Ssthen WIN_HOST_OBJ_LINK="rsrc_unbound_host.o" 1656933707f3Ssthen AC_SUBST(WIN_HOST_OBJ_LINK) 1657933707f3Ssthen WIN_UBANCHOR_OBJ_LINK="rsrc_unbound_anchor.o log.lo locks.lo" 1658933707f3Ssthen AC_SUBST(WIN_UBANCHOR_OBJ_LINK) 1659933707f3Ssthen WIN_CONTROL_OBJ_LINK="rsrc_unbound_control.o" 1660933707f3Ssthen AC_SUBST(WIN_CONTROL_OBJ_LINK) 1661933707f3Ssthen WIN_CHECKCONF_OBJ_LINK="rsrc_unbound_checkconf.o" 1662933707f3Ssthen AC_SUBST(WIN_CHECKCONF_OBJ_LINK) 16630bdb4f62Ssthen AC_DEFINE(__USE_MINGW_ANSI_STDIO, 1, [defined to use gcc ansi snprintf and sscanf that understands %lld when compiled for windows.]) 1664933707f3Ssthenfi 1665933707f3Ssthenif test $ac_cv_func_getaddrinfo = no; then 1666933707f3Ssthen AC_LIBOBJ([fake-rfc2553]) 1667933707f3Ssthenfi 1668933707f3Ssthen# check after getaddrinfo for its libraries 1669933707f3SsthenACX_FUNC_IOCTLSOCKET 1670933707f3Ssthen 1671933707f3Ssthen# see if daemon(3) exists, and if it is deprecated. 1672933707f3SsthenAC_CHECK_FUNCS([daemon]) 1673933707f3Ssthenif test $ac_cv_func_daemon = yes; then 1674933707f3Ssthen ACX_FUNC_DEPRECATED([daemon], [(void)daemon(0, 0);], [ 1675933707f3Ssthen#include <stdlib.h> 1676191f22c6Ssthen#include <unistd.h> 1677933707f3Ssthen]) 1678933707f3Ssthenfi 1679933707f3Ssthen 168031f127bbSsthenAC_CHECK_MEMBERS([struct sockaddr_un.sun_len],,,[ 168131f127bbSsthenAC_INCLUDES_DEFAULT 168231f127bbSsthen#ifdef HAVE_SYS_UN_H 168331f127bbSsthen#include <sys/un.h> 168431f127bbSsthen#endif 168531f127bbSsthen]) 1686163a4143SsthenAC_CHECK_MEMBERS([struct in_pktinfo.ipi_spec_dst],,,[ 1687163a4143SsthenAC_INCLUDES_DEFAULT 1688163a4143Ssthen#if HAVE_SYS_PARAM_H 1689163a4143Ssthen#include <sys/param.h> 1690163a4143Ssthen#endif 1691163a4143Ssthen 1692163a4143Ssthen#ifdef HAVE_SYS_SOCKET_H 1693163a4143Ssthen#include <sys/socket.h> 1694163a4143Ssthen#endif 1695163a4143Ssthen 1696163a4143Ssthen#ifdef HAVE_SYS_UIO_H 1697163a4143Ssthen#include <sys/uio.h> 1698163a4143Ssthen#endif 1699163a4143Ssthen 1700163a4143Ssthen#ifdef HAVE_NETINET_IN_H 1701163a4143Ssthen#include <netinet/in.h> 1702163a4143Ssthen#endif 1703163a4143Ssthen 170432e31f52Ssthen#ifdef HAVE_NETINET_TCP_H 170532e31f52Ssthen#include <netinet/tcp.h> 170632e31f52Ssthen#endif 170732e31f52Ssthen 1708163a4143Ssthen#ifdef HAVE_ARPA_INET_H 1709163a4143Ssthen#include <arpa/inet.h> 1710163a4143Ssthen#endif 1711163a4143Ssthen 1712163a4143Ssthen#ifdef HAVE_WINSOCK2_H 1713163a4143Ssthen#include <winsock2.h> 1714163a4143Ssthen#endif 1715163a4143Ssthen 1716163a4143Ssthen#ifdef HAVE_WS2TCPIP_H 1717163a4143Ssthen#include <ws2tcpip.h> 1718163a4143Ssthen#endif 1719163a4143Ssthen]) 1720eaf2578eSsthen 1721eaf2578eSsthenAC_MSG_CHECKING([for htobe64]) 1722eaf2578eSsthenAC_LINK_IFELSE([AC_LANG_PROGRAM([ 1723eaf2578eSsthen#include <stdio.h> 1724eaf2578eSsthen#ifdef HAVE_ENDIAN_H 1725eaf2578eSsthen# include <endian.h> 1726eaf2578eSsthen#endif 1727eaf2578eSsthen#ifdef HAVE_SYS_ENDIAN_H 1728eaf2578eSsthen# include <sys/endian.h> 1729eaf2578eSsthen#endif 1730eaf2578eSsthen], [unsigned long long x = htobe64(0); printf("%u", (unsigned)x);])], 1731eaf2578eSsthen AC_MSG_RESULT(yes) 1732eaf2578eSsthen AC_DEFINE(HAVE_HTOBE64, 1, [If we have htobe64]), 1733eaf2578eSsthen AC_MSG_RESULT(no)) 1734eaf2578eSsthen 1735eaf2578eSsthenAC_MSG_CHECKING([for be64toh]) 1736eaf2578eSsthenAC_LINK_IFELSE([AC_LANG_PROGRAM([ 1737eaf2578eSsthen#include <stdio.h> 1738eaf2578eSsthen#ifdef HAVE_ENDIAN_H 1739eaf2578eSsthen# include <endian.h> 1740eaf2578eSsthen#endif 1741eaf2578eSsthen#ifdef HAVE_SYS_ENDIAN_H 1742eaf2578eSsthen# include <sys/endian.h> 1743eaf2578eSsthen#endif 1744eaf2578eSsthen], [unsigned long long x = be64toh(0); printf("%u", (unsigned)x);])], 1745eaf2578eSsthen AC_MSG_RESULT(yes) 1746eaf2578eSsthen AC_DEFINE(HAVE_BE64TOH, 1, [If we have be64toh]), 1747eaf2578eSsthen AC_MSG_RESULT(no)) 1748eaf2578eSsthen 1749933707f3SsthenAC_SEARCH_LIBS([setusercontext], [util]) 175045872187SsthenAC_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]) 1751933707f3SsthenAC_CHECK_FUNCS([setresuid],,[AC_CHECK_FUNCS([setreuid])]) 1752933707f3SsthenAC_CHECK_FUNCS([setresgid],,[AC_CHECK_FUNCS([setregid])]) 1753933707f3Ssthen 1754933707f3Ssthen# check if setreuid en setregid fail, on MacOSX10.4(darwin8). 1755191f22c6Ssthenif echo $host_os | grep darwin8 > /dev/null; then 1756933707f3Ssthen AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work]) 1757933707f3Ssthenfi 175877079be7SsthenAC_CHECK_DECLS([inet_pton,inet_ntop], [], [], [ 175977079be7SsthenAC_INCLUDES_DEFAULT 176077079be7Ssthen#ifdef HAVE_NETINET_IN_H 176177079be7Ssthen#include <netinet/in.h> 176277079be7Ssthen#endif 176377079be7Ssthen 176477079be7Ssthen#ifdef HAVE_NETINET_TCP_H 176577079be7Ssthen#include <netinet/tcp.h> 176677079be7Ssthen#endif 176777079be7Ssthen 176877079be7Ssthen#ifdef HAVE_ARPA_INET_H 176977079be7Ssthen#include <arpa/inet.h> 177077079be7Ssthen#endif 177177079be7Ssthen 177277079be7Ssthen#ifdef HAVE_WINSOCK2_H 177377079be7Ssthen#include <winsock2.h> 177477079be7Ssthen#endif 177577079be7Ssthen 177677079be7Ssthen#ifdef HAVE_WS2TCPIP_H 177777079be7Ssthen#include <ws2tcpip.h> 177877079be7Ssthen#endif 177977079be7Ssthen]) 1780933707f3SsthenAC_REPLACE_FUNCS(inet_aton) 1781933707f3SsthenAC_REPLACE_FUNCS(inet_pton) 1782933707f3SsthenAC_REPLACE_FUNCS(inet_ntop) 1783933707f3SsthenAC_REPLACE_FUNCS(snprintf) 178424893edcSsthen# test if snprintf return the proper length 178524893edcSsthenif test "x$ac_cv_func_snprintf" = xyes; then 178624893edcSsthen if test c${cross_compiling} = cno; then 178724893edcSsthen AC_MSG_CHECKING([for correct snprintf return value]) 178824893edcSsthen AC_RUN_IFELSE([AC_LANG_SOURCE(AC_INCLUDES_DEFAULT 178924893edcSsthen[[ 179024893edcSsthenint main(void) { return !(snprintf(NULL, 0, "test") == 4); } 179124893edcSsthen]])], [AC_MSG_RESULT(yes)], [ 179224893edcSsthen AC_MSG_RESULT(no) 179324893edcSsthen AC_DEFINE([SNPRINTF_RET_BROKEN], [], [define if (v)snprintf does not return length needed, (but length used)]) 179424893edcSsthen AC_LIBOBJ(snprintf) 1795d896b962Ssthen ], [AC_MSG_RESULT(maybe)]) 179624893edcSsthen fi 179724893edcSsthenfi 17980b68ff31SsthenAC_REPLACE_FUNCS(strlcat) 1799933707f3SsthenAC_REPLACE_FUNCS(strlcpy) 1800933707f3SsthenAC_REPLACE_FUNCS(memmove) 1801933707f3SsthenAC_REPLACE_FUNCS(gmtime_r) 180224893edcSsthenAC_REPLACE_FUNCS(isblank) 1803452a1548SsthenAC_REPLACE_FUNCS(explicit_bzero) 1804a58bff56Ssthendnl without CTIME, ARC4-functions and without reallocarray. 1805e10d3884SbradLIBOBJ_WITHOUT_CTIMEARC4="$LIBOBJS" 1806e10d3884SbradAC_SUBST(LIBOBJ_WITHOUT_CTIMEARC4) 1807550cf4a9SsthenAC_MSG_CHECKING([for reallocarray]) 1808550cf4a9SsthenAC_LINK_IFELSE([AC_LANG_SOURCE(AC_INCLUDES_DEFAULT 1809550cf4a9Ssthen[[ 1810550cf4a9Ssthen#ifndef _OPENBSD_SOURCE 1811550cf4a9Ssthen#define _OPENBSD_SOURCE 1 1812550cf4a9Ssthen#endif 1813550cf4a9Ssthen#include <stdlib.h> 1814550cf4a9Ssthenint main(void) { 1815550cf4a9Ssthen void* p = reallocarray(NULL, 10, 100); 1816550cf4a9Ssthen free(p); 1817550cf4a9Ssthen return 0; 1818550cf4a9Ssthen} 1819550cf4a9Ssthen]])], [AC_MSG_RESULT(yes) 1820550cf4a9Ssthen AC_DEFINE(HAVE_REALLOCARRAY, 1, [If we have reallocarray(3)]) 1821550cf4a9Ssthen], [ 1822550cf4a9Ssthen AC_MSG_RESULT(no) 1823550cf4a9Ssthen AC_LIBOBJ(reallocarray) 1824550cf4a9Ssthen]) 1825ebf5bb73SsthenAC_CHECK_DECLS([reallocarray]) 1826e10d3884Sbradif test "$USE_NSS" = "no"; then 1827e10d3884Sbrad AC_REPLACE_FUNCS(arc4random) 1828e10d3884Sbrad AC_REPLACE_FUNCS(arc4random_uniform) 1829e10d3884Sbrad if test "$ac_cv_func_arc4random" = "no"; then 1830e10d3884Sbrad AC_LIBOBJ(arc4_lock) 1831e10d3884Sbrad AC_CHECK_FUNCS([getentropy],,[ 1832e10d3884Sbrad if test "$USE_WINSOCK" = 1; then 1833e10d3884Sbrad AC_LIBOBJ(getentropy_win) 1834e10d3884Sbrad else 183577079be7Ssthen case "$host" in 183677079be7Ssthen Darwin|*darwin*) 1837e10d3884Sbrad AC_LIBOBJ(getentropy_osx) 1838e10d3884Sbrad ;; 183977079be7Ssthen *solaris*|*sunos*|SunOS) 1840e10d3884Sbrad AC_LIBOBJ(getentropy_solaris) 1841e10d3884Sbrad AC_CHECK_HEADERS([sys/sha2.h],, [ 1842e10d3884Sbrad AC_CHECK_FUNCS([SHA512_Update],,[ 1843e10d3884Sbrad AC_LIBOBJ(sha512) 1844e10d3884Sbrad ]) 1845e10d3884Sbrad ], [AC_INCLUDES_DEFAULT]) 1846e10d3884Sbrad if test "$ac_cv_header_sys_sha2_h" = "yes"; then 1847e10d3884Sbrad # this lib needed for sha2 on solaris 1848e10d3884Sbrad LIBS="$LIBS -lmd" 1849e10d3884Sbrad fi 1850a58bff56Ssthen AC_SEARCH_LIBS([clock_gettime], [rt]) 1851e10d3884Sbrad ;; 1852ebf5bb73Ssthen *freebsd*|*FreeBSD) 1853ebf5bb73Ssthen AC_LIBOBJ(getentropy_freebsd) 1854ebf5bb73Ssthen ;; 185577079be7Ssthen *linux*|Linux|*) 1856e10d3884Sbrad AC_LIBOBJ(getentropy_linux) 1857e10d3884Sbrad AC_CHECK_FUNCS([SHA512_Update],,[ 1858e10d3884Sbrad AC_DEFINE([COMPAT_SHA512], [1], [Do sha512 definitions in config.h]) 1859e10d3884Sbrad AC_LIBOBJ(sha512) 1860e10d3884Sbrad ]) 1861e10d3884Sbrad AC_CHECK_HEADERS([sys/sysctl.h],,, [AC_INCLUDES_DEFAULT]) 186231f127bbSsthen AC_CHECK_FUNCS([getauxval]) 1863e10d3884Sbrad AC_SEARCH_LIBS([clock_gettime], [rt]) 1864e10d3884Sbrad ;; 1865e10d3884Sbrad esac 1866e10d3884Sbrad fi 1867e10d3884Sbrad ]) 1868e10d3884Sbrad fi 1869e10d3884Sbradfi 1870933707f3SsthenLIBOBJ_WITHOUT_CTIME="$LIBOBJS" 1871933707f3SsthenAC_SUBST(LIBOBJ_WITHOUT_CTIME) 1872933707f3SsthenAC_REPLACE_FUNCS(ctime_r) 18732ee382b6SsthenAC_REPLACE_FUNCS(strsep) 1874933707f3Ssthen 18759982a05dSsthenAC_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])) 1876933707f3Ssthencase "$enable_allsymbols" in 1877933707f3Ssthen yes) 1878933707f3Ssthen COMMON_OBJ_ALL_SYMBOLS="" 1879933707f3Ssthen UBSYMS="" 1880191f22c6Ssthen EXTRALINK="libunbound.la" 1881933707f3Ssthen 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]) 1882933707f3Ssthen ;; 1883933707f3Ssthen no|*) 1884933707f3Ssthen COMMON_OBJ_ALL_SYMBOLS='$(COMMON_OBJ)' 1885933707f3Ssthen UBSYMS='-export-symbols $(srcdir)/libunbound/ubsyms.def' 1886933707f3Ssthen EXTRALINK="" 1887933707f3Ssthen ;; 1888933707f3Ssthenesac 1889933707f3SsthenAC_SUBST(COMMON_OBJ_ALL_SYMBOLS) 1890933707f3SsthenAC_SUBST(EXTRALINK) 1891933707f3SsthenAC_SUBST(UBSYMS) 1892933707f3Ssthenif test x_$enable_lock_checks = x_yes; then 1893933707f3Ssthen UBSYMS="-export-symbols clubsyms.def" 1894933707f3Ssthen cp ${srcdir}/libunbound/ubsyms.def clubsyms.def 1895933707f3Ssthen echo lock_protect >> clubsyms.def 1896933707f3Ssthen echo lock_unprotect >> clubsyms.def 1897933707f3Ssthen echo lock_get_mem >> clubsyms.def 1898933707f3Ssthen echo checklock_start >> clubsyms.def 1899933707f3Ssthen echo checklock_stop >> clubsyms.def 1900933707f3Ssthen echo checklock_lock >> clubsyms.def 1901933707f3Ssthen echo checklock_unlock >> clubsyms.def 1902933707f3Ssthen echo checklock_init >> clubsyms.def 1903933707f3Ssthen echo checklock_thrcreate >> clubsyms.def 1904933707f3Ssthen echo checklock_thrjoin >> clubsyms.def 1905933707f3Ssthenfi 1906933707f3Ssthen 1907e10d3884Sbrad# check for dnstap if requested 1908e10d3884Sbraddt_DNSTAP([$UNBOUND_RUN_DIR/dnstap.sock], 1909e10d3884Sbrad [ 1910e10d3884Sbrad AC_DEFINE([USE_DNSTAP], [1], [Define to 1 to enable dnstap support]) 1911e10d3884Sbrad AC_SUBST([ENABLE_DNSTAP], [1]) 1912e10d3884Sbrad 1913e10d3884Sbrad AC_SUBST([opt_dnstap_socket_path]) 1914e10d3884Sbrad ACX_ESCAPE_BACKSLASH($opt_dnstap_socket_path, hdr_dnstap_socket_path) 1915e10d3884Sbrad AC_DEFINE_UNQUOTED(DNSTAP_SOCKET_PATH, 1916e10d3884Sbrad ["$hdr_dnstap_socket_path"], [default dnstap socket path]) 1917a3167c07Ssthen AC_SUBST(DNSTAP_SOCKET_PATH,["$hdr_dnstap_socket_path"]) 19189982a05dSsthen AC_SUBST(DNSTAP_SOCKET_TESTBIN,['unbound-dnstap-socket$(EXEEXT)']) 1919a3167c07Ssthen AC_SUBST([DNSTAP_SRC], ["dnstap/dnstap.c dnstap/dnstap.pb-c.c dnstap/dnstap_fstrm.c dnstap/dtstream.c"]) 1920a3167c07Ssthen AC_SUBST([DNSTAP_OBJ], ["dnstap.lo dnstap.pb-c.lo dnstap_fstrm.lo dtstream.lo"]) 1921e10d3884Sbrad ], 1922e10d3884Sbrad [ 1923e10d3884Sbrad AC_SUBST([ENABLE_DNSTAP], [0]) 1924e10d3884Sbrad ] 1925e10d3884Sbrad) 1926e10d3884Sbrad 19272be9e038Ssthen# check for dnscrypt if requested 19282be9e038Ssthendnsc_DNSCRYPT([ 19292be9e038Ssthen AC_DEFINE([USE_DNSCRYPT], [1], [Define to 1 to enable dnscrypt support]) 19302be9e038Ssthen AC_SUBST([ENABLE_DNSCRYPT], [1]) 19312be9e038Ssthen 19322be9e038Ssthen AC_SUBST([DNSCRYPT_SRC], ["dnscrypt/dnscrypt.c"]) 19332be9e038Ssthen AC_SUBST([DNSCRYPT_OBJ], ["dnscrypt.lo"]) 19342be9e038Ssthen ], 19352be9e038Ssthen [ 19362be9e038Ssthen AC_SUBST([ENABLE_DNSCRYPT], [0]) 19372be9e038Ssthen ] 19382be9e038Ssthen) 19392be9e038Ssthen 19402ee382b6Ssthen# check for cachedb if requested 19419982a05dSsthenAC_ARG_ENABLE(cachedb, AS_HELP_STRING([--enable-cachedb],[enable cachedb module that can use external cache storage])) 194220237c55Ssthen# turn on cachedb when hiredis support is enabled. 194320237c55Ssthenif test "$found_libhiredis" = "yes"; then enable_cachedb="yes"; fi 19442ee382b6Ssthencase "$enable_cachedb" in 19452ee382b6Ssthen yes) 19462ee382b6Ssthen AC_DEFINE([USE_CACHEDB], [1], [Define to 1 to use cachedb support]) 1947191f22c6Ssthen AC_SUBST([CACHEDB_SRC], ["cachedb/cachedb.c cachedb/redis.c"]) 1948191f22c6Ssthen AC_SUBST([CACHEDB_OBJ], ["cachedb.lo redis.lo"]) 19492ee382b6Ssthen ;; 19502ee382b6Ssthen no|*) 19512ee382b6Ssthen # nothing 19522ee382b6Ssthen ;; 19532ee382b6Ssthenesac 19542ee382b6Ssthen 19552be9e038Ssthen# check for ipsecmod if requested 19569982a05dSsthenAC_ARG_ENABLE(ipsecmod, AS_HELP_STRING([--enable-ipsecmod],[Enable ipsecmod module that facilitates opportunistic IPsec])) 19572be9e038Ssthencase "$enable_ipsecmod" in 19582be9e038Ssthen yes) 19592be9e038Ssthen AC_DEFINE([USE_IPSECMOD], [1], [Define to 1 to use ipsecmod support.]) 19602be9e038Ssthen IPSECMOD_OBJ="ipsecmod.lo ipsecmod-whitelist.lo" 19612be9e038Ssthen AC_SUBST(IPSECMOD_OBJ) 19622be9e038Ssthen IPSECMOD_HEADER='$(srcdir)/ipsecmod/ipsecmod.h $(srcdir)/ipsecmod/ipsecmod-whitelist.h' 19632be9e038Ssthen AC_SUBST(IPSECMOD_HEADER) 19642be9e038Ssthen ;; 19652be9e038Ssthen no|*) 19662be9e038Ssthen # nothing 19672be9e038Ssthen ;; 19682be9e038Ssthenesac 19692be9e038Ssthen 19708240c1b9Ssthen# check for ipset if requested 19719982a05dSsthenAC_ARG_ENABLE(ipset, AS_HELP_STRING([--enable-ipset],[enable ipset module])) 19728240c1b9Ssthencase "$enable_ipset" in 19738240c1b9Ssthen yes) 19748240c1b9Ssthen AC_DEFINE([USE_IPSET], [1], [Define to 1 to use ipset support]) 19758240c1b9Ssthen IPSET_SRC="ipset/ipset.c" 19768240c1b9Ssthen AC_SUBST(IPSET_SRC) 19778240c1b9Ssthen IPSET_OBJ="ipset.lo" 19788240c1b9Ssthen AC_SUBST(IPSET_OBJ) 19798240c1b9Ssthen 198098bc733bSsthen # BSD's pf 198198bc733bSsthen AC_CHECK_HEADERS([net/pfvar.h], [], [ 19828240c1b9Ssthen # mnl 19839982a05dSsthen AC_ARG_WITH(libmnl, AS_HELP_STRING([--with-libmnl=path],[specify explicit path for libmnl.]), 19848240c1b9Ssthen [ ],[ withval="yes" ]) 19858240c1b9Ssthen found_libmnl="no" 19868240c1b9Ssthen AC_MSG_CHECKING(for libmnl) 19878240c1b9Ssthen if test x_$withval = x_ -o x_$withval = x_yes; then 19888240c1b9Ssthen withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" 19898240c1b9Ssthen fi 19908240c1b9Ssthen for dir in $withval ; do 19910bdb4f62Ssthen if test -f "$dir/include/libmnl/libmnl.h" -o -f "$dir/include/libmnl/libmnl/libmnl.h"; then 19928240c1b9Ssthen found_libmnl="yes" 19938240c1b9Ssthen dnl assume /usr is in default path. 19940bdb4f62Ssthen extralibmnl="" 19950bdb4f62Ssthen if test -f "$dir/include/libmnl/libmnl/libmnl.h"; then 19960bdb4f62Ssthen extralibmnl="/libmnl" 19970bdb4f62Ssthen fi 19980bdb4f62Ssthen if test "$dir" != "/usr" -o -n "$extralibmnl"; then 19990bdb4f62Ssthen CPPFLAGS="$CPPFLAGS -I$dir/include$extralibmnl" 20000bdb4f62Ssthen fi 20018240c1b9Ssthen if test "$dir" != "/usr"; then 20028240c1b9Ssthen LDFLAGS="$LDFLAGS -L$dir/lib" 20038240c1b9Ssthen fi 20048240c1b9Ssthen AC_MSG_RESULT(found in $dir) 20058240c1b9Ssthen LIBS="$LIBS -lmnl" 20068240c1b9Ssthen break; 20078240c1b9Ssthen fi 20088240c1b9Ssthen done 20098240c1b9Ssthen if test x_$found_libmnl != x_yes; then 20109982a05dSsthen AC_MSG_ERROR([Could not find libmnl, libmnl.h]) 20118240c1b9Ssthen fi 201298bc733bSsthen ], [ 201398bc733bSsthen #include <netinet/in.h> 201498bc733bSsthen #include <net/if.h> 201598bc733bSsthen ]) 20168240c1b9Ssthen ;; 20178240c1b9Ssthen no|*) 20188240c1b9Ssthen # nothing 20198240c1b9Ssthen ;; 20208240c1b9Ssthenesac 20219982a05dSsthenAC_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])) 2022a3167c07Ssthencase "$enable_explicit_port_randomisation" in 2023a3167c07Ssthen no) 2024a3167c07Ssthen AC_DEFINE([DISABLE_EXPLICIT_PORT_RANDOMISATION], [1], [Define this to enable kernel based UDP source port randomization.]) 2025a3167c07Ssthen ;; 2026a3167c07Ssthen yes|*) 2027a3167c07Ssthen ;; 2028a3167c07Ssthenesac 2029a3167c07Ssthen 2030191f22c6Ssthenif echo "$host" | $GREP -i -e linux >/dev/null; then 2031d896b962Ssthen AC_ARG_ENABLE(linux-ip-local-port-range, AS_HELP_STRING([--enable-linux-ip-local-port-range], [Define this to enable use of /proc/sys/net/ipv4/ip_local_port_range as a default outgoing port range. This is only for the libunbound on Linux and does not affect unbound resolving daemon itself. This may severely limit the number of available outgoing ports and thus decrease randomness. Define this only when the target system restricts (e.g. some of SELinux enabled distributions) the use of non-ephemeral ports.])) 2032191f22c6Ssthen case "$enable_linux_ip_local_port_range" in 2033191f22c6Ssthen yes) 2034191f22c6Ssthen 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.]) 2035191f22c6Ssthen ;; 2036191f22c6Ssthen no|*) 2037191f22c6Ssthen ;; 2038191f22c6Ssthen esac 2039191f22c6Ssthenfi 2040191f22c6Ssthen 20418240c1b9Ssthen 2042933707f3SsthenAC_MSG_CHECKING([if ${MAKE:-make} supports $< with implicit rule in scope]) 2043933707f3Ssthen# on openBSD, the implicit rule make $< work. 2044933707f3Ssthen# on Solaris, it does not work ($? is changed sources, $^ lists dependencies). 2045933707f3Ssthen# gmake works. 2046933707f3Ssthencat >conftest.make <<EOF 2047933707f3Ssthenall: conftest.lo 2048933707f3Ssthen 2049933707f3Ssthenconftest.lo foo.lo bla.lo: 2050933707f3Ssthen if test -f "\$<"; then touch \$@; fi 2051933707f3Ssthen 2052933707f3Ssthen.SUFFIXES: .lo 2053933707f3Ssthen.c.lo: 2054933707f3Ssthen if test -f "\$<"; then touch \$@; fi 2055933707f3Ssthen 2056933707f3Ssthenconftest.lo: conftest.dir/conftest.c 2057933707f3SsthenEOF 2058933707f3Ssthenmkdir conftest.dir 2059933707f3Ssthentouch conftest.dir/conftest.c 2060933707f3Ssthenrm -f conftest.lo conftest.c 2061933707f3Ssthen${MAKE:-make} -f conftest.make >/dev/null 2062933707f3Ssthenrm -f conftest.make conftest.c conftest.dir/conftest.c 2063933707f3Ssthenrm -rf conftest.dir 2064933707f3Ssthenif test ! -f conftest.lo; then 2065933707f3Ssthen AC_MSG_RESULT(no) 2066933707f3Ssthen SOURCEDETERMINE='echo "$^" | awk "-F " "{print \$$1;}" > .source' 2067933707f3Ssthen SOURCEFILE='`cat .source`' 2068933707f3Ssthenelse 2069933707f3Ssthen AC_MSG_RESULT(yes) 2070933707f3Ssthen SOURCEDETERMINE=':' 2071933707f3Ssthen SOURCEFILE='$<' 2072933707f3Ssthenfi 2073933707f3Ssthenrm -f conftest.lo 2074933707f3SsthenAC_SUBST(SOURCEDETERMINE) 2075933707f3SsthenAC_SUBST(SOURCEFILE) 2076933707f3Ssthen 2077cebdf579Ssthen# see if we want to build the library or everything 2078cebdf579SsthenALLTARGET="alltargets" 20790b68ff31SsthenINSTALLTARGET="install-all" 20809982a05dSsthenAC_ARG_WITH(libunbound-only, AS_HELP_STRING([--with-libunbound-only],[do not build daemon and tool programs]), 2081cebdf579Ssthen [ 2082cebdf579Ssthen if test "$withval" = "yes"; then 2083cebdf579Ssthen ALLTARGET="lib" 20840b68ff31Ssthen INSTALLTARGET="install-lib" 2085cebdf579Ssthen fi 2086cebdf579Ssthen]) 2087bdfc4d55Sflorianif test $ALLTARGET = "alltargets"; then 2088bdfc4d55Sflorian if test $USE_NSS = "yes"; then 20899982a05dSsthen AC_MSG_ERROR([--with-nss can only be used in combination with --with-libunbound-only.]) 2090bdfc4d55Sflorian fi 2091bdfc4d55Sflorian if test $USE_NETTLE = "yes"; then 20929982a05dSsthen AC_MSG_ERROR([--with-nettle can only be used in combination with --with-libunbound-only.]) 2093bdfc4d55Sflorian fi 2094bdfc4d55Sflorianfi 2095bdfc4d55Sflorian 2096cebdf579SsthenAC_SUBST(ALLTARGET) 20970b68ff31SsthenAC_SUBST(INSTALLTARGET) 2098933707f3Ssthen 2099933707f3SsthenACX_STRIP_EXT_FLAGS 21007191de28Ssthenif test -n "$LATE_LDFLAGS"; then 2101933707f3Ssthen LDFLAGS="$LATE_LDFLAGS $LDFLAGS" 21027191de28Ssthenfi 21037191de28Ssthen# remove start spaces 21047191de28SsthenLDFLAGS=`echo "$LDFLAGS"|sed -e 's/^ *//'` 21057191de28SsthenLIBS=`echo "$LIBS"|sed -e 's/^ *//'` 2106933707f3Ssthen 2107933707f3SsthenAC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [10240], [Define to the maximum message length to pass to syslog.]) 2108933707f3Ssthen 2109933707f3SsthenAH_BOTTOM( 2110933707f3Ssthendnl this must be first AH_CONFIG, to define the flags before any includes. 2111933707f3SsthenAHX_CONFIG_EXT_FLAGS 2112933707f3Ssthen 2113933707f3Ssthendnl includes 2114933707f3Ssthen[ 2115550cf4a9Ssthen#ifndef _OPENBSD_SOURCE 2116550cf4a9Ssthen#define _OPENBSD_SOURCE 1 2117550cf4a9Ssthen#endif 2118550cf4a9Ssthen 2119933707f3Ssthen#ifndef UNBOUND_DEBUG 2120550cf4a9Ssthen# ifndef NDEBUG 2121933707f3Ssthen# define NDEBUG 2122933707f3Ssthen# endif 2123550cf4a9Ssthen#endif 2124933707f3Ssthen 21250b68ff31Ssthen/** Use small-ldns codebase */ 21260b68ff31Ssthen#define USE_SLDNS 1 21270b68ff31Ssthen#ifdef HAVE_SSL 21280b68ff31Ssthen# define LDNS_BUILD_CONFIG_HAVE_SSL 1 21290b68ff31Ssthen#endif 21300b68ff31Ssthen 2131933707f3Ssthen#include <stdio.h> 2132933707f3Ssthen#include <string.h> 2133933707f3Ssthen#include <unistd.h> 2134933707f3Ssthen#include <assert.h> 2135933707f3Ssthen 2136933707f3Ssthen#if STDC_HEADERS 2137933707f3Ssthen#include <stdlib.h> 2138933707f3Ssthen#include <stddef.h> 2139933707f3Ssthen#endif 2140933707f3Ssthen 21410b68ff31Ssthen#ifdef HAVE_STDARG_H 21420b68ff31Ssthen#include <stdarg.h> 21430b68ff31Ssthen#endif 21440b68ff31Ssthen 2145933707f3Ssthen#ifdef HAVE_STDINT_H 2146933707f3Ssthen#include <stdint.h> 2147933707f3Ssthen#endif 2148933707f3Ssthen 2149933707f3Ssthen#include <errno.h> 2150933707f3Ssthen 2151933707f3Ssthen#if HAVE_SYS_PARAM_H 2152933707f3Ssthen#include <sys/param.h> 2153933707f3Ssthen#endif 2154933707f3Ssthen 2155933707f3Ssthen#ifdef HAVE_SYS_SOCKET_H 2156933707f3Ssthen#include <sys/socket.h> 2157933707f3Ssthen#endif 2158933707f3Ssthen 2159933707f3Ssthen#ifdef HAVE_SYS_UIO_H 2160933707f3Ssthen#include <sys/uio.h> 2161933707f3Ssthen#endif 2162933707f3Ssthen 2163933707f3Ssthen#ifdef HAVE_NETINET_IN_H 2164933707f3Ssthen#include <netinet/in.h> 2165933707f3Ssthen#endif 2166933707f3Ssthen 216732e31f52Ssthen#ifdef HAVE_NETINET_TCP_H 216832e31f52Ssthen#include <netinet/tcp.h> 216932e31f52Ssthen#endif 217032e31f52Ssthen 2171933707f3Ssthen#ifdef HAVE_ARPA_INET_H 2172933707f3Ssthen#include <arpa/inet.h> 2173933707f3Ssthen#endif 2174933707f3Ssthen 2175933707f3Ssthen#ifdef HAVE_WINSOCK2_H 2176933707f3Ssthen#include <winsock2.h> 2177933707f3Ssthen#endif 2178933707f3Ssthen 2179933707f3Ssthen#ifdef HAVE_WS2TCPIP_H 2180933707f3Ssthen#include <ws2tcpip.h> 2181933707f3Ssthen#endif 21820b68ff31Ssthen 21830bdb4f62Ssthen#if !defined(USE_WINSOCK) || !defined(HAVE_SNPRINTF) || defined(SNPRINTF_RET_BROKEN) || defined(__USE_MINGW_ANSI_STDIO) 21840b68ff31Ssthen#define ARG_LL "%ll" 21850b68ff31Ssthen#else 21860b68ff31Ssthen#define ARG_LL "%I64" 21870b68ff31Ssthen#endif 218831f127bbSsthen 218931f127bbSsthen#ifndef AF_LOCAL 219031f127bbSsthen#define AF_LOCAL AF_UNIX 219131f127bbSsthen#endif 2192933707f3Ssthen] 2193933707f3Ssthen 2194933707f3SsthenAHX_CONFIG_FORMAT_ATTRIBUTE 2195933707f3SsthenAHX_CONFIG_UNUSED_ATTRIBUTE 2196933707f3SsthenAHX_CONFIG_FSEEKO 2197933707f3SsthenAHX_CONFIG_MAXHOSTNAMELEN 219824893edcSsthen#if !defined(HAVE_SNPRINTF) || defined(SNPRINTF_RET_BROKEN) 219924893edcSsthen#define snprintf snprintf_unbound 220024893edcSsthen#define vsnprintf vsnprintf_unbound 220124893edcSsthen#include <stdarg.h> 220224893edcSsthenint snprintf (char *str, size_t count, const char *fmt, ...); 220324893edcSsthenint vsnprintf (char *str, size_t count, const char *fmt, va_list arg); 220424893edcSsthen#endif /* HAVE_SNPRINTF or SNPRINTF_RET_BROKEN */ 2205933707f3SsthenAHX_CONFIG_INET_PTON(unbound) 2206933707f3SsthenAHX_CONFIG_INET_NTOP(unbound) 2207933707f3SsthenAHX_CONFIG_INET_ATON(unbound) 2208933707f3SsthenAHX_CONFIG_MEMMOVE(unbound) 22090b68ff31SsthenAHX_CONFIG_STRLCAT(unbound) 2210933707f3SsthenAHX_CONFIG_STRLCPY(unbound) 2211933707f3SsthenAHX_CONFIG_GMTIME_R(unbound) 2212a58bff56SsthenAHX_CONFIG_REALLOCARRAY(unbound) 2213933707f3SsthenAHX_CONFIG_W32_SLEEP 2214933707f3SsthenAHX_CONFIG_W32_USLEEP 2215933707f3SsthenAHX_CONFIG_W32_RANDOM 2216933707f3SsthenAHX_CONFIG_W32_SRANDOM 2217933707f3SsthenAHX_CONFIG_W32_FD_SET_T 2218933707f3SsthenAHX_CONFIG_IPV6_MIN_MTU 2219933707f3SsthenAHX_MEMCMP_BROKEN(unbound) 2220933707f3Ssthen 2221933707f3Ssthen[ 2222933707f3Ssthen#ifndef HAVE_CTIME_R 2223933707f3Ssthen#define ctime_r unbound_ctime_r 2224933707f3Ssthenchar *ctime_r(const time_t *timep, char *buf); 2225933707f3Ssthen#endif 2226933707f3Ssthen 22272ee382b6Ssthen#ifndef HAVE_STRSEP 22282ee382b6Ssthen#define strsep unbound_strsep 22292ee382b6Ssthenchar *strsep(char **stringp, const char *delim); 22302ee382b6Ssthen#endif 22312ee382b6Ssthen 223224893edcSsthen#ifndef HAVE_ISBLANK 223324893edcSsthen#define isblank unbound_isblank 223424893edcSsthenint isblank(int c); 223524893edcSsthen#endif 223624893edcSsthen 2237452a1548Ssthen#ifndef HAVE_EXPLICIT_BZERO 2238452a1548Ssthen#define explicit_bzero unbound_explicit_bzero 2239452a1548Ssthenvoid explicit_bzero(void* buf, size_t len); 2240452a1548Ssthen#endif 2241452a1548Ssthen 224277079be7Ssthen#if defined(HAVE_INET_NTOP) && !HAVE_DECL_INET_NTOP 224377079be7Ssthenconst char *inet_ntop(int af, const void *src, char *dst, size_t size); 224477079be7Ssthen#endif 224577079be7Ssthen 224677079be7Ssthen#if defined(HAVE_INET_PTON) && !HAVE_DECL_INET_PTON 224777079be7Ssthenint inet_pton(int af, const char* src, void* dst); 224877079be7Ssthen#endif 224977079be7Ssthen 2250933707f3Ssthen#if !defined(HAVE_STRPTIME) || !defined(STRPTIME_WORKS) 2251933707f3Ssthen#define strptime unbound_strptime 2252933707f3Ssthenstruct tm; 2253933707f3Ssthenchar *strptime(const char *s, const char *format, struct tm *tm); 2254933707f3Ssthen#endif 2255933707f3Ssthen 2256ebf5bb73Ssthen#if !HAVE_DECL_REALLOCARRAY 2257ebf5bb73Ssthenvoid *reallocarray(void *ptr, size_t nmemb, size_t size); 2258ebf5bb73Ssthen#endif 2259ebf5bb73Ssthen 2260eaf2578eSsthen#ifdef HAVE_LIBBSD 2261eaf2578eSsthen#include <bsd/string.h> 2262eaf2578eSsthen#include <bsd/stdlib.h> 2263eaf2578eSsthen#endif 2264eaf2578eSsthen 2265e10d3884Sbrad#ifdef HAVE_LIBRESSL 2266e10d3884Sbrad# if !HAVE_DECL_STRLCPY 2267e10d3884Sbradsize_t strlcpy(char *dst, const char *src, size_t siz); 2268e10d3884Sbrad# endif 2269e10d3884Sbrad# if !HAVE_DECL_STRLCAT 2270e10d3884Sbradsize_t strlcat(char *dst, const char *src, size_t siz); 2271e10d3884Sbrad# endif 2272e10d3884Sbrad# if !HAVE_DECL_ARC4RANDOM && defined(HAVE_ARC4RANDOM) 2273e10d3884Sbraduint32_t arc4random(void); 2274e10d3884Sbrad# endif 2275e10d3884Sbrad# if !HAVE_DECL_ARC4RANDOM_UNIFORM && defined(HAVE_ARC4RANDOM_UNIFORM) 2276e10d3884Sbraduint32_t arc4random_uniform(uint32_t upper_bound); 2277e10d3884Sbrad# endif 2278e10d3884Sbrad#endif /* HAVE_LIBRESSL */ 2279e10d3884Sbrad#ifndef HAVE_ARC4RANDOM 2280e10d3884Sbradint getentropy(void* buf, size_t len); 2281e10d3884Sbraduint32_t arc4random(void); 2282e10d3884Sbradvoid arc4random_buf(void* buf, size_t n); 2283e10d3884Sbradvoid _ARC4_LOCK(void); 2284e10d3884Sbradvoid _ARC4_UNLOCK(void); 2285938a3a5eSflorianvoid _ARC4_LOCK_DESTROY(void); 2286e10d3884Sbrad#endif 2287e10d3884Sbrad#ifndef HAVE_ARC4RANDOM_UNIFORM 2288e10d3884Sbraduint32_t arc4random_uniform(uint32_t upper_bound); 2289e10d3884Sbrad#endif 2290e10d3884Sbrad#ifdef COMPAT_SHA512 2291e10d3884Sbrad#ifndef SHA512_DIGEST_LENGTH 2292e10d3884Sbrad#define SHA512_BLOCK_LENGTH 128 2293e10d3884Sbrad#define SHA512_DIGEST_LENGTH 64 2294e10d3884Sbrad#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) 2295e10d3884Sbradtypedef struct _SHA512_CTX { 2296e10d3884Sbrad uint64_t state[8]; 2297e10d3884Sbrad uint64_t bitcount[2]; 2298e10d3884Sbrad uint8_t buffer[SHA512_BLOCK_LENGTH]; 2299e10d3884Sbrad} SHA512_CTX; 2300e10d3884Sbrad#endif /* SHA512_DIGEST_LENGTH */ 2301e10d3884Sbradvoid SHA512_Init(SHA512_CTX*); 2302e10d3884Sbradvoid SHA512_Update(SHA512_CTX*, void*, size_t); 2303e10d3884Sbradvoid SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*); 2304e10d3884Sbradunsigned char *SHA512(void* data, unsigned int data_len, unsigned char *digest); 2305e10d3884Sbrad#endif /* COMPAT_SHA512 */ 2306e10d3884Sbrad 2307e10d3884Sbrad 2308e10d3884Sbrad 2309933707f3Ssthen#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)) 2310933707f3Ssthen /* using version of libevent that is not threadsafe. */ 2311933707f3Ssthen# define LIBEVENT_SIGNAL_PROBLEM 1 2312933707f3Ssthen#endif 2313933707f3Ssthen 2314933707f3Ssthen#ifndef CHECKED_INET6 2315933707f3Ssthen# define CHECKED_INET6 2316933707f3Ssthen# ifdef AF_INET6 2317933707f3Ssthen# define INET6 2318933707f3Ssthen# else 2319933707f3Ssthen# define AF_INET6 28 2320933707f3Ssthen# endif 2321933707f3Ssthen#endif /* CHECKED_INET6 */ 2322933707f3Ssthen 2323933707f3Ssthen#ifndef HAVE_GETADDRINFO 2324933707f3Ssthenstruct sockaddr_storage; 2325933707f3Ssthen#include "compat/fake-rfc2553.h" 2326933707f3Ssthen#endif 2327933707f3Ssthen 2328933707f3Ssthen#ifdef UNBOUND_ALLOC_STATS 2329933707f3Ssthen# define malloc(s) unbound_stat_malloc_log(s, __FILE__, __LINE__, __func__) 2330933707f3Ssthen# define calloc(n,s) unbound_stat_calloc_log(n, s, __FILE__, __LINE__, __func__) 2331933707f3Ssthen# define free(p) unbound_stat_free_log(p, __FILE__, __LINE__, __func__) 2332933707f3Ssthen# define realloc(p,s) unbound_stat_realloc_log(p, s, __FILE__, __LINE__, __func__) 233398bc733bSsthen# define strdup(s) unbound_stat_strdup_log(s, __FILE__, __LINE__, __func__) 2334933707f3Ssthenvoid *unbound_stat_malloc(size_t size); 2335933707f3Ssthenvoid *unbound_stat_calloc(size_t nmemb, size_t size); 2336933707f3Ssthenvoid unbound_stat_free(void *ptr); 2337933707f3Ssthenvoid *unbound_stat_realloc(void *ptr, size_t size); 2338933707f3Ssthenvoid *unbound_stat_malloc_log(size_t size, const char* file, int line, 2339933707f3Ssthen const char* func); 2340933707f3Ssthenvoid *unbound_stat_calloc_log(size_t nmemb, size_t size, const char* file, 2341933707f3Ssthen int line, const char* func); 2342933707f3Ssthenvoid unbound_stat_free_log(void *ptr, const char* file, int line, 2343933707f3Ssthen const char* func); 2344933707f3Ssthenvoid *unbound_stat_realloc_log(void *ptr, size_t size, const char* file, 2345933707f3Ssthen int line, const char* func); 234698bc733bSsthenchar *unbound_stat_strdup_log(const char *s, const char* file, int line, 234798bc733bSsthen const char* func); 2348933707f3Ssthen#elif defined(UNBOUND_ALLOC_LITE) 2349933707f3Ssthen# include "util/alloc.h" 2350933707f3Ssthen#endif /* UNBOUND_ALLOC_LITE and UNBOUND_ALLOC_STATS */ 2351933707f3Ssthen 2352933707f3Ssthen/** default port for DNS traffic. */ 2353933707f3Ssthen#define UNBOUND_DNS_PORT 53 235420237c55Ssthen/** default port for DNS over TLS traffic. */ 235520237c55Ssthen#define UNBOUND_DNS_OVER_TLS_PORT 853 23562c144df0Ssthen/** default port for DNS over HTTPS traffic. */ 23572c144df0Ssthen#define UNBOUND_DNS_OVER_HTTPS_PORT 443 2358933707f3Ssthen/** default port for unbound control traffic, registered port with IANA, 2359933707f3Ssthen ub-dns-control 8953/tcp unbound dns nameserver control */ 2360933707f3Ssthen#define UNBOUND_CONTROL_PORT 8953 2361933707f3Ssthen/** the version of unbound-control that this software implements */ 2362933707f3Ssthen#define UNBOUND_CONTROL_VERSION 1 2363933707f3Ssthen 2364933707f3Ssthen]) 2365933707f3Ssthen 2366e10d3884Sbraddnl if we build from source tree, the man pages need @date@ and @version@ 2367e10d3884Sbraddnl if this is a distro tarball, that was already done by makedist.sh 2368e10d3884SbradAC_SUBST(version, [VERSION_MAJOR.VERSION_MINOR.VERSION_MICRO]) 2369e10d3884SbradAC_SUBST(date, [`date +'%b %e, %Y'`]) 2370e10d3884Sbrad 23712be9e038SsthenAC_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]) 23729982a05dSsthenAC_CONFIG_HEADERS([config.h]) 2373933707f3SsthenAC_OUTPUT 2374