1dnl 2dnl Some global settings 3dnl 4 5sinclude(acx_nlnetlabs.m4) 6sinclude(dnstap/dnstap.m4) 7 8AC_INIT([NSD],[4.6.0],[nsd-bugs@nlnetlabs.nl]) 9AC_CONFIG_HEADERS([config.h]) 10 11# 12# Setup the standard programs 13# https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Setting-Output-Variables.html 14 15AC_ARG_VAR(SED, [location of the sed program]) 16AC_ARG_VAR(AWK, [location of the awk program]) 17AC_ARG_VAR(GREP, [location of the grep program]) 18AC_ARG_VAR(EGREP, [location of the egrep program]) 19AC_ARG_VAR(LEX, [location of the lex program with GNU extensions (flex)]) 20AC_ARG_VAR(YACC, [location of the yacc program with GNU extensions (bison)]) 21 22cmdln="`echo $@ | sed -e 's/\\\\/\\\\\\\\/g' | sed -e 's/"/\\\\"/'g`" 23AC_DEFINE_UNQUOTED(CONFCMDLINE, ["$cmdln"], [Command line arguments used with configure]) 24 25CFLAGS="$CFLAGS" 26AC_USE_SYSTEM_EXTENSIONS 27if test "$ac_cv_header_minix_config_h" = "yes"; then 28 AC_DEFINE(_NETBSD_SOURCE,1, [Enable for compile on Minix]) 29fi 30 31dnl 32dnl By default set $sysconfdir to /etc and $localstatedir to /var 33dnl 34case "$prefix" in 35 NONE) 36 case "$sysconfdir" in 37 '${prefix}/etc') 38 sysconfdir=/etc 39 ;; 40 esac 41 case "$localstatedir" in 42 '${prefix}/var') 43 localstatedir=/var 44 ;; 45 esac 46 ;; 47esac 48 49# 50# Determine configuration directory 51# 52configdir=$sysconfdir/nsd 53AC_ARG_WITH([configdir], 54 AS_HELP_STRING([--with-configdir=dir],[NSD configuration directory]), 55 [configdir=$withval]) 56AC_DEFINE_UNQUOTED(CONFIGDIR, ["`eval echo $configdir`"], [NSD config dir]) 57AC_SUBST(configdir) 58 59# 60# Determine configuration file 61nsd_conf_file=${configdir}/nsd.conf 62AC_ARG_WITH([nsd_conf_file], 63 AS_HELP_STRING([--with-nsd_conf_file=path],[Pathname to the NSD configuration file]), 64 [nsd_conf_file=$withval]) 65AC_SUBST(nsd_conf_file) 66# the eval is to evaluate shell expansion twice, once 67# for $nsd_conf_file and once for the ${prefix} within it. 68AC_DEFINE_UNQUOTED(CONFIGFILE, ["`eval echo $nsd_conf_file`"], [Pathname to the NSD configuration file]) 69 70# 71# Default logfile 72# 73logfile=${localstatedir}/log/nsd.log 74AC_ARG_WITH([logfile], 75 AS_HELP_STRING([--with-logfile=path],[Pathname to the default log file]), 76 [logfile=$withval]) 77AC_SUBST(logfile) 78 79# 80# Database directory 81# 82dbdir=${localstatedir}/db/nsd 83 84# 85# Determine the pidfile location. Check if /var/run exists, if so set pidfile 86# to /var/run/nsd.pid by default 87# 88if test -d ${localstatedir}/run; then 89 pidfile=${localstatedir}/run/nsd.pid 90else 91 pidfile=${dbdir}/nsd.pid 92fi 93AC_ARG_WITH([pidfile], 94 AS_HELP_STRING([--with-pidfile=path],[Pathname to the NSD pidfile]), 95 [pidfile=$withval]) 96AC_SUBST(pidfile) 97AC_DEFINE_UNQUOTED(PIDFILE, ["`eval echo $pidfile`"], [Pathname to the NSD pidfile]) 98 99# 100# Determine location of nsd.db 101# 102dbfile=${dbdir}/nsd.db 103AC_ARG_WITH([dbfile], 104 AS_HELP_STRING([--with-dbfile=path],[Pathname to the NSD database]), 105 [dbfile=$withval]) 106AC_SUBST(dbfile) 107AC_DEFINE_UNQUOTED(DBFILE, ["`eval echo $dbfile`"], [Pathname to the NSD database]) 108 109if test -n "$dbfile"; then 110 dbdir=`dirname $dbfile` 111fi 112AC_SUBST(dbdir) 113 114piddir=`dirname $pidfile` 115AC_SUBST(piddir) 116 117# 118# Determine the default directory for the zone files 119# 120zonesdir=$configdir 121AC_ARG_WITH([zonesdir], 122 AS_HELP_STRING([--with-zonesdir=dir],[NSD default location for zone files]), 123 [zonesdir=$withval]) 124AC_SUBST(zonesdir) 125AC_DEFINE_UNQUOTED(ZONESDIR, ["`eval echo $zonesdir`"], [NSD default location for zone files. Empty string or NULL to disable.]) 126 127# default xfrd file location. 128xfrdfile=${dbdir}/xfrd.state 129AC_ARG_WITH([xfrdfile], AS_HELP_STRING([--with-xfrdfile=path],[Pathname to the NSD xfrd zone timer state file]), [xfrdfile=$withval]) 130AC_DEFINE_UNQUOTED(XFRDFILE, ["`eval echo $xfrdfile`"], [Pathname to the NSD xfrd zone timer state file.]) 131AC_SUBST(xfrdfile) 132 133# default zonelist file location. 134zonelistfile=${dbdir}/zone.list 135AC_ARG_WITH([zonelistfile], AS_HELP_STRING([--with-zonelistfile=path],[Pathname to the NSD zone list file]), [zonelistfile=$withval]) 136AC_DEFINE_UNQUOTED(ZONELISTFILE, ["`eval echo $zonelistfile`"], [Pathname to the NSD zone list file.]) 137AC_SUBST(zonelistfile) 138 139# default xfr dir location. 140xfrdir="/tmp" 141AC_ARG_WITH([xfrdir], AS_HELP_STRING([--with-xfrdir=path],[Pathname to where the NSD transfer dir is created]), [xfrdir=$withval]) 142AC_DEFINE_UNQUOTED(XFRDIR, ["`eval echo $xfrdir`"], [Pathname to where the NSD transfer dir is created.]) 143AC_SUBST(xfrdir) 144 145# nsd sbin location. tmpinstantiate execprefix with defaults if not yet done. 146if test "x${exec_prefix}" = "xNONE"; then 147 if test "x${prefix}" = "xNONE"; then exec_prefix="$ac_default_prefix" 148 else exec_prefix="${prefix}"; fi 149 nsd_start_path="`eval echo $sbindir`/nsd" 150 exec_prefix="NONE" 151else 152 nsd_start_path="`eval echo $sbindir`/nsd" 153fi 154AC_DEFINE_UNQUOTED(NSD_START_PATH, ["$nsd_start_path"], [Pathname to start nsd from nsd-control]) 155 156# 157# Determine default chroot directory 158# 159AC_ARG_WITH([chroot], 160 AS_HELP_STRING([--with-chroot=dir],[NSD default chroot directory]), 161 [ 162 chrootdir=$withval 163 AC_DEFINE_UNQUOTED(CHROOTDIR, ["`eval echo $chrootdir`"], [NSD default chroot directory]) 164 ]) 165AC_SUBST(chrootdir) 166 167# 168# Determine the user name to drop privileges to 169# 170user=nsd 171AC_ARG_WITH([user], 172 AS_HELP_STRING([--with-user=username],[User name or ID to answer the queries with]), 173 [user=$withval]) 174AC_SUBST(user) 175AC_DEFINE_UNQUOTED(USER, ["$user"], [the user name to drop privileges to]) 176 177AC_PROG_CC 178AC_PROG_SED 179AC_PROG_AWK 180AC_PROG_GREP 181AC_PROG_EGREP 182AC_PROG_LEX([noyywrap]) 183AC_PROG_YACC 184AC_PROG_LN_S 185AC_PROG_INSTALL 186 187if test "$LEX" != ":" -a "$LEX" != ""; then 188# Solaris provides anemic tools, and they don't offer GNU extensions like 189# 'flex -i'. Solaris also does not offer GNU replacements in /usr/gnu/bin. 190AC_MSG_CHECKING([whether lex accepts -i]) 191AS_IF([echo "%%" | $LEX -i -t >/dev/null 2>&1], 192 [ 193 AC_MSG_RESULT([yes]) 194 ], 195 [ 196 AC_MSG_RESULT([no]) 197 AC_MSG_ERROR([unable to find a lexer that supports -i. If one is available then set the LEX variable]) 198 ] 199) 200 201 # Check if lex defines yy_current_buffer, because 2.4.6 and older use it, 202 # but later could define it as a macro and then we should not redefine it. 203 AC_MSG_CHECKING(if lex defines yy_current_buffer) 204 cat <<EOF >conftest.lex 205%% 206EOF 207 $LEX -i -t conftest.lex >> conftest.c 2>/dev/null 208 if $GREP "^#define yy_current_buffer" conftest.c >/dev/null; then 209 AC_DEFINE_UNQUOTED(LEX_DEFINES_YY_CURRENT_BUFFER, 1, [If flex defines yy_current_buffer as a macro]) 210 AC_MSG_RESULT(yes) 211 else 212 AC_MSG_RESULT(no) 213 fi 214 rm -f conftest.lex conftest.c 215fi 216 217AC_DEFUN([AC_CHECK_FORMAT_ATTRIBUTE], 218[AC_REQUIRE([AC_PROG_CC]) 219AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "format" attribute) 220AC_CACHE_VAL(ac_cv_c_format_attribute, 221[ac_cv_c_format_attribute=no 222AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h> 223void f (char *format, ...) __attribute__ ((format (printf, 1, 2))); 224void (*pf) (char *format, ...) __attribute__ ((format (printf, 1, 2))); 225]], [[ 226 f ("%s", "str"); 227]])],[ac_cv_c_format_attribute="yes"],[ac_cv_c_format_attribute="no"]) 228]) 229 230AC_MSG_RESULT($ac_cv_c_format_attribute) 231if test $ac_cv_c_format_attribute = yes; then 232 AC_DEFINE(HAVE_ATTR_FORMAT, 1, [Whether the C compiler accepts the "format" attribute]) 233fi 234])dnl 235 236AC_DEFUN([AC_CHECK_UNUSED_ATTRIBUTE], 237[AC_REQUIRE([AC_PROG_CC]) 238AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "unused" attribute) 239AC_CACHE_VAL(ac_cv_c_unused_attribute, 240[ac_cv_c_unused_attribute=no 241AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h> 242void f (char *u __attribute__((unused))); 243]], [[ 244 f ("x"); 245]])],[ac_cv_c_unused_attribute="yes"],[ac_cv_c_unused_attribute="no"]) 246]) 247 248AC_MSG_RESULT($ac_cv_c_unused_attribute) 249if test $ac_cv_c_unused_attribute = yes; then 250 AC_DEFINE(HAVE_ATTR_UNUSED, 1, [Whether the C compiler accepts the "unused" attribute]) 251fi 252])dnl 253 254AC_DEFUN([CHECK_WEAK_ATTRIBUTE], 255[AC_REQUIRE([AC_PROG_CC]) 256AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "weak" attribute) 257AC_CACHE_VAL(ac_cv_c_weak_attribute, 258[ac_cv_c_weak_attribute=no 259AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> 260__attribute__((weak)) void f(int x) { printf("%d", x); } 261]], [[ 262 f(1); 263]])],[ac_cv_c_weak_attribute="yes"],[ac_cv_c_weak_attribute="no"]) 264]) 265 266AC_MSG_RESULT($ac_cv_c_weak_attribute) 267if test $ac_cv_c_weak_attribute = yes; then 268 AC_DEFINE(HAVE_ATTR_WEAK, 1, [Whether the C compiler accepts the "weak" attribute]) 269 AC_DEFINE(ATTR_WEAK, [__attribute__((weak))], [apply the weak attribute to a symbol]) 270fi 271])dnl End of CHECK_WEAK_ATTRIBUTE 272 273AC_DEFUN([CHECK_NORETURN_ATTRIBUTE], 274[AC_REQUIRE([AC_PROG_CC]) 275AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "noreturn" attribute) 276AC_CACHE_VAL(ac_cv_c_noreturn_attribute, 277[ac_cv_c_noreturn_attribute=no 278AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> 279__attribute__((noreturn)) void f(int x) { printf("%d", x); } 280]], [[ 281 f(1); 282]])],[ac_cv_c_noreturn_attribute="yes"],[ac_cv_c_noreturn_attribute="no"]) 283]) 284 285AC_MSG_RESULT($ac_cv_c_noreturn_attribute) 286if test $ac_cv_c_noreturn_attribute = yes; then 287 AC_DEFINE(HAVE_ATTR_NORETURN, 1, [Whether the C compiler accepts the "noreturn" attribute]) 288 AC_DEFINE(ATTR_NORETURN, [__attribute__((__noreturn__))], [apply the noreturn attribute to a function that exits the program]) 289fi 290])dnl End of CHECK_NORETURN_ATTRIBUTE 291 292AC_DEFUN([CHECK_COMPILER_FLAG], 293[ 294AC_REQUIRE([AC_PROG_CC]) 295AC_MSG_CHECKING(whether $CC supports -$1) 296cache=`echo $1 | $SED 'y%.=/+-%___p_%'` 297AC_CACHE_VAL(cv_prog_cc_flag_$cache, 298[ 299echo 'void f(){}' >conftest.c 300if test -z "`$CC -$1 -c conftest.c 2>&1`"; then 301eval "cv_prog_cc_flag_$cache=yes" 302else 303eval "cv_prog_cc_flag_$cache=no" 304fi 305rm -f conftest* 306]) 307if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then 308AC_MSG_RESULT(yes) 309: 310$2 311else 312AC_MSG_RESULT(no) 313: 314$3 315fi 316]) 317 318AC_DEFUN([AC_CHECK_CTIME_R], 319[AC_REQUIRE([AC_PROG_CC]) 320AC_MSG_CHECKING(whether ctime_r works with two arguments) 321AC_CACHE_VAL(ac_cv_c_ctime_c, 322[ac_cv_c_ctime_c=no 323AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h> 324void testing (void) { time_t clock; char current_time[40]; ctime_r(&clock, current_time); }]], [[ 325 testing(); 326]])],[ac_cv_c_ctime_c="yes"],[ac_cv_c_ctime_c="no"]) 327]) 328 329AC_MSG_RESULT($ac_cv_c_ctime_c) 330if test $ac_cv_c_ctime_c = no; then 331 CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS" 332fi 333])dnl 334 335# Checks for typedefs, structures, and compiler characteristics. 336# allow user to override the -g -O2 flags. 337if test "x$CFLAGS" = "x" ; then 338 ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="$CFLAGS -g"]) 339 # we do not use O3 because it causes miscompilations. 340 ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"]) 341 ACX_CHECK_FLTO 342 ACX_CHECK_PIE 343 ACX_CHECK_RELRO_NOW 344fi 345AC_C_CONST 346AC_C_INLINE 347AC_TYPE_UID_T 348AC_TYPE_PID_T 349AC_TYPE_SIZE_T 350AC_TYPE_OFF_T 351 352AC_CHECK_FORMAT_ATTRIBUTE 353AC_CHECK_UNUSED_ATTRIBUTE 354CHECK_WEAK_ATTRIBUTE 355CHECK_NORETURN_ATTRIBUTE 356ACX_CHECK_MEMCMP_SIGNED 357AC_CHECK_CTIME_R 358 359# Checks for libraries. 360 361# Check for SSL, original taken from 362# http://www.gnu.org/software/ac-archive/htmldoc/check_ssl.html and 363# modified for NSD. 364AC_DEFUN([CHECK_SSL], [ 365 AC_ARG_WITH(ssl, AS_HELP_STRING([--with-ssl=pathname],[enable SSL (will check /usr/local/ssl 366 /usr/lib/ssl /usr/ssl /usr/sfw /usr/local /usr /usr/local/opt/openssl)]),[ 367 ],[ 368 withval="yes" 369 ]) 370 if test x_$withval != x_no; then 371 AC_MSG_CHECKING(for SSL) 372 if test -n "$withval"; then 373 dnl look for openssl install with different version, eg. 374 dnl in /usr/include/openssl11/openssl/ssl.h 375 dnl and /usr/lib64/openssl11/libssl.so 376 dnl with the --with-ssl=/usr/include/openssl11 377 if test ! -f "$withval/include/openssl/ssl.h" -a -f "$withval/openssl/ssl.h"; then 378 ssldir="$withval" 379 found_ssl="yes" 380 withval="" 381 ssldir_include="$ssldir" 382 CPPFLAGS="$CPPFLAGS -I$ssldir_include"; 383 dnl find the libdir 384 ssldir_lib=`echo $ssldir | sed -e 's/include/lib/'` 385 if test -f "$ssldir_lib/libssl.a" -o -f "$ssldir_lib/libssl.so"; then 386 : # found here 387 else 388 ssldir_lib=`echo $ssldir | sed -e 's/include/lib64/'` 389 if test -f "$ssldir_lib/libssl.a" -o -f "$ssldir_lib/libssl.so"; then 390 : # found here 391 else 392 AC_MSG_ERROR([Could not find openssl lib file, $ssldir_lib/libssl.[so,a], pass like "/usr/local" or "/usr/include/openssl11"]) 393 fi 394 fi 395 fi 396 fi 397 if test x_$withval = x_ -o x_$withval = x_yes; then 398 withval="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/sfw /usr/local /usr /usr/local/opt/openssl" 399 fi 400 for dir in $withval; do 401 ssldir="$dir" 402 if test -f "$dir/include/openssl/ssl.h"; then 403 found_ssl="yes"; 404 if test x_$ssldir != x_/usr; then 405 CPPFLAGS="$CPPFLAGS -I$ssldir/include"; 406 fi 407 ssldir_include="$ssldir/include" 408 if test ! -d "$ssldir/lib" -a -d "$ssldir/lib64"; then 409 ssldir_lib="$ssldir/lib64" 410 else 411 ssldir_lib="$ssldir/lib" 412 fi 413 break; 414 fi 415 done 416 if test x_$found_ssl != x_yes; then 417 AC_MSG_ERROR([Cannot find the SSL libraries in $withval]) 418 else 419 AC_MSG_RESULT([found in $ssldir]) 420 HAVE_SSL=yes 421 AC_DEFINE_UNQUOTED([HAVE_SSL], [], [Define if you have the SSL libraries installed.]) 422 if test x_$ssldir != x_/usr; then 423 LDFLAGS="$LDFLAGS -L$ssldir_lib"; 424 fi 425 if test x_$ssldir = x_/usr/sfw; then 426 LDFLAGS="$LDFLAGS -R$ssldir_lib"; 427 fi 428 fi 429 AC_SUBST(HAVE_SSL) 430 fi 431])dnl 432 433# check for libevent 434AC_ARG_WITH(libevent, AS_HELP_STRING([--with-libevent=pathname],[use libevent (will check /usr/local /opt/local /usr/lib /usr/sfw /usr /usr/local/opt/libevent or you can specify an explicit path), useful when the zone count is high.]), 435 [ ],[ withval="yes" ]) 436if test x_$withval = x_yes -o x_$withval != x_no; then 437 AC_MSG_CHECKING(for libevent) 438 if test x_$withval = x_ -o x_$withval = x_yes; then 439 withval="/usr/local /opt/local /usr/lib /usr/sfw /usr /usr/local/opt/libevent" 440 fi 441 for dir in $withval; do 442 thedir="$dir" 443 if test -f "$dir/include/event.h" -o -f "$dir/include/event2/event.h"; then 444 found_libevent="yes" 445 dnl assume /usr is in default path. 446 if test "$thedir" != "/usr"; then 447 CPPFLAGS="$CPPFLAGS -I$thedir/include" 448 fi 449 break; 450 fi 451 done 452 if test x_$found_libevent != x_yes; then 453 if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then 454 # libevent source directory 455 AC_MSG_RESULT(found in $thedir) 456 CPPFLAGS="$CPPFLAGS -I$thedir -I$thedir/include" 457 # remove evdns from linking 458 ev_files_o=`ls $thedir/*.o | $GREP -v evdns\.o | $GREP -v bufferevent_openssl\.o` 459 cp $ev_files_o . 460 LDFLAGS="$ev_files_o $LDFLAGS -lm" 461 else 462 AC_MSG_ERROR([Cannot find the libevent library. 463You can restart ./configure --with-libevent=no to use a builtin alternative.]) 464 fi 465 else 466 AC_MSG_RESULT(found in $thedir) 467 dnl if event2 exists and no event lib in dir itself, use subdir 468 if test ! -f $thedir/lib/libevent.a -a ! -f $thedir/lib/libevent.so -a -d "$thedir/lib/event2"; then 469 LDFLAGS="$LDFLAGS -L$thedir/lib/event2" 470 ACX_RUNTIME_PATH_ADD([$thedir/lib/event2]) 471 else 472 dnl assume /usr is in default path, do not add "". 473 if test "$thedir" != "/usr" -a "$thedir" != ""; then 474 LDFLAGS="$LDFLAGS -L$thedir/lib" 475 ACX_RUNTIME_PATH_ADD([$thedir/lib]) 476 fi 477 fi 478 fi 479 # check for library used by libevent after 1.3c 480 AC_SEARCH_LIBS([clock_gettime], [rt]) 481 482 # is the event.h header libev or libevent? 483 AC_CHECK_HEADERS([event.h],,, [AC_INCLUDES_DEFAULT]) 484 AC_CHECK_DECL(EV_VERSION_MAJOR, [ 485 AC_SEARCH_LIBS(event_set, [ev]) 486 ],[ 487 AC_SEARCH_LIBS(event_set, [event]) 488 ],[AC_INCLUDES_DEFAULT 489#include <event.h> 490 ]) 491 AC_CHECK_FUNCS([event_base_free]) # only in libevent 1.2 and later 492 AC_CHECK_FUNCS([event_base_once]) # only in libevent 1.4.1 and later 493 AC_CHECK_FUNCS([event_base_new]) # only in libevent 1.4.1 and later 494 AC_CHECK_FUNCS([event_base_get_method]) # only in libevent 1.4.3 and later 495 AC_CHECK_FUNCS([ev_loop]) # only in libev. (tested on 3.51) 496 AC_CHECK_FUNCS([ev_default_loop]) # only in libev. (tested on 4.00) 497else 498 AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events]) 499fi 500 501# Checks for header files. 502AC_HEADER_SYS_WAIT 503AC_CHECK_HEADERS([time.h arpa/inet.h signal.h string.h strings.h fcntl.h limits.h netinet/in.h netinet/tcp.h stddef.h sys/param.h sys/socket.h sys/un.h syslog.h unistd.h sys/select.h stdarg.h stdint.h netdb.h sys/bitypes.h tcpd.h glob.h grp.h endian.h sys/random.h ifaddrs.h],,, [AC_INCLUDES_DEFAULT]) 504 505AC_DEFUN([CHECK_VALIST_DEF], 506[ 507AC_REQUIRE([AC_PROG_CC]) 508AC_MSG_CHECKING(for double definition of struct va_list) 509AC_CACHE_VAL(ac_cv_c_va_list_def, 510[ 511cat >conftest.c <<EOF 512#include <stdio.h> 513#include <stdarg.h> 514int foo(void); 515EOF 516if test -z "`$CC -Werror -D_XOPEN_SOURCE=600 -c conftest.c 2>&1`"; then 517eval "ac_cv_c_va_list_def=no" 518else 519eval "ac_cv_c_va_list_def=yes" 520fi 521rm -f conftest* 522]) 523if test $ac_cv_c_va_list_def = yes; then 524AC_MSG_RESULT(yes) 525: 526AC_DEFINE_UNQUOTED([HAVE_VA_LIST_DOUBLE_DEF], [], [Define this if you have double va_list definitions.]) 527else 528AC_MSG_RESULT(no) 529: 530 531fi 532]) 533 534CHECK_VALIST_DEF 535 536AC_DEFUN([AC_CHECK_STRPTIME], 537[AC_REQUIRE([AC_PROG_CC]) 538AC_MSG_CHECKING(whether strptime needs defines) 539AC_CACHE_VAL(ac_cv_c_strptime_needs_defs, 540[ 541cat >conftest.c <<EOF 542#include <time.h> 543int testing (void) { struct tm t; const char *timestr="201201"; return strptime(timestr, "%Y%m", &t) != 0; } 544EOF 545if test -z "`$CC -Wall -Werror -c conftest.c 2>&1`"; then 546eval "ac_cv_c_strptime_needs_defs=no" 547else 548eval "ac_cv_c_strptime_needs_defs=yes" 549fi 550rm -f conftest* 551]) 552 553AC_MSG_RESULT($ac_cv_c_strptime_needs_defs) 554if test $ac_cv_c_strptime_needs_defs = yes; then 555AC_DEFINE_UNQUOTED([STRPTIME_NEEDS_DEFINES], 1, [strptime is available from time.h with some defines.]) 556fi 557])dnl 558 559AC_CHECK_STRPTIME 560 561# check wether strptime also works 562AC_DEFUN([AC_CHECK_STRPTIME_WORKS], 563[AC_REQUIRE([AC_PROG_CC]) 564AC_MSG_CHECKING(whether strptime works) 565if test c${cross_compiling} = cno; then 566AC_RUN_IFELSE([AC_LANG_SOURCE([[ 567#define _XOPEN_SOURCE 600 568#include <time.h> 569int main(void) { struct tm tm; char *res; 570res = strptime("20070207111842", "%Y%m%d%H%M%S", &tm); 571if (!res) return 1; return 0; } 572]])] , [eval "ac_cv_c_strptime_works=yes"], [eval "ac_cv_c_strptime_works=no"]) 573else 574eval "ac_cv_c_strptime_works=maybe" 575fi 576AC_MSG_RESULT($ac_cv_c_strptime_works) 577if test $ac_cv_c_strptime_works = no; then 578AC_LIBOBJ(strptime) 579else 580AC_DEFINE_UNQUOTED([STRPTIME_WORKS], 1, [use default strptime.]) 581fi 582])dnl 583 584AC_SEARCH_LIBS(inet_pton, [nsl]) 585AC_SEARCH_LIBS(socket, [socket]) 586 587AC_CHECK_STRPTIME_WORKS 588ACX_CHECK_NONBLOCKING_BROKEN 589ACX_MKDIR_ONE_ARG 590 591# set -I. and -Isrcdir 592if test -n "$CPPFLAGS"; then 593 CPPFLAGS="$CPPFLAGS -I." 594else 595 CPPFLAGS="-I." 596fi 597if test "$srcdir" != "."; then 598 CPPFLAGS="$CPPFLAGS -I$srcdir" 599 if test -f $srcdir/config.h; then 600 AC_MSG_ERROR([$srcdir/config.h is in the way, please remove it]) 601 fi 602fi 603 604dnl LIBGTOP_CHECK_TYPE 605dnl Stolen from Gnome's anjuta 606dnl Improved version of AC_CHECK_TYPE which takes into account 607dnl that we need to #include some other header files on some 608dnl systems to get some types. 609 610dnl AC_LIBGTOP_CHECK_TYPE(TYPE, DEFAULT) 611AC_DEFUN([AC_LIBGTOP_CHECK_TYPE], 612[AC_MSG_CHECKING(for $1) 613AC_CACHE_VAL(ac_cv_type_$1, 614[AC_EGREP_CPP(dnl 615changequote(<<,>>)dnl 616<<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl 617changequote([,]), [ 618#include <sys/types.h> 619#include <stdlib.h> 620#include <stddef.h> 621 622#ifdef HAVE_STDINT_H 623#include <stdint.h> 624#endif 625 626#ifdef HAVE_SYS_SOCKET_H 627#include <sys/socket.h> 628#endif 629 630#ifdef HAVE_ARPA_INET_H 631#include <arpa/inet.h> 632#endif 633 634#ifdef HAVE_SIGNAL_H 635#include <signal.h> 636#endif 637 638/* For Tru64 */ 639#ifdef HAVE_SYS_BITYPES_H 640#include <sys/bitypes.h> 641#endif 642], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl 643AC_MSG_RESULT($ac_cv_type_$1) 644if test $ac_cv_type_$1 = no; then 645 AC_DEFINE($1, $2, Define "$1" to "$2" if "$1" is missing) 646fi 647]) 648 649AC_LIBGTOP_CHECK_TYPE(int8_t, char) 650AC_LIBGTOP_CHECK_TYPE(int16_t, short) 651AC_LIBGTOP_CHECK_TYPE(int32_t, int) 652AC_LIBGTOP_CHECK_TYPE(int64_t, long long) 653AC_LIBGTOP_CHECK_TYPE(uint8_t, unsigned char) 654AC_LIBGTOP_CHECK_TYPE(uint16_t, unsigned short) 655AC_LIBGTOP_CHECK_TYPE(uint32_t, unsigned int) 656AC_LIBGTOP_CHECK_TYPE(uint64_t, unsigned long long) 657AC_LIBGTOP_CHECK_TYPE(socklen_t, int) 658AC_LIBGTOP_CHECK_TYPE(sig_atomic_t, int) 659AC_LIBGTOP_CHECK_TYPE(ssize_t, int) 660AC_LIBGTOP_CHECK_TYPE(suseconds_t, time_t) 661 662AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [ 663#if HAVE_SYS_TYPES_H 664# include <sys/types.h> 665#endif 666#if HAVE_NETINET_IN_H 667# include <netinet/in.h> 668#endif]) 669ACX_CHECK_SS_FAMILY 670AC_CHECK_MEMBERS([struct stat.st_mtimensec, struct stat.st_mtim.tv_nsec]) 671AC_CHECK_MEMBERS([struct sockaddr_un.sun_len],,,[ 672AC_INCLUDES_DEFAULT 673#ifdef HAVE_SYS_UN_H 674#include <sys/un.h> 675#endif 676]) 677 678# Checks for library functions. 679AC_FUNC_CHOWN 680AC_FUNC_FORK 681AC_FUNC_MALLOC 682AC_DEFINE(RETSIGTYPE,void,[Return type of signal handlers, but autoconf 2.70 says 'your code may safely assume C89 semantics that RETSIGTYPE is void.']) 683AC_FUNC_FSEEKO 684AC_SYS_LARGEFILE 685AC_CHECK_SIZEOF(void*) 686AC_CHECK_SIZEOF(off_t) 687AC_CHECK_FUNCS([getrandom arc4random arc4random_uniform]) 688AC_SEARCH_LIBS([setusercontext],[util],[AC_CHECK_HEADERS([login_cap.h],,, [AC_INCLUDES_DEFAULT])]) 689AC_CHECK_FUNCS([tzset alarm chroot dup2 endpwent gethostname memset memcpy pwrite socket strcasecmp strchr strdup strerror strncasecmp strtol writev getaddrinfo getnameinfo freeaddrinfo gai_strerror sigaction sigprocmask strptime strftime localtime_r setusercontext glob initgroups setresuid setreuid setresgid setregid getpwnam mmap ppoll clock_gettime accept4 getifaddrs]) 690 691AC_CHECK_TYPE([struct mmsghdr], AC_DEFINE(HAVE_MMSGHDR, 1, [If sys/socket.h has a struct mmsghdr.]), [], [ 692AC_INCLUDES_DEFAULT 693#include <sys/socket.h> 694]) 695 696AC_ARG_ENABLE(recvmmsg, AS_HELP_STRING([--enable-recvmmsg],[Enable recvmmsg and sendmmsg compilation, faster but some kernel versions may have implementation problems for IPv6])) 697case "$enable_recvmmsg" in 698 yes) 699 AC_CHECK_FUNC([recvmmsg], [ 700AC_RUN_IFELSE([AC_LANG_SOURCE([[ 701#include <sys/socket.h> 702#include <errno.h> 703int main(void) 704{ 705 int s = socket(AF_INET, SOCK_DGRAM, 0); 706 int r = recvmmsg(s, 0, 0, 0, 0) == -1 && errno == ENOSYS; 707 close(s); 708 return r; 709} 710]])], [ 711AC_DEFINE([HAVE_RECVMMSG], [1], [Define if recvmmsg is implemented])], [ 712], [ 713AC_DEFINE([HAVE_RECVMMSG], [1], [Define if recvmmsg exists])] 714)]) 715 AC_CHECK_FUNC([sendmmsg], [ 716AC_RUN_IFELSE([AC_LANG_SOURCE([[ 717#include <sys/socket.h> 718#include <errno.h> 719int main(void) 720{ 721 int s = socket(AF_INET, SOCK_DGRAM, 0); 722 int r = sendmmsg(s, 0, 0, 0) == -1 && errno == ENOSYS; 723 close(s); 724 return r; 725} 726]])], [ 727AC_DEFINE([HAVE_SENDMMSG], [1], [Define if sendmmsg is implemented])], [ 728], [ 729AC_DEFINE([HAVE_SENDMMSG], [1], [Define if sendmmsg exists])] 730)]) 731 732 ;; 733 no|*) 734 ;; 735esac 736 737# check if setreuid en setregid fail, on MacOSX10.4(darwin8). 738if echo $target_os | $GREP -i darwin8 > /dev/null; then 739 AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work]) 740fi 741 742# GNU HURD needs _GNU_SOURCE defined for cpu affinity gear 743if echo $target_os | $EGREP -i 'linux|hurd' > /dev/null; then 744 AC_DEFINE([_GNU_SOURCE, 1, [Define this if on Linux or GNU Hurd for cpu affinity interface]]) 745fi 746 747# see comment on _GNU_SOURCE above 748AC_CHECK_HEADERS([sched.h sys/cpuset.h],,, [AC_INCLUDES_DEFAULT]) 749 750# Check for cpu_set_t (Linux) and cpuset_t (FreeBSD and NetBSD) 751AC_CHECK_TYPES([cpu_set_t, cpuset_t, cpuid_t],,,[ 752AC_INCLUDES_DEFAULT 753#if HAVE_SCHED_H 754# include <sched.h> 755#endif 756#if HAVE_SYS_CPUSET_H 757# include <sys/cpuset.h> 758#endif 759]) 760 761AC_DEFUN([AC_CHECK_CPU_OR], 762[AC_REQUIRE([AC_PROG_CC]) 763AC_MSG_CHECKING(whether CPU_OR works with three arguments) 764AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef HAVE_SCHED_H 765# include <sched.h> 766#endif 767#ifdef HAVE_SYS_CPUSET_H 768# include <sys/cpuset.h> 769#endif 770#include <string.h> 771#ifdef HAVE_CPUSET_T 772#define MY_CPUSET_TYPE cpuset_t 773#endif 774#ifdef HAVE_CPU_SET_T 775#define MY_CPUSET_TYPE cpu_set_t 776#endif 777void testing (void) { 778 MY_CPUSET_TYPE a, b; 779 memset(&a, 0, sizeof(a)); 780 memset(&b, 0, sizeof(b)); 781 CPU_OR(&a, &a, &b); 782}]], [[ 783 testing(); 784]])],[ 785 AC_MSG_RESULT(yes) 786 AC_DEFINE([CPU_OR_THREE_ARGS], 1, [number of arguments for CPU_OR is three]) 787],[ 788 AC_MSG_RESULT(no) 789])]) 790 791AS_IF([test x"$ac_cv_type_cpuset_t" = xyes -o x"$ac_cv_type_cpu_set_t" = xyes ],[ 792 AC_CHECK_FUNC(cpuset_create) 793 AC_CHECK_FUNC(cpuset_destroy) 794 AC_CHECK_FUNC(cpuset_zero) 795 AC_CHECK_FUNC(cpuset_set) 796 AC_CHECK_FUNC(cpuset_clr) 797 AC_CHECK_FUNC(cpuset_isset) 798 AC_CHECK_FUNC(cpuset_size) 799 AC_LIBOBJ(cpuset) 800 AC_CHECK_FUNCS([sysconf]) 801 AC_CHECK_CPU_OR 802]) 803 804# 805# sched_setaffinity must be checked using proper includes. 806# also needs _GNU_SOURCE on Linux and Hurd; see above. 807# also see https://github.com/NLnetLabs/nsd/issues/82. 808# 809AC_MSG_CHECKING(for sched_setaffinity) 810AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 811 [[ 812 #ifdef HAVE_SCHED_H 813 # include <sched.h> 814 #endif 815 #ifdef HAVE_SYS_CPUSET_H 816 #include <sys/cpuset.h> 817 #endif 818 #ifdef HAVE_CPUSET_T 819 #define MY_CPUSET_TYPE cpuset_t 820 #endif 821 #ifdef HAVE_CPU_SET_T 822 #define MY_CPUSET_TYPE cpu_set_t 823 #endif 824 void testing (void) { 825 MY_CPUSET_TYPE set; 826 CPU_ZERO(&set); 827 (void)sched_setaffinity(-1, sizeof(set), &set); 828 } 829]])], 830[ AC_MSG_RESULT(yes) 831 AC_DEFINE(HAVE_SCHED_SETAFFINITY, 1, [Define this if sched_setaffinity is available])], 832[ AC_MSG_RESULT(no)]) 833 834# 835# Checking for missing functions we can replace 836# 837AC_REPLACE_FUNCS(basename) 838AC_REPLACE_FUNCS(inet_aton) 839AC_REPLACE_FUNCS(inet_pton) 840AC_REPLACE_FUNCS(inet_ntop) 841AC_REPLACE_FUNCS(snprintf) 842AC_REPLACE_FUNCS(strlcat) 843AC_REPLACE_FUNCS(strlcpy) 844AC_REPLACE_FUNCS(strptime) 845AC_REPLACE_FUNCS(b64_pton) 846AC_REPLACE_FUNCS(b64_ntop) 847AC_REPLACE_FUNCS(pselect) 848AC_REPLACE_FUNCS(memmove) 849AC_REPLACE_FUNCS(setproctitle) 850AC_REPLACE_FUNCS(explicit_bzero) 851AC_MSG_CHECKING([for reallocarray]) 852AC_LINK_IFELSE([AC_LANG_SOURCE( 853[[ 854#ifndef _OPENBSD_SOURCE 855#define _OPENBSD_SOURCE 1 856#endif 857]] 858AC_INCLUDES_DEFAULT 859[[ 860#include <stdlib.h> 861int main(void) { 862 void* p = reallocarray(NULL, 10, 100); 863 free(p); 864 return 0; 865} 866]])], [AC_MSG_RESULT(yes) 867 AC_DEFINE(HAVE_REALLOCARRAY, 1, [If we have reallocarray(3)]) 868 AC_CHECK_DECLS([reallocarray], [], [ 869 AC_DEFINE(REALLOCARRAY_NEEDS_DEFINES, 1, [If reallocarray needs defines to appear in the headers]) 870 ], [ 871AC_INCLUDES_DEFAULT 872#include <stdlib.h> 873 ]) 874], [ 875 AC_MSG_RESULT(no) 876 AC_LIBOBJ(reallocarray) 877]) 878 879AC_MSG_CHECKING(for pselect prototype in sys/select.h) 880AC_EGREP_HEADER([[^a-zA-Z_]*pselect[^a-zA-Z_]], sys/select.h, AC_DEFINE(HAVE_PSELECT_PROTO, 1, 881 [if sys/select.h provides pselect prototype]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) 882 883AC_MSG_CHECKING(for ctime_r prototype in time.h) 884AC_EGREP_HEADER([[^a-zA-Z_]*ctime_r[^a-zA-Z_]], time.h, AC_DEFINE(HAVE_CTIME_R_PROTO, 1, 885 [if time.h provides ctime_r prototype]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) 886 887AC_CHECK_TYPE([struct timespec], AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1, [If time.h has a struct timespec (for pselect).]), [], [ 888AC_INCLUDES_DEFAULT 889#ifdef HAVE_SIGNAL_H 890#include <signal.h> 891#endif 892#ifdef HAVE_TIME_H 893#include <time.h> 894#endif 895]) 896 897dnl 898dnl Some random defines's 899dnl 900AC_DEFINE_UNQUOTED([IDENTITY], ["unidentified server"], [Define to the default nsd identity.]) 901AC_DEFINE_UNQUOTED([VERSION], [PACKAGE_STRING], [Define to the NSD version to answer version.server query.]) 902AC_DEFINE_UNQUOTED([TCP_BACKLOG], [256], [Define to the backlog to be used with listen.]) 903AC_DEFINE_UNQUOTED([TCP_PORT], ["53"], [Define to the default tcp port.]) 904AC_DEFINE_UNQUOTED([TCP_MAX_MESSAGE_LEN], [65535], [Define to the default maximum message length.]) 905AC_DEFINE_UNQUOTED([UDP_PORT], ["53"], [Define to the default udp port.]) 906AC_DEFINE_UNQUOTED([UDP_MAX_MESSAGE_LEN], [512], [Define to the default maximum udp message length.]) 907AC_DEFINE_UNQUOTED([EDNS_MAX_MESSAGE_LEN], [1232], [Define to the default maximum message length with EDNS.]) 908AC_DEFINE_UNQUOTED([TLS_PORT], ["853"], [Define to the default DNS over TLS port.]) 909AC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [512], [Define to the maximum message length to pass to syslog.]) 910AC_DEFINE_UNQUOTED([NSD_CONTROL_PORT], [8952], [Define to the default nsd-control port.]) 911AC_DEFINE_UNQUOTED([NSD_CONTROL_VERSION], [1], [Define to nsd-control proto version.]) 912AC_DEFINE_UNQUOTED([VERIFY_PORT], ["5347"], [Define to the default zone verification udp port.]) 913 914dnl 915dnl Determine the syslog facility to use 916dnl 917facility=LOG_DAEMON 918AC_ARG_WITH([facility], 919 AS_HELP_STRING([--with-facility=name],[Syslog default facility (LOG_DAEMON)]), 920 [facility=$withval]) 921AC_DEFINE_UNQUOTED([FACILITY], $facility, [Define to the default facility for syslog.]) 922 923dnl 924dnl Determine the default tcp timeout 925dnl 926tcp_timeout=120 927AC_ARG_WITH([tcp_timeout], 928 AS_HELP_STRING([--with-tcp-timeout=number],[Limit the default tcp timeout]), 929 [tcp_timeout=$withval]) 930AC_DEFINE_UNQUOTED([TCP_TIMEOUT], $tcp_timeout, [Define to the default tcp timeout.]) 931 932dnl 933dnl Features 934dnl 935AC_ARG_ENABLE(root-server, AS_HELP_STRING([--enable-root-server],[Configure NSD as a root server])) 936case "$enable_root_server" in 937 yes) 938 AC_DEFINE_UNQUOTED([ROOT_SERVER], [], [Define this to configure as a root server.]) 939 ;; 940 no|*) 941 ;; 942esac 943 944AC_ARG_ENABLE(ipv6, AS_HELP_STRING([--disable-ipv6],[Disables IPv6 support])) 945case "$enable_ipv6" in 946 no) 947 ;; 948 yes|*) 949 AC_DEFINE_UNQUOTED([INET6], [], [Define this to enable IPv6 support.]) 950 ;; 951esac 952 953AC_ARG_ENABLE(bind8-stats, AS_HELP_STRING([--enable-bind8-stats],[Enables BIND8 like NSTATS & XSTATS and statistics in nsd-control])) 954 955case "$enable_bind8_stats" in 956 yes|'') 957 AC_DEFINE_UNQUOTED([BIND8_STATS], [], [Define this to enable BIND8 like NSTATS & XSTATS.]) 958 ;; 959 no|*) 960 ;; 961esac 962 963AC_ARG_ENABLE(zone-stats, AS_HELP_STRING([--enable-zone-stats],[Enable per-zone statistics gathering (needs --enable-bind8-stats)])) 964case "$enable_zone_stats" in 965 yes) 966 AC_DEFINE_UNQUOTED([USE_ZONE_STATS], [], [Define this to enable per-zone statistics gathering.]) 967 AC_DEFINE_UNQUOTED([BIND8_STATS], [], [Define this to enable BIND8 like NSTATS & XSTATS.]) 968 ;; 969 no|''|*) 970 ;; 971esac 972 973AC_ARG_ENABLE(checking, AS_HELP_STRING([--enable-checking],[Enable internal runtime checks])) 974case "$enable_checking" in 975 yes) 976 CHECK_COMPILER_FLAG(W, [ CFLAGS="$CFLAGS -W" ]) 977 CHECK_COMPILER_FLAG(Wall, [ CFLAGS="$CFLAGS -Wall" ]) 978 CHECK_COMPILER_FLAG(Wextra, [ CFLAGS="$CFLAGS -Wextra" ]) 979 CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [ CFLAGS="$CFLAGS -Wdeclaration-after-statement" ]) 980 ;; 981 no|*) 982 AC_DEFINE([NDEBUG], [], [Undefine this to enable internal runtime checks.]) 983 ;; 984esac 985 986AC_ARG_ENABLE(memclean, AS_HELP_STRING([--enable-memclean],[Cleanup memory (at exit) for eg. valgrind, memcheck])) 987if test "$enable_memclean" = "yes"; then AC_DEFINE_UNQUOTED([MEMCLEAN], [1], [Define this to cleanup memory at exit (eg. for valgrind, etc.)]) 988fi 989 990AC_ARG_ENABLE(ratelimit, AS_HELP_STRING([--enable-ratelimit],[Enable rate limiting])) 991case "$enable_ratelimit" in 992 yes) 993 AC_DEFINE_UNQUOTED([RATELIMIT], [], [Define this to enable rate limiting.]) 994 dnl causes awk to not match the exclusion start marker. 995 ratelimit="xx" 996 ;; 997 no|*) 998 ratelimit="" 999 ;; 1000esac 1001AC_SUBST(ratelimit) 1002 1003AC_ARG_ENABLE(ratelimit-default-is-off, AS_HELP_STRING([--enable-ratelimit-default-is-off],[Enable this to set default of ratelimit to off (enable in nsd.conf), otherwise ratelimit is enabled by default if --enable-ratelimit is enabled])) 1004case "$enable_ratelimit_default_is_off" in 1005 yes) 1006 AC_DEFINE_UNQUOTED([RATELIMIT_DEFAULT_OFF], [], [Define this to set ratelimit to off by default.]) 1007 ratelimit_default="off" 1008 ;; 1009 no|*) 1010 ratelimit_default="on" 1011 ;; 1012esac 1013AC_SUBST(ratelimit_default) 1014 1015# we need SSL for TSIG (and maybe also for NSEC3). 1016CHECK_SSL 1017if test x$HAVE_SSL = x"yes"; then 1018 ACX_LIB_SSL 1019 # remove space after -ldl if there. 1020 LIBS=`echo "$LIBS" | sed -e 's/ $//'` 1021 1022 # Check for -pthread 1023 BAKLIBS="$LIBS" 1024 LIBS="-lcrypto $LIBS" 1025 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ 1026 int EVP_sha256(void); 1027 (void)EVP_sha256(); 1028 ]])],[],[ 1029 dnl so link fails for EVP_sha256, try with -pthread. 1030 BAKCFLAGS="$CFLAGS" 1031 CFLAGS="$CFLAGS -pthread" 1032 AC_MSG_CHECKING([if libcrypto needs -pthread]) 1033 AC_TRY_LINK_FUNC([EVP_sha256], [ 1034 AC_MSG_RESULT([yes]) 1035 ] , [ 1036 AC_MSG_RESULT([no]) 1037 dnl restore the nonpthread value 1038 CFLAGS="$BAKCFLAGS" 1039 ]) 1040 ]) 1041 LIBS="$BAKLIBS" 1042 1043 if test -n "$ssldir"; then 1044 AC_CHECK_LIB(crypto, EVP_sha256,, [ 1045 AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required]) 1046 ]) 1047 fi 1048 SSL_LIBS="-lssl" 1049 AC_SUBST(SSL_LIBS) 1050 AC_CHECK_HEADERS([openssl/ssl.h openssl/err.h openssl/rand.h openssl/ocsp.h openssl/core_names.h],,, [AC_INCLUDES_DEFAULT]) 1051 AC_CHECK_FUNCS([HMAC_CTX_reset HMAC_CTX_new EVP_cleanup ERR_load_crypto_strings OPENSSL_init_crypto CRYPTO_memcmp EC_KEY_new_by_curve_name EVP_MAC_CTX_new EVP_MAC_CTX_set_params EVP_MAC_CTX_get_mac_size SHA1_Init]) 1052 if test "$ac_cv_func_SHA1_Init" = "yes"; then 1053 ACX_FUNC_DEPRECATED([SHA1_Init], [(void)SHA1_Init(NULL);], [ 1054#include <openssl/sha.h> 1055]) 1056 fi 1057 AC_CHECK_DECLS([SSL_CTX_set_ecdh_auto,SSL_CTX_set_tmp_ecdh], [], [], [ 1058AC_INCLUDES_DEFAULT 1059#ifdef HAVE_OPENSSL_ERR_H 1060#include <openssl/err.h> 1061#endif 1062 1063#ifdef HAVE_OPENSSL_RAND_H 1064#include <openssl/rand.h> 1065#endif 1066 1067#ifdef HAVE_OPENSSL_CONF_H 1068#include <openssl/conf.h> 1069#endif 1070 1071#ifdef HAVE_OPENSSL_ENGINE_H 1072#include <openssl/engine.h> 1073#endif 1074#include <openssl/ssl.h> 1075#include <openssl/evp.h> 1076]) 1077 AC_CHECK_DECL([TLS1_3_VERSION], 1078 [AC_DEFINE([HAVE_TLS_1_3], [1], [Define if TLS 1.3 is supported by OpenSSL])], 1079 [AC_MSG_WARN([No TLS 1.3, therefore XFR-over-TLS is disabled])], [[#include <openssl/ssl.h>]]) 1080 1081 BAKLIBS="$LIBS" 1082 LIBS="-lssl $LIBS" 1083 AC_CHECK_FUNCS([OPENSSL_init_ssl SSL_get1_peer_certificate SSL_CTX_set_security_level ERR_load_SSL_strings]) 1084 if test "$ac_cv_func_ERR_load_SSL_strings" = "yes"; then 1085 ACX_FUNC_DEPRECATED([ERR_load_SSL_strings], [(void)ERR_load_SSL_strings();], [ 1086#include <openssl/ssl.h> 1087]) 1088 fi 1089 LIBS="$BAKLIBS" 1090 1091else 1092 AC_MSG_WARN([No SSL, therefore remote-control is disabled]) 1093 AC_MSG_WARN([No SSL, therefore TLS is disabled]) 1094fi 1095 1096AC_ARG_ENABLE(nsec3, AS_HELP_STRING([--disable-nsec3],[Disable NSEC3 support])) 1097case "$enable_nsec3" in 1098 no) 1099 ;; 1100 yes) 1101 AC_DEFINE_UNQUOTED([NSEC3], [], [Define this to enable NSEC3 support.]) 1102 ;; 1103 *) 1104 if test x$HAVE_SSL = x"yes"; then 1105 AC_DEFINE_UNQUOTED([NSEC3], [], [Define this to enable NSEC3 support.]) 1106 else 1107 AC_MSG_WARN([No SSL, therefore NSEC3 is disabled]) 1108 fi 1109 ;; 1110esac 1111 1112AC_ARG_ENABLE(minimal-responses, AS_HELP_STRING([--disable-minimal-responses],[Disable response minimization. More truncation.])) 1113case "$enable_minimal_responses" in 1114 no) 1115 ;; 1116 yes|*) 1117 AC_DEFINE_UNQUOTED([MINIMAL_RESPONSES], [], [Define this to enable response minimalization to reduce truncation.]) 1118 ;; 1119esac 1120 1121AC_ARG_ENABLE(mmap, AS_HELP_STRING([--enable-mmap],[Use mmap instead of malloc. Experimental.])) 1122case "$enable_mmap" in 1123 yes) 1124 AC_CHECK_HEADERS([sys/mman.h],,, [AC_INCLUDES_DEFAULT]) 1125 AC_LIBGTOP_CHECK_TYPE(uintptr_t, void*) 1126 AC_CHECK_FUNCS([mmap munmap]) 1127 AC_DEFINE_UNQUOTED([USE_MMAP_ALLOC], [], [Define this to enable mmap instead of malloc. Experimental.]) 1128 ;; 1129 no|*) 1130 ;; 1131esac 1132 1133AC_ARG_ENABLE(radix-tree, AS_HELP_STRING([--disable-radix-tree],[You can disable the radix tree and use the red-black tree for the main lookups, the red-black tree uses less memory, but uses some more CPU.])) 1134case "$enable_radix_tree" in 1135 no) 1136 ;; 1137 yes|*) 1138 AC_DEFINE_UNQUOTED([USE_RADIX_TREE], [], [Define this to configure to use the radix tree.]) 1139 ;; 1140esac 1141 1142AC_ARG_ENABLE(packed, AS_HELP_STRING([--enable-packed],[Enable packed structure alignment, uses less memory, but unaligned reads.])) 1143case "$enable_packed" in 1144 yes) 1145 AC_DEFINE_UNQUOTED([PACKED_STRUCTS], [], [Define this to use packed structure alignment.]) 1146 ACX_CHECK_COMPILER_FLAG(Wno-address-of-packed-member, [CFLAGS="$CFLAGS -Wno-address-of-packed-member"]) 1147 ;; 1148 no|*) 1149 ;; 1150esac 1151 1152# check for dnstap if requested 1153dt_DNSTAP([${localstatedir}/run/nsd-dnstap.sock], 1154 [ 1155 AC_DEFINE([USE_DNSTAP], [1], [Define to 1 to enable dnstap support]) 1156 AC_SUBST([ENABLE_DNSTAP], [1]) 1157 1158 AC_SUBST([opt_dnstap_socket_path]) 1159 ACX_ESCAPE_BACKSLASH($opt_dnstap_socket_path, hdr_dnstap_socket_path) 1160 AC_DEFINE_UNQUOTED(DNSTAP_SOCKET_PATH, 1161 ["$hdr_dnstap_socket_path"], [default dnstap socket path]) 1162 1163 AC_SUBST([DNSTAP_SRC], ["dnstap/dnstap.c dnstap/dnstap.pb-c.c dnstap/dnstap_collector.c"]) 1164 AC_SUBST([DNSTAP_OBJ], ["dnstap.o dnstap_collector.o dnstap.pb-c.o"]) 1165 dnstap_config="dnstap/dnstap_config.h" 1166 ], 1167 [ 1168 AC_SUBST([ENABLE_DNSTAP], [0]) 1169 ] 1170) 1171 1172# Include systemd.m4 - begin 1173sinclude(systemd.m4) 1174# Include systemd.m4 - end 1175 1176AC_ARG_ENABLE(tcp-fastopen, AS_HELP_STRING([--enable-tcp-fastopen],[Enable TCP Fast Open])) 1177case "$enable_tcp_fastopen" in 1178 yes) 1179 AC_CHECK_DECL([TCP_FASTOPEN], [], [AC_MSG_ERROR([TCP Fast Open is not available: please rerun without --enable-tcp-fastopen])], [AC_INCLUDES_DEFAULT 1180#include <netinet/tcp.h> 1181 ]) 1182 AC_DEFINE_UNQUOTED([USE_TCP_FASTOPEN], [1], [Define this to enable TCP fast open.]) 1183 ;; 1184 no|*) 1185 ;; 1186esac 1187 1188AH_BOTTOM([ 1189/* define before includes as it specifies what standard to use. */ 1190#if (defined(HAVE_PSELECT) && !defined (HAVE_PSELECT_PROTO)) \ 1191 || !defined (HAVE_CTIME_R_PROTO) \ 1192 || defined (STRPTIME_NEEDS_DEFINES) || defined(REALLOCARRAY_NEEDS_DEFINES) 1193# ifndef _XOPEN_SOURCE 1194# define _XOPEN_SOURCE 600 1195# endif 1196# ifndef _POSIX_C_SOURCE 1197# define _POSIX_C_SOURCE 200112 1198# endif 1199# ifndef _BSD_SOURCE 1200# define _BSD_SOURCE 1 1201# endif 1202# ifndef _OPENBSD_SOURCE 1203# define _OPENBSD_SOURCE 1 1204# endif 1205# ifndef _DEFAULT_SOURCE 1206# define _DEFAULT_SOURCE 1 1207# endif 1208# ifndef __EXTENSIONS__ 1209# define __EXTENSIONS__ 1 1210# endif 1211# ifndef _STDC_C99 1212# define _STDC_C99 1 1213# endif 1214# ifndef _ALL_SOURCE 1215# define _ALL_SOURCE 1 1216# endif 1217#endif 1218]) 1219 1220AH_BOTTOM([ 1221#ifdef HAVE_VA_LIST_DOUBLE_DEF 1222/* workaround double va_list definition on some platforms */ 1223# ifndef _VA_LIST_DEFINED 1224# define _VA_LIST_DEFINED 1225# endif 1226#endif 1227]) 1228 1229AH_BOTTOM([ 1230#include <sys/types.h> 1231#include <stdlib.h> 1232#include <stddef.h> 1233 1234#ifdef HAVE_TIME_H 1235#include <time.h> 1236#endif 1237 1238#ifdef HAVE_STDINT_H 1239#include <stdint.h> 1240#endif 1241 1242#ifdef HAVE_SYS_SOCKET_H 1243#include <sys/socket.h> 1244#endif 1245 1246#ifdef HAVE_NETINET_IN_H 1247#include <netinet/in.h> 1248#endif 1249 1250#ifdef HAVE_NETINET_TCP_H 1251#include <netinet/tcp.h> 1252#endif 1253 1254#ifdef HAVE_ARPA_INET_H 1255#include <arpa/inet.h> 1256#endif 1257 1258/* For Tru64 */ 1259#ifdef HAVE_SYS_BITYPES_H 1260#include <sys/bitypes.h> 1261#endif 1262]) 1263 1264AH_BOTTOM([ 1265#ifdef HAVE_ATTR_FORMAT 1266#define ATTR_FORMAT(archetype, string_index, first_to_check) \ 1267 __attribute__ ((format (archetype, string_index, first_to_check))) 1268#else /* !HAVE_ATTR_FORMAT */ 1269#define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */ 1270#endif /* !HAVE_ATTR_FORMAT */ 1271#if defined(__cplusplus) 1272#define ATTR_UNUSED(x) 1273#elif defined(HAVE_ATTR_UNUSED) 1274#define ATTR_UNUSED(x) x __attribute__((unused)) 1275#else /* !HAVE_ATTR_UNUSED */ 1276#define ATTR_UNUSED(x) x 1277#endif /* !HAVE_ATTR_UNUSED */ 1278]) 1279 1280AH_BOTTOM([ 1281#ifndef IPV6_MIN_MTU 1282#define IPV6_MIN_MTU 1280 1283#endif /* IPV6_MIN_MTU */ 1284 1285#ifndef AF_INET6 1286#define AF_INET6 28 1287#endif /* AF_INET6 */ 1288]) 1289 1290if test $ac_cv_func_getaddrinfo = no; then 1291AC_LIBOBJ([fake-rfc2553]) 1292fi 1293 1294AH_BOTTOM([ 1295/* maximum nesting of included files */ 1296#define MAXINCLUDES 10 1297]) 1298 1299AH_BOTTOM([ 1300#ifndef HAVE_B64_NTOP 1301int b64_ntop(uint8_t const *src, size_t srclength, 1302 char *target, size_t targsize); 1303#endif /* !HAVE_B64_NTOP */ 1304#ifndef HAVE_B64_PTON 1305int b64_pton(char const *src, uint8_t *target, size_t targsize); 1306#endif /* !HAVE_B64_PTON */ 1307#ifndef HAVE_FSEEKO 1308#define fseeko fseek 1309#define ftello ftell 1310#endif /* HAVE_FSEEKO */ 1311#ifndef HAVE_SNPRINTF 1312#include <stdarg.h> 1313int snprintf (char *str, size_t count, const char *fmt, ...); 1314int vsnprintf (char *str, size_t count, const char *fmt, va_list arg); 1315#endif /* HAVE_SNPRINTF */ 1316#ifndef HAVE_INET_PTON 1317int inet_pton(int af, const char* src, void* dst); 1318#endif /* HAVE_INET_PTON */ 1319#ifndef HAVE_INET_NTOP 1320const char *inet_ntop(int af, const void *src, char *dst, size_t size); 1321#endif 1322#ifndef HAVE_INET_ATON 1323int inet_aton(const char *cp, struct in_addr *addr); 1324#endif 1325#ifndef HAVE_MEMMOVE 1326void *memmove(void *dest, const void *src, size_t n); 1327#endif 1328#ifndef HAVE_EXPLICIT_BZERO 1329#define explicit_bzero nsd_explicit_bzero 1330void explicit_bzero(void* buf, size_t len); 1331#endif 1332#ifndef HAVE_STRLCAT 1333size_t strlcat(char *dst, const char *src, size_t siz); 1334#endif 1335#ifndef HAVE_STRLCPY 1336size_t strlcpy(char *dst, const char *src, size_t siz); 1337#endif 1338#ifndef HAVE_REALLOCARRAY 1339void* reallocarray(void *ptr, size_t nmemb, size_t size); 1340#endif 1341#ifndef HAVE_GETADDRINFO 1342#include "compat/fake-rfc2553.h" 1343#endif 1344#ifndef HAVE_STRPTIME 1345#define HAVE_STRPTIME 1 1346char *strptime(const char *s, const char *format, struct tm *tm); 1347#endif 1348#ifndef STRPTIME_WORKS 1349#define STRPTIME_WORKS 1 1350char *nsd_strptime(const char *s, const char *format, struct tm *tm); 1351#define strptime(a,b,c) nsd_strptime((a),(b),(c)) 1352#endif 1353#if (HAVE_CPU_SET_T || HAVE_CPUSET_T) 1354#include "compat/cpuset.h" 1355#endif 1356#ifndef HAVE_SETPROCTITLE 1357#ifdef __linux__ 1358#define HAVE_SETPROCTITLE 1 1359#include <stdarg.h> 1360void setproctitle(const char *fmt, ...); 1361#endif 1362#endif 1363]) 1364AH_BOTTOM( 1365AHX_MEMCMP_BROKEN(nsd) 1366AHX_CONFIG_MAXHOSTNAMELEN 1367) 1368AH_BOTTOM([ 1369 1370/* provide timespec def if not available */ 1371#ifndef CONFIG_DEFINES 1372#define CONFIG_DEFINES 1373#ifndef HAVE_STRUCT_TIMESPEC 1374#ifndef __timespec_defined 1375#define __timespec_defined 1 1376 struct timespec { 1377 long tv_sec; /* seconds */ 1378 long tv_nsec; /* nanoseconds */ 1379 }; 1380#endif /* !__timespec_defined */ 1381#endif /* !HAVE_STRUCT_TIMESPEC */ 1382#endif /* !CONFIG_DEFINES */ 1383 1384#ifdef PACKED_STRUCTS 1385#define ATTR_PACKED __attribute__((packed)) 1386#else 1387#define ATTR_PACKED 1388#endif 1389]) 1390 1391# big fat warning 1392if test "$enable_checking" = "yes"; then 1393 echo "************************************************" 1394 echo "* You have activated \"--enable-checking\" *" 1395 echo "* *" 1396 echo "* This will instruct NSD to be stricter *" 1397 echo "* when validating its input. This could lead *" 1398 echo "* to a reduced service level. *" 1399 echo "* *" 1400 echo "************************************************" 1401fi 1402 1403AC_CONFIG_FILES([Makefile $dnstap_config]) 1404AC_OUTPUT 1405