xref: /openbsd-src/usr.sbin/nsd/configure.ac (revision 4c4bdeb849a3fa82dc4f1c4d2bc9fdb703c887a3)
162ac0c33Sjakobdnl
262ac0c33Sjakobdnl Some global settings
362ac0c33Sjakobdnl
462ac0c33Sjakob
562ac0c33Sjakobsinclude(acx_nlnetlabs.m4)
6e02bc0dfSfloriansinclude(dnstap/dnstap.m4)
762ac0c33Sjakob
8bf87c3c0SflorianAC_INIT([NSD],[4.9.1],[https://github.com/NLnetLabs/nsd/issues or nsd-bugs@nlnetlabs.nl])
98d298c9fSsthenAC_CONFIG_HEADERS([config.h])
1062ac0c33Sjakob
11308d2509Sflorian#
12308d2509Sflorian# Setup the standard programs
13308d2509Sflorian# https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Setting-Output-Variables.html
14308d2509Sflorian
15308d2509SflorianAC_ARG_VAR(SED, [location of the sed program])
16308d2509SflorianAC_ARG_VAR(AWK, [location of the awk program])
17308d2509SflorianAC_ARG_VAR(GREP, [location of the grep program])
18308d2509SflorianAC_ARG_VAR(EGREP, [location of the egrep program])
19308d2509SflorianAC_ARG_VAR(LEX, [location of the lex program with GNU extensions (flex)])
20308d2509SflorianAC_ARG_VAR(YACC, [location of the yacc program with GNU extensions (bison)])
21308d2509Sflorian
22ac5517e4Sfloriancmdln="`echo $@ | sed -e 's/\\\\/\\\\\\\\/g' | sed -e 's/"/\\\\"/'g`"
23ac5517e4SflorianAC_DEFINE_UNQUOTED(CONFCMDLINE, ["$cmdln"], [Command line arguments used with configure])
24ac5517e4Sflorian
25533110e2SbradCFLAGS="$CFLAGS"
268d298c9fSsthenAC_USE_SYSTEM_EXTENSIONS
275fab9a23Sbradif test "$ac_cv_header_minix_config_h" = "yes"; then
285fab9a23Sbrad	AC_DEFINE(_NETBSD_SOURCE,1, [Enable for compile on Minix])
295fab9a23Sbradfi
3062ac0c33Sjakob
3162ac0c33Sjakobdnl
3262ac0c33Sjakobdnl By default set $sysconfdir to /etc and $localstatedir to /var
3362ac0c33Sjakobdnl
3462ac0c33Sjakobcase "$prefix" in
3562ac0c33Sjakob	NONE)
3662ac0c33Sjakob		case "$sysconfdir" in
3762ac0c33Sjakob			'${prefix}/etc')
3862ac0c33Sjakob				sysconfdir=/etc
3962ac0c33Sjakob			;;
4062ac0c33Sjakob                esac
4162ac0c33Sjakob		case "$localstatedir" in
4262ac0c33Sjakob			'${prefix}/var')
4362ac0c33Sjakob				localstatedir=/var
4462ac0c33Sjakob			;;
4562ac0c33Sjakob		esac
4662ac0c33Sjakob	;;
4762ac0c33Sjakobesac
4862ac0c33Sjakob
4962ac0c33Sjakob#
5062ac0c33Sjakob# Determine configuration directory
5162ac0c33Sjakob#
5262ac0c33Sjakobconfigdir=$sysconfdir/nsd
5362ac0c33SjakobAC_ARG_WITH([configdir],
548d298c9fSsthen	AS_HELP_STRING([--with-configdir=dir],[NSD configuration directory]),
5562ac0c33Sjakob	[configdir=$withval])
56dd5b221eSsthenAC_DEFINE_UNQUOTED(CONFIGDIR, ["`eval echo $configdir`"], [NSD config dir])
5762ac0c33SjakobAC_SUBST(configdir)
5862ac0c33Sjakob
5962ac0c33Sjakob#
6062ac0c33Sjakob# Determine configuration file
6162ac0c33Sjakobnsd_conf_file=${configdir}/nsd.conf
6262ac0c33SjakobAC_ARG_WITH([nsd_conf_file],
638d298c9fSsthen	AS_HELP_STRING([--with-nsd_conf_file=path],[Pathname to the NSD configuration file]),
6462ac0c33Sjakob	[nsd_conf_file=$withval])
6562ac0c33SjakobAC_SUBST(nsd_conf_file)
6662ac0c33Sjakob# the eval is to evaluate shell expansion twice, once
6762ac0c33Sjakob# for $nsd_conf_file and once for the ${prefix} within it.
6862ac0c33SjakobAC_DEFINE_UNQUOTED(CONFIGFILE, ["`eval echo $nsd_conf_file`"], [Pathname to the NSD configuration file])
6962ac0c33Sjakob
7062ac0c33Sjakob#
713b0b19f7Sjakob# Default logfile
723b0b19f7Sjakob#
733b0b19f7Sjakoblogfile=${localstatedir}/log/nsd.log
74dd5b221eSsthenAC_ARG_WITH([logfile],
758d298c9fSsthen	AS_HELP_STRING([--with-logfile=path],[Pathname to the default log file]),
76dd5b221eSsthen	[logfile=$withval])
775bcb494bSjakobAC_SUBST(logfile)
783b0b19f7Sjakob
793b0b19f7Sjakob#
8062ac0c33Sjakob# Database directory
8162ac0c33Sjakob#
8262ac0c33Sjakobdbdir=${localstatedir}/db/nsd
8362ac0c33Sjakob
8462ac0c33Sjakob#
8562ac0c33Sjakob# Determine the pidfile location. Check if /var/run exists, if so set pidfile
8662ac0c33Sjakob# to /var/run/nsd.pid by default
8762ac0c33Sjakob#
8862ac0c33Sjakobif test -d ${localstatedir}/run; then
8962ac0c33Sjakob	pidfile=${localstatedir}/run/nsd.pid
9062ac0c33Sjakobelse
9162ac0c33Sjakob	pidfile=${dbdir}/nsd.pid
9262ac0c33Sjakobfi
9362ac0c33SjakobAC_ARG_WITH([pidfile],
948d298c9fSsthen	AS_HELP_STRING([--with-pidfile=path],[Pathname to the NSD pidfile]),
9562ac0c33Sjakob	[pidfile=$withval])
9662ac0c33SjakobAC_SUBST(pidfile)
9762ac0c33SjakobAC_DEFINE_UNQUOTED(PIDFILE, ["`eval echo $pidfile`"], [Pathname to the NSD pidfile])
9862ac0c33Sjakob
9962ac0c33SjakobAC_ARG_WITH([dbfile],
100b71395eaSflorian	AS_HELP_STRING([--with-dbfile=path],[Pathname to the NSD database (obsolete)]),[])
10162ac0c33Sjakob
10262ac0c33Sjakobpiddir=`dirname $pidfile`
10362ac0c33SjakobAC_SUBST(piddir)
10462ac0c33Sjakob
10562ac0c33Sjakob#
10662ac0c33Sjakob# Determine the default directory for the zone files
10762ac0c33Sjakob#
10862ac0c33Sjakobzonesdir=$configdir
10962ac0c33SjakobAC_ARG_WITH([zonesdir],
1108d298c9fSsthen	AS_HELP_STRING([--with-zonesdir=dir],[NSD default location for zone files]),
11162ac0c33Sjakob	[zonesdir=$withval])
11262ac0c33SjakobAC_SUBST(zonesdir)
11362ac0c33SjakobAC_DEFINE_UNQUOTED(ZONESDIR, ["`eval echo $zonesdir`"], [NSD default location for zone files. Empty string or NULL to disable.])
11462ac0c33Sjakob
11562ac0c33Sjakob# default xfrd file location.
11662ac0c33Sjakobxfrdfile=${dbdir}/xfrd.state
1178d298c9fSsthenAC_ARG_WITH([xfrdfile], AS_HELP_STRING([--with-xfrdfile=path],[Pathname to the NSD xfrd zone timer state file]), [xfrdfile=$withval])
11862ac0c33SjakobAC_DEFINE_UNQUOTED(XFRDFILE, ["`eval echo $xfrdfile`"], [Pathname to the NSD xfrd zone timer state file.])
11962ac0c33SjakobAC_SUBST(xfrdfile)
12062ac0c33Sjakob
121dd5b221eSsthen# default zonelist file location.
122dd5b221eSsthenzonelistfile=${dbdir}/zone.list
1238d298c9fSsthenAC_ARG_WITH([zonelistfile], AS_HELP_STRING([--with-zonelistfile=path],[Pathname to the NSD zone list file]), [zonelistfile=$withval])
124dd5b221eSsthenAC_DEFINE_UNQUOTED(ZONELISTFILE, ["`eval echo $zonelistfile`"], [Pathname to the NSD zone list file.])
125dd5b221eSsthenAC_SUBST(zonelistfile)
126dd5b221eSsthen
127dd5b221eSsthen# default xfr dir location.
128dd5b221eSsthenxfrdir="/tmp"
1298d298c9fSsthenAC_ARG_WITH([xfrdir], AS_HELP_STRING([--with-xfrdir=path],[Pathname to where the NSD transfer dir is created]), [xfrdir=$withval])
130dd5b221eSsthenAC_DEFINE_UNQUOTED(XFRDIR, ["`eval echo $xfrdir`"], [Pathname to where the NSD transfer dir is created.])
131dd5b221eSsthenAC_SUBST(xfrdir)
132dd5b221eSsthen
133dd5b221eSsthen# nsd sbin location. tmpinstantiate execprefix with defaults if not yet done.
134dd5b221eSsthenif test "x${exec_prefix}" = "xNONE"; then
135dd5b221eSsthen	if test "x${prefix}" = "xNONE"; then exec_prefix="$ac_default_prefix"
136dd5b221eSsthen	else exec_prefix="${prefix}"; fi
137dd5b221eSsthen	nsd_start_path="`eval echo $sbindir`/nsd"
138dd5b221eSsthen	exec_prefix="NONE"
139dd5b221eSsthenelse
140dd5b221eSsthen	nsd_start_path="`eval echo $sbindir`/nsd"
141dd5b221eSsthenfi
142dd5b221eSsthenAC_DEFINE_UNQUOTED(NSD_START_PATH, ["$nsd_start_path"], [Pathname to start nsd from nsd-control])
143dd5b221eSsthen
14462ac0c33Sjakob#
145fe5b9529Sjakob# Determine default chroot directory
146fe5b9529Sjakob#
147fe5b9529SjakobAC_ARG_WITH([chroot],
1488d298c9fSsthen	AS_HELP_STRING([--with-chroot=dir],[NSD default chroot directory]),
149a58d140aSjakob	[
150a58d140aSjakob		chrootdir=$withval
1514ab91c82Sjakob		AC_DEFINE_UNQUOTED(CHROOTDIR, ["`eval echo $chrootdir`"], [NSD default chroot directory])
152a58d140aSjakob	])
153dd5b221eSsthenAC_SUBST(chrootdir)
154fe5b9529Sjakob
155fe5b9529Sjakob#
15662ac0c33Sjakob# Determine the user name to drop privileges to
15762ac0c33Sjakob#
15862ac0c33Sjakobuser=nsd
15962ac0c33SjakobAC_ARG_WITH([user],
1608d298c9fSsthen	AS_HELP_STRING([--with-user=username],[User name or ID to answer the queries with]),
16162ac0c33Sjakob	[user=$withval])
16262ac0c33SjakobAC_SUBST(user)
16362ac0c33SjakobAC_DEFINE_UNQUOTED(USER, ["$user"], [the user name to drop privileges to])
16462ac0c33Sjakob
165*4c4bdeb8Sflorianm4_version_prereq([2.70], [AC_PROG_CC], [m4_warn([obsolete],
166*4c4bdeb8Sflorian[AC_PROG_CC_STDC is obsolete; use AC_PROG_CC
167*4c4bdeb8Sflorian])dnl
168*4c4bdeb8SflorianAC_REQUIRE(AC_PROG_CC)])
169308d2509SflorianAC_PROG_SED
170308d2509SflorianAC_PROG_AWK
171308d2509SflorianAC_PROG_GREP
172308d2509SflorianAC_PROG_EGREP
1738d298c9fSsthenAC_PROG_LEX([noyywrap])
17462ac0c33SjakobAC_PROG_YACC
175308d2509SflorianAC_PROG_LN_S
176308d2509SflorianAC_PROG_INSTALL
17762ac0c33Sjakob
1788d8f1862Ssthenif test "$LEX" != ":" -a "$LEX" != ""; then
179308d2509Sflorian# Solaris provides anemic tools, and they don't offer GNU extensions like
180308d2509Sflorian# 'flex -i'. Solaris also does not offer GNU replacements in /usr/gnu/bin.
181308d2509SflorianAC_MSG_CHECKING([whether lex accepts -i])
182308d2509SflorianAS_IF([echo "%%" | $LEX -i -t >/dev/null 2>&1],
183308d2509Sflorian  [
184308d2509Sflorian    AC_MSG_RESULT([yes])
185308d2509Sflorian  ],
186308d2509Sflorian  [
187308d2509Sflorian    AC_MSG_RESULT([no])
188308d2509Sflorian    AC_MSG_ERROR([unable to find a lexer that supports -i. If one is available then set the LEX variable])
189308d2509Sflorian  ]
190308d2509Sflorian)
191308d2509Sflorian
1928d8f1862Ssthen  # Check if lex defines yy_current_buffer, because 2.4.6 and older use it,
1938d8f1862Ssthen  # but later could define it as a macro and then we should not redefine it.
1948d8f1862Ssthen  AC_MSG_CHECKING(if lex defines yy_current_buffer)
1958d8f1862Ssthen  cat <<EOF >conftest.lex
1968d8f1862Ssthen%%
1978d8f1862SsthenEOF
198308d2509Sflorian  $LEX -i -t conftest.lex >> conftest.c 2>/dev/null
199308d2509Sflorian  if $GREP "^#define yy_current_buffer" conftest.c >/dev/null; then
2008d8f1862Ssthen	  AC_DEFINE_UNQUOTED(LEX_DEFINES_YY_CURRENT_BUFFER, 1, [If flex defines yy_current_buffer as a macro])
2018d8f1862Ssthen	AC_MSG_RESULT(yes)
2028d8f1862Ssthen  else
2038d8f1862Ssthen	AC_MSG_RESULT(no)
2048d8f1862Ssthen  fi
2058d8f1862Ssthen  rm -f conftest.lex conftest.c
2068d8f1862Ssthenfi
2078d8f1862Ssthen
20862ac0c33SjakobAC_DEFUN([AC_CHECK_FORMAT_ATTRIBUTE],
20962ac0c33Sjakob[AC_REQUIRE([AC_PROG_CC])
21062ac0c33SjakobAC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "format" attribute)
21162ac0c33SjakobAC_CACHE_VAL(ac_cv_c_format_attribute,
21262ac0c33Sjakob[ac_cv_c_format_attribute=no
2138d298c9fSsthenAC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
21462ac0c33Sjakobvoid f (char *format, ...) __attribute__ ((format (printf, 1, 2)));
21562ac0c33Sjakobvoid (*pf) (char *format, ...) __attribute__ ((format (printf, 1, 2)));
2168d298c9fSsthen]], [[
21762ac0c33Sjakob   f ("%s", "str");
2188d298c9fSsthen]])],[ac_cv_c_format_attribute="yes"],[ac_cv_c_format_attribute="no"])
21962ac0c33Sjakob])
22062ac0c33Sjakob
22162ac0c33SjakobAC_MSG_RESULT($ac_cv_c_format_attribute)
22262ac0c33Sjakobif test $ac_cv_c_format_attribute = yes; then
22362ac0c33Sjakob  AC_DEFINE(HAVE_ATTR_FORMAT, 1, [Whether the C compiler accepts the "format" attribute])
22462ac0c33Sjakobfi
22562ac0c33Sjakob])dnl
22662ac0c33Sjakob
22762ac0c33SjakobAC_DEFUN([AC_CHECK_UNUSED_ATTRIBUTE],
22862ac0c33Sjakob[AC_REQUIRE([AC_PROG_CC])
22962ac0c33SjakobAC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "unused" attribute)
23062ac0c33SjakobAC_CACHE_VAL(ac_cv_c_unused_attribute,
23162ac0c33Sjakob[ac_cv_c_unused_attribute=no
2328d298c9fSsthenAC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
23362ac0c33Sjakobvoid f (char *u __attribute__((unused)));
2348d298c9fSsthen]], [[
23562ac0c33Sjakob   f ("x");
2368d298c9fSsthen]])],[ac_cv_c_unused_attribute="yes"],[ac_cv_c_unused_attribute="no"])
23762ac0c33Sjakob])
23862ac0c33Sjakob
23962ac0c33SjakobAC_MSG_RESULT($ac_cv_c_unused_attribute)
24062ac0c33Sjakobif test $ac_cv_c_unused_attribute = yes; then
24162ac0c33Sjakob  AC_DEFINE(HAVE_ATTR_UNUSED, 1, [Whether the C compiler accepts the "unused" attribute])
24262ac0c33Sjakobfi
24362ac0c33Sjakob])dnl
24462ac0c33Sjakob
245063644e9SflorianAC_DEFUN([CHECK_WEAK_ATTRIBUTE],
246063644e9Sflorian[AC_REQUIRE([AC_PROG_CC])
247063644e9SflorianAC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "weak" attribute)
248063644e9SflorianAC_CACHE_VAL(ac_cv_c_weak_attribute,
249063644e9Sflorian[ac_cv_c_weak_attribute=no
250063644e9SflorianAC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h>
251063644e9Sflorian__attribute__((weak)) void f(int x) { printf("%d", x); }
252063644e9Sflorian]], [[
253063644e9Sflorian   f(1);
254063644e9Sflorian]])],[ac_cv_c_weak_attribute="yes"],[ac_cv_c_weak_attribute="no"])
255063644e9Sflorian])
256063644e9Sflorian
257063644e9SflorianAC_MSG_RESULT($ac_cv_c_weak_attribute)
258063644e9Sflorianif test $ac_cv_c_weak_attribute = yes; then
259063644e9Sflorian  AC_DEFINE(HAVE_ATTR_WEAK, 1, [Whether the C compiler accepts the "weak" attribute])
260063644e9Sflorian  AC_DEFINE(ATTR_WEAK, [__attribute__((weak))], [apply the weak attribute to a symbol])
261063644e9Sflorianfi
262063644e9Sflorian])dnl End of CHECK_WEAK_ATTRIBUTE
263063644e9Sflorian
2644b6a9f59SflorianAC_DEFUN([CHECK_NORETURN_ATTRIBUTE],
2654b6a9f59Sflorian[AC_REQUIRE([AC_PROG_CC])
2664b6a9f59SflorianAC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "noreturn" attribute)
2674b6a9f59SflorianAC_CACHE_VAL(ac_cv_c_noreturn_attribute,
2684b6a9f59Sflorian[ac_cv_c_noreturn_attribute=no
2698d298c9fSsthenAC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h>
2704b6a9f59Sflorian__attribute__((noreturn)) void f(int x) { printf("%d", x); }
2718d298c9fSsthen]], [[
2724b6a9f59Sflorian   f(1);
2738d298c9fSsthen]])],[ac_cv_c_noreturn_attribute="yes"],[ac_cv_c_noreturn_attribute="no"])
2744b6a9f59Sflorian])
2754b6a9f59Sflorian
2764b6a9f59SflorianAC_MSG_RESULT($ac_cv_c_noreturn_attribute)
2774b6a9f59Sflorianif test $ac_cv_c_noreturn_attribute = yes; then
2784b6a9f59Sflorian  AC_DEFINE(HAVE_ATTR_NORETURN, 1, [Whether the C compiler accepts the "noreturn" attribute])
2794b6a9f59Sflorian  AC_DEFINE(ATTR_NORETURN, [__attribute__((__noreturn__))], [apply the noreturn attribute to a function that exits the program])
2804b6a9f59Sflorianfi
2814b6a9f59Sflorian])dnl End of CHECK_NORETURN_ATTRIBUTE
2824b6a9f59Sflorian
28362ac0c33SjakobAC_DEFUN([CHECK_COMPILER_FLAG],
28462ac0c33Sjakob[
28562ac0c33SjakobAC_REQUIRE([AC_PROG_CC])
28662ac0c33SjakobAC_MSG_CHECKING(whether $CC supports -$1)
287308d2509Sfloriancache=`echo $1 | $SED 'y%.=/+-%___p_%'`
28862ac0c33SjakobAC_CACHE_VAL(cv_prog_cc_flag_$cache,
28962ac0c33Sjakob[
2903efee2e1Sflorianecho 'void f(void){}' >conftest.c
29162ac0c33Sjakobif test -z "`$CC -$1 -c conftest.c 2>&1`"; then
29262ac0c33Sjakobeval "cv_prog_cc_flag_$cache=yes"
29362ac0c33Sjakobelse
29462ac0c33Sjakobeval "cv_prog_cc_flag_$cache=no"
29562ac0c33Sjakobfi
29662ac0c33Sjakobrm -f conftest*
29762ac0c33Sjakob])
29862ac0c33Sjakobif eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then
29962ac0c33SjakobAC_MSG_RESULT(yes)
30062ac0c33Sjakob:
30162ac0c33Sjakob$2
30262ac0c33Sjakobelse
30362ac0c33SjakobAC_MSG_RESULT(no)
30462ac0c33Sjakob:
30562ac0c33Sjakob$3
30662ac0c33Sjakobfi
30762ac0c33Sjakob])
30862ac0c33Sjakob
30962ac0c33SjakobAC_DEFUN([AC_CHECK_CTIME_R],
31062ac0c33Sjakob[AC_REQUIRE([AC_PROG_CC])
31162ac0c33SjakobAC_MSG_CHECKING(whether ctime_r works with two arguments)
31262ac0c33SjakobAC_CACHE_VAL(ac_cv_c_ctime_c,
31362ac0c33Sjakob[ac_cv_c_ctime_c=no
3148d298c9fSsthenAC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>
3158d298c9fSsthenvoid testing (void) { time_t clock; char current_time[40]; ctime_r(&clock, current_time); }]], [[
31662ac0c33Sjakob        testing();
3178d298c9fSsthen]])],[ac_cv_c_ctime_c="yes"],[ac_cv_c_ctime_c="no"])
31862ac0c33Sjakob])
31962ac0c33Sjakob
32062ac0c33SjakobAC_MSG_RESULT($ac_cv_c_ctime_c)
32162ac0c33Sjakobif test $ac_cv_c_ctime_c = no; then
32262ac0c33Sjakob        CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
32362ac0c33Sjakobfi
32462ac0c33Sjakob])dnl
32562ac0c33Sjakob
32662ac0c33Sjakob# Checks for typedefs, structures, and compiler characteristics.
327533110e2Sbrad# allow user to override the -g -O2 flags.
328533110e2Sbradif test "x$CFLAGS" = "x" ; then
329533110e2Sbrad	ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="$CFLAGS -g"])
330533110e2Sbrad	# we do not use O3 because it causes miscompilations.
331533110e2Sbrad	ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"])
332dd5b221eSsthen	ACX_CHECK_FLTO
333e3d8a0a5Ssthen	ACX_CHECK_PIE
334e3d8a0a5Ssthen	ACX_CHECK_RELRO_NOW
335533110e2Sbradfi
33662ac0c33SjakobAC_C_CONST
33762ac0c33SjakobAC_C_INLINE
33862ac0c33SjakobAC_TYPE_UID_T
33962ac0c33SjakobAC_TYPE_PID_T
34062ac0c33SjakobAC_TYPE_SIZE_T
34162ac0c33SjakobAC_TYPE_OFF_T
34262ac0c33Sjakob
34362ac0c33SjakobAC_CHECK_FORMAT_ATTRIBUTE
34462ac0c33SjakobAC_CHECK_UNUSED_ATTRIBUTE
345063644e9SflorianCHECK_WEAK_ATTRIBUTE
3464b6a9f59SflorianCHECK_NORETURN_ATTRIBUTE
3474ab91c82SjakobACX_CHECK_MEMCMP_SIGNED
34862ac0c33SjakobAC_CHECK_CTIME_R
34962ac0c33Sjakob
35062ac0c33Sjakob# Checks for libraries.
35162ac0c33Sjakob
35262ac0c33Sjakob# Check for SSL, original taken from
35362ac0c33Sjakob# http://www.gnu.org/software/ac-archive/htmldoc/check_ssl.html and
35462ac0c33Sjakob# modified for NSD.
35562ac0c33SjakobAC_DEFUN([CHECK_SSL], [
3568d298c9fSsthen    AC_ARG_WITH(ssl, AS_HELP_STRING([--with-ssl=pathname],[enable SSL (will check /usr/local/ssl
357308d2509Sflorian                /usr/lib/ssl /usr/ssl /usr/pkg /usr/sfw /usr/local /usr /usr/local/opt/openssl)]),[
35862ac0c33Sjakob        ],[
35962ac0c33Sjakob            withval="yes"
36062ac0c33Sjakob        ])
36162ac0c33Sjakob    if test x_$withval != x_no; then
36262ac0c33Sjakob        AC_MSG_CHECKING(for SSL)
363a904e103Sflorian	if test -n "$withval"; then
364a904e103Sflorian        	dnl look for openssl install with different version, eg.
365a904e103Sflorian                dnl in /usr/include/openssl11/openssl/ssl.h
366a904e103Sflorian                dnl and /usr/lib64/openssl11/libssl.so
367a904e103Sflorian                dnl with the --with-ssl=/usr/include/openssl11
368a904e103Sflorian                if test ! -f "$withval/include/openssl/ssl.h" -a -f "$withval/openssl/ssl.h"; then
369a904e103Sflorian                        ssldir="$withval"
370a904e103Sflorian                        found_ssl="yes"
371a904e103Sflorian                        withval=""
372a904e103Sflorian                        ssldir_include="$ssldir"
373a904e103Sflorian                        CPPFLAGS="$CPPFLAGS -I$ssldir_include";
374a904e103Sflorian                        dnl find the libdir
375a904e103Sflorian                        ssldir_lib=`echo $ssldir | sed -e 's/include/lib/'`
376a904e103Sflorian                        if test -f "$ssldir_lib/libssl.a" -o -f "$ssldir_lib/libssl.so"; then
377a904e103Sflorian                                : # found here
378a904e103Sflorian                        else
379a904e103Sflorian                                ssldir_lib=`echo $ssldir | sed -e 's/include/lib64/'`
380a904e103Sflorian                                if test -f "$ssldir_lib/libssl.a" -o -f "$ssldir_lib/libssl.so"; then
381a904e103Sflorian                                        : # found here
382a904e103Sflorian                                else
383a904e103Sflorian                                        AC_MSG_ERROR([Could not find openssl lib file, $ssldir_lib/libssl.[so,a], pass like "/usr/local" or "/usr/include/openssl11"])
384a904e103Sflorian                                fi
385a904e103Sflorian                        fi
386a904e103Sflorian                fi
387a904e103Sflorian	fi
38862ac0c33Sjakob        if test x_$withval = x_ -o x_$withval = x_yes; then
389308d2509Sflorian            withval="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/sfw /usr/local /usr /usr/local/opt/openssl"
39062ac0c33Sjakob        fi
39162ac0c33Sjakob        for dir in $withval; do
39262ac0c33Sjakob            ssldir="$dir"
39362ac0c33Sjakob            if test -f "$dir/include/openssl/ssl.h"; then
39462ac0c33Sjakob                found_ssl="yes";
395f72b2965Sjakob                if test x_$ssldir != x_/usr; then
39662ac0c33Sjakob                    CPPFLAGS="$CPPFLAGS -I$ssldir/include";
397f72b2965Sjakob                fi
398a904e103Sflorian		ssldir_include="$ssldir/include"
399a904e103Sflorian		if test ! -d "$ssldir/lib" -a -d "$ssldir/lib64"; then
400a904e103Sflorian			ssldir_lib="$ssldir/lib64"
401a904e103Sflorian		else
402a904e103Sflorian			ssldir_lib="$ssldir/lib"
403a904e103Sflorian		fi
40462ac0c33Sjakob                break;
40562ac0c33Sjakob            fi
40662ac0c33Sjakob        done
40762ac0c33Sjakob        if test x_$found_ssl != x_yes; then
4088d298c9fSsthen            AC_MSG_ERROR([Cannot find the SSL libraries in $withval])
40962ac0c33Sjakob        else
4108d298c9fSsthen            AC_MSG_RESULT([found in $ssldir])
41162ac0c33Sjakob            HAVE_SSL=yes
412a904e103Sflorian            AC_DEFINE_UNQUOTED([HAVE_SSL], [], [Define if you have the SSL libraries installed.])
413f72b2965Sjakob            if test x_$ssldir != x_/usr; then
414a904e103Sflorian                LDFLAGS="$LDFLAGS -L$ssldir_lib";
415f72b2965Sjakob            fi
41662ac0c33Sjakob	    if test x_$ssldir = x_/usr/sfw; then
417a904e103Sflorian		LDFLAGS="$LDFLAGS -R$ssldir_lib";
41862ac0c33Sjakob	    fi
41962ac0c33Sjakob        fi
42062ac0c33Sjakob        AC_SUBST(HAVE_SSL)
42162ac0c33Sjakob    fi
42262ac0c33Sjakob])dnl
42362ac0c33Sjakob
424dd5b221eSsthen# check for libevent
4258d298c9fSsthenAC_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.]),
426dd5b221eSsthen    [ ],[ withval="yes" ])
427dd5b221eSsthenif test x_$withval = x_yes -o x_$withval != x_no; then
428dd5b221eSsthen        AC_MSG_CHECKING(for libevent)
429dd5b221eSsthen        if test x_$withval = x_ -o x_$withval = x_yes; then
430308d2509Sflorian            withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr /usr/local/opt/libevent"
431dd5b221eSsthen        fi
432dd5b221eSsthen        for dir in $withval; do
433dd5b221eSsthen            thedir="$dir"
4345fab9a23Sbrad            if test -f "$dir/include/event.h" -o -f "$dir/include/event2/event.h"; then
435dd5b221eSsthen                found_libevent="yes"
436dd5b221eSsthen		dnl assume /usr is in default path.
437dd5b221eSsthen		if test "$thedir" != "/usr"; then
438dd5b221eSsthen                    CPPFLAGS="$CPPFLAGS -I$thedir/include"
439dd5b221eSsthen		fi
440dd5b221eSsthen                break;
441dd5b221eSsthen            fi
442dd5b221eSsthen        done
443dd5b221eSsthen        if test x_$found_libevent != x_yes; then
444dd5b221eSsthen		if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then
445dd5b221eSsthen			# libevent source directory
446dd5b221eSsthen            		AC_MSG_RESULT(found in $thedir)
447dd5b221eSsthen                	CPPFLAGS="$CPPFLAGS -I$thedir -I$thedir/include"
448dd5b221eSsthen			# remove evdns from linking
449308d2509Sflorian			ev_files_o=`ls $thedir/*.o | $GREP -v evdns\.o | $GREP -v bufferevent_openssl\.o`
450dd5b221eSsthen			cp $ev_files_o .
451dd5b221eSsthen			LDFLAGS="$ev_files_o $LDFLAGS -lm"
452dd5b221eSsthen		else
453dd5b221eSsthen            		AC_MSG_ERROR([Cannot find the libevent library.
454dd5b221eSsthenYou can restart ./configure --with-libevent=no to use a builtin alternative.])
455dd5b221eSsthen		fi
456dd5b221eSsthen        else
457dd5b221eSsthen            AC_MSG_RESULT(found in $thedir)
4585fab9a23Sbrad	    dnl if event2 exists and no event lib in dir itself, use subdir
4595fab9a23Sbrad	    if test ! -f $thedir/lib/libevent.a -a ! -f $thedir/lib/libevent.so -a -d "$thedir/lib/event2"; then
4605fab9a23Sbrad		LDFLAGS="$LDFLAGS -L$thedir/lib/event2"
4615fab9a23Sbrad		ACX_RUNTIME_PATH_ADD([$thedir/lib/event2])
4625fab9a23Sbrad	    else
463dd5b221eSsthen		    dnl assume /usr is in default path, do not add "".
464dd5b221eSsthen		    if test "$thedir" != "/usr" -a "$thedir" != ""; then
465dd5b221eSsthen			LDFLAGS="$LDFLAGS -L$thedir/lib"
466dd5b221eSsthen			ACX_RUNTIME_PATH_ADD([$thedir/lib])
467dd5b221eSsthen		    fi
468dd5b221eSsthen	    fi
4695fab9a23Sbrad        fi
470dd5b221eSsthen	# check for library used by libevent after 1.3c
471dd5b221eSsthen	AC_SEARCH_LIBS([clock_gettime], [rt])
472dd5b221eSsthen
473dd5b221eSsthen	# is the event.h header libev or libevent?
474dd5b221eSsthen	AC_CHECK_HEADERS([event.h],,, [AC_INCLUDES_DEFAULT])
475dd5b221eSsthen	AC_CHECK_DECL(EV_VERSION_MAJOR, [
476dd5b221eSsthen		AC_SEARCH_LIBS(event_set, [ev])
477dd5b221eSsthen	],[
478dd5b221eSsthen		AC_SEARCH_LIBS(event_set, [event])
479dd5b221eSsthen	],[AC_INCLUDES_DEFAULT
480dd5b221eSsthen#include <event.h>
481dd5b221eSsthen	])
482dd5b221eSsthen	AC_CHECK_FUNCS([event_base_free]) # only in libevent 1.2 and later
483dd5b221eSsthen	AC_CHECK_FUNCS([event_base_once]) # only in libevent 1.4.1 and later
484dd5b221eSsthen	AC_CHECK_FUNCS([event_base_new]) # only in libevent 1.4.1 and later
485dd5b221eSsthen	AC_CHECK_FUNCS([event_base_get_method]) # only in libevent 1.4.3 and later
486dd5b221eSsthen	AC_CHECK_FUNCS([ev_loop]) # only in libev. (tested on 3.51)
487dd5b221eSsthen	AC_CHECK_FUNCS([ev_default_loop]) # only in libev. (tested on 4.00)
488dd5b221eSsthenelse
489dd5b221eSsthen	AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events])
490dd5b221eSsthenfi
491dd5b221eSsthen
49262ac0c33Sjakob# Checks for header files.
49362ac0c33SjakobAC_HEADER_SYS_WAIT
4948d298c9fSsthenAC_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])
49562ac0c33Sjakob
49662ac0c33SjakobAC_DEFUN([CHECK_VALIST_DEF],
49762ac0c33Sjakob[
49862ac0c33SjakobAC_REQUIRE([AC_PROG_CC])
49962ac0c33SjakobAC_MSG_CHECKING(for double definition of struct va_list)
50062ac0c33SjakobAC_CACHE_VAL(ac_cv_c_va_list_def,
50162ac0c33Sjakob[
50262ac0c33Sjakobcat >conftest.c <<EOF
50362ac0c33Sjakob#include <stdio.h>
50462ac0c33Sjakob#include <stdarg.h>
50562ac0c33Sjakobint foo(void);
50662ac0c33SjakobEOF
50762ac0c33Sjakobif test -z "`$CC -Werror -D_XOPEN_SOURCE=600 -c conftest.c 2>&1`"; then
50862ac0c33Sjakobeval "ac_cv_c_va_list_def=no"
50962ac0c33Sjakobelse
51062ac0c33Sjakobeval "ac_cv_c_va_list_def=yes"
51162ac0c33Sjakobfi
51262ac0c33Sjakobrm -f conftest*
51362ac0c33Sjakob])
51462ac0c33Sjakobif test $ac_cv_c_va_list_def = yes; then
51562ac0c33SjakobAC_MSG_RESULT(yes)
51662ac0c33Sjakob:
51762ac0c33SjakobAC_DEFINE_UNQUOTED([HAVE_VA_LIST_DOUBLE_DEF], [], [Define this if you have double va_list definitions.])
51862ac0c33Sjakobelse
51962ac0c33SjakobAC_MSG_RESULT(no)
52062ac0c33Sjakob:
52162ac0c33Sjakob
52262ac0c33Sjakobfi
52362ac0c33Sjakob])
52462ac0c33Sjakob
52562ac0c33SjakobCHECK_VALIST_DEF
52662ac0c33Sjakob
52762ac0c33SjakobAC_DEFUN([AC_CHECK_STRPTIME],
52862ac0c33Sjakob[AC_REQUIRE([AC_PROG_CC])
52962ac0c33SjakobAC_MSG_CHECKING(whether strptime needs defines)
53062ac0c33SjakobAC_CACHE_VAL(ac_cv_c_strptime_needs_defs,
53162ac0c33Sjakob[
53262ac0c33Sjakobcat >conftest.c <<EOF
53362ac0c33Sjakob#include <time.h>
53461eb1089Ssthenint testing (void) { struct tm t; const char *timestr="201201"; return strptime(timestr, "%Y%m", &t) != 0; }
53562ac0c33SjakobEOF
53662ac0c33Sjakobif test -z "`$CC -Wall -Werror -c conftest.c 2>&1`"; then
53762ac0c33Sjakobeval "ac_cv_c_strptime_needs_defs=no"
53862ac0c33Sjakobelse
53962ac0c33Sjakobeval "ac_cv_c_strptime_needs_defs=yes"
54062ac0c33Sjakobfi
54162ac0c33Sjakobrm -f conftest*
54262ac0c33Sjakob])
54362ac0c33Sjakob
54462ac0c33SjakobAC_MSG_RESULT($ac_cv_c_strptime_needs_defs)
54562ac0c33Sjakobif test $ac_cv_c_strptime_needs_defs = yes; then
54662ac0c33SjakobAC_DEFINE_UNQUOTED([STRPTIME_NEEDS_DEFINES], 1, [strptime is available from time.h with some defines.])
54762ac0c33Sjakobfi
54862ac0c33Sjakob])dnl
54962ac0c33Sjakob
55062ac0c33SjakobAC_CHECK_STRPTIME
55162ac0c33Sjakob
55262ac0c33Sjakob# check wether strptime also works
55362ac0c33SjakobAC_DEFUN([AC_CHECK_STRPTIME_WORKS],
55462ac0c33Sjakob[AC_REQUIRE([AC_PROG_CC])
55562ac0c33SjakobAC_MSG_CHECKING(whether strptime works)
55662ac0c33Sjakobif test c${cross_compiling} = cno; then
557dd5b221eSsthenAC_RUN_IFELSE([AC_LANG_SOURCE([[
558533110e2Sbrad#define _XOPEN_SOURCE 600
55962ac0c33Sjakob#include <time.h>
56062ac0c33Sjakobint main(void) { struct tm tm; char *res;
56162ac0c33Sjakobres = strptime("20070207111842", "%Y%m%d%H%M%S", &tm);
56262ac0c33Sjakobif (!res) return 1; return 0; }
563b71395eaSflorian]])] , [eval "ac_cv_c_strptime_works=yes"], [eval "ac_cv_c_strptime_works=no"],
564b71395eaSflorian[eval "ac_cv_c_strptime_works=maybe"])
56562ac0c33Sjakobelse
56662ac0c33Sjakobeval "ac_cv_c_strptime_works=maybe"
56762ac0c33Sjakobfi
56862ac0c33SjakobAC_MSG_RESULT($ac_cv_c_strptime_works)
56962ac0c33Sjakobif test $ac_cv_c_strptime_works = no; then
57062ac0c33SjakobAC_LIBOBJ(strptime)
57162ac0c33Sjakobelse
57262ac0c33SjakobAC_DEFINE_UNQUOTED([STRPTIME_WORKS], 1, [use default strptime.])
57362ac0c33Sjakobfi
57462ac0c33Sjakob])dnl
57562ac0c33Sjakob
57662ac0c33SjakobAC_SEARCH_LIBS(inet_pton, [nsl])
57762ac0c33SjakobAC_SEARCH_LIBS(socket, [socket])
57862ac0c33Sjakob
5799c620270SsthenAC_CHECK_STRPTIME_WORKS
580dd5b221eSsthenACX_CHECK_NONBLOCKING_BROKEN
581dd5b221eSsthenACX_MKDIR_ONE_ARG
582dd5b221eSsthen
583dd5b221eSsthen# set -I. and -Isrcdir
584dd5b221eSsthenif test -n "$CPPFLAGS"; then
585dd5b221eSsthen	CPPFLAGS="$CPPFLAGS -I."
586dd5b221eSsthenelse
587dd5b221eSsthen	CPPFLAGS="-I."
588dd5b221eSsthenfi
589dd5b221eSsthenif test "$srcdir" != "."; then
590dd5b221eSsthen	CPPFLAGS="$CPPFLAGS -I$srcdir"
591a302926fSbrad	if test -f $srcdir/config.h; then
5928d298c9fSsthen		AC_MSG_ERROR([$srcdir/config.h is in the way, please remove it])
593a302926fSbrad	fi
594dd5b221eSsthenfi
5959c620270Ssthen
59662ac0c33Sjakobdnl LIBGTOP_CHECK_TYPE
59762ac0c33Sjakobdnl Stolen from Gnome's anjuta
59862ac0c33Sjakobdnl Improved version of AC_CHECK_TYPE which takes into account
59962ac0c33Sjakobdnl that we need to #include some other header files on some
60062ac0c33Sjakobdnl systems to get some types.
60162ac0c33Sjakob
60262ac0c33Sjakobdnl AC_LIBGTOP_CHECK_TYPE(TYPE, DEFAULT)
60362ac0c33SjakobAC_DEFUN([AC_LIBGTOP_CHECK_TYPE],
6048d298c9fSsthen[AC_MSG_CHECKING(for $1)
60562ac0c33SjakobAC_CACHE_VAL(ac_cv_type_$1,
60662ac0c33Sjakob[AC_EGREP_CPP(dnl
60762ac0c33Sjakobchangequote(<<,>>)dnl
60862ac0c33Sjakob<<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
60962ac0c33Sjakobchangequote([,]), [
61062ac0c33Sjakob#include <sys/types.h>
61162ac0c33Sjakob#include <stdlib.h>
61262ac0c33Sjakob#include <stddef.h>
61362ac0c33Sjakob
61462ac0c33Sjakob#ifdef HAVE_STDINT_H
61562ac0c33Sjakob#include <stdint.h>
61662ac0c33Sjakob#endif
61762ac0c33Sjakob
61862ac0c33Sjakob#ifdef HAVE_SYS_SOCKET_H
61962ac0c33Sjakob#include <sys/socket.h>
62062ac0c33Sjakob#endif
62162ac0c33Sjakob
62262ac0c33Sjakob#ifdef HAVE_ARPA_INET_H
62362ac0c33Sjakob#include <arpa/inet.h>
62462ac0c33Sjakob#endif
62562ac0c33Sjakob
62662ac0c33Sjakob#ifdef HAVE_SIGNAL_H
62762ac0c33Sjakob#include <signal.h>
62862ac0c33Sjakob#endif
62962ac0c33Sjakob
63062ac0c33Sjakob/* For Tru64 */
63162ac0c33Sjakob#ifdef HAVE_SYS_BITYPES_H
63262ac0c33Sjakob#include <sys/bitypes.h>
63362ac0c33Sjakob#endif
63462ac0c33Sjakob], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl
63562ac0c33SjakobAC_MSG_RESULT($ac_cv_type_$1)
63662ac0c33Sjakobif test $ac_cv_type_$1 = no; then
63762ac0c33Sjakob  AC_DEFINE($1, $2, Define "$1" to "$2" if "$1" is missing)
63862ac0c33Sjakobfi
63962ac0c33Sjakob])
64062ac0c33Sjakob
64162ac0c33SjakobAC_LIBGTOP_CHECK_TYPE(int8_t, char)
64262ac0c33SjakobAC_LIBGTOP_CHECK_TYPE(int16_t, short)
64362ac0c33SjakobAC_LIBGTOP_CHECK_TYPE(int32_t, int)
64462ac0c33SjakobAC_LIBGTOP_CHECK_TYPE(int64_t, long long)
64562ac0c33SjakobAC_LIBGTOP_CHECK_TYPE(uint8_t, unsigned char)
64662ac0c33SjakobAC_LIBGTOP_CHECK_TYPE(uint16_t, unsigned short)
64762ac0c33SjakobAC_LIBGTOP_CHECK_TYPE(uint32_t, unsigned int)
64862ac0c33SjakobAC_LIBGTOP_CHECK_TYPE(uint64_t, unsigned long long)
64962ac0c33SjakobAC_LIBGTOP_CHECK_TYPE(socklen_t, int)
65062ac0c33SjakobAC_LIBGTOP_CHECK_TYPE(sig_atomic_t, int)
65162ac0c33SjakobAC_LIBGTOP_CHECK_TYPE(ssize_t, int)
652c3fd4e2aSjakobAC_LIBGTOP_CHECK_TYPE(suseconds_t, time_t)
65362ac0c33Sjakob
65462ac0c33SjakobAC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [
65562ac0c33Sjakob#if HAVE_SYS_TYPES_H
65662ac0c33Sjakob# include <sys/types.h>
65762ac0c33Sjakob#endif
65862ac0c33Sjakob#if HAVE_NETINET_IN_H
65962ac0c33Sjakob# include <netinet/in.h>
66062ac0c33Sjakob#endif])
661c3fd4e2aSjakobACX_CHECK_SS_FAMILY
662275a8d89SflorianAC_CHECK_MEMBERS([struct stat.st_mtimensec, struct stat.st_mtim.tv_nsec])
66318e77612SflorianAC_CHECK_MEMBERS([struct sockaddr_un.sun_len],,,[
66418e77612SflorianAC_INCLUDES_DEFAULT
66518e77612Sflorian#ifdef HAVE_SYS_UN_H
66618e77612Sflorian#include <sys/un.h>
66718e77612Sflorian#endif
66818e77612Sflorian])
66962ac0c33Sjakob
67062ac0c33Sjakob# Checks for library functions.
67162ac0c33SjakobAC_FUNC_CHOWN
67262ac0c33SjakobAC_FUNC_FORK
67362ac0c33SjakobAC_FUNC_MALLOC
6748d298c9fSsthenAC_DEFINE(RETSIGTYPE,void,[Return type of signal handlers, but autoconf 2.70 says 'your code may safely assume C89 semantics that RETSIGTYPE is void.'])
67562ac0c33SjakobAC_FUNC_FSEEKO
67662ac0c33SjakobAC_SYS_LARGEFILE
677dd5b221eSsthenAC_CHECK_SIZEOF(void*)
678dd5b221eSsthenAC_CHECK_SIZEOF(off_t)
679308d2509SflorianAC_CHECK_FUNCS([getrandom arc4random arc4random_uniform])
6808d298c9fSsthenAC_SEARCH_LIBS([setusercontext],[util],[AC_CHECK_HEADERS([login_cap.h],,, [AC_INCLUDES_DEFAULT])])
6813b24e79eSsthenAC_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])
682dd5b221eSsthen
6835435475dSsthenAC_CHECK_TYPE([struct mmsghdr], AC_DEFINE(HAVE_MMSGHDR, 1, [If sys/socket.h has a struct mmsghdr.]), [], [
6845435475dSsthenAC_INCLUDES_DEFAULT
6855435475dSsthen#include <sys/socket.h>
6865435475dSsthen])
6875435475dSsthen
6888d298c9fSsthenAC_ARG_ENABLE(recvmmsg, AS_HELP_STRING([--enable-recvmmsg],[Enable recvmmsg and sendmmsg compilation, faster but some kernel versions may have implementation problems for IPv6]))
689dd5b221eSsthencase "$enable_recvmmsg" in
6905fab9a23Sbrad        yes)
691dd5b221eSsthen		AC_CHECK_FUNC([recvmmsg], [
692dd5b221eSsthenAC_RUN_IFELSE([AC_LANG_SOURCE([[
6933efee2e1Sflorian#ifdef HAVE_UNISTD_H
6943efee2e1Sflorian#include <unistd.h>
6953efee2e1Sflorian#endif
696dd5b221eSsthen#include <sys/socket.h>
697dd5b221eSsthen#include <errno.h>
698dd5b221eSsthenint main(void)
699dd5b221eSsthen{
700dd5b221eSsthen	int s = socket(AF_INET, SOCK_DGRAM, 0);
701dd5b221eSsthen	int r = recvmmsg(s, 0, 0, 0, 0) == -1 && errno == ENOSYS;
702dd5b221eSsthen	close(s);
703dd5b221eSsthen	return r;
704dd5b221eSsthen}
705dd5b221eSsthen]])], [
706dd5b221eSsthenAC_DEFINE([HAVE_RECVMMSG], [1], [Define if recvmmsg is implemented])], [
707dd5b221eSsthen], [
708dd5b221eSsthenAC_DEFINE([HAVE_RECVMMSG], [1], [Define if recvmmsg exists])]
709dd5b221eSsthen)])
710dd5b221eSsthen		AC_CHECK_FUNC([sendmmsg], [
711dd5b221eSsthenAC_RUN_IFELSE([AC_LANG_SOURCE([[
7123efee2e1Sflorian#ifdef HAVE_UNISTD_H
7133efee2e1Sflorian#include <unistd.h>
7143efee2e1Sflorian#endif
715dd5b221eSsthen#include <sys/socket.h>
716dd5b221eSsthen#include <errno.h>
717dd5b221eSsthenint main(void)
718dd5b221eSsthen{
719dd5b221eSsthen	int s = socket(AF_INET, SOCK_DGRAM, 0);
720dd5b221eSsthen	int r = sendmmsg(s, 0, 0, 0) == -1 && errno == ENOSYS;
721dd5b221eSsthen	close(s);
722dd5b221eSsthen	return r;
723dd5b221eSsthen}
724dd5b221eSsthen]])], [
725dd5b221eSsthenAC_DEFINE([HAVE_SENDMMSG], [1], [Define if sendmmsg is implemented])], [
726dd5b221eSsthen], [
727dd5b221eSsthenAC_DEFINE([HAVE_SENDMMSG], [1], [Define if sendmmsg exists])]
728dd5b221eSsthen)])
729dd5b221eSsthen
730dd5b221eSsthen		;;
7315fab9a23Sbrad        no|*)
7325fab9a23Sbrad                ;;
733dd5b221eSsthenesac
73462ac0c33Sjakob
73562ac0c33Sjakob# check if setreuid en setregid fail, on MacOSX10.4(darwin8).
736308d2509Sflorianif echo $target_os | $GREP -i darwin8 > /dev/null; then
73762ac0c33Sjakob	AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work])
73862ac0c33Sjakobfi
73962ac0c33Sjakob
740308d2509Sflorian# GNU HURD needs _GNU_SOURCE defined for cpu affinity gear
741308d2509Sflorianif echo $target_os | $EGREP -i 'linux|hurd' > /dev/null; then
742308d2509Sflorian  AC_DEFINE([_GNU_SOURCE, 1, [Define this if on Linux or GNU Hurd for cpu affinity interface]])
743308d2509Sflorianfi
744308d2509Sflorian
745308d2509Sflorian# see comment on _GNU_SOURCE above
7468d298c9fSsthenAC_CHECK_HEADERS([sched.h sys/cpuset.h],,, [AC_INCLUDES_DEFAULT])
747308d2509Sflorian
748308d2509Sflorian# Check for cpu_set_t (Linux) and cpuset_t (FreeBSD and NetBSD)
749308d2509SflorianAC_CHECK_TYPES([cpu_set_t, cpuset_t, cpuid_t],,,[
750308d2509SflorianAC_INCLUDES_DEFAULT
751308d2509Sflorian#if HAVE_SCHED_H
752308d2509Sflorian# include <sched.h>
753308d2509Sflorian#endif
754308d2509Sflorian#if HAVE_SYS_CPUSET_H
755308d2509Sflorian# include <sys/cpuset.h>
756308d2509Sflorian#endif
757308d2509Sflorian])
758308d2509Sflorian
759308d2509SflorianAC_DEFUN([AC_CHECK_CPU_OR],
760308d2509Sflorian[AC_REQUIRE([AC_PROG_CC])
761308d2509SflorianAC_MSG_CHECKING(whether CPU_OR works with three arguments)
7628d298c9fSsthenAC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef HAVE_SCHED_H
763308d2509Sflorian# include <sched.h>
764308d2509Sflorian#endif
765308d2509Sflorian#ifdef HAVE_SYS_CPUSET_H
766308d2509Sflorian# include <sys/cpuset.h>
767308d2509Sflorian#endif
768308d2509Sflorian#include <string.h>
769308d2509Sflorian#ifdef HAVE_CPUSET_T
770308d2509Sflorian#define MY_CPUSET_TYPE cpuset_t
771308d2509Sflorian#endif
772308d2509Sflorian#ifdef HAVE_CPU_SET_T
773308d2509Sflorian#define MY_CPUSET_TYPE cpu_set_t
774308d2509Sflorian#endif
775308d2509Sflorianvoid testing (void) {
776308d2509Sflorian	MY_CPUSET_TYPE a, b;
777308d2509Sflorian	memset(&a, 0, sizeof(a));
778308d2509Sflorian	memset(&b, 0, sizeof(b));
779308d2509Sflorian	CPU_OR(&a, &a, &b);
7808d298c9fSsthen}]], [[
781308d2509Sflorian        testing();
7828d298c9fSsthen]])],[
783308d2509Sflorian	AC_MSG_RESULT(yes)
784308d2509Sflorian	AC_DEFINE([CPU_OR_THREE_ARGS], 1, [number of arguments for CPU_OR is three])
785308d2509Sflorian],[
786308d2509Sflorian	AC_MSG_RESULT(no)
787308d2509Sflorian])])
788308d2509Sflorian
789308d2509SflorianAS_IF([test x"$ac_cv_type_cpuset_t" = xyes -o x"$ac_cv_type_cpu_set_t" = xyes ],[
790308d2509Sflorian	AC_CHECK_FUNC(cpuset_create)
791308d2509Sflorian	AC_CHECK_FUNC(cpuset_destroy)
792308d2509Sflorian	AC_CHECK_FUNC(cpuset_zero)
793308d2509Sflorian	AC_CHECK_FUNC(cpuset_set)
794308d2509Sflorian	AC_CHECK_FUNC(cpuset_clr)
795308d2509Sflorian	AC_CHECK_FUNC(cpuset_isset)
796308d2509Sflorian	AC_CHECK_FUNC(cpuset_size)
797308d2509Sflorian	AC_LIBOBJ(cpuset)
798308d2509Sflorian	AC_CHECK_FUNCS([sysconf])
799308d2509Sflorian	AC_CHECK_CPU_OR
800308d2509Sflorian])
801308d2509Sflorian
802308d2509Sflorian#
803308d2509Sflorian# sched_setaffinity must be checked using proper includes.
804308d2509Sflorian# also needs _GNU_SOURCE on Linux and Hurd; see above.
805308d2509Sflorian# also see https://github.com/NLnetLabs/nsd/issues/82.
806308d2509Sflorian#
807308d2509SflorianAC_MSG_CHECKING(for sched_setaffinity)
808308d2509SflorianAC_COMPILE_IFELSE([AC_LANG_PROGRAM(
809308d2509Sflorian  [[
810308d2509Sflorian    #ifdef HAVE_SCHED_H
811308d2509Sflorian    # include <sched.h>
812308d2509Sflorian    #endif
813308d2509Sflorian    #ifdef HAVE_SYS_CPUSET_H
814308d2509Sflorian    #include <sys/cpuset.h>
815308d2509Sflorian    #endif
816308d2509Sflorian    #ifdef HAVE_CPUSET_T
817308d2509Sflorian    #define MY_CPUSET_TYPE cpuset_t
818308d2509Sflorian    #endif
819308d2509Sflorian    #ifdef HAVE_CPU_SET_T
820308d2509Sflorian    #define MY_CPUSET_TYPE cpu_set_t
821308d2509Sflorian    #endif
822308d2509Sflorian    void testing (void) {
823308d2509Sflorian      MY_CPUSET_TYPE set;
824308d2509Sflorian      CPU_ZERO(&set);
825308d2509Sflorian      (void)sched_setaffinity(-1, sizeof(set), &set);
826308d2509Sflorian    }
827308d2509Sflorian]])],
828308d2509Sflorian[  AC_MSG_RESULT(yes)
829308d2509Sflorian   AC_DEFINE(HAVE_SCHED_SETAFFINITY, 1, [Define this if sched_setaffinity is available])],
830308d2509Sflorian[  AC_MSG_RESULT(no)])
831308d2509Sflorian
83262ac0c33Sjakob#
83362ac0c33Sjakob# Checking for missing functions we can replace
83462ac0c33Sjakob#
83562ac0c33SjakobAC_REPLACE_FUNCS(basename)
83662ac0c33SjakobAC_REPLACE_FUNCS(inet_aton)
83762ac0c33SjakobAC_REPLACE_FUNCS(inet_pton)
83862ac0c33SjakobAC_REPLACE_FUNCS(inet_ntop)
83962ac0c33SjakobAC_REPLACE_FUNCS(snprintf)
8404ab91c82SjakobAC_REPLACE_FUNCS(strlcat)
84162ac0c33SjakobAC_REPLACE_FUNCS(strlcpy)
84262ac0c33SjakobAC_REPLACE_FUNCS(strptime)
84362ac0c33SjakobAC_REPLACE_FUNCS(pselect)
84462ac0c33SjakobAC_REPLACE_FUNCS(memmove)
845308d2509SflorianAC_REPLACE_FUNCS(setproctitle)
846063644e9SflorianAC_REPLACE_FUNCS(explicit_bzero)
847eab1363eSsthenAC_MSG_CHECKING([for reallocarray])
848308d2509SflorianAC_LINK_IFELSE([AC_LANG_SOURCE(
849eab1363eSsthen[[
850eab1363eSsthen#ifndef _OPENBSD_SOURCE
851eab1363eSsthen#define _OPENBSD_SOURCE 1
852eab1363eSsthen#endif
853308d2509Sflorian]]
854308d2509SflorianAC_INCLUDES_DEFAULT
855308d2509Sflorian[[
856eab1363eSsthen#include <stdlib.h>
857eab1363eSsthenint main(void) {
858eab1363eSsthen	void* p = reallocarray(NULL, 10, 100);
859eab1363eSsthen	free(p);
860eab1363eSsthen	return 0;
861eab1363eSsthen}
862eab1363eSsthen]])], [AC_MSG_RESULT(yes)
863eab1363eSsthen	AC_DEFINE(HAVE_REALLOCARRAY, 1, [If we have reallocarray(3)])
864308d2509Sflorian	AC_CHECK_DECLS([reallocarray], [], [
865308d2509Sflorian		AC_DEFINE(REALLOCARRAY_NEEDS_DEFINES, 1, [If reallocarray needs defines to appear in the headers])
866308d2509Sflorian	], [
867308d2509SflorianAC_INCLUDES_DEFAULT
868308d2509Sflorian#include <stdlib.h>
869308d2509Sflorian	])
870eab1363eSsthen], [
871eab1363eSsthen	AC_MSG_RESULT(no)
872eab1363eSsthen	AC_LIBOBJ(reallocarray)
873eab1363eSsthen])
87462ac0c33Sjakob
87572628ec9Ssthen#
87672628ec9Ssthen# Check for b64_ntop (and assume result applies to b64_pton as well).
87772628ec9Ssthen# The functions are actually prefixed with __ and resolv.h defines
87872628ec9Ssthen# macros for the unprefixed versions, however including this header
87972628ec9Ssthen# causes conflicts with our T_xx defines.
88072628ec9Ssthen#
88172628ec9SsthenAC_MSG_CHECKING(for __b64_ntop)
882*4c4bdeb8SflorianAC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>]], [[__b64_ntop(NULL, 0, NULL, 0);]])],[found_b64_ntop=yes],[found_b64_ntop=no
883*4c4bdeb8Sflorian])
88472628ec9Ssthenif test "x$found_b64_ntop" = xno; then
88572628ec9Ssthen	AC_MSG_RESULT(no)
88672628ec9Ssthen
88772628ec9Ssthen	AC_MSG_CHECKING(for __b64_ntop with -lresolv)
88872628ec9Ssthen	LIBS="$LIBS -lresolv"
889*4c4bdeb8Sflorian	AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>]], [[__b64_ntop(NULL, 0, NULL, 0);]])],[found_b64_ntop=yes],[found_b64_ntop=no
890*4c4bdeb8Sflorian	])
89172628ec9Ssthen	if test "x$found_b64_ntop" = xno; then
89272628ec9Ssthen		AC_MSG_RESULT(no)
89372628ec9Ssthen	fi
89472628ec9Ssthenfi
89572628ec9Ssthenif test "x$found_b64_ntop" = xyes; then
896c58791a6Smillert	AC_DEFINE(HAVE_B64_NTOP, 1, [Define to 1 if you have the `b64_ntop' function.])
897c58791a6Smillert	AC_DEFINE(HAVE_B64_PTON, 1, [Define to 1 if you have the `b64_pton' function.])
89872628ec9Ssthen	AC_MSG_RESULT(yes)
89972628ec9Ssthenelse
90072628ec9Ssthen	AC_LIBOBJ([b64_ntop])
90172628ec9Ssthen	AC_LIBOBJ([b64_pton])
90272628ec9Ssthenfi
90372628ec9Ssthen
90462ac0c33SjakobAC_MSG_CHECKING(for pselect prototype in sys/select.h)
90562ac0c33SjakobAC_EGREP_HEADER([[^a-zA-Z_]*pselect[^a-zA-Z_]], sys/select.h, AC_DEFINE(HAVE_PSELECT_PROTO, 1,
90662ac0c33Sjakob	[if sys/select.h provides pselect prototype]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
90762ac0c33Sjakob
90862ac0c33SjakobAC_MSG_CHECKING(for ctime_r prototype in time.h)
90962ac0c33SjakobAC_EGREP_HEADER([[^a-zA-Z_]*ctime_r[^a-zA-Z_]], time.h, AC_DEFINE(HAVE_CTIME_R_PROTO, 1,
91062ac0c33Sjakob	[if time.h provides ctime_r prototype]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
91162ac0c33Sjakob
91262ac0c33SjakobAC_CHECK_TYPE([struct timespec], AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1, [If time.h has a struct timespec (for pselect).]), [], [
91362ac0c33SjakobAC_INCLUDES_DEFAULT
91462ac0c33Sjakob#ifdef HAVE_SIGNAL_H
91562ac0c33Sjakob#include <signal.h>
91662ac0c33Sjakob#endif
91762ac0c33Sjakob#ifdef HAVE_TIME_H
91862ac0c33Sjakob#include <time.h>
91962ac0c33Sjakob#endif
92062ac0c33Sjakob])
92162ac0c33Sjakob
92262ac0c33Sjakobdnl
92362ac0c33Sjakobdnl Some random defines's
92462ac0c33Sjakobdnl
92562ac0c33SjakobAC_DEFINE_UNQUOTED([IDENTITY], ["unidentified server"], [Define to the default nsd identity.])
92662ac0c33SjakobAC_DEFINE_UNQUOTED([VERSION], [PACKAGE_STRING], [Define to the NSD version to answer version.server query.])
927dd5b221eSsthenAC_DEFINE_UNQUOTED([TCP_BACKLOG], [256], [Define to the backlog to be used with listen.])
92862ac0c33SjakobAC_DEFINE_UNQUOTED([TCP_PORT], ["53"], [Define to the default tcp port.])
92962ac0c33SjakobAC_DEFINE_UNQUOTED([TCP_MAX_MESSAGE_LEN], [65535], [Define to the default maximum message length.])
93062ac0c33SjakobAC_DEFINE_UNQUOTED([UDP_PORT], ["53"], [Define to the default udp port.])
93162ac0c33SjakobAC_DEFINE_UNQUOTED([UDP_MAX_MESSAGE_LEN], [512], [Define to the default maximum udp message length.])
9323b24e79eSsthenAC_DEFINE_UNQUOTED([EDNS_MAX_MESSAGE_LEN], [1232], [Define to the default maximum message length with EDNS.])
933eab1363eSsthenAC_DEFINE_UNQUOTED([TLS_PORT], ["853"], [Define to the default DNS over TLS port.])
93462ac0c33SjakobAC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [512], [Define to the maximum message length to pass to syslog.])
935dd5b221eSsthenAC_DEFINE_UNQUOTED([NSD_CONTROL_PORT], [8952], [Define to the default nsd-control port.])
936dd5b221eSsthenAC_DEFINE_UNQUOTED([NSD_CONTROL_VERSION], [1], [Define to nsd-control proto version.])
9373f21e8ccSflorianAC_DEFINE_UNQUOTED([VERIFY_PORT], ["5347"], [Define to the default zone verification udp port.])
93862ac0c33Sjakob
93962ac0c33Sjakobdnl
94062ac0c33Sjakobdnl Determine the syslog facility to use
94162ac0c33Sjakobdnl
94262ac0c33Sjakobfacility=LOG_DAEMON
94362ac0c33SjakobAC_ARG_WITH([facility],
9448d298c9fSsthen        AS_HELP_STRING([--with-facility=name],[Syslog default facility (LOG_DAEMON)]),
94562ac0c33Sjakob        [facility=$withval])
94662ac0c33SjakobAC_DEFINE_UNQUOTED([FACILITY], $facility, [Define to the default facility for syslog.])
94762ac0c33Sjakob
94862ac0c33Sjakobdnl
94962ac0c33Sjakobdnl Determine the default tcp timeout
95062ac0c33Sjakobdnl
95162ac0c33Sjakobtcp_timeout=120
95262ac0c33SjakobAC_ARG_WITH([tcp_timeout],
9538d298c9fSsthen	AS_HELP_STRING([--with-tcp-timeout=number],[Limit the default tcp timeout]),
95462ac0c33Sjakob	[tcp_timeout=$withval])
95562ac0c33SjakobAC_DEFINE_UNQUOTED([TCP_TIMEOUT], $tcp_timeout, [Define to the default tcp timeout.])
95662ac0c33Sjakob
95762ac0c33Sjakobdnl
95862ac0c33Sjakobdnl Features
95962ac0c33Sjakobdnl
9603efee2e1SflorianAC_ARG_ENABLE(root-server, AS_HELP_STRING([--enable-root-server],[Configure NSD as a root server (obsolete)]))
96162ac0c33Sjakob
9628d298c9fSsthenAC_ARG_ENABLE(ipv6, AS_HELP_STRING([--disable-ipv6],[Disables IPv6 support]))
96362ac0c33Sjakobcase "$enable_ipv6" in
96462ac0c33Sjakob        no)
96562ac0c33Sjakob                ;;
96662ac0c33Sjakob        yes|*)
96762ac0c33Sjakob		AC_DEFINE_UNQUOTED([INET6], [], [Define this to enable IPv6 support.])
96862ac0c33Sjakob		;;
96962ac0c33Sjakobesac
97062ac0c33Sjakob
9718d298c9fSsthenAC_ARG_ENABLE(bind8-stats, AS_HELP_STRING([--enable-bind8-stats],[Enables BIND8 like NSTATS & XSTATS and statistics in nsd-control]))
97262ac0c33Sjakob
97362ac0c33Sjakobcase "$enable_bind8_stats" in
97462ac0c33Sjakob	yes|'')
97562ac0c33Sjakob		AC_DEFINE_UNQUOTED([BIND8_STATS], [], [Define this to enable BIND8 like NSTATS & XSTATS.])
97662ac0c33Sjakob		;;
97762ac0c33Sjakob	no|*)
97862ac0c33Sjakob		;;
97962ac0c33Sjakobesac
98062ac0c33Sjakob
9818d298c9fSsthenAC_ARG_ENABLE(zone-stats, AS_HELP_STRING([--enable-zone-stats],[Enable per-zone statistics gathering (needs --enable-bind8-stats)]))
982c1404d4fSbradcase "$enable_zone_stats" in
983c1404d4fSbrad	yes)
984c1404d4fSbrad		AC_DEFINE_UNQUOTED([USE_ZONE_STATS], [], [Define this to enable per-zone statistics gathering.])
985c1404d4fSbrad		AC_DEFINE_UNQUOTED([BIND8_STATS], [], [Define this to enable BIND8 like NSTATS & XSTATS.])
986c1404d4fSbrad		;;
987c1404d4fSbrad	no|''|*)
988c1404d4fSbrad		;;
989c1404d4fSbradesac
990c1404d4fSbrad
9918d298c9fSsthenAC_ARG_ENABLE(checking, AS_HELP_STRING([--enable-checking],[Enable internal runtime checks]))
99262ac0c33Sjakobcase "$enable_checking" in
99362ac0c33Sjakob        yes)
99462ac0c33Sjakob		CHECK_COMPILER_FLAG(W, [ CFLAGS="$CFLAGS -W" ])
99562ac0c33Sjakob		CHECK_COMPILER_FLAG(Wall, [ CFLAGS="$CFLAGS -Wall" ])
99662ac0c33Sjakob		CHECK_COMPILER_FLAG(Wextra, [ CFLAGS="$CFLAGS -Wextra" ])
99775343be4Ssthen		CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [ CFLAGS="$CFLAGS -Wdeclaration-after-statement" ])
99862ac0c33Sjakob		;;
99962ac0c33Sjakob        no|*)
100062ac0c33Sjakob                AC_DEFINE([NDEBUG], [], [Undefine this to enable internal runtime checks.])
100162ac0c33Sjakob                ;;
100262ac0c33Sjakobesac
100362ac0c33Sjakob
1004bf87c3c0SflorianAC_ARG_ENABLE(log-role, AS_HELP_STRING([--enable-log-role],[Shows the role of processes in the logfile (enable this only for debugging purposes)]))
1005bf87c3c0Sfloriancase "$enable_log_role" in
1006bf87c3c0Sflorian        yes)
1007bf87c3c0Sflorian		AC_DEFINE_UNQUOTED([USE_LOG_PROCESS_ROLE], [], [Define this to show the role of processes in the logfile for debugging purposes.])
1008bf87c3c0Sflorian		;;
1009bf87c3c0Sflorian        no|*)
1010bf87c3c0Sflorian                ;;
1011bf87c3c0Sflorianesac
1012bf87c3c0Sflorian
1013bf87c3c0Sflorian
10148d298c9fSsthenAC_ARG_ENABLE(memclean, AS_HELP_STRING([--enable-memclean],[Cleanup memory (at exit) for eg. valgrind, memcheck]))
1015b90bb40eSsthenif test "$enable_memclean" = "yes"; then AC_DEFINE_UNQUOTED([MEMCLEAN], [1], [Define this to cleanup memory at exit (eg. for valgrind, etc.)])
1016b90bb40eSsthenfi
1017b90bb40eSsthen
10188d298c9fSsthenAC_ARG_ENABLE(ratelimit, AS_HELP_STRING([--enable-ratelimit],[Enable rate limiting]))
101975343be4Ssthencase "$enable_ratelimit" in
102075343be4Ssthen	yes)
102175343be4Ssthen		AC_DEFINE_UNQUOTED([RATELIMIT], [], [Define this to enable rate limiting.])
102275343be4Ssthen		dnl causes awk to not match the exclusion start marker.
102375343be4Ssthen		ratelimit="xx"
102475343be4Ssthen		;;
102575343be4Ssthen	no|*)
102675343be4Ssthen		ratelimit=""
102775343be4Ssthen		;;
102875343be4Ssthenesac
102975343be4SsthenAC_SUBST(ratelimit)
103075343be4Ssthen
10318d298c9fSsthenAC_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]))
10323126abd5Ssthencase "$enable_ratelimit_default_is_off" in
10333126abd5Ssthen	yes)
10343126abd5Ssthen		AC_DEFINE_UNQUOTED([RATELIMIT_DEFAULT_OFF], [], [Define this to set ratelimit to off by default.])
10353126abd5Ssthen		ratelimit_default="off"
10363126abd5Ssthen		;;
10373126abd5Ssthen	no|*)
10383126abd5Ssthen		ratelimit_default="on"
10393126abd5Ssthen		;;
10403126abd5Ssthenesac
10413126abd5SsthenAC_SUBST(ratelimit_default)
10423126abd5Ssthen
1043c3fd4e2aSjakob# we need SSL for TSIG (and maybe also for NSEC3).
104462ac0c33SjakobCHECK_SSL
1045dd5b221eSsthenif test x$HAVE_SSL = x"yes"; then
1046dd5b221eSsthen	ACX_LIB_SSL
10473b24e79eSsthen	# remove space after -ldl if there.
10483b24e79eSsthen	LIBS=`echo "$LIBS" | sed -e 's/ $//'`
1049275a8d89Sflorian
1050275a8d89Sflorian	# Check for -pthread
1051275a8d89Sflorian	BAKLIBS="$LIBS"
1052275a8d89Sflorian	LIBS="-lcrypto $LIBS"
10538d298c9fSsthen	AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
10543b24e79eSsthen		int EVP_sha256(void);
10553b24e79eSsthen		(void)EVP_sha256();
10568d298c9fSsthen	]])],[],[
10573b24e79eSsthen		dnl so link fails for EVP_sha256, try with -pthread.
1058275a8d89Sflorian		BAKCFLAGS="$CFLAGS"
1059275a8d89Sflorian		CFLAGS="$CFLAGS -pthread"
1060275a8d89Sflorian		AC_MSG_CHECKING([if libcrypto needs -pthread])
10613b24e79eSsthen		AC_TRY_LINK_FUNC([EVP_sha256], [
1062275a8d89Sflorian			AC_MSG_RESULT([yes])
1063275a8d89Sflorian		] , [
1064275a8d89Sflorian			AC_MSG_RESULT([no])
1065275a8d89Sflorian			dnl restore the nonpthread value
1066275a8d89Sflorian			CFLAGS="$BAKCFLAGS"
1067275a8d89Sflorian		])
1068275a8d89Sflorian	])
1069275a8d89Sflorian	LIBS="$BAKLIBS"
1070275a8d89Sflorian
10713126abd5Ssthen	if test -n "$ssldir"; then
10723b24e79eSsthen            AC_CHECK_LIB(crypto, EVP_sha256,, [
10733126abd5Ssthen                    AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required])
10743126abd5Ssthen                ])
10753126abd5Ssthen	fi
1076dd5b221eSsthen	SSL_LIBS="-lssl"
1077dd5b221eSsthen	AC_SUBST(SSL_LIBS)
10783b24e79eSsthen	AC_CHECK_HEADERS([openssl/ssl.h openssl/err.h openssl/rand.h openssl/ocsp.h openssl/core_names.h],,, [AC_INCLUDES_DEFAULT])
1079a904e103Sflorian	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])
1080a904e103Sflorian	if test "$ac_cv_func_SHA1_Init" = "yes"; then
1081a904e103Sflorian		ACX_FUNC_DEPRECATED([SHA1_Init], [(void)SHA1_Init(NULL);], [
1082a904e103Sflorian#include <openssl/sha.h>
1083a904e103Sflorian])
1084a904e103Sflorian	fi
1085eab1363eSsthen	AC_CHECK_DECLS([SSL_CTX_set_ecdh_auto,SSL_CTX_set_tmp_ecdh], [], [], [
1086eab1363eSsthenAC_INCLUDES_DEFAULT
1087eab1363eSsthen#ifdef HAVE_OPENSSL_ERR_H
1088eab1363eSsthen#include <openssl/err.h>
1089eab1363eSsthen#endif
1090eab1363eSsthen
1091eab1363eSsthen#ifdef HAVE_OPENSSL_RAND_H
1092eab1363eSsthen#include <openssl/rand.h>
1093eab1363eSsthen#endif
1094eab1363eSsthen
1095eab1363eSsthen#ifdef HAVE_OPENSSL_CONF_H
1096eab1363eSsthen#include <openssl/conf.h>
1097eab1363eSsthen#endif
1098eab1363eSsthen
1099eab1363eSsthen#ifdef HAVE_OPENSSL_ENGINE_H
1100eab1363eSsthen#include <openssl/engine.h>
1101eab1363eSsthen#endif
1102eab1363eSsthen#include <openssl/ssl.h>
1103eab1363eSsthen#include <openssl/evp.h>
1104eab1363eSsthen])
1105063644e9Sflorian	AC_CHECK_DECL([TLS1_3_VERSION],
1106063644e9Sflorian		[AC_DEFINE([HAVE_TLS_1_3], [1], [Define if TLS 1.3 is supported by OpenSSL])],
1107063644e9Sflorian		[AC_MSG_WARN([No TLS 1.3, therefore XFR-over-TLS is disabled])], [[#include <openssl/ssl.h>]])
1108c1e73312Sflorian
1109c1e73312Sflorian	BAKLIBS="$LIBS"
1110c1e73312Sflorian	LIBS="-lssl $LIBS"
1111a904e103Sflorian	AC_CHECK_FUNCS([OPENSSL_init_ssl SSL_get1_peer_certificate SSL_CTX_set_security_level ERR_load_SSL_strings])
1112a904e103Sflorian	if test "$ac_cv_func_ERR_load_SSL_strings" = "yes"; then
1113a904e103Sflorian		ACX_FUNC_DEPRECATED([ERR_load_SSL_strings], [(void)ERR_load_SSL_strings();], [
1114a904e103Sflorian#include <openssl/ssl.h>
1115a904e103Sflorian])
1116a904e103Sflorian	fi
1117c1e73312Sflorian	LIBS="$BAKLIBS"
1118c1e73312Sflorian
1119dd5b221eSsthenelse
1120eab1363eSsthen	AC_MSG_WARN([No SSL, therefore TLS is disabled])
1121dd5b221eSsthenfi
112262ac0c33Sjakob
11238d298c9fSsthenAC_ARG_ENABLE(nsec3, AS_HELP_STRING([--disable-nsec3],[Disable NSEC3 support]))
112462ac0c33Sjakobcase "$enable_nsec3" in
112562ac0c33Sjakob        no)
112662ac0c33Sjakob		;;
1127dd5b221eSsthen        yes)
112862ac0c33Sjakob		AC_DEFINE_UNQUOTED([NSEC3], [], [Define this to enable NSEC3 support.])
112962ac0c33Sjakob		;;
1130dd5b221eSsthen		*)
1131dd5b221eSsthen		if test x$HAVE_SSL = x"yes"; then
1132dd5b221eSsthen			AC_DEFINE_UNQUOTED([NSEC3], [], [Define this to enable NSEC3 support.])
1133dd5b221eSsthen		else
1134dd5b221eSsthen			AC_MSG_WARN([No SSL, therefore NSEC3 is disabled])
1135dd5b221eSsthen		fi
11365bcb494bSjakob                ;;
11375bcb494bSjakobesac
11385bcb494bSjakob
11398d298c9fSsthenAC_ARG_ENABLE(minimal-responses, AS_HELP_STRING([--disable-minimal-responses],[Disable response minimization. More truncation.]))
11405bcb494bSjakobcase "$enable_minimal_responses" in
11415bcb494bSjakob        no)
11425bcb494bSjakob		;;
11435bcb494bSjakob        yes|*)
11445bcb494bSjakob		AC_DEFINE_UNQUOTED([MINIMAL_RESPONSES], [], [Define this to enable response minimalization to reduce truncation.])
11455bcb494bSjakob                ;;
11465bcb494bSjakobesac
11475bcb494bSjakob
11488d298c9fSsthenAC_ARG_ENABLE(mmap, AS_HELP_STRING([--enable-mmap],[Use mmap instead of malloc. Experimental.]))
11494ab91c82Sjakobcase "$enable_mmap" in
11504ab91c82Sjakob        yes)
11518d298c9fSsthen		AC_CHECK_HEADERS([sys/mman.h],,, [AC_INCLUDES_DEFAULT])
11524ab91c82Sjakob		AC_LIBGTOP_CHECK_TYPE(uintptr_t, void*)
1153c3fd4e2aSjakob		AC_CHECK_FUNCS([mmap munmap])
11544ab91c82Sjakob		AC_DEFINE_UNQUOTED([USE_MMAP_ALLOC], [], [Define this to enable mmap instead of malloc. Experimental.])
11554ab91c82Sjakob		;;
115662ac0c33Sjakob        no|*)
115762ac0c33Sjakob                ;;
115862ac0c33Sjakobesac
115962ac0c33Sjakob
11608d298c9fSsthenAC_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.]))
1161c1e73312Sfloriancase "$enable_radix_tree" in
1162c1e73312Sflorian        no)
1163c1e73312Sflorian	;;
1164c1e73312Sflorian	yes|*)
1165c1e73312Sflorian	AC_DEFINE_UNQUOTED([USE_RADIX_TREE], [], [Define this to configure to use the radix tree.])
1166c1e73312Sflorian	;;
1167c1e73312Sflorianesac
1168c1e73312Sflorian
11698d298c9fSsthenAC_ARG_ENABLE(packed, AS_HELP_STRING([--enable-packed],[Enable packed structure alignment, uses less memory, but unaligned reads.]))
1170a8d230d1Ssthencase "$enable_packed" in
1171a8d230d1Ssthen	yes)
1172a8d230d1Ssthen	AC_DEFINE_UNQUOTED([PACKED_STRUCTS], [], [Define this to use packed structure alignment.])
1173a8d230d1Ssthen	ACX_CHECK_COMPILER_FLAG(Wno-address-of-packed-member, [CFLAGS="$CFLAGS -Wno-address-of-packed-member"])
1174a8d230d1Ssthen	;;
1175a8d230d1Ssthen	no|*)
1176a8d230d1Ssthen	;;
1177a8d230d1Ssthenesac
1178a8d230d1Ssthen
1179e02bc0dfSflorian# check for dnstap if requested
1180e02bc0dfSfloriandt_DNSTAP([${localstatedir}/run/nsd-dnstap.sock],
1181e02bc0dfSflorian    [
1182e02bc0dfSflorian        AC_DEFINE([USE_DNSTAP], [1], [Define to 1 to enable dnstap support])
1183e02bc0dfSflorian        AC_SUBST([ENABLE_DNSTAP], [1])
1184e02bc0dfSflorian
1185e02bc0dfSflorian        AC_SUBST([opt_dnstap_socket_path])
1186e02bc0dfSflorian        ACX_ESCAPE_BACKSLASH($opt_dnstap_socket_path, hdr_dnstap_socket_path)
1187e02bc0dfSflorian        AC_DEFINE_UNQUOTED(DNSTAP_SOCKET_PATH,
1188e02bc0dfSflorian            ["$hdr_dnstap_socket_path"], [default dnstap socket path])
1189e02bc0dfSflorian
1190e02bc0dfSflorian        AC_SUBST([DNSTAP_SRC], ["dnstap/dnstap.c dnstap/dnstap.pb-c.c dnstap/dnstap_collector.c"])
1191e02bc0dfSflorian        AC_SUBST([DNSTAP_OBJ], ["dnstap.o dnstap_collector.o dnstap.pb-c.o"])
1192e02bc0dfSflorian	dnstap_config="dnstap/dnstap_config.h"
1193e02bc0dfSflorian    ],
1194e02bc0dfSflorian    [
1195e02bc0dfSflorian        AC_SUBST([ENABLE_DNSTAP], [0])
1196e02bc0dfSflorian    ]
1197e02bc0dfSflorian)
1198e02bc0dfSflorian
119918e77612Sflorian# Include systemd.m4 - begin
120018e77612Sfloriansinclude(systemd.m4)
120118e77612Sflorian# Include systemd.m4 - end
120218e77612Sflorian
12038d298c9fSsthenAC_ARG_ENABLE(tcp-fastopen, AS_HELP_STRING([--enable-tcp-fastopen],[Enable TCP Fast Open]))
1204eab1363eSsthencase "$enable_tcp_fastopen" in
1205eab1363eSsthen       yes)
1206eab1363eSsthen             AC_CHECK_DECL([TCP_FASTOPEN], [], [AC_MSG_ERROR([TCP Fast Open is not available: please rerun without --enable-tcp-fastopen])], [AC_INCLUDES_DEFAULT
1207eab1363eSsthen#include <netinet/tcp.h>
1208eab1363eSsthen             ])
1209eab1363eSsthen               AC_DEFINE_UNQUOTED([USE_TCP_FASTOPEN], [1], [Define this to enable TCP fast open.])
1210eab1363eSsthen               ;;
1211eab1363eSsthen       no|*)
1212eab1363eSsthen               ;;
1213eab1363eSsthenesac
1214eab1363eSsthen
121562ac0c33SjakobAH_BOTTOM([
121662ac0c33Sjakob/* define before includes as it specifies what standard to use. */
121762ac0c33Sjakob#if (defined(HAVE_PSELECT) && !defined (HAVE_PSELECT_PROTO)) \
121862ac0c33Sjakob	|| !defined (HAVE_CTIME_R_PROTO) \
1219308d2509Sflorian	|| defined (STRPTIME_NEEDS_DEFINES) || defined(REALLOCARRAY_NEEDS_DEFINES)
122062ac0c33Sjakob#  ifndef _XOPEN_SOURCE
122162ac0c33Sjakob#    define _XOPEN_SOURCE 600
122262ac0c33Sjakob#  endif
122362ac0c33Sjakob#  ifndef _POSIX_C_SOURCE
122462ac0c33Sjakob#    define _POSIX_C_SOURCE 200112
122562ac0c33Sjakob#  endif
122662ac0c33Sjakob#  ifndef _BSD_SOURCE
122762ac0c33Sjakob#    define _BSD_SOURCE 1
122862ac0c33Sjakob#  endif
1229eab1363eSsthen#  ifndef _OPENBSD_SOURCE
1230eab1363eSsthen#    define _OPENBSD_SOURCE 1
1231eab1363eSsthen#  endif
1232275a8d89Sflorian#  ifndef _DEFAULT_SOURCE
1233275a8d89Sflorian#    define _DEFAULT_SOURCE 1
1234275a8d89Sflorian#  endif
123562ac0c33Sjakob#  ifndef __EXTENSIONS__
123662ac0c33Sjakob#    define __EXTENSIONS__ 1
123762ac0c33Sjakob#  endif
123862ac0c33Sjakob#  ifndef _STDC_C99
123962ac0c33Sjakob#    define _STDC_C99 1
124062ac0c33Sjakob#  endif
124162ac0c33Sjakob#  ifndef _ALL_SOURCE
124262ac0c33Sjakob#    define _ALL_SOURCE 1
124362ac0c33Sjakob#  endif
124462ac0c33Sjakob#endif
124562ac0c33Sjakob])
124662ac0c33Sjakob
124762ac0c33SjakobAH_BOTTOM([
124862ac0c33Sjakob#ifdef HAVE_VA_LIST_DOUBLE_DEF
124962ac0c33Sjakob/* workaround double va_list definition on some platforms */
125062ac0c33Sjakob#  ifndef _VA_LIST_DEFINED
125162ac0c33Sjakob#    define _VA_LIST_DEFINED
125262ac0c33Sjakob#  endif
125362ac0c33Sjakob#endif
125462ac0c33Sjakob])
125562ac0c33Sjakob
125662ac0c33SjakobAH_BOTTOM([
125762ac0c33Sjakob#include <sys/types.h>
125862ac0c33Sjakob#include <stdlib.h>
125962ac0c33Sjakob#include <stddef.h>
1260b71395eaSflorian#include <string.h>
126162ac0c33Sjakob
126262ac0c33Sjakob#ifdef HAVE_TIME_H
126362ac0c33Sjakob#include <time.h>
126462ac0c33Sjakob#endif
126562ac0c33Sjakob
126662ac0c33Sjakob#ifdef HAVE_STDINT_H
126762ac0c33Sjakob#include <stdint.h>
126862ac0c33Sjakob#endif
126962ac0c33Sjakob
127062ac0c33Sjakob#ifdef HAVE_SYS_SOCKET_H
127162ac0c33Sjakob#include <sys/socket.h>
127262ac0c33Sjakob#endif
127362ac0c33Sjakob
127462ac0c33Sjakob#ifdef HAVE_NETINET_IN_H
127562ac0c33Sjakob#include <netinet/in.h>
127662ac0c33Sjakob#endif
127762ac0c33Sjakob
1278275a8d89Sflorian#ifdef HAVE_NETINET_TCP_H
1279275a8d89Sflorian#include <netinet/tcp.h>
1280275a8d89Sflorian#endif
1281275a8d89Sflorian
128262ac0c33Sjakob#ifdef HAVE_ARPA_INET_H
128362ac0c33Sjakob#include <arpa/inet.h>
128462ac0c33Sjakob#endif
128562ac0c33Sjakob
128662ac0c33Sjakob/* For Tru64 */
128762ac0c33Sjakob#ifdef HAVE_SYS_BITYPES_H
128862ac0c33Sjakob#include <sys/bitypes.h>
128962ac0c33Sjakob#endif
129062ac0c33Sjakob])
129162ac0c33Sjakob
129262ac0c33SjakobAH_BOTTOM([
129362ac0c33Sjakob#ifdef HAVE_ATTR_FORMAT
129462ac0c33Sjakob#define ATTR_FORMAT(archetype, string_index, first_to_check) \
129562ac0c33Sjakob    __attribute__ ((format (archetype, string_index, first_to_check)))
129662ac0c33Sjakob#else /* !HAVE_ATTR_FORMAT */
129762ac0c33Sjakob#define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */
129862ac0c33Sjakob#endif /* !HAVE_ATTR_FORMAT */
129962ac0c33Sjakob#if defined(__cplusplus)
130062ac0c33Sjakob#define ATTR_UNUSED(x)
130162ac0c33Sjakob#elif defined(HAVE_ATTR_UNUSED)
130262ac0c33Sjakob#define ATTR_UNUSED(x)  x __attribute__((unused))
130362ac0c33Sjakob#else /* !HAVE_ATTR_UNUSED */
130462ac0c33Sjakob#define ATTR_UNUSED(x)  x
130562ac0c33Sjakob#endif /* !HAVE_ATTR_UNUSED */
130662ac0c33Sjakob])
130762ac0c33Sjakob
130862ac0c33SjakobAH_BOTTOM([
130962ac0c33Sjakob#ifndef IPV6_MIN_MTU
131062ac0c33Sjakob#define IPV6_MIN_MTU 1280
131162ac0c33Sjakob#endif /* IPV6_MIN_MTU */
131262ac0c33Sjakob
131362ac0c33Sjakob#ifndef AF_INET6
131462ac0c33Sjakob#define AF_INET6	28
131562ac0c33Sjakob#endif /* AF_INET6 */
131662ac0c33Sjakob])
131762ac0c33Sjakob
131862ac0c33Sjakobif test $ac_cv_func_getaddrinfo = no; then
131962ac0c33SjakobAC_LIBOBJ([fake-rfc2553])
132062ac0c33Sjakobfi
132162ac0c33Sjakob
132262ac0c33SjakobAH_BOTTOM([
132362ac0c33Sjakob/* maximum nesting of included files */
132462ac0c33Sjakob#define MAXINCLUDES 10
132562ac0c33Sjakob])
132662ac0c33Sjakob
132762ac0c33SjakobAH_BOTTOM([
132872628ec9Ssthenint __b64_ntop(uint8_t const *src, size_t srclength,
132962ac0c33Sjakob	     char *target, size_t targsize);
133072628ec9Ssthenint __b64_pton(char const *src, uint8_t *target, size_t targsize);
133172628ec9Ssthen])
133272628ec9SsthenAH_BOTTOM([
133362ac0c33Sjakob#ifndef HAVE_FSEEKO
133462ac0c33Sjakob#define fseeko fseek
133562ac0c33Sjakob#define ftello ftell
133662ac0c33Sjakob#endif /* HAVE_FSEEKO */
133762ac0c33Sjakob#ifndef HAVE_SNPRINTF
133862ac0c33Sjakob#include <stdarg.h>
133962ac0c33Sjakobint snprintf (char *str, size_t count, const char *fmt, ...);
134062ac0c33Sjakobint vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
134162ac0c33Sjakob#endif /* HAVE_SNPRINTF */
134262ac0c33Sjakob#ifndef HAVE_INET_PTON
134362ac0c33Sjakobint inet_pton(int af, const char* src, void* dst);
134462ac0c33Sjakob#endif /* HAVE_INET_PTON */
134562ac0c33Sjakob#ifndef HAVE_INET_NTOP
134662ac0c33Sjakobconst char *inet_ntop(int af, const void *src, char *dst, size_t size);
134762ac0c33Sjakob#endif
134862ac0c33Sjakob#ifndef HAVE_INET_ATON
134962ac0c33Sjakobint inet_aton(const char *cp, struct in_addr *addr);
135062ac0c33Sjakob#endif
135162ac0c33Sjakob#ifndef HAVE_MEMMOVE
135262ac0c33Sjakobvoid *memmove(void *dest, const void *src, size_t n);
135362ac0c33Sjakob#endif
1354063644e9Sflorian#ifndef HAVE_EXPLICIT_BZERO
1355063644e9Sflorian#define explicit_bzero nsd_explicit_bzero
1356063644e9Sflorianvoid explicit_bzero(void* buf, size_t len);
1357063644e9Sflorian#endif
13584ab91c82Sjakob#ifndef HAVE_STRLCAT
13594ab91c82Sjakobsize_t strlcat(char *dst, const char *src, size_t siz);
13604ab91c82Sjakob#endif
136162ac0c33Sjakob#ifndef HAVE_STRLCPY
136262ac0c33Sjakobsize_t strlcpy(char *dst, const char *src, size_t siz);
136362ac0c33Sjakob#endif
13648d8f1862Ssthen#ifndef HAVE_REALLOCARRAY
13658d8f1862Ssthenvoid* reallocarray(void *ptr, size_t nmemb, size_t size);
13668d8f1862Ssthen#endif
136762ac0c33Sjakob#ifndef HAVE_GETADDRINFO
136862ac0c33Sjakob#include "compat/fake-rfc2553.h"
136962ac0c33Sjakob#endif
137062ac0c33Sjakob#ifndef HAVE_STRPTIME
137162ac0c33Sjakob#define HAVE_STRPTIME 1
137262ac0c33Sjakobchar *strptime(const char *s, const char *format, struct tm *tm);
137362ac0c33Sjakob#endif
137462ac0c33Sjakob#ifndef STRPTIME_WORKS
137562ac0c33Sjakob#define STRPTIME_WORKS 1
1376533110e2Sbradchar *nsd_strptime(const char *s, const char *format, struct tm *tm);
137762ac0c33Sjakob#define strptime(a,b,c) nsd_strptime((a),(b),(c))
137862ac0c33Sjakob#endif
1379308d2509Sflorian#if (HAVE_CPU_SET_T || HAVE_CPUSET_T)
1380308d2509Sflorian#include "compat/cpuset.h"
1381308d2509Sflorian#endif
1382308d2509Sflorian#ifndef HAVE_SETPROCTITLE
1383308d2509Sflorian#ifdef __linux__
1384308d2509Sflorian#define HAVE_SETPROCTITLE 1
1385308d2509Sflorian#include <stdarg.h>
1386977db6e5Sflorianvoid setproctitle(const char *fmt, ...);
1387308d2509Sflorian#endif
1388308d2509Sflorian#endif
13894ab91c82Sjakob])
13904ab91c82SjakobAH_BOTTOM(
13914ab91c82SjakobAHX_MEMCMP_BROKEN(nsd)
139272f0a8e9SsthenAHX_CONFIG_MAXHOSTNAMELEN
13934ab91c82Sjakob)
13944ab91c82SjakobAH_BOTTOM([
139562ac0c33Sjakob
139662ac0c33Sjakob/* provide timespec def if not available */
139762ac0c33Sjakob#ifndef CONFIG_DEFINES
139862ac0c33Sjakob#define CONFIG_DEFINES
139962ac0c33Sjakob#ifndef HAVE_STRUCT_TIMESPEC
140062ac0c33Sjakob#ifndef __timespec_defined
140162ac0c33Sjakob#define __timespec_defined 1
140262ac0c33Sjakob	struct timespec {
140362ac0c33Sjakob		long    tv_sec;         /* seconds */
140462ac0c33Sjakob		long    tv_nsec;        /* nanoseconds */
140562ac0c33Sjakob	};
140662ac0c33Sjakob#endif /* !__timespec_defined */
140762ac0c33Sjakob#endif /* !HAVE_STRUCT_TIMESPEC */
140862ac0c33Sjakob#endif /* !CONFIG_DEFINES */
1409a8d230d1Ssthen
1410a8d230d1Ssthen#ifdef PACKED_STRUCTS
1411a8d230d1Ssthen#define ATTR_PACKED __attribute__((packed))
1412a8d230d1Ssthen#else
1413a8d230d1Ssthen#define ATTR_PACKED
1414a8d230d1Ssthen#endif
141562ac0c33Sjakob])
141662ac0c33Sjakob
141762ac0c33Sjakob# big fat warning
141862ac0c33Sjakobif test "$enable_checking" = "yes"; then
1419dd5b221eSsthen        echo "************************************************"
142062ac0c33Sjakob        echo "* You have activated \"--enable-checking\"       *"
142162ac0c33Sjakob        echo "*                                              *"
142262ac0c33Sjakob        echo "* This will instruct NSD to be stricter        *"
142362ac0c33Sjakob        echo "* when validating its input. This could lead   *"
142462ac0c33Sjakob        echo "* to a reduced service level.                  *"
142562ac0c33Sjakob        echo "*                                              *"
1426dd5b221eSsthen        echo "************************************************"
142762ac0c33Sjakobfi
142862ac0c33Sjakob
1429e02bc0dfSflorianAC_CONFIG_FILES([Makefile $dnstap_config])
143062ac0c33SjakobAC_OUTPUT
1431*4c4bdeb8Sflorianm4_unquote(
1432*4c4bdeb8Sflorian  _m4_defn([_m4_wrap_text])_m4_popdef([_m4_wrap_text]))