"Fossies" - the Fresh Open Source Software Archive

Member "nsd-4.3.6/configure.ac" (6 Apr 2021, 40416 Bytes) of package /linux/misc/dns/nsd-4.3.6.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "configure.ac": 4.3.5_vs_4.3.6.

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