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) 9 10# must be numbers. ac_defun because of later processing 11m4_define([VERSION_MAJOR],[1]) 12m4_define([VERSION_MINOR],[5]) 13m4_define([VERSION_MICRO],[7]) 14AC_INIT(unbound, m4_defn([VERSION_MAJOR]).m4_defn([VERSION_MINOR]).m4_defn([VERSION_MICRO]), unbound-bugs@nlnetlabs.nl, unbound) 15AC_SUBST(UNBOUND_VERSION_MAJOR, [VERSION_MAJOR]) 16AC_SUBST(UNBOUND_VERSION_MINOR, [VERSION_MINOR]) 17AC_SUBST(UNBOUND_VERSION_MICRO, [VERSION_MICRO]) 18 19LIBUNBOUND_CURRENT=5 20LIBUNBOUND_REVISION=10 21LIBUNBOUND_AGE=3 22# 1.0.0 had 0:12:0 23# 1.0.1 had 0:13:0 24# 1.0.2 had 0:14:0 25# 1.1.0 had 0:15:0 26# 1.1.1 had 0:16:0 27# 1.2.0 had 0:17:0 28# 1.2.1 had 0:18:0 29# 1.3.0 had 1:0:0 # ub_cancel and -export-symbols. 30# 1.3.1 had 1:1:0 31# 1.3.2 had 1:2:0 32# 1.3.3 had 1:3:0 33# 1.3.4 had 1:4:0 34# 1.4.0-snapshots had 1:5:0 35# 1.4.0 had 1:5:0 (not 2:0:0) # ub_result.why_bogus 36# 1.4.1 had 2:1:0 37# 1.4.2 had 2:2:0 38# 1.4.3 had 2:3:0 39# 1.4.4 had 2:4:0 40# 1.4.5 had 2:5:0 41# 1.4.6 had 2:6:0 42# 1.4.7 had 2:7:0 43# 1.4.8 had 2:8:0 44# 1.4.9 had 2:9:0 45# 1.4.10 had 2:10:0 46# 1.4.11 had 2:11:0 47# 1.4.12 had 2:12:0 48# 1.4.13 had 2:13:0 49# and 1.4.13p1 and 1.4.13.p2 50# 1.4.14 had 2:14:0 51# 1.4.15 had 3:0:1 # adds ub_version() 52# 1.4.16 had 3:1:1 53# 1.4.17 had 3:2:1 54# 1.4.18 had 3:3:1 55# 1.4.19 had 3:4:1 56# 1.4.20 had 4:0:2 # adds libunbound.ttl # but shipped 3:5:1 57# 1.4.21 had 4:1:2 58# 1.4.22 had 4:1:2 59# 1.5.0 had 5:3:3 # adds ub_ctx_add_ta_autr 60# 1.5.1 had 5:3:3 61# 1.5.2 had 5:5:3 62# 1.5.3 had 5:6:3 63# 1.5.4 had 5:7:3 64# 1.5.5 had 5:8:3 65# 1.5.6 had 5:9:3 66# 1.5.7 had 5:10:3 67 68# Current -- the number of the binary API that we're implementing 69# Revision -- which iteration of the implementation of the binary 70# API are we supplying? 71# Age -- How many previous binary API versions do we also 72# support? 73# 74# If we release a new version that does not change the binary API, 75# increment Revision. 76# 77# If we release a new version that changes the binary API, but does 78# not break programs compiled against the old binary API, increment 79# Current and Age. Set Revision to 0, since this is the first 80# implementation of the new API. 81# 82# Otherwise, we're changing the binary API and breaking bakward 83# compatibility with old binaries. Increment Current. Set Age to 0, 84# since we're backward compatible with no previous APIs. Set Revision 85# to 0 too. 86AC_SUBST(LIBUNBOUND_CURRENT) 87AC_SUBST(LIBUNBOUND_REVISION) 88AC_SUBST(LIBUNBOUND_AGE) 89 90CFLAGS="$CFLAGS" 91AC_AIX 92if test "$ac_cv_header_minix_config_h" = "yes"; then 93 AC_DEFINE(_NETBSD_SOURCE,1, [Enable for compile on Minix]) 94fi 95 96dnl 97dnl By default set prefix to /usr/local 98dnl 99case "$prefix" in 100 NONE) 101 prefix="/usr/local" 102 ;; 103esac 104 105# are we on MinGW? 106if uname -s 2>&1 | grep MINGW32 >/dev/null; then on_mingw="yes" 107else 108 if echo $target | grep mingw32 >/dev/null; then on_mingw="yes" 109 else on_mingw="no"; fi 110fi 111 112# 113# Determine configuration file 114# the eval is to evaluate shell expansion twice 115if test $on_mingw = "no"; then 116 ub_conf_file=`eval echo "${sysconfdir}/unbound/unbound.conf"` 117else 118 ub_conf_file="C:\\Program Files\\Unbound\\service.conf" 119fi 120AC_ARG_WITH([conf_file], 121 AC_HELP_STRING([--with-conf-file=path], 122 [Pathname to the Unbound configuration file]), 123 [ub_conf_file="$withval"]) 124AC_SUBST(ub_conf_file) 125ACX_ESCAPE_BACKSLASH($ub_conf_file, hdr_config) 126AC_DEFINE_UNQUOTED(CONFIGFILE, ["$hdr_config"], [Pathname to the Unbound configuration file]) 127ub_conf_dir=`AS_DIRNAME(["$ub_conf_file"])` 128AC_SUBST(ub_conf_dir) 129 130# Determine run, chroot directory and pidfile locations 131AC_ARG_WITH(run-dir, 132 AC_HELP_STRING([--with-run-dir=path], 133 [set default directory to chdir to (by default dir part of cfg file)]), 134 UNBOUND_RUN_DIR="$withval", 135if test $on_mingw = no; then 136 UNBOUND_RUN_DIR=`dirname "$ub_conf_file"` 137else 138 UNBOUND_RUN_DIR="" 139fi 140) 141AC_SUBST(UNBOUND_RUN_DIR) 142ACX_ESCAPE_BACKSLASH($UNBOUND_RUN_DIR, hdr_run) 143AC_DEFINE_UNQUOTED(RUN_DIR, ["$hdr_run"], [Directory to chdir to]) 144 145AC_ARG_WITH(chroot-dir, 146 AC_HELP_STRING([--with-chroot-dir=path], 147 [set default directory to chroot to (by default same as run-dir)]), 148 UNBOUND_CHROOT_DIR="$withval", 149if test $on_mingw = no; then 150 UNBOUND_CHROOT_DIR="$UNBOUND_RUN_DIR" 151else 152 UNBOUND_CHROOT_DIR="" 153fi 154) 155AC_SUBST(UNBOUND_CHROOT_DIR) 156ACX_ESCAPE_BACKSLASH($UNBOUND_CHROOT_DIR, hdr_chroot) 157AC_DEFINE_UNQUOTED(CHROOT_DIR, ["$hdr_chroot"], [Directory to chroot to]) 158 159AC_ARG_WITH(share-dir, 160 AC_HELP_STRING([--with-share-dir=path], 161 [set default directory with shared data (by default same as share/unbound)]), 162 UNBOUND_SHARE_DIR="$withval", 163 UNBOUND_SHARE_DIR="$UNBOUND_RUN_DIR") 164AC_SUBST(UNBOUND_SHARE_DIR) 165AC_DEFINE_UNQUOTED(SHARE_DIR, ["$UNBOUND_SHARE_DIR"], [Shared data]) 166 167AC_ARG_WITH(pidfile, 168 AC_HELP_STRING([--with-pidfile=filename], 169 [set default pathname to unbound pidfile (default run-dir/unbound.pid)]), 170 UNBOUND_PIDFILE="$withval", 171if test $on_mingw = no; then 172 UNBOUND_PIDFILE="$UNBOUND_RUN_DIR/unbound.pid" 173else 174 UNBOUND_PIDFILE="" 175fi 176) 177AC_SUBST(UNBOUND_PIDFILE) 178ACX_ESCAPE_BACKSLASH($UNBOUND_PIDFILE, hdr_pid) 179AC_DEFINE_UNQUOTED(PIDFILE, ["$hdr_pid"], [default pidfile location]) 180 181AC_ARG_WITH(rootkey-file, 182 AC_HELP_STRING([--with-rootkey-file=filename], 183 [set default pathname to root key file (default run-dir/root.key). This file is read and written.]), 184 UNBOUND_ROOTKEY_FILE="$withval", 185if test $on_mingw = no; then 186 UNBOUND_ROOTKEY_FILE="$UNBOUND_RUN_DIR/root.key" 187else 188 UNBOUND_ROOTKEY_FILE="C:\\Program Files\\Unbound\\root.key" 189fi 190) 191AC_SUBST(UNBOUND_ROOTKEY_FILE) 192ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTKEY_FILE, hdr_rkey) 193AC_DEFINE_UNQUOTED(ROOT_ANCHOR_FILE, ["$hdr_rkey"], [default rootkey location]) 194 195AC_ARG_WITH(rootcert-file, 196 AC_HELP_STRING([--with-rootcert-file=filename], 197 [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.]), 198 UNBOUND_ROOTCERT_FILE="$withval", 199if test $on_mingw = no; then 200 UNBOUND_ROOTCERT_FILE="$UNBOUND_RUN_DIR/icannbundle.pem" 201else 202 UNBOUND_ROOTCERT_FILE="C:\\Program Files\\Unbound\\icannbundle.pem" 203fi 204) 205AC_SUBST(UNBOUND_ROOTCERT_FILE) 206ACX_ESCAPE_BACKSLASH($UNBOUND_ROOTCERT_FILE, hdr_rpem) 207AC_DEFINE_UNQUOTED(ROOT_CERT_FILE, ["$hdr_rpem"], [default rootcert location]) 208 209AC_ARG_WITH(username, 210 AC_HELP_STRING([--with-username=user], 211 [set default user that unbound changes to (default user is unbound)]), 212 UNBOUND_USERNAME="$withval", 213 UNBOUND_USERNAME="unbound") 214AC_SUBST(UNBOUND_USERNAME) 215AC_DEFINE_UNQUOTED(UB_USERNAME, ["$UNBOUND_USERNAME"], [default username]) 216 217AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled]) 218ACX_RSRC_VERSION(wnvs) 219AC_DEFINE_UNQUOTED(RSRC_PACKAGE_VERSION, [$wnvs], [version number for resource files]) 220 221# Checks for typedefs, structures, and compiler characteristics. 222AC_C_CONST 223AC_LANG_C 224# allow user to override the -g -O2 flags. 225if test "x$CFLAGS" = "x" ; then 226ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="$CFLAGS -g"]) 227ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"]) 228fi 229AC_PROG_CC 230ACX_DEPFLAG 231ACX_DETERMINE_EXT_FLAGS_UNBOUND 232 233# debug mode flags warnings 234AC_ARG_ENABLE(checking, AC_HELP_STRING([--enable-checking], [Enable warnings, asserts, makefile-dependencies])) 235AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [same as enable-checking])) 236if test "$enable_debug" = "yes"; then debug_enabled="$enable_debug"; 237else debug_enabled="$enable_checking"; fi 238AC_SUBST(debug_enabled) 239case "$debug_enabled" in 240 yes) 241 ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="$CFLAGS -W"]) 242 ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="$CFLAGS -Wall"]) 243 ACX_CHECK_COMPILER_FLAG(Wextra, [CFLAGS="$CFLAGS -Wextra"]) 244 ACX_CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [CFLAGS="$CFLAGS -Wdeclaration-after-statement"]) 245 AC_DEFINE([UNBOUND_DEBUG], [], [define this to enable debug checks.]) 246 ;; 247 no|*) 248 # nothing to do. 249 ;; 250esac 251ACX_CHECK_FLTO 252ACX_CHECK_PIE 253ACX_CHECK_RELRO_NOW 254 255AC_C_INLINE 256ACX_CHECK_FORMAT_ATTRIBUTE 257ACX_CHECK_UNUSED_ATTRIBUTE 258 259if test "$srcdir" != "."; then 260 CPPFLAGS="$CPPFLAGS -I$srcdir" 261fi 262 263AC_DEFUN([ACX_YYLEX_DESTROY], [ 264 AC_MSG_CHECKING([for yylex_destroy]) 265 if echo %% | $LEX -t 2>&1 | grep yylex_destroy >/dev/null 2>&1; then 266 AC_DEFINE(LEX_HAS_YYLEX_DESTROY, 1, [if lex has yylex_destroy]) 267 AC_MSG_RESULT(yes) 268 else AC_MSG_RESULT(no); fi 269]) 270 271AC_PROG_LEX 272ACX_YYLEX_DESTROY 273AC_PROG_YACC 274AC_CHECK_PROG(doxygen, doxygen, doxygen) 275AC_CHECK_TOOL(STRIP, strip) 276ACX_LIBTOOL_C_ONLY 277 278# Checks for header files. 279AC_CHECK_HEADERS([stdarg.h stdbool.h netinet/in.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],,, [AC_INCLUDES_DEFAULT]) 280 281# check for types. 282# Using own tests for int64* because autoconf builtin only give 32bit. 283AC_CHECK_TYPE(int8_t, signed char) 284AC_CHECK_TYPE(int16_t, short) 285AC_CHECK_TYPE(int32_t, int) 286AC_CHECK_TYPE(int64_t, long long) 287AC_CHECK_TYPE(uint8_t, unsigned char) 288AC_CHECK_TYPE(uint16_t, unsigned short) 289AC_CHECK_TYPE(uint32_t, unsigned int) 290AC_CHECK_TYPE(uint64_t, unsigned long long) 291AC_TYPE_SIZE_T 292AC_CHECK_TYPE(ssize_t, int) 293AC_TYPE_UID_T 294AC_TYPE_PID_T 295AC_TYPE_OFF_T 296ACX_TYPE_U_CHAR 297ACX_TYPE_RLIM_T 298ACX_TYPE_SOCKLEN_T 299ACX_TYPE_IN_ADDR_T 300ACX_TYPE_IN_PORT_T 301ACX_CHECK_MEMCMP_SIGNED 302 303AC_CHECK_SIZEOF(time_t,,[ 304AC_INCLUDES_DEFAULT 305#ifdef TIME_WITH_SYS_TIME 306# include <sys/time.h> 307# include <time.h> 308#else 309# ifdef HAVE_SYS_TIME_H 310# include <sys/time.h> 311# else 312# include <time.h> 313# endif 314#endif 315]) 316 317# add option to disable the evil rpath 318ACX_ARG_RPATH 319AC_SUBST(RUNTIME_PATH) 320 321# check to see if libraries are needed for these functions. 322AC_SEARCH_LIBS([inet_pton], [nsl]) 323AC_SEARCH_LIBS([socket], [socket]) 324 325# check wether strptime also works 326AC_DEFUN([AC_CHECK_STRPTIME_WORKS], 327[AC_REQUIRE([AC_PROG_CC]) 328AC_MSG_CHECKING(whether strptime works) 329if test c${cross_compiling} = cno; then 330AC_RUN_IFELSE([AC_LANG_SOURCE([[ 331#define _XOPEN_SOURCE 600 332#include <time.h> 333int main(void) { struct tm tm; char *res; 334res = 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); 335if (!res) return 2; 336res = strptime("20070207111842", "%Y%m%d%H%M%S", &tm); 337if (!res) return 1; return 0; } 338]])] , [eval "ac_cv_c_strptime_works=yes"], [eval "ac_cv_c_strptime_works=no"]) 339else 340eval "ac_cv_c_strptime_works=maybe" 341fi 342AC_MSG_RESULT($ac_cv_c_strptime_works) 343if test $ac_cv_c_strptime_works = no; then 344AC_LIBOBJ(strptime) 345else 346AC_DEFINE_UNQUOTED([STRPTIME_WORKS], 1, [use default strptime.]) 347fi 348])dnl 349 350# check some functions of the OS before linking libs (while still runnable). 351AC_FUNC_CHOWN 352AC_FUNC_FORK 353AC_TYPE_SIGNAL 354AC_FUNC_FSEEKO 355ACX_SYS_LARGEFILE 356ACX_CHECK_NONBLOCKING_BROKEN 357ACX_MKDIR_ONE_ARG 358AC_CHECK_FUNCS([strptime],[AC_CHECK_STRPTIME_WORKS],[AC_LIBOBJ([strptime])]) 359 360# set memory allocation checking if requested 361AC_ARG_ENABLE(alloc-checks, AC_HELP_STRING([--enable-alloc-checks], 362 [ enable to memory allocation statistics, for debug purposes ]), 363 , ) 364AC_ARG_ENABLE(alloc-lite, AC_HELP_STRING([--enable-alloc-lite], 365 [ enable for lightweight alloc assertions, for debug purposes ]), 366 , ) 367AC_ARG_ENABLE(alloc-nonregional, AC_HELP_STRING([--enable-alloc-nonregional], 368 [ enable nonregional allocs, slow but exposes regional allocations to other memory purifiers, for debug purposes ]), 369 , ) 370if test x_$enable_alloc_nonregional = x_yes; then 371 AC_DEFINE(UNBOUND_ALLOC_NONREGIONAL, 1, [use malloc not regions, for debug use]) 372fi 373if test x_$enable_alloc_checks = x_yes; then 374 AC_DEFINE(UNBOUND_ALLOC_STATS, 1, [use statistics for allocs and frees, for debug use]) 375else 376 if test x_$enable_alloc_lite = x_yes; then 377 AC_DEFINE(UNBOUND_ALLOC_LITE, 1, [use to enable lightweight alloc assertions, for debug use]) 378 else 379 ACX_FUNC_MALLOC([unbound]) 380 fi 381fi 382 383# check windows threads (we use them, not pthreads, on windows). 384if test "$on_mingw" = "yes"; then 385# check windows threads 386 AC_CHECK_HEADERS([windows.h],,, [AC_INCLUDES_DEFAULT]) 387 AC_MSG_CHECKING([for CreateThread]) 388 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ 389#ifdef HAVE_WINDOWS_H 390#include <windows.h> 391#endif 392], [ 393 HANDLE t = CreateThread(NULL, 0, NULL, NULL, 0, NULL); 394])], 395 AC_MSG_RESULT(yes) 396 AC_DEFINE(HAVE_WINDOWS_THREADS, 1, [Using Windows threads]) 397, 398 AC_MSG_RESULT(no) 399) 400 401else 402# not on mingw, check thread libraries. 403 404# check for thread library. 405# check this first, so that the pthread lib does not get linked in via 406# libssl or libpython, and thus distorts the tests, and we end up using 407# the non-threadsafe C libraries. 408AC_ARG_WITH(pthreads, AC_HELP_STRING([--with-pthreads], 409 [use pthreads library, or --without-pthreads to disable threading support.]), 410 [ ],[ withval="yes" ]) 411ub_have_pthreads=no 412if test x_$withval != x_no; then 413 AX_PTHREAD([ 414 AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]) 415 LIBS="$PTHREAD_LIBS $LIBS" 416 CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 417 CC="$PTHREAD_CC" 418 ub_have_pthreads=yes 419 AC_CHECK_TYPES([pthread_spinlock_t, pthread_rwlock_t],,,[#include <pthread.h>]) 420 ]) 421fi 422 423# check solaris thread library 424AC_ARG_WITH(solaris-threads, AC_HELP_STRING([--with-solaris-threads], 425 [use solaris native thread library.]), [ ],[ withval="no" ]) 426ub_have_sol_threads=no 427if test x_$withval != x_no; then 428 if test x_$ub_have_pthreads != x_no; then 429 AC_WARN([Have pthreads already, ignoring --with-solaris-threads]) 430 else 431 AC_SEARCH_LIBS(thr_create, [thread], 432 [ 433 AC_DEFINE(HAVE_SOLARIS_THREADS, 1, [Using Solaris threads]) 434 435 ACX_CHECK_COMPILER_FLAG(mt, [CFLAGS="$CFLAGS -mt"], 436 [CFLAGS="$CFLAGS -D_REENTRANT"]) 437 ub_have_sol_threads=yes 438 ] , [ 439 AC_ERROR([no solaris threads found.]) 440 ]) 441 fi 442fi 443 444fi # end of non-mingw check of thread libraries 445 446# Check for PyUnbound 447AC_ARG_WITH(pyunbound, 448 AC_HELP_STRING([--with-pyunbound], 449 [build PyUnbound, or --without-pyunbound to skip it. (default=no)]), 450 [], [ withval="no" ]) 451 452ub_test_python=no 453ub_with_pyunbound=no 454if test x_$withval != x_no; then 455 ub_with_pyunbound=yes 456 ub_test_python=yes 457fi 458 459# Check for Python module 460AC_ARG_WITH(pythonmodule, 461 AC_HELP_STRING([--with-pythonmodule], 462 [build Python module, or --without-pythonmodule to disable script engine. (default=no)]), 463 [], [ withval="no" ]) 464 465ub_with_pythonmod=no 466if test x_$withval != x_no; then 467 ub_with_pythonmod=yes 468 ub_test_python=yes 469fi 470 471# Check for Python & SWIG only on PyUnbound or PyModule 472if test x_$ub_test_python != x_no; then 473 474 # Check for Python 475 ub_have_python=no 476 ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS 477 AC_PYTHON_DEVEL 478 if test ! -z "$PYTHON_VERSION"; then 479 if test `$PYTHON -c "print('$PYTHON_VERSION' >= '2.4.0')"` = "False"; then 480 AC_ERROR([Python version >= 2.4.0 is required]) 481 fi 482 483 [PY_MAJOR_VERSION="`$PYTHON -c \"import sys; print(sys.version_info[0])\"`"] 484 AC_SUBST(PY_MAJOR_VERSION) 485 # Have Python 486 AC_DEFINE(HAVE_PYTHON,1,[Define if you have Python libraries and header files.]) 487 LIBS="$PYTHON_LDFLAGS $LIBS" 488 CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS" 489 ub_have_python=yes 490 491 # Check for SWIG 492 ub_have_swig=no 493 AC_PROG_SWIG 494 AC_MSG_CHECKING(SWIG) 495 if test ! -x "$SWIG"; then 496 AC_ERROR([failed to find swig tool, install it, or do not build Python module and PyUnbound]) 497 else 498 AC_DEFINE(HAVE_SWIG, 1, [Define if you have Swig libraries and header files.]) 499 AC_SUBST(swig, "$SWIG") 500 AC_MSG_RESULT(present) 501 502 # If have Python & SWIG 503 # Declare PythonMod 504 if test x_$ub_with_pythonmod != x_no; then 505 AC_DEFINE(WITH_PYTHONMODULE, 1, [Define if you want Python module.]) 506 WITH_PYTHONMODULE=yes 507 AC_SUBST(WITH_PYTHONMODULE) 508 PYTHONMOD_OBJ="pythonmod.lo pythonmod_utils.lo" 509 AC_SUBST(PYTHONMOD_OBJ) 510 PYTHONMOD_HEADER='$(srcdir)/pythonmod/pythonmod.h' 511 AC_SUBST(PYTHONMOD_HEADER) 512 PYTHONMOD_INSTALL=pythonmod-install 513 AC_SUBST(PYTHONMOD_INSTALL) 514 PYTHONMOD_UNINSTALL=pythonmod-uninstall 515 AC_SUBST(PYTHONMOD_UNINSTALL) 516 fi 517 518 # Declare PyUnbound 519 if test x_$ub_with_pyunbound != x_no; then 520 AC_DEFINE(WITH_PYUNBOUND, 1, [Define if you want PyUnbound.]) 521 WITH_PYUNBOUND=yes 522 AC_SUBST(WITH_PYUNBOUND) 523 PYUNBOUND_OBJ="libunbound_wrap.lo" 524 AC_SUBST(PYUNBOUND_OBJ) 525 PYUNBOUND_TARGET="_unbound.la" 526 AC_SUBST(PYUNBOUND_TARGET) 527 PYUNBOUND_INSTALL=pyunbound-install 528 AC_SUBST(PYUNBOUND_INSTALL) 529 PYUNBOUND_UNINSTALL=pyunbound-uninstall 530 AC_SUBST(PYUNBOUND_UNINSTALL) 531 fi 532 fi 533 else 534 AC_MSG_RESULT([*** Python libraries not found, won't build PythonMod or PyUnbound ***]) 535 ub_with_pyunbound=no 536 ub_with_pythonmod=no 537 fi 538fi 539 540if test "`uname`" = "NetBSD"; then 541 NETBSD_LINTFLAGS='"-D__RENAME(x)=" -D_NETINET_IN_H_' 542 AC_SUBST(NETBSD_LINTFLAGS) 543fi 544CONFIG_DATE=`date +%Y%m%d` 545AC_SUBST(CONFIG_DATE) 546 547# Checks for libraries. 548 549# libnss 550USE_NSS="no" 551AC_ARG_WITH([nss], AC_HELP_STRING([--with-nss=path], 552 [use libnss instead of openssl, installed at path.]), 553 [ 554 USE_NSS="yes" 555 AC_DEFINE(HAVE_NSS, 1, [Use libnss for crypto]) 556 if test "$withval" != "" -a "$withval" != "yes"; then 557 CPPFLAGS="$CPPFLAGS -I$withval/include/nss3" 558 LDFLAGS="$LDFLAGS -L$withval/lib" 559 ACX_RUNTIME_PATH_ADD([$withval/lib]) 560 CPPFLAGS="-I$withval/include/nspr4 $CPPFLAGS" 561 else 562 CPPFLAGS="$CPPFLAGS -I/usr/include/nss3" 563 CPPFLAGS="-I/usr/include/nspr4 $CPPFLAGS" 564 fi 565 LIBS="$LIBS -lnss3 -lnspr4" 566 SSLLIB="" 567 ] 568) 569 570# libnettle 571USE_NETTLE="no" 572AC_ARG_WITH([nettle], AC_HELP_STRING([--with-nettle=path], 573 [use libnettle as crypto library, installed at path.]), 574 [ 575 USE_NETTLE="yes" 576 AC_DEFINE(HAVE_NETTLE, 1, [Use libnettle for crypto]) 577 if test "$withval" != "" -a "$withval" != "yes"; then 578 CPPFLAGS="$CPPFLAGS -I$withval/include/nettle" 579 LDFLAGS="$LDFLAGS -L$withval/lib" 580 ACX_RUNTIME_PATH_ADD([$withval/lib]) 581 else 582 CPPFLAGS="$CPPFLAGS -I/usr/include/nettle" 583 fi 584 LIBS="$LIBS -lhogweed -lnettle -lgmp" 585 SSLLIB="" 586 ] 587) 588 589# openssl 590if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then 591ACX_WITH_SSL 592ACX_LIB_SSL 593SSLLIB="-lssl" 594AC_MSG_CHECKING([for LibreSSL]) 595if grep VERSION_TEXT $ssldir/include/openssl/opensslv.h | grep "LibreSSL" >/dev/null; then 596 AC_MSG_RESULT([yes]) 597 AC_DEFINE([HAVE_LIBRESSL], [1], [Define if we have LibreSSL]) 598 # libressl provides these compat functions, but they may also be 599 # declared by the OS in libc. See if they have been declared. 600 AC_CHECK_DECLS([strlcpy,strlcat,arc4random,arc4random_uniform,reallocarray]) 601else 602 AC_MSG_RESULT([no]) 603fi 604AC_CHECK_HEADERS([openssl/conf.h],,, [AC_INCLUDES_DEFAULT]) 605AC_CHECK_HEADERS([openssl/engine.h],,, [AC_INCLUDES_DEFAULT]) 606AC_CHECK_FUNCS([OPENSSL_config EVP_sha1 EVP_sha256 EVP_sha512 FIPS_mode]) 607AC_CHECK_DECLS([SSL_COMP_get_compression_methods,sk_SSL_COMP_pop_free,SSL_CTX_set_ecdh_auto], [], [], [ 608AC_INCLUDES_DEFAULT 609#ifdef HAVE_OPENSSL_ERR_H 610#include <openssl/err.h> 611#endif 612 613#ifdef HAVE_OPENSSL_RAND_H 614#include <openssl/rand.h> 615#endif 616 617#ifdef HAVE_OPENSSL_CONF_H 618#include <openssl/conf.h> 619#endif 620 621#ifdef HAVE_OPENSSL_ENGINE_H 622#include <openssl/engine.h> 623#endif 624#include <openssl/ssl.h> 625#include <openssl/evp.h> 626]) 627fi 628AC_SUBST(SSLLIB) 629 630 631AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support])) 632case "$enable_sha2" in 633 no) 634 ;; 635 yes|*) 636 AC_DEFINE([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.]) 637 ;; 638esac 639 640# check wether gost also works 641AC_DEFUN([AC_CHECK_GOST_WORKS], 642[AC_REQUIRE([AC_PROG_CC]) 643AC_MSG_CHECKING([if GOST works]) 644if test c${cross_compiling} = cno; then 645BAKCFLAGS="$CFLAGS" 646if test -n "$ssldir"; then 647 CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib" 648fi 649AC_RUN_IFELSE([AC_LANG_SOURCE([[ 650#include <string.h> 651#include <openssl/ssl.h> 652#include <openssl/evp.h> 653#include <openssl/engine.h> 654#include <openssl/conf.h> 655/* routine to load gost (from sldns) */ 656int load_gost_id(void) 657{ 658 static int gost_id = 0; 659 const EVP_PKEY_ASN1_METHOD* meth; 660 ENGINE* e; 661 662 if(gost_id) return gost_id; 663 664 /* see if configuration loaded gost implementation from other engine*/ 665 meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1); 666 if(meth) { 667 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); 668 return gost_id; 669 } 670 671 /* see if engine can be loaded already */ 672 e = ENGINE_by_id("gost"); 673 if(!e) { 674 /* load it ourself, in case statically linked */ 675 ENGINE_load_builtin_engines(); 676 ENGINE_load_dynamic(); 677 e = ENGINE_by_id("gost"); 678 } 679 if(!e) { 680 /* no gost engine in openssl */ 681 return 0; 682 } 683 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) { 684 ENGINE_finish(e); 685 ENGINE_free(e); 686 return 0; 687 } 688 689 meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1); 690 if(!meth) { 691 /* algo not found */ 692 ENGINE_finish(e); 693 ENGINE_free(e); 694 return 0; 695 } 696 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth); 697 return gost_id; 698} 699int main(void) { 700 EVP_MD_CTX* ctx; 701 const EVP_MD* md; 702 unsigned char digest[64]; /* its a 256-bit digest, so uses 32 bytes */ 703 const char* str = "Hello world"; 704 const unsigned char check[] = { 705 0x40 , 0xed , 0xf8 , 0x56 , 0x5a , 0xc5 , 0x36 , 0xe1 , 706 0x33 , 0x7c , 0x7e , 0x87 , 0x62 , 0x1c , 0x42 , 0xe0 , 707 0x17 , 0x1b , 0x5e , 0xce , 0xa8 , 0x46 , 0x65 , 0x4d , 708 0x8d , 0x3e , 0x22 , 0x9b , 0xe1 , 0x30 , 0x19 , 0x9d 709 }; 710 OPENSSL_config(NULL); 711 (void)load_gost_id(); 712 md = EVP_get_digestbyname("md_gost94"); 713 if(!md) return 1; 714 memset(digest, 0, sizeof(digest)); 715 ctx = EVP_MD_CTX_create(); 716 if(!ctx) return 2; 717 if(!EVP_DigestInit_ex(ctx, md, NULL)) return 3; 718 if(!EVP_DigestUpdate(ctx, str, 10)) return 4; 719 if(!EVP_DigestFinal_ex(ctx, digest, NULL)) return 5; 720 /* uncomment to see the hash calculated. 721 {int i; 722 for(i=0; i<32; i++) 723 printf(" %2.2x", (int)digest[i]); 724 printf("\n");} 725 */ 726 if(memcmp(digest, check, sizeof(check)) != 0) 727 return 6; 728 return 0; 729} 730]])] , [eval "ac_cv_c_gost_works=yes"], [eval "ac_cv_c_gost_works=no"]) 731CFLAGS="$BAKCFLAGS" 732else 733eval "ac_cv_c_gost_works=maybe" 734fi 735AC_MSG_RESULT($ac_cv_c_gost_works) 736])dnl 737 738AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support])) 739use_gost="no" 740if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then 741case "$enable_gost" in 742 no) 743 ;; 744 *) 745 AC_CHECK_FUNC(EVP_PKEY_set_type_str, [:],[AC_MSG_ERROR([OpenSSL 1.0.0 is needed for GOST support])]) 746 AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([OpenSSL does not support ECC, needed for GOST support])]) 747 AC_CHECK_GOST_WORKS 748 if test "$ac_cv_c_gost_works" != no; then 749 use_gost="yes" 750 AC_DEFINE([USE_GOST], [1], [Define this to enable GOST support.]) 751 fi 752 ;; 753esac 754fi dnl !USE_NSS && !USE_NETTLE 755 756AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support])) 757use_ecdsa="no" 758case "$enable_ecdsa" in 759 no) 760 ;; 761 *) 762 if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then 763 AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade or rerun with --disable-ecdsa])]) 764 AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade or rerun with --disable-ecdsa])]) 765 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 766#include <openssl/evp.h> 767 ]) 768 # see if OPENSSL 1.0.0 or later (has EVP MD and Verify independency) 769 AC_MSG_CHECKING([if openssl supports SHA2 and ECDSA with EVP]) 770 if grep OPENSSL_VERSION_TEXT $ssldir/include/openssl/opensslv.h | grep "OpenSSL" >/dev/null; then 771 if grep OPENSSL_VERSION_NUMBER $ssldir/include/openssl/opensslv.h | grep 0x0 >/dev/null; then 772 AC_MSG_RESULT([no]) 773 AC_DEFINE_UNQUOTED([USE_ECDSA_EVP_WORKAROUND], [1], [Define this to enable an EVP workaround for older openssl]) 774 else 775 AC_MSG_RESULT([yes]) 776 fi 777 else 778 # not OpenSSL, thus likely LibreSSL, which supports it 779 AC_MSG_RESULT([yes]) 780 fi 781 fi 782 # we now know we have ECDSA and the required curves. 783 AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.]) 784 use_ecdsa="yes" 785 ;; 786esac 787 788AC_ARG_ENABLE(event-api, AC_HELP_STRING([--enable-event-api], [Enable (experimental) libevent-based libunbound API installed to unbound-event.h])) 789use_unbound_event="no" 790case "$enable_event_api" in 791 yes) 792 use_unbound_event="yes" 793 ;; 794 *) 795 ;; 796esac 797 798# check for libevent 799AC_ARG_WITH(libevent, AC_HELP_STRING([--with-libevent=pathname], 800 [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.]), 801 [ ],[ withval="no" ]) 802if test x_$withval = x_yes -o x_$withval != x_no; then 803 AC_MSG_CHECKING(for libevent) 804 if test x_$withval = x_ -o x_$withval = x_yes; then 805 withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" 806 fi 807 for dir in $withval; do 808 thedir="$dir" 809 if test -f "$dir/include/event.h" -o -f "$dir/include/event2/event.h"; then 810 found_libevent="yes" 811 dnl assume /usr is in default path. 812 if test "$thedir" != "/usr"; then 813 CPPFLAGS="$CPPFLAGS -I$thedir/include" 814 fi 815 break; 816 fi 817 done 818 if test x_$found_libevent != x_yes; then 819 if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then 820 # libevent source directory 821 AC_MSG_RESULT(found in $thedir) 822 CPPFLAGS="$CPPFLAGS -I$thedir -I$thedir/include" 823 BAK_LDFLAGS_SET="1" 824 BAK_LDFLAGS="$LDFLAGS" 825 # remove evdns from linking 826 mkdir build >/dev/null 2>&1 827 mkdir build/libevent >/dev/null 2>&1 828 mkdir build/libevent/.libs >/dev/null 2>&1 829 ev_files_o=`ls $thedir/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o` 830 ev_files_lo=`ls $thedir/*.lo | grep -v evdns\.lo | grep -v bufferevent_openssl\.lo` 831 ev_files_libso=`ls $thedir/.libs/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o` 832 cp $ev_files_o build/libevent 833 cp $ev_files_lo build/libevent 834 cp $ev_files_libso build/libevent/.libs 835 LATE_LDFLAGS="build/libevent/*.lo -lm" 836 LDFLAGS="build/libevent/*.o $LDFLAGS -lm" 837 else 838 AC_MSG_ERROR([Cannot find the libevent library in $withval 839You can restart ./configure --with-libevent=no to use a builtin alternative. 840Please note that this alternative is not as capable as libevent when using 841large outgoing port ranges. ]) 842 fi 843 else 844 AC_MSG_RESULT(found in $thedir) 845 dnl if event2 exists and no event lib in dir itself, use subdir 846 if test ! -f $thedir/lib/libevent.a -a ! -f $thedir/lib/libevent.so -a -d "$thedir/lib/event2"; then 847 LDFLAGS="$LDFLAGS -L$thedir/lib/event2" 848 ACX_RUNTIME_PATH_ADD([$thedir/lib/event2]) 849 else 850 dnl assume /usr is in default path, do not add "". 851 if test "$thedir" != "/usr" -a "$thedir" != ""; then 852 LDFLAGS="$LDFLAGS -L$thedir/lib" 853 ACX_RUNTIME_PATH_ADD([$thedir/lib]) 854 fi 855 fi 856 fi 857 # check for library used by libevent after 1.3c 858 AC_SEARCH_LIBS([clock_gettime], [rt]) 859 860 # is the event.h header libev or libevent? 861 AC_CHECK_HEADERS([event.h],,, [AC_INCLUDES_DEFAULT]) 862 AC_CHECK_DECL(EV_VERSION_MAJOR, [ 863 AC_SEARCH_LIBS(event_set, [ev]) 864 ],[ 865 AC_SEARCH_LIBS(event_set, [event]) 866 ],[AC_INCLUDES_DEFAULT 867#include <event.h> 868 ]) 869 AC_CHECK_FUNCS([event_base_free]) # only in libevent 1.2 and later 870 AC_CHECK_FUNCS([event_base_once]) # only in libevent 1.4.1 and later 871 AC_CHECK_FUNCS([event_base_new]) # only in libevent 1.4.1 and later 872 AC_CHECK_FUNCS([event_base_get_method]) # only in libevent 1.4.3 and later 873 AC_CHECK_FUNCS([ev_loop]) # only in libev. (tested on 3.51) 874 AC_CHECK_FUNCS([ev_default_loop]) # only in libev. (tested on 4.00) 875 if test -n "$BAK_LDFLAGS_SET"; then 876 LDFLAGS="$BAK_LDFLAGS" 877 fi 878 if test "$use_unbound_event" = "yes"; then 879 AC_SUBST(UNBOUND_EVENT_INSTALL, [unbound-event-install]) 880 AC_SUBST(UNBOUND_EVENT_UNINSTALL, [unbound-event-uninstall]) 881 fi 882else 883 AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events]) 884fi 885 886# check for libexpat 887AC_ARG_WITH(libexpat, AC_HELP_STRING([--with-libexpat=path], 888 [specify explicit path for libexpat.]), 889 [ ],[ withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" ]) 890AC_MSG_CHECKING(for libexpat) 891found_libexpat="no" 892for dir in $withval ; do 893 if test -f "$dir/include/expat.h"; then 894 found_libexpat="yes" 895 dnl assume /usr is in default path. 896 if test "$dir" != "/usr"; then 897 CPPFLAGS="$CPPFLAGS -I$dir/include" 898 LDFLAGS="$LDFLAGS -L$dir/lib" 899 fi 900 AC_MSG_RESULT(found in $dir) 901 break; 902 fi 903done 904if test x_$found_libexpat != x_yes; then 905 AC_ERROR([Could not find libexpat, expat.h]) 906fi 907AC_CHECK_HEADERS([expat.h],,, [AC_INCLUDES_DEFAULT]) 908AC_CHECK_DECLS([XML_StopParser], [], [], [AC_INCLUDES_DEFAULT 909#include <expat.h> 910]) 911 912# set static linking if requested 913AC_SUBST(staticexe) 914staticexe="" 915AC_ARG_ENABLE(static-exe, AC_HELP_STRING([--enable-static-exe], 916 [ enable to compile executables statically against (event) libs, for debug purposes ]), 917 , ) 918if test x_$enable_static_exe = x_yes; then 919 staticexe="-static" 920 if test "$on_mingw" = yes; then 921 staticexe="-all-static" 922 # for static crosscompile, include gdi32 and zlib here. 923 if test "`uname`" = "Linux"; then 924 LIBS="$LIBS -lgdi32 -lz" 925 fi 926 fi 927fi 928 929# set lock checking if requested 930AC_ARG_ENABLE(lock_checks, AC_HELP_STRING([--enable-lock-checks], 931 [ enable to check lock and unlock calls, for debug purposes ]), 932 , ) 933if test x_$enable_lock_checks = x_yes; then 934 AC_DEFINE(ENABLE_LOCK_CHECKS, 1, [Define if you want to use debug lock checking (slow).]) 935 CHECKLOCK_OBJ="checklocks.lo" 936 AC_SUBST(CHECKLOCK_OBJ) 937fi 938 939ACX_CHECK_GETADDRINFO_WITH_INCLUDES 940if test "$USE_WINSOCK" = 1; then 941 AC_DEFINE(UB_ON_WINDOWS, 1, [Use win32 resources and API]) 942 AC_CHECK_HEADERS([iphlpapi.h],,, [AC_INCLUDES_DEFAULT 943#include <windows.h> 944 ]) 945 AC_CHECK_TOOL(WINDRES, windres) 946 LIBS="$LIBS -liphlpapi" 947 WINAPPS="unbound-service-install.exe unbound-service-remove.exe anchor-update.exe" 948 AC_SUBST(WINAPPS) 949 WIN_DAEMON_SRC="winrc/win_svc.c winrc/w_inst.c" 950 AC_SUBST(WIN_DAEMON_SRC) 951 WIN_DAEMON_OBJ="win_svc.lo w_inst.lo" 952 AC_SUBST(WIN_DAEMON_OBJ) 953 WIN_DAEMON_OBJ_LINK="rsrc_unbound.o" 954 AC_SUBST(WIN_DAEMON_OBJ_LINK) 955 WIN_HOST_OBJ_LINK="rsrc_unbound_host.o" 956 AC_SUBST(WIN_HOST_OBJ_LINK) 957 WIN_UBANCHOR_OBJ_LINK="rsrc_unbound_anchor.o log.lo locks.lo" 958 AC_SUBST(WIN_UBANCHOR_OBJ_LINK) 959 WIN_CONTROL_OBJ_LINK="rsrc_unbound_control.o" 960 AC_SUBST(WIN_CONTROL_OBJ_LINK) 961 WIN_CHECKCONF_OBJ_LINK="rsrc_unbound_checkconf.o" 962 AC_SUBST(WIN_CHECKCONF_OBJ_LINK) 963fi 964if test $ac_cv_func_getaddrinfo = no; then 965 AC_LIBOBJ([fake-rfc2553]) 966fi 967# check after getaddrinfo for its libraries 968ACX_FUNC_IOCTLSOCKET 969 970# see if daemon(3) exists, and if it is deprecated. 971AC_CHECK_FUNCS([daemon]) 972if test $ac_cv_func_daemon = yes; then 973 ACX_FUNC_DEPRECATED([daemon], [(void)daemon(0, 0);], [ 974#include <stdlib.h> 975]) 976fi 977 978AC_CHECK_MEMBERS([struct sockaddr_un.sun_len],,,[ 979AC_INCLUDES_DEFAULT 980#ifdef HAVE_SYS_UN_H 981#include <sys/un.h> 982#endif 983]) 984AC_CHECK_MEMBERS([struct in_pktinfo.ipi_spec_dst],,,[ 985AC_INCLUDES_DEFAULT 986#if HAVE_SYS_PARAM_H 987#include <sys/param.h> 988#endif 989 990#ifdef HAVE_SYS_SOCKET_H 991#include <sys/socket.h> 992#endif 993 994#ifdef HAVE_SYS_UIO_H 995#include <sys/uio.h> 996#endif 997 998#ifdef HAVE_NETINET_IN_H 999#include <netinet/in.h> 1000#endif 1001 1002#ifdef HAVE_ARPA_INET_H 1003#include <arpa/inet.h> 1004#endif 1005 1006#ifdef HAVE_WINSOCK2_H 1007#include <winsock2.h> 1008#endif 1009 1010#ifdef HAVE_WS2TCPIP_H 1011#include <ws2tcpip.h> 1012#endif 1013]) 1014AC_SEARCH_LIBS([setusercontext], [util]) 1015AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam getrlimit setrlimit setsid sbrk chroot kill chown sleep usleep random srandom recvmsg sendmsg writev socketpair glob initgroups strftime localtime_r setusercontext _beginthreadex endservent endprotoent fsync]) 1016AC_CHECK_FUNCS([setresuid],,[AC_CHECK_FUNCS([setreuid])]) 1017AC_CHECK_FUNCS([setresgid],,[AC_CHECK_FUNCS([setregid])]) 1018 1019# check if setreuid en setregid fail, on MacOSX10.4(darwin8). 1020if echo $build_os | grep darwin8 > /dev/null; then 1021 AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work]) 1022fi 1023AC_REPLACE_FUNCS(inet_aton) 1024AC_REPLACE_FUNCS(inet_pton) 1025AC_REPLACE_FUNCS(inet_ntop) 1026AC_REPLACE_FUNCS(snprintf) 1027# test if snprintf return the proper length 1028if test "x$ac_cv_func_snprintf" = xyes; then 1029 if test c${cross_compiling} = cno; then 1030 AC_MSG_CHECKING([for correct snprintf return value]) 1031 AC_RUN_IFELSE([AC_LANG_SOURCE(AC_INCLUDES_DEFAULT 1032[[ 1033int main(void) { return !(snprintf(NULL, 0, "test") == 4); } 1034]])], [AC_MSG_RESULT(yes)], [ 1035 AC_MSG_RESULT(no) 1036 AC_DEFINE([SNPRINTF_RET_BROKEN], [], [define if (v)snprintf does not return length needed, (but length used)]) 1037 AC_LIBOBJ(snprintf) 1038 ]) 1039 fi 1040fi 1041AC_REPLACE_FUNCS(strlcat) 1042AC_REPLACE_FUNCS(strlcpy) 1043AC_REPLACE_FUNCS(memmove) 1044AC_REPLACE_FUNCS(gmtime_r) 1045AC_REPLACE_FUNCS(isblank) 1046dnl without CTIME, ARC4-functions and without reallocarray. 1047LIBOBJ_WITHOUT_CTIMEARC4="$LIBOBJS" 1048AC_SUBST(LIBOBJ_WITHOUT_CTIMEARC4) 1049AC_REPLACE_FUNCS(reallocarray) 1050if test "$USE_NSS" = "no"; then 1051 AC_REPLACE_FUNCS(arc4random) 1052 AC_REPLACE_FUNCS(arc4random_uniform) 1053 if test "$ac_cv_func_arc4random" = "no"; then 1054 AC_LIBOBJ(explicit_bzero) 1055 AC_LIBOBJ(arc4_lock) 1056 AC_CHECK_FUNCS([getentropy],,[ 1057 if test "$USE_WINSOCK" = 1; then 1058 AC_LIBOBJ(getentropy_win) 1059 else 1060 case `uname` in 1061 Darwin) 1062 AC_LIBOBJ(getentropy_osx) 1063 ;; 1064 SunOS) 1065 AC_LIBOBJ(getentropy_solaris) 1066 AC_CHECK_HEADERS([sys/sha2.h],, [ 1067 AC_CHECK_FUNCS([SHA512_Update],,[ 1068 AC_LIBOBJ(sha512) 1069 ]) 1070 ], [AC_INCLUDES_DEFAULT]) 1071 if test "$ac_cv_header_sys_sha2_h" = "yes"; then 1072 # this lib needed for sha2 on solaris 1073 LIBS="$LIBS -lmd" 1074 fi 1075 AC_SEARCH_LIBS([clock_gettime], [rt]) 1076 ;; 1077 Linux|*) 1078 AC_LIBOBJ(getentropy_linux) 1079 AC_CHECK_FUNCS([SHA512_Update],,[ 1080 AC_DEFINE([COMPAT_SHA512], [1], [Do sha512 definitions in config.h]) 1081 AC_LIBOBJ(sha512) 1082 ]) 1083 AC_CHECK_HEADERS([sys/sysctl.h],,, [AC_INCLUDES_DEFAULT]) 1084 AC_CHECK_FUNCS([getauxval]) 1085 AC_SEARCH_LIBS([clock_gettime], [rt]) 1086 ;; 1087 esac 1088 fi 1089 ]) 1090 fi 1091fi 1092LIBOBJ_WITHOUT_CTIME="$LIBOBJS" 1093AC_SUBST(LIBOBJ_WITHOUT_CTIME) 1094AC_REPLACE_FUNCS(ctime_r) 1095 1096AC_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])) 1097case "$enable_allsymbols" in 1098 yes) 1099 COMMON_OBJ_ALL_SYMBOLS="" 1100 UBSYMS="" 1101 EXTRALINK="-L. -L.libs -lunbound" 1102 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]) 1103 ;; 1104 no|*) 1105 COMMON_OBJ_ALL_SYMBOLS='$(COMMON_OBJ)' 1106 UBSYMS='-export-symbols $(srcdir)/libunbound/ubsyms.def' 1107 EXTRALINK="" 1108 ;; 1109esac 1110AC_SUBST(COMMON_OBJ_ALL_SYMBOLS) 1111AC_SUBST(EXTRALINK) 1112AC_SUBST(UBSYMS) 1113if test x_$enable_lock_checks = x_yes; then 1114 UBSYMS="-export-symbols clubsyms.def" 1115 cp ${srcdir}/libunbound/ubsyms.def clubsyms.def 1116 echo lock_protect >> clubsyms.def 1117 echo lock_unprotect >> clubsyms.def 1118 echo lock_get_mem >> clubsyms.def 1119 echo checklock_start >> clubsyms.def 1120 echo checklock_stop >> clubsyms.def 1121 echo checklock_lock >> clubsyms.def 1122 echo checklock_unlock >> clubsyms.def 1123 echo checklock_init >> clubsyms.def 1124 echo checklock_thrcreate >> clubsyms.def 1125 echo checklock_thrjoin >> clubsyms.def 1126fi 1127 1128# check for dnstap if requested 1129dt_DNSTAP([$UNBOUND_RUN_DIR/dnstap.sock], 1130 [ 1131 AC_DEFINE([USE_DNSTAP], [1], [Define to 1 to enable dnstap support]) 1132 AC_SUBST([ENABLE_DNSTAP], [1]) 1133 1134 AC_SUBST([opt_dnstap_socket_path]) 1135 ACX_ESCAPE_BACKSLASH($opt_dnstap_socket_path, hdr_dnstap_socket_path) 1136 AC_DEFINE_UNQUOTED(DNSTAP_SOCKET_PATH, 1137 ["$hdr_dnstap_socket_path"], [default dnstap socket path]) 1138 1139 AC_SUBST([DNSTAP_SRC], ["dnstap/dnstap.c dnstap/dnstap.pb-c.c"]) 1140 AC_SUBST([DNSTAP_OBJ], ["dnstap.lo dnstap.pb-c.lo"]) 1141 ], 1142 [ 1143 AC_SUBST([ENABLE_DNSTAP], [0]) 1144 ] 1145) 1146 1147AC_MSG_CHECKING([if ${MAKE:-make} supports $< with implicit rule in scope]) 1148# on openBSD, the implicit rule make $< work. 1149# on Solaris, it does not work ($? is changed sources, $^ lists dependencies). 1150# gmake works. 1151cat >conftest.make <<EOF 1152all: conftest.lo 1153 1154conftest.lo foo.lo bla.lo: 1155 if test -f "\$<"; then touch \$@; fi 1156 1157.SUFFIXES: .lo 1158.c.lo: 1159 if test -f "\$<"; then touch \$@; fi 1160 1161conftest.lo: conftest.dir/conftest.c 1162EOF 1163mkdir conftest.dir 1164touch conftest.dir/conftest.c 1165rm -f conftest.lo conftest.c 1166${MAKE:-make} -f conftest.make >/dev/null 1167rm -f conftest.make conftest.c conftest.dir/conftest.c 1168rm -rf conftest.dir 1169if test ! -f conftest.lo; then 1170 AC_MSG_RESULT(no) 1171 SOURCEDETERMINE='echo "$^" | awk "-F " "{print \$$1;}" > .source' 1172 SOURCEFILE='`cat .source`' 1173else 1174 AC_MSG_RESULT(yes) 1175 SOURCEDETERMINE=':' 1176 SOURCEFILE='$<' 1177fi 1178rm -f conftest.lo 1179AC_SUBST(SOURCEDETERMINE) 1180AC_SUBST(SOURCEFILE) 1181 1182# see if we want to build the library or everything 1183ALLTARGET="alltargets" 1184INSTALLTARGET="install-all" 1185AC_ARG_WITH(libunbound-only, AC_HELP_STRING([--with-libunbound-only], 1186 [do not build daemon and tool programs]), 1187 [ 1188 if test "$withval" = "yes"; then 1189 ALLTARGET="lib" 1190 INSTALLTARGET="install-lib" 1191 fi 1192]) 1193AC_SUBST(ALLTARGET) 1194AC_SUBST(INSTALLTARGET) 1195 1196ACX_STRIP_EXT_FLAGS 1197LDFLAGS="$LATE_LDFLAGS $LDFLAGS" 1198 1199AC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [10240], [Define to the maximum message length to pass to syslog.]) 1200 1201AH_BOTTOM( 1202dnl this must be first AH_CONFIG, to define the flags before any includes. 1203AHX_CONFIG_EXT_FLAGS 1204 1205dnl includes 1206[ 1207#ifndef UNBOUND_DEBUG 1208# define NDEBUG 1209#endif 1210 1211/** Use small-ldns codebase */ 1212#define USE_SLDNS 1 1213#ifdef HAVE_SSL 1214# define LDNS_BUILD_CONFIG_HAVE_SSL 1 1215#endif 1216 1217#include <stdio.h> 1218#include <string.h> 1219#include <unistd.h> 1220#include <assert.h> 1221 1222#if STDC_HEADERS 1223#include <stdlib.h> 1224#include <stddef.h> 1225#endif 1226 1227#ifdef HAVE_STDARG_H 1228#include <stdarg.h> 1229#endif 1230 1231#ifdef HAVE_STDINT_H 1232#include <stdint.h> 1233#endif 1234 1235#include <errno.h> 1236 1237#if HAVE_SYS_PARAM_H 1238#include <sys/param.h> 1239#endif 1240 1241#ifdef HAVE_SYS_SOCKET_H 1242#include <sys/socket.h> 1243#endif 1244 1245#ifdef HAVE_SYS_UIO_H 1246#include <sys/uio.h> 1247#endif 1248 1249#ifdef HAVE_NETINET_IN_H 1250#include <netinet/in.h> 1251#endif 1252 1253#ifdef HAVE_ARPA_INET_H 1254#include <arpa/inet.h> 1255#endif 1256 1257#ifdef HAVE_WINSOCK2_H 1258#include <winsock2.h> 1259#endif 1260 1261#ifdef HAVE_WS2TCPIP_H 1262#include <ws2tcpip.h> 1263#endif 1264 1265#ifndef USE_WINSOCK 1266#define ARG_LL "%ll" 1267#else 1268#define ARG_LL "%I64" 1269#endif 1270 1271#ifndef AF_LOCAL 1272#define AF_LOCAL AF_UNIX 1273#endif 1274] 1275 1276AHX_CONFIG_FORMAT_ATTRIBUTE 1277AHX_CONFIG_UNUSED_ATTRIBUTE 1278AHX_CONFIG_FSEEKO 1279AHX_CONFIG_MAXHOSTNAMELEN 1280#if !defined(HAVE_SNPRINTF) || defined(SNPRINTF_RET_BROKEN) 1281#define snprintf snprintf_unbound 1282#define vsnprintf vsnprintf_unbound 1283#include <stdarg.h> 1284int snprintf (char *str, size_t count, const char *fmt, ...); 1285int vsnprintf (char *str, size_t count, const char *fmt, va_list arg); 1286#endif /* HAVE_SNPRINTF or SNPRINTF_RET_BROKEN */ 1287AHX_CONFIG_INET_PTON(unbound) 1288AHX_CONFIG_INET_NTOP(unbound) 1289AHX_CONFIG_INET_ATON(unbound) 1290AHX_CONFIG_MEMMOVE(unbound) 1291AHX_CONFIG_STRLCAT(unbound) 1292AHX_CONFIG_STRLCPY(unbound) 1293AHX_CONFIG_GMTIME_R(unbound) 1294AHX_CONFIG_REALLOCARRAY(unbound) 1295AHX_CONFIG_W32_SLEEP 1296AHX_CONFIG_W32_USLEEP 1297AHX_CONFIG_W32_RANDOM 1298AHX_CONFIG_W32_SRANDOM 1299AHX_CONFIG_W32_FD_SET_T 1300AHX_CONFIG_IPV6_MIN_MTU 1301AHX_MEMCMP_BROKEN(unbound) 1302 1303[ 1304#ifndef HAVE_CTIME_R 1305#define ctime_r unbound_ctime_r 1306char *ctime_r(const time_t *timep, char *buf); 1307#endif 1308 1309#ifndef HAVE_ISBLANK 1310#define isblank unbound_isblank 1311int isblank(int c); 1312#endif 1313 1314#if !defined(HAVE_STRPTIME) || !defined(STRPTIME_WORKS) 1315#define strptime unbound_strptime 1316struct tm; 1317char *strptime(const char *s, const char *format, struct tm *tm); 1318#endif 1319 1320#ifdef HAVE_LIBRESSL 1321# if !HAVE_DECL_STRLCPY 1322size_t strlcpy(char *dst, const char *src, size_t siz); 1323# endif 1324# if !HAVE_DECL_STRLCAT 1325size_t strlcat(char *dst, const char *src, size_t siz); 1326# endif 1327# if !HAVE_DECL_ARC4RANDOM && defined(HAVE_ARC4RANDOM) 1328uint32_t arc4random(void); 1329# endif 1330# if !HAVE_DECL_ARC4RANDOM_UNIFORM && defined(HAVE_ARC4RANDOM_UNIFORM) 1331uint32_t arc4random_uniform(uint32_t upper_bound); 1332# endif 1333# if !HAVE_DECL_REALLOCARRAY 1334void *reallocarray(void *ptr, size_t nmemb, size_t size); 1335# endif 1336#endif /* HAVE_LIBRESSL */ 1337#ifndef HAVE_ARC4RANDOM 1338void explicit_bzero(void* buf, size_t len); 1339int getentropy(void* buf, size_t len); 1340uint32_t arc4random(void); 1341void arc4random_buf(void* buf, size_t n); 1342void _ARC4_LOCK(void); 1343void _ARC4_UNLOCK(void); 1344#endif 1345#ifndef HAVE_ARC4RANDOM_UNIFORM 1346uint32_t arc4random_uniform(uint32_t upper_bound); 1347#endif 1348#ifdef COMPAT_SHA512 1349#ifndef SHA512_DIGEST_LENGTH 1350#define SHA512_BLOCK_LENGTH 128 1351#define SHA512_DIGEST_LENGTH 64 1352#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) 1353typedef struct _SHA512_CTX { 1354 uint64_t state[8]; 1355 uint64_t bitcount[2]; 1356 uint8_t buffer[SHA512_BLOCK_LENGTH]; 1357} SHA512_CTX; 1358#endif /* SHA512_DIGEST_LENGTH */ 1359void SHA512_Init(SHA512_CTX*); 1360void SHA512_Update(SHA512_CTX*, void*, size_t); 1361void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*); 1362unsigned char *SHA512(void* data, unsigned int data_len, unsigned char *digest); 1363#endif /* COMPAT_SHA512 */ 1364 1365 1366 1367#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)) 1368 /* using version of libevent that is not threadsafe. */ 1369# define LIBEVENT_SIGNAL_PROBLEM 1 1370#endif 1371 1372#ifndef CHECKED_INET6 1373# define CHECKED_INET6 1374# ifdef AF_INET6 1375# define INET6 1376# else 1377# define AF_INET6 28 1378# endif 1379#endif /* CHECKED_INET6 */ 1380 1381#ifndef HAVE_GETADDRINFO 1382struct sockaddr_storage; 1383#include "compat/fake-rfc2553.h" 1384#endif 1385 1386#ifdef UNBOUND_ALLOC_STATS 1387# define malloc(s) unbound_stat_malloc_log(s, __FILE__, __LINE__, __func__) 1388# define calloc(n,s) unbound_stat_calloc_log(n, s, __FILE__, __LINE__, __func__) 1389# define free(p) unbound_stat_free_log(p, __FILE__, __LINE__, __func__) 1390# define realloc(p,s) unbound_stat_realloc_log(p, s, __FILE__, __LINE__, __func__) 1391void *unbound_stat_malloc(size_t size); 1392void *unbound_stat_calloc(size_t nmemb, size_t size); 1393void unbound_stat_free(void *ptr); 1394void *unbound_stat_realloc(void *ptr, size_t size); 1395void *unbound_stat_malloc_log(size_t size, const char* file, int line, 1396 const char* func); 1397void *unbound_stat_calloc_log(size_t nmemb, size_t size, const char* file, 1398 int line, const char* func); 1399void unbound_stat_free_log(void *ptr, const char* file, int line, 1400 const char* func); 1401void *unbound_stat_realloc_log(void *ptr, size_t size, const char* file, 1402 int line, const char* func); 1403#elif defined(UNBOUND_ALLOC_LITE) 1404# include "util/alloc.h" 1405#endif /* UNBOUND_ALLOC_LITE and UNBOUND_ALLOC_STATS */ 1406 1407/** default port for DNS traffic. */ 1408#define UNBOUND_DNS_PORT 53 1409/** default port for unbound control traffic, registered port with IANA, 1410 ub-dns-control 8953/tcp unbound dns nameserver control */ 1411#define UNBOUND_CONTROL_PORT 8953 1412/** the version of unbound-control that this software implements */ 1413#define UNBOUND_CONTROL_VERSION 1 1414 1415]) 1416 1417dnl if we build from source tree, the man pages need @date@ and @version@ 1418dnl if this is a distro tarball, that was already done by makedist.sh 1419AC_SUBST(version, [VERSION_MAJOR.VERSION_MINOR.VERSION_MICRO]) 1420AC_SUBST(date, [`date +'%b %e, %Y'`]) 1421 1422AC_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]) 1423AC_CONFIG_HEADER([config.h]) 1424AC_OUTPUT 1425