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