1# -*- Autoconf -*- 2# Process this file with autoconf to produce a configure script. 3AC_PREREQ(2.56) 4sinclude(acx_nlnetlabs.m4) 5sinclude(ax_pthread.m4) 6sinclude(acx_python.m4) 7sinclude(ac_pkg_swig.m4) 8sinclude(dnstap/dnstap.m4) 9sinclude(dnscrypt/dnscrypt.m4) 10 11# must be numbers. ac_defun because of later processing 12m4_define([VERSION_MAJOR],[1]) 13m4_define([VERSION_MINOR],[8]) 14m4_define([VERSION_MICRO],[1]) 15AC_INIT(unbound, m4_defn([VERSION_MAJOR]).m4_defn([VERSION_MINOR]).m4_defn([VERSION_MICRO]), unbound-bugs@nlnetlabs.nl, unbound) 16AC_SUBST(UNBOUND_VERSION_MAJOR, [VERSION_MAJOR]) 17AC_SUBST(UNBOUND_VERSION_MINOR, [VERSION_MINOR]) 18AC_SUBST(UNBOUND_VERSION_MICRO, [VERSION_MICRO]) 19 20LIBUNBOUND_CURRENT=8 21LIBUNBOUND_REVISION=1 22LIBUNBOUND_AGE=0 23# 1.0.0 had 0:12:0 24# 1.0.1 had 0:13:0 25# 1.0.2 had 0:14:0 26# 1.1.0 had 0:15:0 27# 1.1.1 had 0:16:0 28# 1.2.0 had 0:17:0 29# 1.2.1 had 0:18:0 30# 1.3.0 had 1:0:0 # ub_cancel and -export-symbols. 31# 1.3.1 had 1:1:0 32# 1.3.2 had 1:2:0 33# 1.3.3 had 1:3:0 34# 1.3.4 had 1:4:0 35# 1.4.0-snapshots had 1:5:0 36# 1.4.0 had 1:5:0 (not 2:0:0) # ub_result.why_bogus 37# 1.4.1 had 2:1:0 38# 1.4.2 had 2:2:0 39# 1.4.3 had 2:3:0 40# 1.4.4 had 2:4:0 41# 1.4.5 had 2:5:0 42# 1.4.6 had 2:6:0 43# 1.4.7 had 2:7:0 44# 1.4.8 had 2:8:0 45# 1.4.9 had 2:9:0 46# 1.4.10 had 2:10:0 47# 1.4.11 had 2:11:0 48# 1.4.12 had 2:12:0 49# 1.4.13 had 2:13:0 50# and 1.4.13p1 and 1.4.13.p2 51# 1.4.14 had 2:14:0 52# 1.4.15 had 3:0:1 # adds ub_version() 53# 1.4.16 had 3:1:1 54# 1.4.17 had 3:2:1 55# 1.4.18 had 3:3:1 56# 1.4.19 had 3:4:1 57# 1.4.20 had 4:0:2 # adds libunbound.ttl # but shipped 3:5:1 58# 1.4.21 had 4:1:2 59# 1.4.22 had 4:1:2 60# 1.5.0 had 5:3:3 # adds ub_ctx_add_ta_autr 61# 1.5.1 had 5:3:3 62# 1.5.2 had 5:5:3 63# 1.5.3 had 5:6:3 64# 1.5.4 had 5:7:3 65# 1.5.5 had 5:8:3 66# 1.5.6 had 5:9:3 67# 1.5.7 had 5:10:3 68# 1.5.8 had 6:0:4 # adds ub_ctx_set_stub 69# 1.5.9 had 6:1:4 70# 1.5.10 had 6:2:4 71# 1.6.0 had 6:3:4 72# 1.6.1 had 7:0:5 # ub_callback_t typedef renamed to ub_callback_type 73# 1.6.2 had 7:1:5 74# 1.6.3 had 7:2:5 75# 1.6.4 had 7:3:5 76# 1.6.5 had 7:4:5 77# 1.6.6 had 7:5:5 78# 1.6.7 had 7:6:5 79# 1.6.8 had 7:7:5 80# 1.7.0 had 7:8:5 81# 1.7.1 had 7:9:5 82# 1.7.2 had 7:10:5 83# 1.7.3 had 7:11:5 84# 1.8.0 had 8:0:0 # changes the event callback function signature 85# 1.8.1 had 8:1:0 86 87# Current -- the number of the binary API that we're implementing 88# Revision -- which iteration of the implementation of the binary 89# API are we supplying? 90# Age -- How many previous binary API versions do we also 91# support? 92# 93# If we release a new version that does not change the binary API, 94# increment Revision. 95# 96# If we release a new version that changes the binary API, but does 97# not break programs compiled against the old binary API, increment 98# Current and Age. Set Revision to 0, since this is the first 99# implementation of the new API. 100# 101# Otherwise, we're changing the binary API and breaking backward 102# compatibility with old binaries. Increment Current. Set Age to 0, 103# since we're backward compatible with no previous APIs. Set Revision 104# to 0 too. 105AC_SUBST(LIBUNBOUND_CURRENT) 106AC_SUBST(LIBUNBOUND_REVISION) 107AC_SUBST(LIBUNBOUND_AGE) 108 109CFLAGS="$CFLAGS" 110AC_AIX 111if test "$ac_cv_header_minix_config_h" = "yes"; then 112 AC_DEFINE(_NETBSD_SOURCE,1, [Enable for compile on Minix]) 113fi 114 115dnl 116dnl By default set prefix to /usr/local 117dnl 118case "$prefix" in 119 NONE) 120 prefix="/usr/local" 121 ;; 122esac 123case "$exec_prefix" in 124 NONE) 125 exec_prefix="$prefix" 126 ;; 127esac 128 129# are we on MinGW? 130if uname -s 2>&1 | grep MINGW32 >/dev/null; then on_mingw="yes" 131else 132 if echo $host $target | grep mingw32 >/dev/null; then on_mingw="yes" 133 else on_mingw="no"; fi 134fi 135 136# 137# Determine configuration file 138# the eval is to evaluate shell expansion twice 139UNBOUND_SBIN_DIR=`eval echo "${sbindir}"` 140AC_SUBST(UNBOUND_SBIN_DIR) 141UNBOUND_SYSCONF_DIR=`eval echo "${sysconfdir}"` 142AC_SUBST(UNBOUND_SYSCONF_DIR) 143UNBOUND_LOCALSTATE_DIR=`eval echo "${localstatedir}"` 144AC_SUBST(UNBOUND_LOCALSTATE_DIR) 145if test $on_mingw = "no"; then 146 ub_conf_file=`eval echo "${sysconfdir}/unbound/unbound.conf"` 147else 148 ub_conf_file="C:\\Program Files\\Unbound\\service.conf" 149fi 150AC_ARG_WITH([conf_file], 151 AC_HELP_STRING([--with-conf-file=path], 152 [Pathname to the Unbound configuration file]), 153 [ub_conf_file="$withval"]) 154AC_SUBST(ub_conf_file) 155ACX_ESCAPE_BACKSLASH($ub_conf_file, hdr_config) 156AC_DEFINE_UNQUOTED(CONFIGFILE, ["$hdr_config"], [Pathname to the Unbound configuration file]) 157ub_conf_dir=`AS_DIRNAME(["$ub_conf_file"])` 158AC_SUBST(ub_conf_dir) 159 160# Determine run, chroot directory and pidfile locations 161AC_ARG_WITH(run-dir, 162 AC_HELP_STRING([--with-run-dir=path], 163 [set default directory to chdir to (by default dir part of cfg file)]), 164 UNBOUND_RUN_DIR="$withval", 165if test $on_mingw = no; then 166 UNBOUND_RUN_DIR=`dirname "$ub_conf_file"` 167else 168 UNBOUND_RUN_DIR="" 169fi 170) 171AC_SUBST(UNBOUND_RUN_DIR) 172ACX_ESCAPE_BACKSLASH($UNBOUND_RUN_DIR, hdr_run) 173AC_DEFINE_UNQUOTED(RUN_DIR, ["$hdr_run"], [Directory to chdir to]) 174 175AC_ARG_WITH(chroot-dir, 176 AC_HELP_STRING([--with-chroot-dir=path], 177 [set default directory to chroot to (by default same as run-dir)]), 178 UNBOUND_CHROOT_DIR="$withval", 179if test $on_mingw = no; then 180 UNBOUND_CHROOT_DIR="$UNBOUND_RUN_DIR" 181else 182 UNBOUND_CHROOT_DIR="" 183fi 184) 185AC_SUBST(UNBOUND_CHROOT_DIR) 186ACX_ESCAPE_BACKSLASH($UNBOUND_CHROOT_DIR, hdr_chroot) 187AC_DEFINE_UNQUOTED(CHROOT_DIR, ["$hdr_chroot"], [Directory to chroot to]) 188 189AC_ARG_WITH(share-dir, 190 AC_HELP_STRING([--with-share-dir=path], 191 [set default directory with shared data (by default same as share/unbound)]), 192 UNBOUND_SHARE_DIR="$withval", 193 UNBOUND_SHARE_DIR="$UNBOUND_RUN_DIR") 194AC_SUBST(UNBOUND_SHARE_DIR) 195AC_DEFINE_UNQUOTED(SHARE_DIR, ["$UNBOUND_SHARE_DIR"], [Shared data]) 196 197AC_ARG_WITH(pidfile, 198 AC_HELP_STRING([--with-pidfile=filename], 199 [set default pathname to unbound pidfile (default run-dir/unbound.pid)]), 200 UNBOUND_PIDFILE="$withval", 201if test $on_mingw = no; then 202 UNBOUND_PIDFILE="$UNBOUND_RUN_DIR/unbound.pid" 203else 204 UNBOUND_PIDFILE="" 205fi 206) 207AC_SUBST(UNBOUND_PIDFILE) 208ACX_ESCAPE_BACKSLASH($UNBOUND_PIDFILE, hdr_pid) 209AC_DEFINE_UNQUOTED(PIDFILE, ["$hdr_pid"], [default pidfile location]) 210 211AC_ARG_WITH(rootkey-file, 212 AC_HELP_STRING([--with-rootkey-file=filename], 213 [set default pathname to root key file (default run-dir/root.key). This file is read and written.]), 214 UNBOUND_ROOTKEY_FILE="$withval", 215if test $on_mingw = no; then 216 UNBOUND_ROOTKEY_FILE="$UNBOUND_RUN_DIR/root.key" 217else 218 UNBOUND_ROOTKEY_FILE="C:\\Program Files\\Unbound\\root.key" 219fi 220) 221AC_SUBST(UNBOUND_ROOTKEY_FILE) 222ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTKEY_FILE, hdr_rkey) 223AC_DEFINE_UNQUOTED(ROOT_ANCHOR_FILE, ["$hdr_rkey"], [default rootkey location]) 224 225AC_ARG_WITH(rootcert-file, 226 AC_HELP_STRING([--with-rootcert-file=filename], 227 [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.]), 228 UNBOUND_ROOTCERT_FILE="$withval", 229if test $on_mingw = no; then 230 UNBOUND_ROOTCERT_FILE="$UNBOUND_RUN_DIR/icannbundle.pem" 231else 232 UNBOUND_ROOTCERT_FILE="C:\\Program Files\\Unbound\\icannbundle.pem" 233fi 234) 235AC_SUBST(UNBOUND_ROOTCERT_FILE) 236ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTCERT_FILE, hdr_rpem) 237AC_DEFINE_UNQUOTED(ROOT_CERT_FILE, ["$hdr_rpem"], [default rootcert location]) 238 239AC_ARG_WITH(username, 240 AC_HELP_STRING([--with-username=user], 241 [set default user that unbound changes to (default user is unbound)]), 242 UNBOUND_USERNAME="$withval", 243 UNBOUND_USERNAME="unbound") 244AC_SUBST(UNBOUND_USERNAME) 245AC_DEFINE_UNQUOTED(UB_USERNAME, ["$UNBOUND_USERNAME"], [default username]) 246 247AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled]) 248ACX_RSRC_VERSION(wnvs) 249AC_DEFINE_UNQUOTED(RSRC_PACKAGE_VERSION, [$wnvs], [version number for resource files]) 250 251# Checks for typedefs, structures, and compiler characteristics. 252AC_C_CONST 253AC_LANG_C 254# allow user to override the -g -O2 flags. 255default_cflags=no 256if test "x$CFLAGS" = "x" ; then 257ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="$CFLAGS -g"]) 258ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"]) 259default_cflags=yes 260fi 261AC_PROG_CC 262ACX_DEPFLAG 263ACX_DETERMINE_EXT_FLAGS_UNBOUND 264 265# debug mode flags warnings 266AC_ARG_ENABLE(checking, AC_HELP_STRING([--enable-checking], [Enable warnings, asserts, makefile-dependencies])) 267AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [same as enable-checking])) 268if test "$enable_debug" = "yes"; then debug_enabled="$enable_debug"; 269else debug_enabled="$enable_checking"; fi 270AC_SUBST(debug_enabled) 271case "$debug_enabled" in 272 yes) 273 ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="$CFLAGS -W"]) 274 ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="$CFLAGS -Wall"]) 275 ACX_CHECK_COMPILER_FLAG(Wextra, [CFLAGS="$CFLAGS -Wextra"]) 276 ACX_CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [CFLAGS="$CFLAGS -Wdeclaration-after-statement"]) 277 AC_DEFINE([UNBOUND_DEBUG], [], [define this to enable debug checks.]) 278 ;; 279 no|*) 280 # nothing to do. 281 ;; 282esac 283if test "$default_cflags" = "yes"; then 284 # only when CFLAGS was "" at the start, if the users wants to 285 # override we shouldn't add default cflags, because they wouldn't 286 # be able to turn off these options and set the CFLAGS wanted. 287 ACX_CHECK_FLTO 288 ACX_CHECK_PIE 289 ACX_CHECK_RELRO_NOW 290fi 291 292AC_C_INLINE 293ACX_CHECK_FORMAT_ATTRIBUTE 294ACX_CHECK_UNUSED_ATTRIBUTE 295 296AC_DEFUN([CHECK_WEAK_ATTRIBUTE], 297[AC_REQUIRE([AC_PROG_CC]) 298AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "weak" attribute) 299AC_CACHE_VAL(ac_cv_c_weak_attribute, 300[ac_cv_c_weak_attribute=no 301AC_TRY_COMPILE( 302[ #include <stdio.h> 303__attribute__((weak)) void f(int x) { printf("%d", x); } 304], [ 305 f(1); 306], 307[ac_cv_c_weak_attribute="yes"], 308[ac_cv_c_weak_attribute="no"]) 309]) 310 311AC_MSG_RESULT($ac_cv_c_weak_attribute) 312if test $ac_cv_c_weak_attribute = yes; then 313 AC_DEFINE(HAVE_ATTR_WEAK, 1, [Whether the C compiler accepts the "weak" attribute]) 314 AC_DEFINE(ATTR_WEAK, [__attribute__((weak))], [apply the weak attribute to a symbol]) 315fi 316])dnl End of CHECK_WEAK_ATTRIBUTE 317 318CHECK_WEAK_ATTRIBUTE 319 320AC_DEFUN([CHECK_NORETURN_ATTRIBUTE], 321[AC_REQUIRE([AC_PROG_CC]) 322AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "noreturn" attribute) 323AC_CACHE_VAL(ac_cv_c_noreturn_attribute, 324[ac_cv_c_noreturn_attribute=no 325AC_TRY_COMPILE( 326[ #include <stdio.h> 327__attribute__((noreturn)) void f(int x) { printf("%d", x); } 328], [ 329 f(1); 330], 331[ac_cv_c_noreturn_attribute="yes"], 332[ac_cv_c_noreturn_attribute="no"]) 333]) 334 335AC_MSG_RESULT($ac_cv_c_noreturn_attribute) 336if test $ac_cv_c_noreturn_attribute = yes; then 337 AC_DEFINE(HAVE_ATTR_NORETURN, 1, [Whether the C compiler accepts the "noreturn" attribute]) 338 AC_DEFINE(ATTR_NORETURN, [__attribute__((__noreturn__))], [apply the noreturn attribute to a function that exits the program]) 339fi 340])dnl End of CHECK_NORETURN_ATTRIBUTE 341 342CHECK_NORETURN_ATTRIBUTE 343 344if test "$srcdir" != "."; then 345 CPPFLAGS="$CPPFLAGS -I$srcdir" 346fi 347 348AC_DEFUN([ACX_YYLEX_DESTROY], [ 349 AC_MSG_CHECKING([for yylex_destroy]) 350 if echo %% | $LEX -t 2>&1 | grep yylex_destroy >/dev/null 2>&1; then 351 AC_DEFINE(LEX_HAS_YYLEX_DESTROY, 1, [if lex has yylex_destroy]) 352 AC_MSG_RESULT(yes) 353 else AC_MSG_RESULT(no); 354 LEX=":" 355 fi 356]) 357 358AC_DEFUN([ACX_YYLEX_OPTION], [ 359 AC_MSG_CHECKING([for lex %option]) 360 if cat <<EOF | $LEX -t 2>&1 | grep yy_delete_buffer >/dev/null 2>&1; then 361%option nounput 362%% 363EOF 364 AC_MSG_RESULT(yes) 365 else AC_MSG_RESULT(no); 366 LEX=":" 367 fi 368]) 369 370AC_PROG_LEX 371if test "$LEX" != "" -a "$LEX" != ":"; then 372ACX_YYLEX_DESTROY 373fi 374if test "$LEX" != "" -a "$LEX" != ":"; then 375ACX_YYLEX_OPTION 376fi 377AC_PROG_YACC 378AC_CHECK_PROG(doxygen, doxygen, doxygen) 379AC_CHECK_TOOL(STRIP, strip) 380ACX_LIBTOOL_C_ONLY 381 382# Checks for header files. 383AC_CHECK_HEADERS([stdarg.h stdbool.h netinet/in.h netinet/tcp.h sys/param.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],,, [AC_INCLUDES_DEFAULT]) 384 385# check for types. 386# Using own tests for int64* because autoconf builtin only give 32bit. 387AC_CHECK_TYPE(int8_t, signed char) 388AC_CHECK_TYPE(int16_t, short) 389AC_CHECK_TYPE(int32_t, int) 390AC_CHECK_TYPE(int64_t, long long) 391AC_CHECK_TYPE(uint8_t, unsigned char) 392AC_CHECK_TYPE(uint16_t, unsigned short) 393AC_CHECK_TYPE(uint32_t, unsigned int) 394AC_CHECK_TYPE(uint64_t, unsigned long long) 395AC_TYPE_SIZE_T 396AC_CHECK_TYPE(ssize_t, int) 397AC_TYPE_UID_T 398AC_TYPE_PID_T 399AC_TYPE_OFF_T 400ACX_TYPE_U_CHAR 401ACX_TYPE_RLIM_T 402ACX_TYPE_SOCKLEN_T 403ACX_TYPE_IN_ADDR_T 404ACX_TYPE_IN_PORT_T 405ACX_CHECK_MEMCMP_SIGNED 406 407AC_CHECK_SIZEOF(time_t,,[ 408AC_INCLUDES_DEFAULT 409#ifdef TIME_WITH_SYS_TIME 410# include <sys/time.h> 411# include <time.h> 412#else 413# ifdef HAVE_SYS_TIME_H 414# include <sys/time.h> 415# else 416# include <time.h> 417# endif 418#endif 419]) 420 421# add option to disable the evil rpath 422ACX_ARG_RPATH 423AC_SUBST(RUNTIME_PATH) 424 425# check to see if libraries are needed for these functions. 426AC_SEARCH_LIBS([inet_pton], [nsl]) 427AC_SEARCH_LIBS([socket], [socket]) 428 429# check wether strptime also works 430AC_DEFUN([AC_CHECK_STRPTIME_WORKS], 431[AC_REQUIRE([AC_PROG_CC]) 432AC_MSG_CHECKING(whether strptime works) 433if test c${cross_compiling} = cno; then 434AC_RUN_IFELSE([AC_LANG_SOURCE([[ 435#define _XOPEN_SOURCE 600 436#include <time.h> 437int main(void) { struct tm tm; char *res; 438res = 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); 439if (!res) return 2; 440res = strptime("20070207111842", "%Y%m%d%H%M%S", &tm); 441if (!res) return 1; return 0; } 442]])] , [eval "ac_cv_c_strptime_works=yes"], [eval "ac_cv_c_strptime_works=no"]) 443else 444eval "ac_cv_c_strptime_works=maybe" 445fi 446AC_MSG_RESULT($ac_cv_c_strptime_works) 447if test $ac_cv_c_strptime_works = no; then 448AC_LIBOBJ(strptime) 449else 450AC_DEFINE_UNQUOTED([STRPTIME_WORKS], 1, [use default strptime.]) 451fi 452])dnl 453 454# check some functions of the OS before linking libs (while still runnable). 455AC_FUNC_CHOWN 456AC_FUNC_FORK 457AC_TYPE_SIGNAL 458AC_FUNC_FSEEKO 459ACX_SYS_LARGEFILE 460ACX_CHECK_NONBLOCKING_BROKEN 461ACX_MKDIR_ONE_ARG 462AC_CHECK_FUNCS([strptime],[AC_CHECK_STRPTIME_WORKS],[AC_LIBOBJ([strptime])]) 463 464# set memory allocation checking if requested 465AC_ARG_ENABLE(alloc-checks, AC_HELP_STRING([--enable-alloc-checks], 466 [ enable to memory allocation statistics, for debug purposes ]), 467 , ) 468AC_ARG_ENABLE(alloc-lite, AC_HELP_STRING([--enable-alloc-lite], 469 [ enable for lightweight alloc assertions, for debug purposes ]), 470 , ) 471AC_ARG_ENABLE(alloc-nonregional, AC_HELP_STRING([--enable-alloc-nonregional], 472 [ enable nonregional allocs, slow but exposes regional allocations to other memory purifiers, for debug purposes ]), 473 , ) 474if test x_$enable_alloc_nonregional = x_yes; then 475 AC_DEFINE(UNBOUND_ALLOC_NONREGIONAL, 1, [use malloc not regions, for debug use]) 476fi 477if test x_$enable_alloc_checks = x_yes; then 478 AC_DEFINE(UNBOUND_ALLOC_STATS, 1, [use statistics for allocs and frees, for debug use]) 479else 480 if test x_$enable_alloc_lite = x_yes; then 481 AC_DEFINE(UNBOUND_ALLOC_LITE, 1, [use to enable lightweight alloc assertions, for debug use]) 482 else 483 ACX_FUNC_MALLOC([unbound]) 484 fi 485fi 486 487# check windows threads (we use them, not pthreads, on windows). 488if test "$on_mingw" = "yes"; then 489# check windows threads 490 AC_CHECK_HEADERS([windows.h],,, [AC_INCLUDES_DEFAULT]) 491 AC_MSG_CHECKING([for CreateThread]) 492 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ 493#ifdef HAVE_WINDOWS_H 494#include <windows.h> 495#endif 496], [ 497 HANDLE t = CreateThread(NULL, 0, NULL, NULL, 0, NULL); 498])], 499 AC_MSG_RESULT(yes) 500 AC_DEFINE(HAVE_WINDOWS_THREADS, 1, [Using Windows threads]) 501, 502 AC_MSG_RESULT(no) 503) 504 505else 506# not on mingw, check thread libraries. 507 508# check for thread library. 509# check this first, so that the pthread lib does not get linked in via 510# libssl or libpython, and thus distorts the tests, and we end up using 511# the non-threadsafe C libraries. 512AC_ARG_WITH(pthreads, AC_HELP_STRING([--with-pthreads], 513 [use pthreads library, or --without-pthreads to disable threading support.]), 514 [ ],[ withval="yes" ]) 515ub_have_pthreads=no 516if test x_$withval != x_no; then 517 AX_PTHREAD([ 518 AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]) 519 if test -n "$PTHREAD_LIBS"; then 520 LIBS="$PTHREAD_LIBS $LIBS" 521 fi 522 CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 523 CC="$PTHREAD_CC" 524 ub_have_pthreads=yes 525 AC_CHECK_TYPES([pthread_spinlock_t, pthread_rwlock_t],,,[#include <pthread.h>]) 526 527 if echo "$CFLAGS" | $GREP -e "-pthread" >/dev/null; then 528 AC_MSG_CHECKING([if -pthread unused during linking]) 529 # catch clang warning 'argument unused during compilation' 530 AC_LANG_CONFTEST([AC_LANG_SOURCE(AC_INCLUDES_DEFAULT 531[[ 532int main(void) {return 0;} 533]])]) 534 pthread_unused="yes" 535 # first compile 536 echo "$CC $CFLAGS -c conftest.c -o conftest.o" >&AS_MESSAGE_LOG_FD 537 $CC $CFLAGS -c conftest.c -o conftest.o 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD 538 if test $? = 0; then 539 # then link 540 echo "$CC $CFLAGS -Werror $LDFLAGS $LIBS -o conftest contest.o" >&AS_MESSAGE_LOG_FD 541 $CC $CFLAGS -Werror $LDFLAGS $LIBS -o conftest conftest.o 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD 542 if test $? -ne 0; then 543 AC_MSG_RESULT(yes) 544 CFLAGS=`echo "$CFLAGS" | sed -e 's/-pthread//'` 545 PTHREAD_CFLAGS_ONLY="-pthread" 546 AC_SUBST(PTHREAD_CFLAGS_ONLY) 547 else 548 AC_MSG_RESULT(no) 549 fi 550 else 551 AC_MSG_RESULT(no) 552 fi # endif cc successful 553 rm -f conftest conftest.c conftest.o 554 fi # endif -pthread in CFLAGS 555 556 ]) 557fi 558 559# check solaris thread library 560AC_ARG_WITH(solaris-threads, AC_HELP_STRING([--with-solaris-threads], 561 [use solaris native thread library.]), [ ],[ withval="no" ]) 562ub_have_sol_threads=no 563if test x_$withval != x_no; then 564 if test x_$ub_have_pthreads != x_no; then 565 AC_WARN([Have pthreads already, ignoring --with-solaris-threads]) 566 else 567 AC_SEARCH_LIBS(thr_create, [thread], 568 [ 569 AC_DEFINE(HAVE_SOLARIS_THREADS, 1, [Using Solaris threads]) 570 571 ACX_CHECK_COMPILER_FLAG(mt, [CFLAGS="$CFLAGS -mt"], 572 [CFLAGS="$CFLAGS -D_REENTRANT"]) 573 ub_have_sol_threads=yes 574 ] , [ 575 AC_ERROR([no solaris threads found.]) 576 ]) 577 fi 578fi 579 580fi # end of non-mingw check of thread libraries 581 582# Check for PyUnbound 583AC_ARG_WITH(pyunbound, 584 AC_HELP_STRING([--with-pyunbound], 585 [build PyUnbound, or --without-pyunbound to skip it. (default=no)]), 586 [], [ withval="no" ]) 587 588ub_test_python=no 589ub_with_pyunbound=no 590if test x_$withval != x_no; then 591 ub_with_pyunbound=yes 592 ub_test_python=yes 593fi 594 595# Check for Python module 596AC_ARG_WITH(pythonmodule, 597 AC_HELP_STRING([--with-pythonmodule], 598 [build Python module, or --without-pythonmodule to disable script engine. (default=no)]), 599 [], [ withval="no" ]) 600 601ub_with_pythonmod=no 602if test x_$withval != x_no; then 603 ub_with_pythonmod=yes 604 ub_test_python=yes 605fi 606 607# Check for Python & SWIG only on PyUnbound or PyModule 608if test x_$ub_test_python != x_no; then 609 610 # Check for Python 611 ub_have_python=no 612 ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS 613 AC_PYTHON_DEVEL 614 if test ! -z "$PYTHON_VERSION"; then 615 if test `$PYTHON -c "print('$PYTHON_VERSION' >= '2.4.0')"` = "False"; then 616 AC_ERROR([Python version >= 2.4.0 is required]) 617 fi 618 619 [PY_MAJOR_VERSION="`$PYTHON -c \"import sys; print(sys.version_info[0])\"`"] 620 AC_SUBST(PY_MAJOR_VERSION) 621 # Have Python 622 AC_DEFINE(HAVE_PYTHON,1,[Define if you have Python libraries and header files.]) 623 if test -n "$LIBS"; then 624 LIBS="$PYTHON_LDFLAGS $LIBS" 625 else 626 LIBS="$PYTHON_LDFLAGS" 627 fi 628 if test -n "$CPPFLAGS"; then 629 CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS" 630 else 631 CPPFLAGS="$PYTHON_CPPFLAGS" 632 fi 633 ub_have_python=yes 634 PKG_PROG_PKG_CONFIG 635 PKG_CHECK_EXISTS(["python${PY_MAJOR_VERSION}"], 636 [PC_PY_DEPENDENCY="python${PY_MAJOR_VERSION}"], 637 [PC_PY_DEPENDENCY="python"]) 638 AC_SUBST(PC_PY_DEPENDENCY) 639 640 # Check for SWIG 641 ub_have_swig=no 642 AC_ARG_ENABLE(swig-version-check, AC_HELP_STRING([--disable-swig-version-check], [Disable swig version check to build python modules with older swig even though that is unreliable])) 643 if test "$enable_swig_version_check" = "yes"; then 644 AC_PROG_SWIG(2.0.1) 645 else 646 AC_PROG_SWIG 647 fi 648 AC_MSG_CHECKING(SWIG) 649 if test ! -x "$SWIG"; then 650 AC_ERROR([failed to find swig tool, install it, or do not build Python module and PyUnbound]) 651 else 652 AC_DEFINE(HAVE_SWIG, 1, [Define if you have Swig libraries and header files.]) 653 AC_SUBST(swig, "$SWIG") 654 AC_MSG_RESULT(present) 655 656 # If have Python & SWIG 657 # Declare PythonMod 658 if test x_$ub_with_pythonmod != x_no; then 659 AC_DEFINE(WITH_PYTHONMODULE, 1, [Define if you want Python module.]) 660 WITH_PYTHONMODULE=yes 661 AC_SUBST(WITH_PYTHONMODULE) 662 PYTHONMOD_OBJ="pythonmod.lo pythonmod_utils.lo" 663 AC_SUBST(PYTHONMOD_OBJ) 664 PYTHONMOD_HEADER='$(srcdir)/pythonmod/pythonmod.h' 665 AC_SUBST(PYTHONMOD_HEADER) 666 PYTHONMOD_INSTALL=pythonmod-install 667 AC_SUBST(PYTHONMOD_INSTALL) 668 PYTHONMOD_UNINSTALL=pythonmod-uninstall 669 AC_SUBST(PYTHONMOD_UNINSTALL) 670 fi 671 672 # Declare PyUnbound 673 if test x_$ub_with_pyunbound != x_no; then 674 AC_DEFINE(WITH_PYUNBOUND, 1, [Define if you want PyUnbound.]) 675 WITH_PYUNBOUND=yes 676 AC_SUBST(WITH_PYUNBOUND) 677 PYUNBOUND_OBJ="libunbound_wrap.lo" 678 AC_SUBST(PYUNBOUND_OBJ) 679 PYUNBOUND_TARGET="_unbound.la" 680 AC_SUBST(PYUNBOUND_TARGET) 681 PYUNBOUND_INSTALL=pyunbound-install 682 AC_SUBST(PYUNBOUND_INSTALL) 683 PYUNBOUND_UNINSTALL=pyunbound-uninstall 684 AC_SUBST(PYUNBOUND_UNINSTALL) 685 fi 686 fi 687 else 688 AC_MSG_RESULT([*** Python libraries not found, won't build PythonMod or PyUnbound ***]) 689 ub_with_pyunbound=no 690 ub_with_pythonmod=no 691 fi 692fi 693 694if test "`uname`" = "NetBSD"; then 695 NETBSD_LINTFLAGS='"-D__RENAME(x)=" -D_NETINET_IN_H_' 696 AC_SUBST(NETBSD_LINTFLAGS) 697fi 698CONFIG_DATE=`date +%Y%m%d` 699AC_SUBST(CONFIG_DATE) 700 701# Checks for libraries. 702 703# libnss 704USE_NSS="no" 705AC_ARG_WITH([nss], AC_HELP_STRING([--with-nss=path], 706 [use libnss instead of openssl, installed at path.]), 707 [ 708 USE_NSS="yes" 709 AC_DEFINE(HAVE_NSS, 1, [Use libnss for crypto]) 710 if test "$withval" != "" -a "$withval" != "yes"; then 711 CPPFLAGS="$CPPFLAGS -I$withval/include/nss3" 712 LDFLAGS="$LDFLAGS -L$withval/lib" 713 ACX_RUNTIME_PATH_ADD([$withval/lib]) 714 CPPFLAGS="-I$withval/include/nspr4 $CPPFLAGS" 715 else 716 CPPFLAGS="$CPPFLAGS -I/usr/include/nss3" 717 CPPFLAGS="-I/usr/include/nspr4 $CPPFLAGS" 718 fi 719 LIBS="$LIBS -lnss3 -lnspr4" 720 SSLLIB="" 721 ] 722) 723 724# libnettle 725USE_NETTLE="no" 726AC_ARG_WITH([nettle], AC_HELP_STRING([--with-nettle=path], 727 [use libnettle as crypto library, installed at path.]), 728 [ 729 USE_NETTLE="yes" 730 AC_DEFINE(HAVE_NETTLE, 1, [Use libnettle for crypto]) 731 AC_CHECK_HEADERS([nettle/dsa-compat.h],,, [AC_INCLUDES_DEFAULT]) 732 if test "$withval" != "" -a "$withval" != "yes"; then 733 CPPFLAGS="$CPPFLAGS -I$withval/include/nettle" 734 LDFLAGS="$LDFLAGS -L$withval/lib" 735 ACX_RUNTIME_PATH_ADD([$withval/lib]) 736 else 737 CPPFLAGS="$CPPFLAGS -I/usr/include/nettle" 738 fi 739 LIBS="$LIBS -lhogweed -lnettle -lgmp" 740 SSLLIB="" 741 ] 742) 743 744# openssl 745if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then 746ACX_WITH_SSL 747ACX_LIB_SSL 748SSLLIB="-lssl" 749 750# check if -lcrypt32 is needed because CAPIENG needs that. (on windows) 751BAKLIBS="$LIBS" 752LIBS="-lssl $LIBS" 753AC_MSG_CHECKING([if libssl needs -lcrypt32]) 754AC_TRY_LINK_FUNC([HMAC_Update], [ 755 AC_MSG_RESULT([no]) 756 LIBS="$BAKLIBS" 757], [ 758 AC_MSG_RESULT([yes]) 759 LIBS="$BAKLIBS" 760 LIBS="$LIBS -lcrypt32" 761]) 762 763AC_MSG_CHECKING([for LibreSSL]) 764if grep VERSION_TEXT $ssldir/include/openssl/opensslv.h | grep "LibreSSL" >/dev/null; then 765 AC_MSG_RESULT([yes]) 766 AC_DEFINE([HAVE_LIBRESSL], [1], [Define if we have LibreSSL]) 767 # libressl provides these compat functions, but they may also be 768 # declared by the OS in libc. See if they have been declared. 769 AC_CHECK_DECLS([strlcpy,strlcat,arc4random,arc4random_uniform,reallocarray]) 770else 771 AC_MSG_RESULT([no]) 772fi 773AC_CHECK_HEADERS([openssl/conf.h openssl/engine.h openssl/bn.h openssl/dh.h openssl/dsa.h openssl/rsa.h],,, [AC_INCLUDES_DEFAULT]) 774AC_CHECK_FUNCS([OPENSSL_config EVP_sha1 EVP_sha256 EVP_sha512 FIPS_mode EVP_MD_CTX_new OpenSSL_add_all_digests OPENSSL_init_crypto EVP_cleanup ERR_load_crypto_strings CRYPTO_cleanup_all_ex_data ERR_free_strings RAND_cleanup DSA_SIG_set0 EVP_dss1 EVP_DigestVerify]) 775 776# these check_funcs need -lssl 777BAKLIBS="$LIBS" 778LIBS="-lssl $LIBS" 779AC_CHECK_FUNCS([OPENSSL_init_ssl SSL_CTX_set_security_level SSL_set1_host SSL_get0_peername]) 780LIBS="$BAKLIBS" 781 782AC_CHECK_DECLS([SSL_COMP_get_compression_methods,sk_SSL_COMP_pop_free,SSL_CTX_set_ecdh_auto], [], [], [ 783AC_INCLUDES_DEFAULT 784#ifdef HAVE_OPENSSL_ERR_H 785#include <openssl/err.h> 786#endif 787 788#ifdef HAVE_OPENSSL_RAND_H 789#include <openssl/rand.h> 790#endif 791 792#ifdef HAVE_OPENSSL_CONF_H 793#include <openssl/conf.h> 794#endif 795 796#ifdef HAVE_OPENSSL_ENGINE_H 797#include <openssl/engine.h> 798#endif 799#include <openssl/ssl.h> 800#include <openssl/evp.h> 801]) 802fi 803AC_SUBST(SSLLIB) 804 805 806AC_ARG_ENABLE(sha1, AC_HELP_STRING([--disable-sha1], [Disable SHA1 RRSIG support, does not disable nsec3 support])) 807case "$enable_sha1" in 808 no) 809 ;; 810 yes|*) 811 AC_DEFINE([USE_SHA1], [1], [Define this to enable SHA1 support.]) 812 ;; 813esac 814 815 816AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support])) 817case "$enable_sha2" in 818 no) 819 ;; 820 yes|*) 821 AC_DEFINE([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.]) 822 ;; 823esac 824 825AC_ARG_ENABLE(subnet, AC_HELP_STRING([--enable-subnet], [Enable client subnet])) 826case "$enable_subnet" in 827 yes) 828 AC_DEFINE([CLIENT_SUBNET], [1], [Define this to enable client subnet option.]) 829 SUBNET_OBJ="edns-subnet.lo subnetmod.lo addrtree.lo subnet-whitelist.lo" 830 AC_SUBST(SUBNET_OBJ) 831 SUBNET_HEADER='$(srcdir)/edns-subnet/subnetmod.h $(srcdir)/edns-subnet/edns-subnet.h $(srcdir)/edns-subnet/subnet-whitelist.h $(srcdir)/edns-subnet/addrtree.h' 832 AC_SUBST(SUBNET_HEADER) 833 ;; 834 no|*) 835 ;; 836esac 837 838# check wether gost also works 839AC_DEFUN([AC_CHECK_GOST_WORKS], 840[AC_REQUIRE([AC_PROG_CC]) 841AC_MSG_CHECKING([if GOST works]) 842if test c${cross_compiling} = cno; then 843BAKCFLAGS="$CFLAGS" 844if test -n "$ssldir"; then 845 CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib" 846fi 847AC_RUN_IFELSE([AC_LANG_SOURCE([[ 848#include <string.h> 849#include <openssl/ssl.h> 850#include <openssl/evp.h> 851#include <openssl/engine.h> 852#include <openssl/conf.h> 853/* routine to load gost (from sldns) */ 854int load_gost_id(void) 855{ 856 static int gost_id = 0; 857 const EVP_PKEY_ASN1_METHOD* meth; 858 ENGINE* e; 859 860 if(gost_id) return gost_id; 861 862 /* see if configuration loaded gost implementation from other engine*/ 863 meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1); 864 if(meth) { 865 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); 866 return gost_id; 867 } 868 869 /* see if engine can be loaded already */ 870 e = ENGINE_by_id("gost"); 871 if(!e) { 872 /* load it ourself, in case statically linked */ 873 ENGINE_load_builtin_engines(); 874 ENGINE_load_dynamic(); 875 e = ENGINE_by_id("gost"); 876 } 877 if(!e) { 878 /* no gost engine in openssl */ 879 return 0; 880 } 881 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) { 882 ENGINE_finish(e); 883 ENGINE_free(e); 884 return 0; 885 } 886 887 meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1); 888 if(!meth) { 889 /* algo not found */ 890 ENGINE_finish(e); 891 ENGINE_free(e); 892 return 0; 893 } 894 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); 895 return gost_id; 896} 897int main(void) { 898 EVP_MD_CTX* ctx; 899 const EVP_MD* md; 900 unsigned char digest[64]; /* its a 256-bit digest, so uses 32 bytes */ 901 const char* str = "Hello world"; 902 const unsigned char check[] = { 903 0x40 , 0xed , 0xf8 , 0x56 , 0x5a , 0xc5 , 0x36 , 0xe1 , 904 0x33 , 0x7c , 0x7e , 0x87 , 0x62 , 0x1c , 0x42 , 0xe0 , 905 0x17 , 0x1b , 0x5e , 0xce , 0xa8 , 0x46 , 0x65 , 0x4d , 906 0x8d , 0x3e , 0x22 , 0x9b , 0xe1 , 0x30 , 0x19 , 0x9d 907 }; 908 OPENSSL_config(NULL); 909 (void)load_gost_id(); 910 md = EVP_get_digestbyname("md_gost94"); 911 if(!md) return 1; 912 memset(digest, 0, sizeof(digest)); 913 ctx = EVP_MD_CTX_create(); 914 if(!ctx) return 2; 915 if(!EVP_DigestInit_ex(ctx, md, NULL)) return 3; 916 if(!EVP_DigestUpdate(ctx, str, 10)) return 4; 917 if(!EVP_DigestFinal_ex(ctx, digest, NULL)) return 5; 918 /* uncomment to see the hash calculated. 919 {int i; 920 for(i=0; i<32; i++) 921 printf(" %2.2x", (int)digest[i]); 922 printf("\n");} 923 */ 924 if(memcmp(digest, check, sizeof(check)) != 0) 925 return 6; 926 return 0; 927} 928]])] , [eval "ac_cv_c_gost_works=yes"], [eval "ac_cv_c_gost_works=no"]) 929CFLAGS="$BAKCFLAGS" 930else 931eval "ac_cv_c_gost_works=maybe" 932fi 933AC_MSG_RESULT($ac_cv_c_gost_works) 934])dnl 935 936AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support])) 937use_gost="no" 938if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then 939case "$enable_gost" in 940 no) 941 ;; 942 *) 943 AC_CHECK_FUNC(EVP_PKEY_set_type_str, [:],[AC_MSG_ERROR([OpenSSL 1.0.0 is needed for GOST support])]) 944 AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([OpenSSL does not support ECC, needed for GOST support])]) 945 AC_CHECK_GOST_WORKS 946 if test "$ac_cv_c_gost_works" != no; then 947 use_gost="yes" 948 AC_DEFINE([USE_GOST], [1], [Define this to enable GOST support.]) 949 fi 950 ;; 951esac 952fi dnl !USE_NSS && !USE_NETTLE 953 954AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support])) 955use_ecdsa="no" 956case "$enable_ecdsa" in 957 no) 958 ;; 959 *) 960 if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then 961 AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade or rerun with --disable-ecdsa])]) 962 AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade or rerun with --disable-ecdsa])]) 963 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 964#include <openssl/evp.h> 965 ]) 966 # see if OPENSSL 1.0.0 or later (has EVP MD and Verify independency) 967 AC_MSG_CHECKING([if openssl supports SHA2 and ECDSA with EVP]) 968 if grep OPENSSL_VERSION_TEXT $ssldir/include/openssl/opensslv.h | grep "OpenSSL" >/dev/null; then 969 if grep OPENSSL_VERSION_NUMBER $ssldir/include/openssl/opensslv.h | grep 0x0 >/dev/null; then 970 AC_MSG_RESULT([no]) 971 AC_DEFINE_UNQUOTED([USE_ECDSA_EVP_WORKAROUND], [1], [Define this to enable an EVP workaround for older openssl]) 972 else 973 AC_MSG_RESULT([yes]) 974 fi 975 else 976 # not OpenSSL, thus likely LibreSSL, which supports it 977 AC_MSG_RESULT([yes]) 978 fi 979 fi 980 # we now know we have ECDSA and the required curves. 981 AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.]) 982 use_ecdsa="yes" 983 ;; 984esac 985 986AC_ARG_ENABLE(dsa, AC_HELP_STRING([--disable-dsa], [Disable DSA support])) 987use_dsa="no" 988case "$enable_dsa" in 989 no) 990 ;; 991 *) 992 # detect if DSA is supported, and turn it off if not. 993 if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then 994 AC_CHECK_FUNC(DSA_SIG_new, [ 995 AC_CHECK_TYPE(DSA_SIG*, [ 996 AC_DEFINE_UNQUOTED([USE_DSA], [1], [Define this to enable DSA support.]) 997 ], [if test "x$enable_dsa" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support DSA and you used --enable-dsa.]) 998 fi ], [ 999AC_INCLUDES_DEFAULT 1000#ifdef HAVE_OPENSSL_ERR_H 1001#include <openssl/err.h> 1002#endif 1003 1004#ifdef HAVE_OPENSSL_RAND_H 1005#include <openssl/rand.h> 1006#endif 1007 1008#ifdef HAVE_OPENSSL_CONF_H 1009#include <openssl/conf.h> 1010#endif 1011 1012#ifdef HAVE_OPENSSL_ENGINE_H 1013#include <openssl/engine.h> 1014#endif 1015 ]) 1016 ], [if test "x$enable_dsa" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support DSA and you used --enable-dsa.]) 1017 fi ]) 1018 else 1019 AC_DEFINE_UNQUOTED([USE_DSA], [1], [Define this to enable DSA support.]) 1020 fi 1021 ;; 1022esac 1023 1024AC_ARG_ENABLE(ed25519, AC_HELP_STRING([--disable-ed25519], [Disable ED25519 support])) 1025use_ed25519="no" 1026case "$enable_ed25519" in 1027 no) 1028 ;; 1029 *) 1030 if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then 1031 AC_CHECK_DECLS([NID_ED25519], [ 1032 use_ed25519="yes" 1033 ], [ if test "x$enable_ed25519" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support ED25519 and you used --enable-ed25519.]) 1034 fi ], [AC_INCLUDES_DEFAULT 1035#include <openssl/evp.h> 1036 ]) 1037 fi 1038 if test $USE_NETTLE = "yes"; then 1039 AC_CHECK_HEADERS([nettle/eddsa.h], use_ed25519="yes",, [AC_INCLUDES_DEFAULT]) 1040 fi 1041 if test $use_ed25519 = "yes"; then 1042 AC_DEFINE_UNQUOTED([USE_ED25519], [1], [Define this to enable ED25519 support.]) 1043 fi 1044 ;; 1045esac 1046 1047AC_ARG_ENABLE(ed448, AC_HELP_STRING([--disable-ed448], [Disable ED448 support])) 1048use_ed448="no" 1049case "$enable_ed448" in 1050 no) 1051 ;; 1052 *) 1053 if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then 1054 AC_CHECK_DECLS([NID_ED448], [ 1055 use_ed448="yes" 1056 ], [ if test "x$enable_ed448" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support ED448 and you used --enable-ed448.]) 1057 fi ], [AC_INCLUDES_DEFAULT 1058#include <openssl/evp.h> 1059 ]) 1060 fi 1061 if test $use_ed448 = "yes"; then 1062 AC_DEFINE_UNQUOTED([USE_ED448], [1], [Define this to enable ED448 support.]) 1063 fi 1064 ;; 1065esac 1066 1067AC_ARG_ENABLE(event-api, AC_HELP_STRING([--enable-event-api], [Enable (experimental) pluggable event base libunbound API installed to unbound-event.h])) 1068case "$enable_event_api" in 1069 yes) 1070 AC_SUBST(UNBOUND_EVENT_INSTALL, [unbound-event-install]) 1071 AC_SUBST(UNBOUND_EVENT_UNINSTALL, [unbound-event-uninstall]) 1072 ;; 1073 *) 1074 ;; 1075esac 1076 1077AC_ARG_ENABLE(tfo-client, AC_HELP_STRING([--enable-tfo-client], [Enable TCP Fast Open for client mode])) 1078case "$enable_tfo_client" in 1079 yes) 1080 case `uname` in 1081 Linux) AC_CHECK_DECL([MSG_FASTOPEN], [AC_MSG_WARN([Check the platform specific TFO kernel parameters are correctly configured to support client mode TFO])], 1082 [AC_MSG_ERROR([TCP Fast Open is not available for client mode: please rerun without --enable-tfo-client])], 1083 [AC_INCLUDES_DEFAULT 1084#include <netinet/tcp.h> 1085]) 1086 AC_DEFINE_UNQUOTED([USE_MSG_FASTOPEN], [1], [Define this to enable client TCP Fast Open.]) 1087 ;; 1088 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])], 1089 [AC_MSG_ERROR([TCP Fast Open is not available for client mode: please rerun without --enable-tfo-client])], 1090 [AC_INCLUDES_DEFAULT 1091#include <sys/socket.h> 1092]) 1093 AC_DEFINE_UNQUOTED([USE_OSX_MSG_FASTOPEN], [1], [Define this to enable client TCP Fast Open.]) 1094 ;; 1095 esac 1096 ;; 1097 no|*) 1098 ;; 1099esac 1100 1101AC_ARG_ENABLE(tfo-server, AC_HELP_STRING([--enable-tfo-server], [Enable TCP Fast Open for server mode])) 1102case "$enable_tfo_server" in 1103 yes) 1104 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 1105#include <netinet/tcp.h> 1106 ]) 1107 AC_DEFINE_UNQUOTED([USE_TCP_FASTOPEN], [1], [Define this to enable server TCP Fast Open.]) 1108 ;; 1109 no|*) 1110 ;; 1111esac 1112 1113# check for libevent 1114AC_ARG_WITH(libevent, AC_HELP_STRING([--with-libevent=pathname], 1115 [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.]), 1116 [ ],[ withval="no" ]) 1117if test x_$withval = x_yes -o x_$withval != x_no; then 1118 AC_MSG_CHECKING(for libevent) 1119 if test x_$withval = x_ -o x_$withval = x_yes; then 1120 withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" 1121 fi 1122 for dir in $withval; do 1123 thedir="$dir" 1124 if test -f "$dir/include/event.h" -o -f "$dir/include/event2/event.h"; then 1125 found_libevent="yes" 1126 dnl assume /usr is in default path. 1127 if test "$thedir" != "/usr"; then 1128 CPPFLAGS="$CPPFLAGS -I$thedir/include" 1129 fi 1130 break; 1131 fi 1132 done 1133 if test x_$found_libevent != x_yes; then 1134 if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then 1135 # libevent source directory 1136 AC_MSG_RESULT(found in $thedir) 1137 CPPFLAGS="$CPPFLAGS -I$thedir -I$thedir/include" 1138 BAK_LDFLAGS_SET="1" 1139 BAK_LDFLAGS="$LDFLAGS" 1140 # remove evdns from linking 1141 mkdir build >/dev/null 2>&1 1142 mkdir build/libevent >/dev/null 2>&1 1143 mkdir build/libevent/.libs >/dev/null 2>&1 1144 ev_files_o=`ls $thedir/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o` 1145 ev_files_lo=`ls $thedir/*.lo | grep -v evdns\.lo | grep -v bufferevent_openssl\.lo` 1146 ev_files_libso=`ls $thedir/.libs/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o` 1147 cp $ev_files_o build/libevent 1148 cp $ev_files_lo build/libevent 1149 cp $ev_files_libso build/libevent/.libs 1150 LATE_LDFLAGS="build/libevent/*.lo -lm" 1151 LDFLAGS="build/libevent/*.o $LDFLAGS -lm" 1152 else 1153 AC_MSG_ERROR([Cannot find the libevent library in $withval 1154You can restart ./configure --with-libevent=no to use a builtin alternative. 1155Please note that this alternative is not as capable as libevent when using 1156large outgoing port ranges. ]) 1157 fi 1158 else 1159 AC_MSG_RESULT(found in $thedir) 1160 dnl if event2 exists and no event lib in dir itself, use subdir 1161 if test ! -f $thedir/lib/libevent.a -a ! -f $thedir/lib/libevent.so -a -d "$thedir/lib/event2"; then 1162 LDFLAGS="$LDFLAGS -L$thedir/lib/event2" 1163 ACX_RUNTIME_PATH_ADD([$thedir/lib/event2]) 1164 else 1165 dnl assume /usr is in default path, do not add "". 1166 if test "$thedir" != "/usr" -a "$thedir" != ""; then 1167 LDFLAGS="$LDFLAGS -L$thedir/lib" 1168 ACX_RUNTIME_PATH_ADD([$thedir/lib]) 1169 fi 1170 fi 1171 fi 1172 # check for library used by libevent after 1.3c 1173 AC_SEARCH_LIBS([clock_gettime], [rt]) 1174 1175 # is the event.h header libev or libevent? 1176 AC_CHECK_HEADERS([event.h],,, [AC_INCLUDES_DEFAULT]) 1177 AC_CHECK_DECL(EV_VERSION_MAJOR, [ 1178 AC_SEARCH_LIBS(event_set, [ev]) 1179 ],[ 1180 AC_SEARCH_LIBS(event_set, [event]) 1181 ],[AC_INCLUDES_DEFAULT 1182#include <event.h> 1183 ]) 1184 AC_CHECK_FUNCS([event_base_free]) # only in libevent 1.2 and later 1185 AC_CHECK_FUNCS([event_base_once]) # only in libevent 1.4.1 and later 1186 AC_CHECK_FUNCS([event_base_new]) # only in libevent 1.4.1 and later 1187 AC_CHECK_FUNCS([event_base_get_method]) # only in libevent 1.4.3 and later 1188 AC_CHECK_FUNCS([ev_loop]) # only in libev. (tested on 3.51) 1189 AC_CHECK_FUNCS([ev_default_loop]) # only in libev. (tested on 4.00) 1190 PC_LIBEVENT_DEPENDENCY="libevent" 1191 AC_SUBST(PC_LIBEVENT_DEPENDENCY) 1192 if test -n "$BAK_LDFLAGS_SET"; then 1193 LDFLAGS="$BAK_LDFLAGS" 1194 fi 1195else 1196 AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events]) 1197fi 1198 1199# check for libexpat 1200AC_ARG_WITH(libexpat, AC_HELP_STRING([--with-libexpat=path], 1201 [specify explicit path for libexpat.]), 1202 [ ],[ withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" ]) 1203AC_MSG_CHECKING(for libexpat) 1204found_libexpat="no" 1205for dir in $withval ; do 1206 if test -f "$dir/include/expat.h"; then 1207 found_libexpat="yes" 1208 dnl assume /usr is in default path. 1209 if test "$dir" != "/usr"; then 1210 CPPFLAGS="$CPPFLAGS -I$dir/include" 1211 LDFLAGS="$LDFLAGS -L$dir/lib" 1212 fi 1213 AC_MSG_RESULT(found in $dir) 1214 break; 1215 fi 1216done 1217if test x_$found_libexpat != x_yes; then 1218 AC_ERROR([Could not find libexpat, expat.h]) 1219fi 1220AC_CHECK_HEADERS([expat.h],,, [AC_INCLUDES_DEFAULT]) 1221AC_CHECK_DECLS([XML_StopParser], [], [], [AC_INCLUDES_DEFAULT 1222#include <expat.h> 1223]) 1224 1225# hiredis (redis C client for cachedb) 1226AC_ARG_WITH(libhiredis, AC_HELP_STRING([--with-libhiredis=path], 1227 [specify explicit path for libhiredis.]), 1228 [ ],[ withval="no" ]) 1229found_libhiredis="no" 1230if test x_$withval = x_yes -o x_$withval != x_no; then 1231 AC_MSG_CHECKING(for libhiredis) 1232 if test x_$withval = x_ -o x_$withval = x_yes; then 1233 withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" 1234 fi 1235 for dir in $withval ; do 1236 if test -f "$dir/include/hiredis/hiredis.h"; then 1237 found_libhiredis="yes" 1238 dnl assume /usr is in default path. 1239 if test "$dir" != "/usr"; then 1240 CPPFLAGS="$CPPFLAGS -I$dir/include" 1241 LDFLAGS="$LDFLAGS -L$dir/lib" 1242 fi 1243 AC_MSG_RESULT(found in $dir) 1244 AC_DEFINE([USE_REDIS], [1], [Define this to use hiredis client.]) 1245 LIBS="$LIBS -lhiredis" 1246 break; 1247 fi 1248 done 1249 if test x_$found_libhiredis != x_yes; then 1250 AC_ERROR([Could not find libhiredis, hiredis.h]) 1251 fi 1252 AC_CHECK_HEADERS([hiredis/hiredis.h],,, [AC_INCLUDES_DEFAULT]) 1253 AC_CHECK_DECLS([redisConnect], [], [], [AC_INCLUDES_DEFAULT 1254 #include <hiredis/hiredis.h> 1255 ]) 1256fi 1257 1258# set static linking if requested 1259AC_SUBST(staticexe) 1260staticexe="" 1261AC_ARG_ENABLE(static-exe, AC_HELP_STRING([--enable-static-exe], 1262 [ enable to compile executables statically against (event) libs, for debug purposes ]), 1263 , ) 1264if test x_$enable_static_exe = x_yes; then 1265 staticexe="-static" 1266 if test "$on_mingw" = yes; then 1267 staticexe="-all-static" 1268 # for static compile, include gdi32 and zlib here. 1269 if echo $LIBS | grep 'lgdi32' >/dev/null; then 1270 : 1271 else 1272 LIBS="$LIBS -lgdi32" 1273 fi 1274 LIBS="$LIBS -lz" 1275 fi 1276fi 1277 1278# Include systemd.m4 - begin 1279sinclude(systemd.m4) 1280# Include systemd.m4 - end 1281 1282# set lock checking if requested 1283AC_ARG_ENABLE(lock_checks, AC_HELP_STRING([--enable-lock-checks], 1284 [ enable to check lock and unlock calls, for debug purposes ]), 1285 , ) 1286if test x_$enable_lock_checks = x_yes; then 1287 AC_DEFINE(ENABLE_LOCK_CHECKS, 1, [Define if you want to use debug lock checking (slow).]) 1288 CHECKLOCK_OBJ="checklocks.lo" 1289 AC_SUBST(CHECKLOCK_OBJ) 1290fi 1291 1292ACX_CHECK_GETADDRINFO_WITH_INCLUDES 1293if test "$USE_WINSOCK" = 1; then 1294 AC_DEFINE(UB_ON_WINDOWS, 1, [Use win32 resources and API]) 1295 AC_CHECK_HEADERS([iphlpapi.h],,, [AC_INCLUDES_DEFAULT 1296#include <windows.h> 1297 ]) 1298 AC_CHECK_TOOL(WINDRES, windres) 1299 LIBS="$LIBS -liphlpapi -lcrypt32" 1300 WINAPPS="unbound-service-install.exe unbound-service-remove.exe anchor-update.exe" 1301 AC_SUBST(WINAPPS) 1302 WIN_DAEMON_SRC="winrc/win_svc.c winrc/w_inst.c" 1303 AC_SUBST(WIN_DAEMON_SRC) 1304 WIN_DAEMON_OBJ="win_svc.lo w_inst.lo" 1305 AC_SUBST(WIN_DAEMON_OBJ) 1306 WIN_DAEMON_OBJ_LINK="rsrc_unbound.o" 1307 AC_SUBST(WIN_DAEMON_OBJ_LINK) 1308 WIN_HOST_OBJ_LINK="rsrc_unbound_host.o" 1309 AC_SUBST(WIN_HOST_OBJ_LINK) 1310 WIN_UBANCHOR_OBJ_LINK="rsrc_unbound_anchor.o log.lo locks.lo" 1311 AC_SUBST(WIN_UBANCHOR_OBJ_LINK) 1312 WIN_CONTROL_OBJ_LINK="rsrc_unbound_control.o" 1313 AC_SUBST(WIN_CONTROL_OBJ_LINK) 1314 WIN_CHECKCONF_OBJ_LINK="rsrc_unbound_checkconf.o" 1315 AC_SUBST(WIN_CHECKCONF_OBJ_LINK) 1316fi 1317if test $ac_cv_func_getaddrinfo = no; then 1318 AC_LIBOBJ([fake-rfc2553]) 1319fi 1320# check after getaddrinfo for its libraries 1321ACX_FUNC_IOCTLSOCKET 1322 1323# see if daemon(3) exists, and if it is deprecated. 1324AC_CHECK_FUNCS([daemon]) 1325if test $ac_cv_func_daemon = yes; then 1326 ACX_FUNC_DEPRECATED([daemon], [(void)daemon(0, 0);], [ 1327#include <stdlib.h> 1328]) 1329fi 1330 1331AC_CHECK_MEMBERS([struct sockaddr_un.sun_len],,,[ 1332AC_INCLUDES_DEFAULT 1333#ifdef HAVE_SYS_UN_H 1334#include <sys/un.h> 1335#endif 1336]) 1337AC_CHECK_MEMBERS([struct in_pktinfo.ipi_spec_dst],,,[ 1338AC_INCLUDES_DEFAULT 1339#if HAVE_SYS_PARAM_H 1340#include <sys/param.h> 1341#endif 1342 1343#ifdef HAVE_SYS_SOCKET_H 1344#include <sys/socket.h> 1345#endif 1346 1347#ifdef HAVE_SYS_UIO_H 1348#include <sys/uio.h> 1349#endif 1350 1351#ifdef HAVE_NETINET_IN_H 1352#include <netinet/in.h> 1353#endif 1354 1355#ifdef HAVE_NETINET_TCP_H 1356#include <netinet/tcp.h> 1357#endif 1358 1359#ifdef HAVE_ARPA_INET_H 1360#include <arpa/inet.h> 1361#endif 1362 1363#ifdef HAVE_WINSOCK2_H 1364#include <winsock2.h> 1365#endif 1366 1367#ifdef HAVE_WS2TCPIP_H 1368#include <ws2tcpip.h> 1369#endif 1370]) 1371AC_SEARCH_LIBS([setusercontext], [util]) 1372AC_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]) 1373AC_CHECK_FUNCS([setresuid],,[AC_CHECK_FUNCS([setreuid])]) 1374AC_CHECK_FUNCS([setresgid],,[AC_CHECK_FUNCS([setregid])]) 1375 1376# check if setreuid en setregid fail, on MacOSX10.4(darwin8). 1377if echo $target_os | grep darwin8 > /dev/null; then 1378 AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work]) 1379fi 1380AC_CHECK_DECLS([inet_pton,inet_ntop], [], [], [ 1381AC_INCLUDES_DEFAULT 1382#ifdef HAVE_NETINET_IN_H 1383#include <netinet/in.h> 1384#endif 1385 1386#ifdef HAVE_NETINET_TCP_H 1387#include <netinet/tcp.h> 1388#endif 1389 1390#ifdef HAVE_ARPA_INET_H 1391#include <arpa/inet.h> 1392#endif 1393 1394#ifdef HAVE_WINSOCK2_H 1395#include <winsock2.h> 1396#endif 1397 1398#ifdef HAVE_WS2TCPIP_H 1399#include <ws2tcpip.h> 1400#endif 1401]) 1402AC_REPLACE_FUNCS(inet_aton) 1403AC_REPLACE_FUNCS(inet_pton) 1404AC_REPLACE_FUNCS(inet_ntop) 1405AC_REPLACE_FUNCS(snprintf) 1406# test if snprintf return the proper length 1407if test "x$ac_cv_func_snprintf" = xyes; then 1408 if test c${cross_compiling} = cno; then 1409 AC_MSG_CHECKING([for correct snprintf return value]) 1410 AC_RUN_IFELSE([AC_LANG_SOURCE(AC_INCLUDES_DEFAULT 1411[[ 1412int main(void) { return !(snprintf(NULL, 0, "test") == 4); } 1413]])], [AC_MSG_RESULT(yes)], [ 1414 AC_MSG_RESULT(no) 1415 AC_DEFINE([SNPRINTF_RET_BROKEN], [], [define if (v)snprintf does not return length needed, (but length used)]) 1416 AC_LIBOBJ(snprintf) 1417 ]) 1418 fi 1419fi 1420AC_REPLACE_FUNCS(strlcat) 1421AC_REPLACE_FUNCS(strlcpy) 1422AC_REPLACE_FUNCS(memmove) 1423AC_REPLACE_FUNCS(gmtime_r) 1424AC_REPLACE_FUNCS(isblank) 1425AC_REPLACE_FUNCS(explicit_bzero) 1426dnl without CTIME, ARC4-functions and without reallocarray. 1427LIBOBJ_WITHOUT_CTIMEARC4="$LIBOBJS" 1428AC_SUBST(LIBOBJ_WITHOUT_CTIMEARC4) 1429AC_REPLACE_FUNCS(reallocarray) 1430if test "$USE_NSS" = "no"; then 1431 AC_REPLACE_FUNCS(arc4random) 1432 AC_REPLACE_FUNCS(arc4random_uniform) 1433 if test "$ac_cv_func_arc4random" = "no"; then 1434 AC_LIBOBJ(arc4_lock) 1435 AC_CHECK_FUNCS([getentropy],,[ 1436 if test "$USE_WINSOCK" = 1; then 1437 AC_LIBOBJ(getentropy_win) 1438 else 1439 case "$host" in 1440 Darwin|*darwin*) 1441 AC_LIBOBJ(getentropy_osx) 1442 ;; 1443 *solaris*|*sunos*|SunOS) 1444 AC_LIBOBJ(getentropy_solaris) 1445 AC_CHECK_HEADERS([sys/sha2.h],, [ 1446 AC_CHECK_FUNCS([SHA512_Update],,[ 1447 AC_LIBOBJ(sha512) 1448 ]) 1449 ], [AC_INCLUDES_DEFAULT]) 1450 if test "$ac_cv_header_sys_sha2_h" = "yes"; then 1451 # this lib needed for sha2 on solaris 1452 LIBS="$LIBS -lmd" 1453 fi 1454 AC_SEARCH_LIBS([clock_gettime], [rt]) 1455 ;; 1456 *linux*|Linux|*) 1457 AC_LIBOBJ(getentropy_linux) 1458 AC_CHECK_FUNCS([SHA512_Update],,[ 1459 AC_DEFINE([COMPAT_SHA512], [1], [Do sha512 definitions in config.h]) 1460 AC_LIBOBJ(sha512) 1461 ]) 1462 AC_CHECK_HEADERS([sys/sysctl.h],,, [AC_INCLUDES_DEFAULT]) 1463 AC_CHECK_FUNCS([getauxval]) 1464 AC_SEARCH_LIBS([clock_gettime], [rt]) 1465 ;; 1466 esac 1467 fi 1468 ]) 1469 fi 1470fi 1471LIBOBJ_WITHOUT_CTIME="$LIBOBJS" 1472AC_SUBST(LIBOBJ_WITHOUT_CTIME) 1473AC_REPLACE_FUNCS(ctime_r) 1474AC_REPLACE_FUNCS(strsep) 1475 1476AC_ARG_ENABLE(allsymbols, AC_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])) 1477case "$enable_allsymbols" in 1478 yes) 1479 COMMON_OBJ_ALL_SYMBOLS="" 1480 UBSYMS="" 1481 EXTRALINK="-L. -L.libs -lunbound" 1482 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]) 1483 ;; 1484 no|*) 1485 COMMON_OBJ_ALL_SYMBOLS='$(COMMON_OBJ)' 1486 UBSYMS='-export-symbols $(srcdir)/libunbound/ubsyms.def' 1487 EXTRALINK="" 1488 ;; 1489esac 1490AC_SUBST(COMMON_OBJ_ALL_SYMBOLS) 1491AC_SUBST(EXTRALINK) 1492AC_SUBST(UBSYMS) 1493if test x_$enable_lock_checks = x_yes; then 1494 UBSYMS="-export-symbols clubsyms.def" 1495 cp ${srcdir}/libunbound/ubsyms.def clubsyms.def 1496 echo lock_protect >> clubsyms.def 1497 echo lock_unprotect >> clubsyms.def 1498 echo lock_get_mem >> clubsyms.def 1499 echo checklock_start >> clubsyms.def 1500 echo checklock_stop >> clubsyms.def 1501 echo checklock_lock >> clubsyms.def 1502 echo checklock_unlock >> clubsyms.def 1503 echo checklock_init >> clubsyms.def 1504 echo checklock_thrcreate >> clubsyms.def 1505 echo checklock_thrjoin >> clubsyms.def 1506fi 1507 1508# check for dnstap if requested 1509dt_DNSTAP([$UNBOUND_RUN_DIR/dnstap.sock], 1510 [ 1511 AC_DEFINE([USE_DNSTAP], [1], [Define to 1 to enable dnstap support]) 1512 AC_SUBST([ENABLE_DNSTAP], [1]) 1513 1514 AC_SUBST([opt_dnstap_socket_path]) 1515 ACX_ESCAPE_BACKSLASH($opt_dnstap_socket_path, hdr_dnstap_socket_path) 1516 AC_DEFINE_UNQUOTED(DNSTAP_SOCKET_PATH, 1517 ["$hdr_dnstap_socket_path"], [default dnstap socket path]) 1518 1519 AC_SUBST([DNSTAP_SRC], ["dnstap/dnstap.c dnstap/dnstap.pb-c.c"]) 1520 AC_SUBST([DNSTAP_OBJ], ["dnstap.lo dnstap.pb-c.lo"]) 1521 ], 1522 [ 1523 AC_SUBST([ENABLE_DNSTAP], [0]) 1524 ] 1525) 1526 1527# check for dnscrypt if requested 1528dnsc_DNSCRYPT([ 1529 AC_DEFINE([USE_DNSCRYPT], [1], [Define to 1 to enable dnscrypt support]) 1530 AC_SUBST([ENABLE_DNSCRYPT], [1]) 1531 1532 AC_SUBST([DNSCRYPT_SRC], ["dnscrypt/dnscrypt.c"]) 1533 AC_SUBST([DNSCRYPT_OBJ], ["dnscrypt.lo"]) 1534 ], 1535 [ 1536 AC_SUBST([ENABLE_DNSCRYPT], [0]) 1537 ] 1538) 1539 1540# check for cachedb if requested 1541AC_ARG_ENABLE(cachedb, AC_HELP_STRING([--enable-cachedb], [enable cachedb module that can use external cache storage])) 1542# turn on cachedb when hiredis support is enabled. 1543if test "$found_libhiredis" = "yes"; then enable_cachedb="yes"; fi 1544case "$enable_cachedb" in 1545 yes) 1546 AC_DEFINE([USE_CACHEDB], [1], [Define to 1 to use cachedb support]) 1547 ;; 1548 no|*) 1549 # nothing 1550 ;; 1551esac 1552 1553# check for ipsecmod if requested 1554AC_ARG_ENABLE(ipsecmod, AC_HELP_STRING([--enable-ipsecmod], [Enable ipsecmod module that facilitates opportunistic IPsec])) 1555case "$enable_ipsecmod" in 1556 yes) 1557 AC_DEFINE([USE_IPSECMOD], [1], [Define to 1 to use ipsecmod support.]) 1558 IPSECMOD_OBJ="ipsecmod.lo ipsecmod-whitelist.lo" 1559 AC_SUBST(IPSECMOD_OBJ) 1560 IPSECMOD_HEADER='$(srcdir)/ipsecmod/ipsecmod.h $(srcdir)/ipsecmod/ipsecmod-whitelist.h' 1561 AC_SUBST(IPSECMOD_HEADER) 1562 ;; 1563 no|*) 1564 # nothing 1565 ;; 1566esac 1567 1568AC_MSG_CHECKING([if ${MAKE:-make} supports $< with implicit rule in scope]) 1569# on openBSD, the implicit rule make $< work. 1570# on Solaris, it does not work ($? is changed sources, $^ lists dependencies). 1571# gmake works. 1572cat >conftest.make <<EOF 1573all: conftest.lo 1574 1575conftest.lo foo.lo bla.lo: 1576 if test -f "\$<"; then touch \$@; fi 1577 1578.SUFFIXES: .lo 1579.c.lo: 1580 if test -f "\$<"; then touch \$@; fi 1581 1582conftest.lo: conftest.dir/conftest.c 1583EOF 1584mkdir conftest.dir 1585touch conftest.dir/conftest.c 1586rm -f conftest.lo conftest.c 1587${MAKE:-make} -f conftest.make >/dev/null 1588rm -f conftest.make conftest.c conftest.dir/conftest.c 1589rm -rf conftest.dir 1590if test ! -f conftest.lo; then 1591 AC_MSG_RESULT(no) 1592 SOURCEDETERMINE='echo "$^" | awk "-F " "{print \$$1;}" > .source' 1593 SOURCEFILE='`cat .source`' 1594else 1595 AC_MSG_RESULT(yes) 1596 SOURCEDETERMINE=':' 1597 SOURCEFILE='$<' 1598fi 1599rm -f conftest.lo 1600AC_SUBST(SOURCEDETERMINE) 1601AC_SUBST(SOURCEFILE) 1602 1603# see if we want to build the library or everything 1604ALLTARGET="alltargets" 1605INSTALLTARGET="install-all" 1606AC_ARG_WITH(libunbound-only, AC_HELP_STRING([--with-libunbound-only], 1607 [do not build daemon and tool programs]), 1608 [ 1609 if test "$withval" = "yes"; then 1610 ALLTARGET="lib" 1611 INSTALLTARGET="install-lib" 1612 fi 1613]) 1614if test $ALLTARGET = "alltargets"; then 1615 if test $USE_NSS = "yes"; then 1616 AC_ERROR([--with-nss can only be used in combination with --with-libunbound-only.]) 1617 fi 1618 if test $USE_NETTLE = "yes"; then 1619 AC_ERROR([--with-nettle can only be used in combination with --with-libunbound-only.]) 1620 fi 1621fi 1622 1623AC_SUBST(ALLTARGET) 1624AC_SUBST(INSTALLTARGET) 1625 1626ACX_STRIP_EXT_FLAGS 1627if test -n "$LATE_LDFLAGS"; then 1628 LDFLAGS="$LATE_LDFLAGS $LDFLAGS" 1629fi 1630# remove start spaces 1631LDFLAGS=`echo "$LDFLAGS"|sed -e 's/^ *//'` 1632LIBS=`echo "$LIBS"|sed -e 's/^ *//'` 1633 1634AC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [10240], [Define to the maximum message length to pass to syslog.]) 1635 1636AH_BOTTOM( 1637dnl this must be first AH_CONFIG, to define the flags before any includes. 1638AHX_CONFIG_EXT_FLAGS 1639 1640dnl includes 1641[ 1642#ifndef UNBOUND_DEBUG 1643# define NDEBUG 1644#endif 1645 1646/** Use small-ldns codebase */ 1647#define USE_SLDNS 1 1648#ifdef HAVE_SSL 1649# define LDNS_BUILD_CONFIG_HAVE_SSL 1 1650#endif 1651 1652#include <stdio.h> 1653#include <string.h> 1654#include <unistd.h> 1655#include <assert.h> 1656 1657#if STDC_HEADERS 1658#include <stdlib.h> 1659#include <stddef.h> 1660#endif 1661 1662#ifdef HAVE_STDARG_H 1663#include <stdarg.h> 1664#endif 1665 1666#ifdef HAVE_STDINT_H 1667#include <stdint.h> 1668#endif 1669 1670#include <errno.h> 1671 1672#if HAVE_SYS_PARAM_H 1673#include <sys/param.h> 1674#endif 1675 1676#ifdef HAVE_SYS_SOCKET_H 1677#include <sys/socket.h> 1678#endif 1679 1680#ifdef HAVE_SYS_UIO_H 1681#include <sys/uio.h> 1682#endif 1683 1684#ifdef HAVE_NETINET_IN_H 1685#include <netinet/in.h> 1686#endif 1687 1688#ifdef HAVE_NETINET_TCP_H 1689#include <netinet/tcp.h> 1690#endif 1691 1692#ifdef HAVE_ARPA_INET_H 1693#include <arpa/inet.h> 1694#endif 1695 1696#ifdef HAVE_WINSOCK2_H 1697#include <winsock2.h> 1698#endif 1699 1700#ifdef HAVE_WS2TCPIP_H 1701#include <ws2tcpip.h> 1702#endif 1703 1704#ifndef USE_WINSOCK 1705#define ARG_LL "%ll" 1706#else 1707#define ARG_LL "%I64" 1708#endif 1709 1710#ifndef AF_LOCAL 1711#define AF_LOCAL AF_UNIX 1712#endif 1713] 1714 1715AHX_CONFIG_FORMAT_ATTRIBUTE 1716AHX_CONFIG_UNUSED_ATTRIBUTE 1717AHX_CONFIG_FSEEKO 1718AHX_CONFIG_MAXHOSTNAMELEN 1719#if !defined(HAVE_SNPRINTF) || defined(SNPRINTF_RET_BROKEN) 1720#define snprintf snprintf_unbound 1721#define vsnprintf vsnprintf_unbound 1722#include <stdarg.h> 1723int snprintf (char *str, size_t count, const char *fmt, ...); 1724int vsnprintf (char *str, size_t count, const char *fmt, va_list arg); 1725#endif /* HAVE_SNPRINTF or SNPRINTF_RET_BROKEN */ 1726AHX_CONFIG_INET_PTON(unbound) 1727AHX_CONFIG_INET_NTOP(unbound) 1728AHX_CONFIG_INET_ATON(unbound) 1729AHX_CONFIG_MEMMOVE(unbound) 1730AHX_CONFIG_STRLCAT(unbound) 1731AHX_CONFIG_STRLCPY(unbound) 1732AHX_CONFIG_GMTIME_R(unbound) 1733AHX_CONFIG_REALLOCARRAY(unbound) 1734AHX_CONFIG_W32_SLEEP 1735AHX_CONFIG_W32_USLEEP 1736AHX_CONFIG_W32_RANDOM 1737AHX_CONFIG_W32_SRANDOM 1738AHX_CONFIG_W32_FD_SET_T 1739AHX_CONFIG_IPV6_MIN_MTU 1740AHX_MEMCMP_BROKEN(unbound) 1741 1742[ 1743#ifndef HAVE_CTIME_R 1744#define ctime_r unbound_ctime_r 1745char *ctime_r(const time_t *timep, char *buf); 1746#endif 1747 1748#ifndef HAVE_STRSEP 1749#define strsep unbound_strsep 1750char *strsep(char **stringp, const char *delim); 1751#endif 1752 1753#ifndef HAVE_ISBLANK 1754#define isblank unbound_isblank 1755int isblank(int c); 1756#endif 1757 1758#ifndef HAVE_EXPLICIT_BZERO 1759#define explicit_bzero unbound_explicit_bzero 1760void explicit_bzero(void* buf, size_t len); 1761#endif 1762 1763#if defined(HAVE_INET_NTOP) && !HAVE_DECL_INET_NTOP 1764const char *inet_ntop(int af, const void *src, char *dst, size_t size); 1765#endif 1766 1767#if defined(HAVE_INET_PTON) && !HAVE_DECL_INET_PTON 1768int inet_pton(int af, const char* src, void* dst); 1769#endif 1770 1771#if !defined(HAVE_STRPTIME) || !defined(STRPTIME_WORKS) 1772#define strptime unbound_strptime 1773struct tm; 1774char *strptime(const char *s, const char *format, struct tm *tm); 1775#endif 1776 1777#ifdef HAVE_LIBRESSL 1778# if !HAVE_DECL_STRLCPY 1779size_t strlcpy(char *dst, const char *src, size_t siz); 1780# endif 1781# if !HAVE_DECL_STRLCAT 1782size_t strlcat(char *dst, const char *src, size_t siz); 1783# endif 1784# if !HAVE_DECL_ARC4RANDOM && defined(HAVE_ARC4RANDOM) 1785uint32_t arc4random(void); 1786# endif 1787# if !HAVE_DECL_ARC4RANDOM_UNIFORM && defined(HAVE_ARC4RANDOM_UNIFORM) 1788uint32_t arc4random_uniform(uint32_t upper_bound); 1789# endif 1790# if !HAVE_DECL_REALLOCARRAY 1791void *reallocarray(void *ptr, size_t nmemb, size_t size); 1792# endif 1793#endif /* HAVE_LIBRESSL */ 1794#ifndef HAVE_ARC4RANDOM 1795int getentropy(void* buf, size_t len); 1796uint32_t arc4random(void); 1797void arc4random_buf(void* buf, size_t n); 1798void _ARC4_LOCK(void); 1799void _ARC4_UNLOCK(void); 1800void _ARC4_LOCK_DESTROY(void); 1801#endif 1802#ifndef HAVE_ARC4RANDOM_UNIFORM 1803uint32_t arc4random_uniform(uint32_t upper_bound); 1804#endif 1805#ifdef COMPAT_SHA512 1806#ifndef SHA512_DIGEST_LENGTH 1807#define SHA512_BLOCK_LENGTH 128 1808#define SHA512_DIGEST_LENGTH 64 1809#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) 1810typedef struct _SHA512_CTX { 1811 uint64_t state[8]; 1812 uint64_t bitcount[2]; 1813 uint8_t buffer[SHA512_BLOCK_LENGTH]; 1814} SHA512_CTX; 1815#endif /* SHA512_DIGEST_LENGTH */ 1816void SHA512_Init(SHA512_CTX*); 1817void SHA512_Update(SHA512_CTX*, void*, size_t); 1818void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*); 1819unsigned char *SHA512(void* data, unsigned int data_len, unsigned char *digest); 1820#endif /* COMPAT_SHA512 */ 1821 1822 1823 1824#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)) 1825 /* using version of libevent that is not threadsafe. */ 1826# define LIBEVENT_SIGNAL_PROBLEM 1 1827#endif 1828 1829#ifndef CHECKED_INET6 1830# define CHECKED_INET6 1831# ifdef AF_INET6 1832# define INET6 1833# else 1834# define AF_INET6 28 1835# endif 1836#endif /* CHECKED_INET6 */ 1837 1838#ifndef HAVE_GETADDRINFO 1839struct sockaddr_storage; 1840#include "compat/fake-rfc2553.h" 1841#endif 1842 1843#ifdef UNBOUND_ALLOC_STATS 1844# define malloc(s) unbound_stat_malloc_log(s, __FILE__, __LINE__, __func__) 1845# define calloc(n,s) unbound_stat_calloc_log(n, s, __FILE__, __LINE__, __func__) 1846# define free(p) unbound_stat_free_log(p, __FILE__, __LINE__, __func__) 1847# define realloc(p,s) unbound_stat_realloc_log(p, s, __FILE__, __LINE__, __func__) 1848void *unbound_stat_malloc(size_t size); 1849void *unbound_stat_calloc(size_t nmemb, size_t size); 1850void unbound_stat_free(void *ptr); 1851void *unbound_stat_realloc(void *ptr, size_t size); 1852void *unbound_stat_malloc_log(size_t size, const char* file, int line, 1853 const char* func); 1854void *unbound_stat_calloc_log(size_t nmemb, size_t size, const char* file, 1855 int line, const char* func); 1856void unbound_stat_free_log(void *ptr, const char* file, int line, 1857 const char* func); 1858void *unbound_stat_realloc_log(void *ptr, size_t size, const char* file, 1859 int line, const char* func); 1860#elif defined(UNBOUND_ALLOC_LITE) 1861# include "util/alloc.h" 1862#endif /* UNBOUND_ALLOC_LITE and UNBOUND_ALLOC_STATS */ 1863 1864/** default port for DNS traffic. */ 1865#define UNBOUND_DNS_PORT 53 1866/** default port for DNS over TLS traffic. */ 1867#define UNBOUND_DNS_OVER_TLS_PORT 853 1868/** default port for unbound control traffic, registered port with IANA, 1869 ub-dns-control 8953/tcp unbound dns nameserver control */ 1870#define UNBOUND_CONTROL_PORT 8953 1871/** the version of unbound-control that this software implements */ 1872#define UNBOUND_CONTROL_VERSION 1 1873 1874]) 1875 1876dnl if we build from source tree, the man pages need @date@ and @version@ 1877dnl if this is a distro tarball, that was already done by makedist.sh 1878AC_SUBST(version, [VERSION_MAJOR.VERSION_MINOR.VERSION_MICRO]) 1879AC_SUBST(date, [`date +'%b %e, %Y'`]) 1880 1881AC_CONFIG_FILES([Makefile doc/example.conf doc/libunbound.3 doc/unbound.8 doc/unbound-anchor.8 doc/unbound-checkconf.8 doc/unbound.conf.5 doc/unbound-control.8 doc/unbound-host.1 smallapp/unbound-control-setup.sh dnstap/dnstap_config.h dnscrypt/dnscrypt_config.h contrib/libunbound.pc contrib/unbound.socket contrib/unbound.service]) 1882AC_CONFIG_HEADER([config.h]) 1883AC_OUTPUT 1884