configure.ac revision 1.4
1dnl 2dnl Some global settings 3dnl 4 5sinclude(acx_nlnetlabs.m4) 6sinclude(dnstap/dnstap.m4) 7 8AC_INIT([NSD],[4.3.5],[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_NORETURN_ATTRIBUTE], 255[AC_REQUIRE([AC_PROG_CC]) 256AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "noreturn" attribute) 257AC_CACHE_VAL(ac_cv_c_noreturn_attribute, 258[ac_cv_c_noreturn_attribute=no 259AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> 260__attribute__((noreturn)) void f(int x) { printf("%d", x); } 261]], [[ 262 f(1); 263]])],[ac_cv_c_noreturn_attribute="yes"],[ac_cv_c_noreturn_attribute="no"]) 264]) 265 266AC_MSG_RESULT($ac_cv_c_noreturn_attribute) 267if test $ac_cv_c_noreturn_attribute = yes; then 268 AC_DEFINE(HAVE_ATTR_NORETURN, 1, [Whether the C compiler accepts the "noreturn" attribute]) 269 AC_DEFINE(ATTR_NORETURN, [__attribute__((__noreturn__))], [apply the noreturn attribute to a function that exits the program]) 270fi 271])dnl End of CHECK_NORETURN_ATTRIBUTE 272 273AC_DEFUN([CHECK_COMPILER_FLAG], 274[ 275AC_REQUIRE([AC_PROG_CC]) 276AC_MSG_CHECKING(whether $CC supports -$1) 277cache=`echo $1 | $SED 'y%.=/+-%___p_%'` 278AC_CACHE_VAL(cv_prog_cc_flag_$cache, 279[ 280echo 'void f(){}' >conftest.c 281if test -z "`$CC -$1 -c conftest.c 2>&1`"; then 282eval "cv_prog_cc_flag_$cache=yes" 283else 284eval "cv_prog_cc_flag_$cache=no" 285fi 286rm -f conftest* 287]) 288if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then 289AC_MSG_RESULT(yes) 290: 291$2 292else 293AC_MSG_RESULT(no) 294: 295$3 296fi 297]) 298 299AC_DEFUN([AC_CHECK_CTIME_R], 300[AC_REQUIRE([AC_PROG_CC]) 301AC_MSG_CHECKING(whether ctime_r works with two arguments) 302AC_CACHE_VAL(ac_cv_c_ctime_c, 303[ac_cv_c_ctime_c=no 304AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h> 305void testing (void) { time_t clock; char current_time[40]; ctime_r(&clock, current_time); }]], [[ 306 testing(); 307]])],[ac_cv_c_ctime_c="yes"],[ac_cv_c_ctime_c="no"]) 308]) 309 310AC_MSG_RESULT($ac_cv_c_ctime_c) 311if test $ac_cv_c_ctime_c = no; then 312 CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS" 313fi 314])dnl 315 316AC_CANONICAL_HOST 317 318case "${host_os}" in 319 *netbsd*) 320 # NetBSD needs -D_OPENBSD_SOURCE for reallocarray 321 CPPFLAGS="$CPPFLAGS -D_OPENBSD_SOURCE";; 322esac 323 324# Checks for typedefs, structures, and compiler characteristics. 325# allow user to override the -g -O2 flags. 326if test "x$CFLAGS" = "x" ; then 327 ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="$CFLAGS -g"]) 328 # we do not use O3 because it causes miscompilations. 329 ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"]) 330 ACX_CHECK_FLTO 331 ACX_CHECK_PIE 332 ACX_CHECK_RELRO_NOW 333fi 334AC_C_CONST 335AC_C_INLINE 336AC_TYPE_UID_T 337AC_TYPE_PID_T 338AC_TYPE_SIZE_T 339AC_TYPE_OFF_T 340 341AC_CHECK_FORMAT_ATTRIBUTE 342AC_CHECK_UNUSED_ATTRIBUTE 343CHECK_NORETURN_ATTRIBUTE 344ACX_CHECK_MEMCMP_SIGNED 345AC_CHECK_CTIME_R 346 347# Checks for libraries. 348 349# Check for SSL, original taken from 350# http://www.gnu.org/software/ac-archive/htmldoc/check_ssl.html and 351# modified for NSD. 352AC_DEFUN([CHECK_SSL], [ 353 AC_ARG_WITH(ssl, AS_HELP_STRING([--with-ssl=pathname],[enable SSL (will check /usr/local/ssl 354 /usr/lib/ssl /usr/ssl /usr/pkg /usr/sfw /usr/local /usr /usr/local/opt/openssl)]),[ 355 ],[ 356 withval="yes" 357 ]) 358 if test x_$withval != x_no; then 359 AC_MSG_CHECKING(for SSL) 360 if test x_$withval = x_ -o x_$withval = x_yes; then 361 withval="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/sfw /usr/local /usr /usr/local/opt/openssl" 362 fi 363 for dir in $withval; do 364 ssldir="$dir" 365 if test -f "$dir/include/openssl/ssl.h"; then 366 found_ssl="yes"; 367 AC_DEFINE_UNQUOTED([HAVE_SSL], [], [Define if you have the SSL libraries installed.]) 368 if test x_$ssldir != x_/usr; then 369 CPPFLAGS="$CPPFLAGS -I$ssldir/include"; 370 fi 371 break; 372 fi 373 done 374 if test x_$found_ssl != x_yes; then 375 AC_MSG_ERROR([Cannot find the SSL libraries in $withval]) 376 else 377 AC_MSG_RESULT([found in $ssldir]) 378 HAVE_SSL=yes 379 if test x_$ssldir != x_/usr; then 380 LDFLAGS="$LDFLAGS -Wl,-R$ssldir/lib -L$ssldir/lib"; 381 fi 382 fi 383 AC_SUBST(HAVE_SSL) 384 fi 385])dnl 386 387# check for libevent 388AC_ARG_WITH(libevent, AS_HELP_STRING([--with-libevent=pathname],[use libevent (will check /usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr /usr/local/opt/libevent or you can specify an explicit path), useful when the zone count is high.]), 389 [ ],[ withval="yes" ]) 390if test x_$withval = x_yes -o x_$withval != x_no; then 391 AC_MSG_CHECKING(for libevent) 392 if test x_$withval = x_ -o x_$withval = x_yes; then 393 withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr /usr/local/opt/libevent" 394 fi 395 for dir in $withval; do 396 thedir="$dir" 397 if test -f "$dir/include/event.h" -o -f "$dir/include/event2/event.h"; then 398 found_libevent="yes" 399 dnl assume /usr is in default path. 400 if test "$thedir" != "/usr"; then 401 CPPFLAGS="$CPPFLAGS -I$thedir/include" 402 fi 403 break; 404 fi 405 done 406 if test x_$found_libevent != x_yes; then 407 if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then 408 # libevent source directory 409 AC_MSG_RESULT(found in $thedir) 410 CPPFLAGS="$CPPFLAGS -I$thedir -I$thedir/include" 411 # remove evdns from linking 412 ev_files_o=`ls $thedir/*.o | $GREP -v evdns\.o | $GREP -v bufferevent_openssl\.o` 413 cp $ev_files_o . 414 LDFLAGS="$ev_files_o $LDFLAGS -lm" 415 else 416 AC_MSG_ERROR([Cannot find the libevent library. 417You can restart ./configure --with-libevent=no to use a builtin alternative.]) 418 fi 419 else 420 AC_MSG_RESULT(found in $thedir) 421 dnl if event2 exists and no event lib in dir itself, use subdir 422 if test ! -f $thedir/lib/libevent.a -a ! -f $thedir/lib/libevent.so -a -d "$thedir/lib/event2"; then 423 LDFLAGS="$LDFLAGS -Wl,-R$thedir/lib -L$thedir/lib/event2" 424 ACX_RUNTIME_PATH_ADD([$thedir/lib/event2]) 425 else 426 dnl assume /usr is in default path, do not add "". 427 if test "$thedir" != "/usr" -a "$thedir" != ""; then 428 LDFLAGS="$LDFLAGS -Wl,-R$thedir/lib -L$thedir/lib" 429 ACX_RUNTIME_PATH_ADD([$thedir/lib]) 430 fi 431 fi 432 fi 433 # check for library used by libevent after 1.3c 434 AC_SEARCH_LIBS([clock_gettime], [rt]) 435 436 # is the event.h header libev or libevent? 437 AC_CHECK_HEADERS([event.h],,, [AC_INCLUDES_DEFAULT]) 438 AC_CHECK_DECL(EV_VERSION_MAJOR, [ 439 AC_SEARCH_LIBS(event_set, [ev]) 440 ],[ 441 AC_SEARCH_LIBS(event_set, [event]) 442 ],[AC_INCLUDES_DEFAULT 443#include <event.h> 444 ]) 445 AC_CHECK_FUNCS([event_base_free]) # only in libevent 1.2 and later 446 AC_CHECK_FUNCS([event_base_once]) # only in libevent 1.4.1 and later 447 AC_CHECK_FUNCS([event_base_new]) # only in libevent 1.4.1 and later 448 AC_CHECK_FUNCS([event_base_get_method]) # only in libevent 1.4.3 and later 449 AC_CHECK_FUNCS([ev_loop]) # only in libev. (tested on 3.51) 450 AC_CHECK_FUNCS([ev_default_loop]) # only in libev. (tested on 4.00) 451else 452 AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events]) 453fi 454 455# Checks for header files. 456AC_HEADER_SYS_WAIT 457AC_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]) 458 459AC_DEFUN([CHECK_VALIST_DEF], 460[ 461AC_REQUIRE([AC_PROG_CC]) 462AC_MSG_CHECKING(for double definition of struct va_list) 463AC_CACHE_VAL(ac_cv_c_va_list_def, 464[ 465cat >conftest.c <<EOF 466#include <stdio.h> 467#include <stdarg.h> 468int foo(void); 469EOF 470if test -z "`$CC -Werror -D_XOPEN_SOURCE=600 -c conftest.c 2>&1`"; then 471eval "ac_cv_c_va_list_def=no" 472else 473eval "ac_cv_c_va_list_def=yes" 474fi 475rm -f conftest* 476]) 477if test $ac_cv_c_va_list_def = yes; then 478AC_MSG_RESULT(yes) 479: 480AC_DEFINE_UNQUOTED([HAVE_VA_LIST_DOUBLE_DEF], [], [Define this if you have double va_list definitions.]) 481else 482AC_MSG_RESULT(no) 483: 484 485fi 486]) 487 488CHECK_VALIST_DEF 489 490AC_DEFUN([AC_CHECK_STRPTIME], 491[AC_REQUIRE([AC_PROG_CC]) 492AC_MSG_CHECKING(whether strptime needs defines) 493AC_CACHE_VAL(ac_cv_c_strptime_needs_defs, 494[ 495cat >conftest.c <<EOF 496#include <time.h> 497int testing (void) { struct tm t; const char *timestr="201201"; return strptime(timestr, "%Y%m", &t) != 0; } 498EOF 499if test -z "`$CC -Wall -Werror -c conftest.c 2>&1`"; then 500eval "ac_cv_c_strptime_needs_defs=no" 501else 502eval "ac_cv_c_strptime_needs_defs=yes" 503fi 504rm -f conftest* 505]) 506 507AC_MSG_RESULT($ac_cv_c_strptime_needs_defs) 508if test $ac_cv_c_strptime_needs_defs = yes; then 509AC_DEFINE_UNQUOTED([STRPTIME_NEEDS_DEFINES], 1, [strptime is available from time.h with some defines.]) 510fi 511])dnl 512 513AC_CHECK_STRPTIME 514 515# check wether strptime also works 516AC_DEFUN([AC_CHECK_STRPTIME_WORKS], 517[AC_REQUIRE([AC_PROG_CC]) 518AC_MSG_CHECKING(whether strptime works) 519if test c${cross_compiling} = cno; then 520AC_RUN_IFELSE([AC_LANG_SOURCE([[ 521#define _XOPEN_SOURCE 600 522#include <time.h> 523int main(void) { struct tm tm; char *res; 524res = strptime("20070207111842", "%Y%m%d%H%M%S", &tm); 525if (!res) return 1; return 0; } 526]])] , [eval "ac_cv_c_strptime_works=yes"], [eval "ac_cv_c_strptime_works=no"]) 527else 528eval "ac_cv_c_strptime_works=maybe" 529fi 530AC_MSG_RESULT($ac_cv_c_strptime_works) 531if test $ac_cv_c_strptime_works = no; then 532AC_LIBOBJ(strptime) 533else 534AC_DEFINE_UNQUOTED([STRPTIME_WORKS], 1, [use default strptime.]) 535fi 536])dnl 537 538AC_SEARCH_LIBS(inet_pton, [nsl]) 539AC_SEARCH_LIBS(socket, [socket]) 540 541AC_CHECK_STRPTIME_WORKS 542ACX_CHECK_NONBLOCKING_BROKEN 543ACX_MKDIR_ONE_ARG 544 545# set -I. and -Isrcdir 546if test -n "$CPPFLAGS"; then 547 CPPFLAGS="$CPPFLAGS -I." 548else 549 CPPFLAGS="-I." 550fi 551if test "$srcdir" != "."; then 552 CPPFLAGS="$CPPFLAGS -I$srcdir" 553 if test -f $srcdir/config.h; then 554 AC_MSG_ERROR([$srcdir/config.h is in the way, please remove it]) 555 fi 556fi 557 558dnl LIBGTOP_CHECK_TYPE 559dnl Stolen from Gnome's anjuta 560dnl Improved version of AC_CHECK_TYPE which takes into account 561dnl that we need to #include some other header files on some 562dnl systems to get some types. 563 564dnl AC_LIBGTOP_CHECK_TYPE(TYPE, DEFAULT) 565AC_DEFUN([AC_LIBGTOP_CHECK_TYPE], 566[AC_MSG_CHECKING(for $1) 567AC_CACHE_VAL(ac_cv_type_$1, 568[AC_EGREP_CPP(dnl 569changequote(<<,>>)dnl 570<<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl 571changequote([,]), [ 572#include <sys/types.h> 573#include <stdlib.h> 574#include <stddef.h> 575 576#ifdef HAVE_STDINT_H 577#include <stdint.h> 578#endif 579 580#ifdef HAVE_SYS_SOCKET_H 581#include <sys/socket.h> 582#endif 583 584#ifdef HAVE_ARPA_INET_H 585#include <arpa/inet.h> 586#endif 587 588#ifdef HAVE_SIGNAL_H 589#include <signal.h> 590#endif 591 592/* For Tru64 */ 593#ifdef HAVE_SYS_BITYPES_H 594#include <sys/bitypes.h> 595#endif 596], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl 597AC_MSG_RESULT($ac_cv_type_$1) 598if test $ac_cv_type_$1 = no; then 599 AC_DEFINE($1, $2, Define "$1" to "$2" if "$1" is missing) 600fi 601]) 602 603AC_LIBGTOP_CHECK_TYPE(int8_t, char) 604AC_LIBGTOP_CHECK_TYPE(int16_t, short) 605AC_LIBGTOP_CHECK_TYPE(int32_t, int) 606AC_LIBGTOP_CHECK_TYPE(int64_t, long long) 607AC_LIBGTOP_CHECK_TYPE(uint8_t, unsigned char) 608AC_LIBGTOP_CHECK_TYPE(uint16_t, unsigned short) 609AC_LIBGTOP_CHECK_TYPE(uint32_t, unsigned int) 610AC_LIBGTOP_CHECK_TYPE(uint64_t, unsigned long long) 611AC_LIBGTOP_CHECK_TYPE(socklen_t, int) 612AC_LIBGTOP_CHECK_TYPE(sig_atomic_t, int) 613AC_LIBGTOP_CHECK_TYPE(ssize_t, int) 614AC_LIBGTOP_CHECK_TYPE(suseconds_t, time_t) 615 616AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [ 617#if HAVE_SYS_TYPES_H 618# include <sys/types.h> 619#endif 620#if HAVE_NETINET_IN_H 621# include <netinet/in.h> 622#endif]) 623ACX_CHECK_SS_FAMILY 624AC_CHECK_MEMBERS([struct stat.st_mtimensec, struct stat.st_mtim.tv_nsec]) 625AC_CHECK_MEMBERS([struct sockaddr_un.sun_len],,,[ 626AC_INCLUDES_DEFAULT 627#ifdef HAVE_SYS_UN_H 628#include <sys/un.h> 629#endif 630]) 631 632# Checks for library functions. 633AC_FUNC_CHOWN 634AC_FUNC_FORK 635AC_FUNC_MALLOC 636AC_DEFINE(RETSIGTYPE,void,[Return type of signal handlers, but autoconf 2.70 says 'your code may safely assume C89 semantics that RETSIGTYPE is void.']) 637AC_FUNC_FSEEKO 638AC_SYS_LARGEFILE 639AC_CHECK_SIZEOF(void*) 640AC_CHECK_SIZEOF(off_t) 641AC_CHECK_FUNCS([getrandom arc4random arc4random_uniform]) 642AC_SEARCH_LIBS([setusercontext],[util],[AC_CHECK_HEADERS([login_cap.h])]) 643AC_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]) 644 645AC_CHECK_TYPE([struct mmsghdr], AC_DEFINE(HAVE_MMSGHDR, 1, [If sys/socket.h has a struct mmsghdr.]), [], [ 646AC_INCLUDES_DEFAULT 647#include <sys/socket.h> 648]) 649 650AC_ARG_ENABLE(recvmmsg, AS_HELP_STRING([--enable-recvmmsg],[Enable recvmmsg and sendmmsg compilation, faster but some kernel versions may have implementation problems for IPv6])) 651case "$enable_recvmmsg" in 652 yes) 653 AC_CHECK_FUNC([recvmmsg], [ 654AC_RUN_IFELSE([AC_LANG_SOURCE([[ 655#include <sys/socket.h> 656#include <errno.h> 657int main(void) 658{ 659 int s = socket(AF_INET, SOCK_DGRAM, 0); 660 int r = recvmmsg(s, 0, 0, 0, 0) == -1 && errno == ENOSYS; 661 close(s); 662 return r; 663} 664]])], [ 665AC_DEFINE([HAVE_RECVMMSG], [1], [Define if recvmmsg is implemented])], [ 666], [ 667AC_DEFINE([HAVE_RECVMMSG], [1], [Define if recvmmsg exists])] 668)]) 669 AC_CHECK_FUNC([sendmmsg], [ 670AC_RUN_IFELSE([AC_LANG_SOURCE([[ 671#include <sys/socket.h> 672#include <errno.h> 673int main(void) 674{ 675 int s = socket(AF_INET, SOCK_DGRAM, 0); 676 int r = sendmmsg(s, 0, 0, 0) == -1 && errno == ENOSYS; 677 close(s); 678 return r; 679} 680]])], [ 681AC_DEFINE([HAVE_SENDMMSG], [1], [Define if sendmmsg is implemented])], [ 682], [ 683AC_DEFINE([HAVE_SENDMMSG], [1], [Define if sendmmsg exists])] 684)]) 685 686 ;; 687 no|*) 688 ;; 689esac 690 691# check if setreuid en setregid fail, on MacOSX10.4(darwin8). 692if echo $target_os | $GREP -i darwin8 > /dev/null; then 693 AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work]) 694fi 695 696# GNU HURD needs _GNU_SOURCE defined for cpu affinity gear 697if echo $target_os | $EGREP -i 'linux|hurd' > /dev/null; then 698 AC_DEFINE([_GNU_SOURCE, 1, [Define this if on Linux or GNU Hurd for cpu affinity interface]]) 699fi 700 701# see comment on _GNU_SOURCE above 702AC_CHECK_HEADERS([sched.h sys/cpuset.h]) 703 704# Check for cpu_set_t (Linux) and cpuset_t (FreeBSD and NetBSD) 705AC_CHECK_TYPES([cpu_set_t, cpuset_t, cpuid_t],,,[ 706AC_INCLUDES_DEFAULT 707#if HAVE_SCHED_H 708# include <sched.h> 709#endif 710#if HAVE_SYS_CPUSET_H 711# include <sys/cpuset.h> 712#endif 713]) 714 715AC_DEFUN([AC_CHECK_CPU_OR], 716[AC_REQUIRE([AC_PROG_CC]) 717AC_MSG_CHECKING(whether CPU_OR works with three arguments) 718AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef HAVE_SCHED_H 719# include <sched.h> 720#endif 721#ifdef HAVE_SYS_CPUSET_H 722# include <sys/cpuset.h> 723#endif 724#include <string.h> 725#ifdef HAVE_CPUSET_T 726#define MY_CPUSET_TYPE cpuset_t 727#endif 728#ifdef HAVE_CPU_SET_T 729#define MY_CPUSET_TYPE cpu_set_t 730#endif 731void testing (void) { 732 MY_CPUSET_TYPE a, b; 733 memset(&a, 0, sizeof(a)); 734 memset(&b, 0, sizeof(b)); 735 CPU_OR(&a, &a, &b); 736}]], [[ 737 testing(); 738]])],[ 739 AC_MSG_RESULT(yes) 740 AC_DEFINE([CPU_OR_THREE_ARGS], 1, [number of arguments for CPU_OR is three]) 741],[ 742 AC_MSG_RESULT(no) 743])]) 744 745AS_IF([test x"$ac_cv_type_cpuset_t" = xyes -o x"$ac_cv_type_cpu_set_t" = xyes ],[ 746 AC_CHECK_FUNC(cpuset_create) 747 AC_CHECK_FUNC(cpuset_destroy) 748 AC_CHECK_FUNC(cpuset_zero) 749 AC_CHECK_FUNC(cpuset_set) 750 AC_CHECK_FUNC(cpuset_clr) 751 AC_CHECK_FUNC(cpuset_isset) 752 AC_CHECK_FUNC(cpuset_size) 753 AC_LIBOBJ(cpuset) 754 AC_CHECK_FUNCS([sysconf]) 755 AC_CHECK_CPU_OR 756]) 757 758# 759# sched_setaffinity must be checked using proper includes. 760# also needs _GNU_SOURCE on Linux and Hurd; see above. 761# also see https://github.com/NLnetLabs/nsd/issues/82. 762# 763AC_MSG_CHECKING(for sched_setaffinity) 764AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 765 [[ 766 #ifdef HAVE_SCHED_H 767 # include <sched.h> 768 #endif 769 #ifdef HAVE_SYS_CPUSET_H 770 #include <sys/cpuset.h> 771 #endif 772 #ifdef HAVE_CPUSET_T 773 #define MY_CPUSET_TYPE cpuset_t 774 #endif 775 #ifdef HAVE_CPU_SET_T 776 #define MY_CPUSET_TYPE cpu_set_t 777 #endif 778 void testing (void) { 779 MY_CPUSET_TYPE set; 780 CPU_ZERO(&set); 781 (void)sched_setaffinity(-1, sizeof(set), &set); 782 } 783]])], 784[ AC_MSG_RESULT(yes) 785 AC_DEFINE(HAVE_SCHED_SETAFFINITY, 1, [Define this if sched_setaffinity is available])], 786[ AC_MSG_RESULT(no)]) 787 788# 789# Checking for missing functions we can replace 790# 791AC_REPLACE_FUNCS(basename) 792AC_REPLACE_FUNCS(inet_aton) 793AC_REPLACE_FUNCS(inet_pton) 794AC_REPLACE_FUNCS(inet_ntop) 795AC_REPLACE_FUNCS(snprintf) 796AC_REPLACE_FUNCS(strlcat) 797AC_REPLACE_FUNCS(strlcpy) 798AC_REPLACE_FUNCS(strptime) 799AC_REPLACE_FUNCS(b64_pton) 800AC_REPLACE_FUNCS(b64_ntop) 801AC_REPLACE_FUNCS(pselect) 802AC_REPLACE_FUNCS(memmove) 803AC_REPLACE_FUNCS(setproctitle) 804AC_MSG_CHECKING([for reallocarray]) 805AC_LINK_IFELSE([AC_LANG_SOURCE( 806[[ 807#ifndef _OPENBSD_SOURCE 808#define _OPENBSD_SOURCE 1 809#endif 810]] 811AC_INCLUDES_DEFAULT 812[[ 813#include <stdlib.h> 814int main(void) { 815 void* p = reallocarray(NULL, 10, 100); 816 free(p); 817 return 0; 818} 819]])], [AC_MSG_RESULT(yes) 820 AC_DEFINE(HAVE_REALLOCARRAY, 1, [If we have reallocarray(3)]) 821 AC_CHECK_DECLS([reallocarray], [], [ 822 AC_DEFINE(REALLOCARRAY_NEEDS_DEFINES, 1, [If reallocarray needs defines to appear in the headers]) 823 ], [ 824AC_INCLUDES_DEFAULT 825#include <stdlib.h> 826 ]) 827], [ 828 AC_MSG_RESULT(no) 829 AC_LIBOBJ(reallocarray) 830]) 831 832AC_MSG_CHECKING(for pselect prototype in sys/select.h) 833AC_EGREP_HEADER([[^a-zA-Z_]*pselect[^a-zA-Z_]], sys/select.h, AC_DEFINE(HAVE_PSELECT_PROTO, 1, 834 [if sys/select.h provides pselect prototype]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) 835 836AC_MSG_CHECKING(for ctime_r prototype in time.h) 837AC_EGREP_HEADER([[^a-zA-Z_]*ctime_r[^a-zA-Z_]], time.h, AC_DEFINE(HAVE_CTIME_R_PROTO, 1, 838 [if time.h provides ctime_r prototype]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) 839 840AC_CHECK_TYPE([struct timespec], AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1, [If time.h has a struct timespec (for pselect).]), [], [ 841AC_INCLUDES_DEFAULT 842#ifdef HAVE_SIGNAL_H 843#include <signal.h> 844#endif 845#ifdef HAVE_TIME_H 846#include <time.h> 847#endif 848]) 849 850dnl 851dnl Some random defines's 852dnl 853AC_DEFINE_UNQUOTED([IDENTITY], ["unidentified server"], [Define to the default nsd identity.]) 854AC_DEFINE_UNQUOTED([VERSION], [PACKAGE_STRING], [Define to the NSD version to answer version.server query.]) 855AC_DEFINE_UNQUOTED([TCP_BACKLOG], [256], [Define to the backlog to be used with listen.]) 856AC_DEFINE_UNQUOTED([TCP_PORT], ["53"], [Define to the default tcp port.]) 857AC_DEFINE_UNQUOTED([TCP_MAX_MESSAGE_LEN], [65535], [Define to the default maximum message length.]) 858AC_DEFINE_UNQUOTED([UDP_PORT], ["53"], [Define to the default udp port.]) 859AC_DEFINE_UNQUOTED([UDP_MAX_MESSAGE_LEN], [512], [Define to the default maximum udp message length.]) 860AC_DEFINE_UNQUOTED([EDNS_MAX_MESSAGE_LEN], [1232], [Define to the default maximum message length with EDNS.]) 861AC_DEFINE_UNQUOTED([TLS_PORT], ["853"], [Define to the default DNS over TLS port.]) 862AC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [512], [Define to the maximum message length to pass to syslog.]) 863AC_DEFINE_UNQUOTED([NSD_CONTROL_PORT], [8952], [Define to the default nsd-control port.]) 864AC_DEFINE_UNQUOTED([NSD_CONTROL_VERSION], [1], [Define to nsd-control proto version.]) 865 866dnl 867dnl Determine the syslog facility to use 868dnl 869facility=LOG_DAEMON 870AC_ARG_WITH([facility], 871 AS_HELP_STRING([--with-facility=name],[Syslog default facility (LOG_DAEMON)]), 872 [facility=$withval]) 873AC_DEFINE_UNQUOTED([FACILITY], $facility, [Define to the default facility for syslog.]) 874 875dnl 876dnl Determine the default tcp timeout 877dnl 878tcp_timeout=120 879AC_ARG_WITH([tcp_timeout], 880 AS_HELP_STRING([--with-tcp-timeout=number],[Limit the default tcp timeout]), 881 [tcp_timeout=$withval]) 882AC_DEFINE_UNQUOTED([TCP_TIMEOUT], $tcp_timeout, [Define to the default tcp timeout.]) 883 884dnl 885dnl Features 886dnl 887AC_ARG_ENABLE(root-server, AS_HELP_STRING([--enable-root-server],[Configure NSD as a root server])) 888case "$enable_root_server" in 889 yes) 890 AC_DEFINE_UNQUOTED([ROOT_SERVER], [], [Define this to configure as a root server.]) 891 ;; 892 no|*) 893 ;; 894esac 895 896AC_ARG_ENABLE(ipv6, AS_HELP_STRING([--disable-ipv6],[Disables IPv6 support])) 897case "$enable_ipv6" in 898 no) 899 ;; 900 yes|*) 901 AC_DEFINE_UNQUOTED([INET6], [], [Define this to enable IPv6 support.]) 902 ;; 903esac 904 905AC_ARG_ENABLE(bind8-stats, AS_HELP_STRING([--enable-bind8-stats],[Enables BIND8 like NSTATS & XSTATS and statistics in nsd-control])) 906 907case "$enable_bind8_stats" in 908 yes|'') 909 AC_DEFINE_UNQUOTED([BIND8_STATS], [], [Define this to enable BIND8 like NSTATS & XSTATS.]) 910 ;; 911 no|*) 912 ;; 913esac 914 915AC_ARG_ENABLE(zone-stats, AS_HELP_STRING([--enable-zone-stats],[Enable per-zone statistics gathering (needs --enable-bind8-stats)])) 916case "$enable_zone_stats" in 917 yes) 918 AC_DEFINE_UNQUOTED([USE_ZONE_STATS], [], [Define this to enable per-zone statistics gathering.]) 919 AC_DEFINE_UNQUOTED([BIND8_STATS], [], [Define this to enable BIND8 like NSTATS & XSTATS.]) 920 ;; 921 no|''|*) 922 ;; 923esac 924 925AC_ARG_ENABLE(checking, AS_HELP_STRING([--enable-checking],[Enable internal runtime checks])) 926case "$enable_checking" in 927 yes) 928 CHECK_COMPILER_FLAG(W, [ CFLAGS="$CFLAGS -W" ]) 929 CHECK_COMPILER_FLAG(Wall, [ CFLAGS="$CFLAGS -Wall" ]) 930 CHECK_COMPILER_FLAG(Wextra, [ CFLAGS="$CFLAGS -Wextra" ]) 931 CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [ CFLAGS="$CFLAGS -Wdeclaration-after-statement" ]) 932 ;; 933 no|*) 934 AC_DEFINE([NDEBUG], [], [Undefine this to enable internal runtime checks.]) 935 ;; 936esac 937 938AC_ARG_ENABLE(memclean, AS_HELP_STRING([--enable-memclean],[Cleanup memory (at exit) for eg. valgrind, memcheck])) 939if test "$enable_memclean" = "yes"; then AC_DEFINE_UNQUOTED([MEMCLEAN], [1], [Define this to cleanup memory at exit (eg. for valgrind, etc.)]) 940fi 941 942AC_ARG_ENABLE(ratelimit, AS_HELP_STRING([--enable-ratelimit],[Enable rate limiting])) 943case "$enable_ratelimit" in 944 yes) 945 AC_DEFINE_UNQUOTED([RATELIMIT], [], [Define this to enable rate limiting.]) 946 dnl causes awk to not match the exclusion start marker. 947 ratelimit="xx" 948 ;; 949 no|*) 950 ratelimit="" 951 ;; 952esac 953AC_SUBST(ratelimit) 954 955AC_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])) 956case "$enable_ratelimit_default_is_off" in 957 yes) 958 AC_DEFINE_UNQUOTED([RATELIMIT_DEFAULT_OFF], [], [Define this to set ratelimit to off by default.]) 959 ratelimit_default="off" 960 ;; 961 no|*) 962 ratelimit_default="on" 963 ;; 964esac 965AC_SUBST(ratelimit_default) 966 967# we need SSL for TSIG (and maybe also for NSEC3). 968CHECK_SSL 969if test x$HAVE_SSL = x"yes"; then 970 ACX_LIB_SSL 971 # remove space after -ldl if there. 972 LIBS=`echo "$LIBS" | sed -e 's/ $//'` 973 974 # Check for -pthread 975 BAKLIBS="$LIBS" 976 LIBS="-lcrypto $LIBS" 977 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ 978 int EVP_sha256(void); 979 (void)EVP_sha256(); 980 ]])],[],[ 981 dnl so link fails for EVP_sha256, try with -pthread. 982 BAKCFLAGS="$CFLAGS" 983 CFLAGS="$CFLAGS -pthread" 984 AC_MSG_CHECKING([if libcrypto needs -pthread]) 985 AC_TRY_LINK_FUNC([EVP_sha256], [ 986 AC_MSG_RESULT([yes]) 987 ] , [ 988 AC_MSG_RESULT([no]) 989 dnl restore the nonpthread value 990 CFLAGS="$BAKCFLAGS" 991 ]) 992 ]) 993 LIBS="$BAKLIBS" 994 995 if test -n "$ssldir"; then 996 AC_CHECK_LIB(crypto, EVP_sha256,, [ 997 AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required]) 998 ]) 999 fi 1000 SSL_LIBS="-lssl" 1001 AC_SUBST(SSL_LIBS) 1002 AC_CHECK_HEADERS([openssl/ssl.h openssl/err.h openssl/rand.h openssl/ocsp.h openssl/core_names.h],,, [AC_INCLUDES_DEFAULT]) 1003 AC_CHECK_FUNCS([HMAC_CTX_reset HMAC_CTX_new EVP_cleanup ERR_load_crypto_strings OPENSSL_init_crypto SSL_CTX_set_security_level CRYPTO_memcmp EC_KEY_new_by_curve_name EVP_MAC_CTX_new EVP_MAC_CTX_set_params]) 1004 AC_CHECK_DECLS([SSL_CTX_set_ecdh_auto,SSL_CTX_set_tmp_ecdh], [], [], [ 1005AC_INCLUDES_DEFAULT 1006#ifdef HAVE_OPENSSL_ERR_H 1007#include <openssl/err.h> 1008#endif 1009 1010#ifdef HAVE_OPENSSL_RAND_H 1011#include <openssl/rand.h> 1012#endif 1013 1014#ifdef HAVE_OPENSSL_CONF_H 1015#include <openssl/conf.h> 1016#endif 1017 1018#ifdef HAVE_OPENSSL_ENGINE_H 1019#include <openssl/engine.h> 1020#endif 1021#include <openssl/ssl.h> 1022#include <openssl/evp.h> 1023]) 1024 1025 1026 BAKLIBS="$LIBS" 1027 LIBS="-lssl $LIBS" 1028 AC_CHECK_FUNCS([OPENSSL_init_ssl]) 1029 LIBS="$BAKLIBS" 1030 1031else 1032 AC_MSG_WARN([No SSL, therefore remote-control is disabled]) 1033 AC_MSG_WARN([No SSL, therefore TLS is disabled]) 1034fi 1035 1036AC_ARG_ENABLE(nsec3, AS_HELP_STRING([--disable-nsec3],[Disable NSEC3 support])) 1037case "$enable_nsec3" in 1038 no) 1039 ;; 1040 yes) 1041 AC_DEFINE_UNQUOTED([NSEC3], [], [Define this to enable NSEC3 support.]) 1042 ;; 1043 *) 1044 if test x$HAVE_SSL = x"yes"; then 1045 AC_DEFINE_UNQUOTED([NSEC3], [], [Define this to enable NSEC3 support.]) 1046 else 1047 AC_MSG_WARN([No SSL, therefore NSEC3 is disabled]) 1048 fi 1049 ;; 1050esac 1051 1052AC_ARG_ENABLE(minimal-responses, AS_HELP_STRING([--disable-minimal-responses],[Disable response minimization. More truncation.])) 1053case "$enable_minimal_responses" in 1054 no) 1055 ;; 1056 yes|*) 1057 AC_DEFINE_UNQUOTED([MINIMAL_RESPONSES], [], [Define this to enable response minimalization to reduce truncation.]) 1058 ;; 1059esac 1060 1061AC_ARG_ENABLE(mmap, AS_HELP_STRING([--enable-mmap],[Use mmap instead of malloc. Experimental.])) 1062case "$enable_mmap" in 1063 yes) 1064 AC_CHECK_HEADERS([sys/mman.h]) 1065 AC_LIBGTOP_CHECK_TYPE(uintptr_t, void*) 1066 AC_CHECK_FUNCS([mmap munmap]) 1067 AC_DEFINE_UNQUOTED([USE_MMAP_ALLOC], [], [Define this to enable mmap instead of malloc. Experimental.]) 1068 ;; 1069 no|*) 1070 ;; 1071esac 1072 1073AC_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.])) 1074case "$enable_radix_tree" in 1075 no) 1076 ;; 1077 yes|*) 1078 AC_DEFINE_UNQUOTED([USE_RADIX_TREE], [], [Define this to configure to use the radix tree.]) 1079 ;; 1080esac 1081 1082AC_ARG_ENABLE(packed, AS_HELP_STRING([--enable-packed],[Enable packed structure alignment, uses less memory, but unaligned reads.])) 1083case "$enable_packed" in 1084 yes) 1085 AC_DEFINE_UNQUOTED([PACKED_STRUCTS], [], [Define this to use packed structure alignment.]) 1086 ACX_CHECK_COMPILER_FLAG(Wno-address-of-packed-member, [CFLAGS="$CFLAGS -Wno-address-of-packed-member"]) 1087 ;; 1088 no|*) 1089 ;; 1090esac 1091 1092# check for dnstap if requested 1093dt_DNSTAP([${localstatedir}/run/nsd-dnstap.sock], 1094 [ 1095 AC_DEFINE([USE_DNSTAP], [1], [Define to 1 to enable dnstap support]) 1096 AC_SUBST([ENABLE_DNSTAP], [1]) 1097 1098 AC_SUBST([opt_dnstap_socket_path]) 1099 ACX_ESCAPE_BACKSLASH($opt_dnstap_socket_path, hdr_dnstap_socket_path) 1100 AC_DEFINE_UNQUOTED(DNSTAP_SOCKET_PATH, 1101 ["$hdr_dnstap_socket_path"], [default dnstap socket path]) 1102 1103 AC_SUBST([DNSTAP_SRC], ["dnstap/dnstap.c dnstap/dnstap.pb-c.c dnstap/dnstap_collector.c"]) 1104 AC_SUBST([DNSTAP_OBJ], ["dnstap.o dnstap_collector.o dnstap.pb-c.o"]) 1105 dnstap_config="dnstap/dnstap_config.h" 1106 ], 1107 [ 1108 AC_SUBST([ENABLE_DNSTAP], [0]) 1109 ] 1110) 1111 1112# Include systemd.m4 - begin 1113sinclude(systemd.m4) 1114# Include systemd.m4 - end 1115 1116AC_ARG_ENABLE(tcp-fastopen, AS_HELP_STRING([--enable-tcp-fastopen],[Enable TCP Fast Open])) 1117case "$enable_tcp_fastopen" in 1118 yes) 1119 AC_CHECK_DECL([TCP_FASTOPEN], [], [AC_MSG_ERROR([TCP Fast Open is not available: please rerun without --enable-tcp-fastopen])], [AC_INCLUDES_DEFAULT 1120#include <netinet/tcp.h> 1121 ]) 1122 AC_DEFINE_UNQUOTED([USE_TCP_FASTOPEN], [1], [Define this to enable TCP fast open.]) 1123 ;; 1124 no|*) 1125 ;; 1126esac 1127 1128AH_BOTTOM([ 1129/* define before includes as it specifies what standard to use. */ 1130#if (defined(HAVE_PSELECT) && !defined (HAVE_PSELECT_PROTO)) \ 1131 || !defined (HAVE_CTIME_R_PROTO) \ 1132 || defined (STRPTIME_NEEDS_DEFINES) || defined(REALLOCARRAY_NEEDS_DEFINES) 1133# ifndef _XOPEN_SOURCE 1134# define _XOPEN_SOURCE 600 1135# endif 1136# ifndef _POSIX_C_SOURCE 1137# define _POSIX_C_SOURCE 200112 1138# endif 1139# ifndef _BSD_SOURCE 1140# define _BSD_SOURCE 1 1141# endif 1142# ifndef _OPENBSD_SOURCE 1143# define _OPENBSD_SOURCE 1 1144# endif 1145# ifndef _DEFAULT_SOURCE 1146# define _DEFAULT_SOURCE 1 1147# endif 1148# ifndef __EXTENSIONS__ 1149# define __EXTENSIONS__ 1 1150# endif 1151# ifndef _STDC_C99 1152# define _STDC_C99 1 1153# endif 1154# ifndef _ALL_SOURCE 1155# define _ALL_SOURCE 1 1156# endif 1157#endif 1158]) 1159 1160AH_BOTTOM([ 1161#ifdef HAVE_VA_LIST_DOUBLE_DEF 1162/* workaround double va_list definition on some platforms */ 1163# ifndef _VA_LIST_DEFINED 1164# define _VA_LIST_DEFINED 1165# endif 1166#endif 1167]) 1168 1169AH_BOTTOM([ 1170#include <sys/types.h> 1171#include <stdlib.h> 1172#include <stddef.h> 1173 1174#ifdef HAVE_TIME_H 1175#include <time.h> 1176#endif 1177 1178#ifdef HAVE_STDINT_H 1179#include <stdint.h> 1180#endif 1181 1182#ifdef HAVE_SYS_SOCKET_H 1183#include <sys/socket.h> 1184#endif 1185 1186#ifdef HAVE_NETINET_IN_H 1187#include <netinet/in.h> 1188#endif 1189 1190#ifdef HAVE_NETINET_TCP_H 1191#include <netinet/tcp.h> 1192#endif 1193 1194#ifdef HAVE_ARPA_INET_H 1195#include <arpa/inet.h> 1196#endif 1197 1198/* For Tru64 */ 1199#ifdef HAVE_SYS_BITYPES_H 1200#include <sys/bitypes.h> 1201#endif 1202]) 1203 1204AH_BOTTOM([ 1205#ifdef HAVE_ATTR_FORMAT 1206#define ATTR_FORMAT(archetype, string_index, first_to_check) \ 1207 __attribute__ ((format (archetype, string_index, first_to_check))) 1208#else /* !HAVE_ATTR_FORMAT */ 1209#define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */ 1210#endif /* !HAVE_ATTR_FORMAT */ 1211#if defined(__cplusplus) 1212#define ATTR_UNUSED(x) 1213#elif defined(HAVE_ATTR_UNUSED) 1214#define ATTR_UNUSED(x) x __attribute__((unused)) 1215#else /* !HAVE_ATTR_UNUSED */ 1216#define ATTR_UNUSED(x) x 1217#endif /* !HAVE_ATTR_UNUSED */ 1218]) 1219 1220AH_BOTTOM([ 1221#ifndef IPV6_MIN_MTU 1222#define IPV6_MIN_MTU 1280 1223#endif /* IPV6_MIN_MTU */ 1224 1225#ifndef AF_INET6 1226#define AF_INET6 28 1227#endif /* AF_INET6 */ 1228]) 1229 1230if test $ac_cv_func_getaddrinfo = no; then 1231AC_LIBOBJ([fake-rfc2553]) 1232fi 1233 1234AH_BOTTOM([ 1235/* maximum nesting of included files */ 1236#define MAXINCLUDES 10 1237]) 1238 1239AH_BOTTOM([ 1240#ifndef HAVE_B64_NTOP 1241int b64_ntop(uint8_t const *src, size_t srclength, 1242 char *target, size_t targsize); 1243#endif /* !HAVE_B64_NTOP */ 1244#ifndef HAVE_B64_PTON 1245int b64_pton(char const *src, uint8_t *target, size_t targsize); 1246#endif /* !HAVE_B64_PTON */ 1247#ifndef HAVE_FSEEKO 1248#define fseeko fseek 1249#define ftello ftell 1250#endif /* HAVE_FSEEKO */ 1251#ifndef HAVE_SNPRINTF 1252#include <stdarg.h> 1253int snprintf (char *str, size_t count, const char *fmt, ...); 1254int vsnprintf (char *str, size_t count, const char *fmt, va_list arg); 1255#endif /* HAVE_SNPRINTF */ 1256#ifndef HAVE_INET_PTON 1257int inet_pton(int af, const char* src, void* dst); 1258#endif /* HAVE_INET_PTON */ 1259#ifndef HAVE_INET_NTOP 1260const char *inet_ntop(int af, const void *src, char *dst, size_t size); 1261#endif 1262#ifndef HAVE_INET_ATON 1263int inet_aton(const char *cp, struct in_addr *addr); 1264#endif 1265#ifndef HAVE_MEMMOVE 1266void *memmove(void *dest, const void *src, size_t n); 1267#endif 1268#ifndef HAVE_STRLCAT 1269size_t strlcat(char *dst, const char *src, size_t siz); 1270#endif 1271#ifndef HAVE_STRLCPY 1272size_t strlcpy(char *dst, const char *src, size_t siz); 1273#endif 1274#ifndef HAVE_REALLOCARRAY 1275void* reallocarray(void *ptr, size_t nmemb, size_t size); 1276#endif 1277#ifndef HAVE_GETADDRINFO 1278#include "compat/fake-rfc2553.h" 1279#endif 1280#ifndef HAVE_STRPTIME 1281#define HAVE_STRPTIME 1 1282char *strptime(const char *s, const char *format, struct tm *tm); 1283#endif 1284#ifndef STRPTIME_WORKS 1285#define STRPTIME_WORKS 1 1286char *nsd_strptime(const char *s, const char *format, struct tm *tm); 1287#define strptime(a,b,c) nsd_strptime((a),(b),(c)) 1288#endif 1289#if (HAVE_CPU_SET_T || HAVE_CPUSET_T) 1290#include "compat/cpuset.h" 1291#endif 1292#ifndef HAVE_SETPROCTITLE 1293#ifdef __linux__ 1294#define HAVE_SETPROCTITLE 1 1295#include <stdarg.h> 1296void setproctitle(const char *fmt, ...); 1297#endif 1298#endif 1299]) 1300AH_BOTTOM( 1301AHX_MEMCMP_BROKEN(nsd) 1302AHX_CONFIG_MAXHOSTNAMELEN 1303) 1304AH_BOTTOM([ 1305 1306/* provide timespec def if not available */ 1307#ifndef CONFIG_DEFINES 1308#define CONFIG_DEFINES 1309#ifndef HAVE_STRUCT_TIMESPEC 1310#ifndef __timespec_defined 1311#define __timespec_defined 1 1312 struct timespec { 1313 long tv_sec; /* seconds */ 1314 long tv_nsec; /* nanoseconds */ 1315 }; 1316#endif /* !__timespec_defined */ 1317#endif /* !HAVE_STRUCT_TIMESPEC */ 1318#endif /* !CONFIG_DEFINES */ 1319 1320#ifdef PACKED_STRUCTS 1321#define ATTR_PACKED __attribute__((packed)) 1322#else 1323#define ATTR_PACKED 1324#endif 1325]) 1326 1327# big fat warning 1328if test "$enable_checking" = "yes"; then 1329 echo "************************************************" 1330 echo "* You have activated \"--enable-checking\" *" 1331 echo "* *" 1332 echo "* This will instruct NSD to be stricter *" 1333 echo "* when validating its input. This could lead *" 1334 echo "* to a reduced service level. *" 1335 echo "* *" 1336 echo "************************************************" 1337fi 1338 1339AC_CONFIG_FILES([Makefile $dnstap_config]) 1340AC_OUTPUT 1341