configure.ac revision 1.1.1.2
1dnl 2dnl Some global settings 3dnl 4 5sinclude(acx_nlnetlabs.m4) 6 7AC_INIT(NSD,4.1.19,nsd-bugs@nlnetlabs.nl) 8AC_CONFIG_HEADER([config.h]) 9 10CFLAGS="$CFLAGS" 11AC_AIX 12if test "$ac_cv_header_minix_config_h" = "yes"; then 13 AC_DEFINE(_NETBSD_SOURCE,1, [Enable for compile on Minix]) 14fi 15 16dnl 17dnl By default set $sysconfdir to /etc and $localstatedir to /var 18dnl 19case "$prefix" in 20 NONE) 21 case "$sysconfdir" in 22 '${prefix}/etc') 23 sysconfdir=/etc 24 ;; 25 esac 26 case "$localstatedir" in 27 '${prefix}/var') 28 localstatedir=/var 29 ;; 30 esac 31 ;; 32esac 33 34# 35# Determine configuration directory 36# 37configdir=$sysconfdir/nsd 38AC_ARG_WITH([configdir], 39 AC_HELP_STRING([--with-configdir=dir], [NSD configuration directory]), 40 [configdir=$withval]) 41AC_DEFINE_UNQUOTED(CONFIGDIR, ["`eval echo $configdir`"], [NSD config dir]) 42AC_SUBST(configdir) 43 44# 45# Determine configuration file 46nsd_conf_file=${configdir}/nsd.conf 47AC_ARG_WITH([nsd_conf_file], 48 AC_HELP_STRING([--with-nsd_conf_file=path], [Pathname to the NSD configuration file]), 49 [nsd_conf_file=$withval]) 50AC_SUBST(nsd_conf_file) 51# the eval is to evaluate shell expansion twice, once 52# for $nsd_conf_file and once for the ${prefix} within it. 53AC_DEFINE_UNQUOTED(CONFIGFILE, ["`eval echo $nsd_conf_file`"], [Pathname to the NSD configuration file]) 54 55# 56# Default logfile 57# 58logfile=${localstatedir}/log/nsd.log 59AC_ARG_WITH([logfile], 60 AC_HELP_STRING([--with-logfile=path], [Pathname to the default log file]), 61 [logfile=$withval]) 62AC_SUBST(logfile) 63 64# 65# Database directory 66# 67dbdir=${localstatedir}/db/nsd 68 69# 70# Determine the pidfile location. Check if /var/run exists, if so set pidfile 71# to /var/run/nsd.pid by default 72# 73if test -d ${localstatedir}/run; then 74 pidfile=${localstatedir}/run/nsd.pid 75else 76 pidfile=${dbdir}/nsd.pid 77fi 78AC_ARG_WITH([pidfile], 79 AC_HELP_STRING([--with-pidfile=path], [Pathname to the NSD pidfile]), 80 [pidfile=$withval]) 81AC_SUBST(pidfile) 82AC_DEFINE_UNQUOTED(PIDFILE, ["`eval echo $pidfile`"], [Pathname to the NSD pidfile]) 83 84# 85# Determine location of nsd.db 86# 87dbfile=${dbdir}/nsd.db 88AC_ARG_WITH([dbfile], 89 AC_HELP_STRING([--with-dbfile=path], [Pathname to the NSD database]), 90 [dbfile=$withval]) 91AC_SUBST(dbfile) 92AC_DEFINE_UNQUOTED(DBFILE, ["`eval echo $dbfile`"], [Pathname to the NSD database]) 93 94if test -n "$dbfile"; then 95 dbdir=`dirname $dbfile` 96fi 97AC_SUBST(dbdir) 98 99piddir=`dirname $pidfile` 100AC_SUBST(piddir) 101 102# 103# Determine the default directory for the zone files 104# 105zonesdir=$configdir 106AC_ARG_WITH([zonesdir], 107 AC_HELP_STRING([--with-zonesdir=dir], [NSD default location for zone files]), 108 [zonesdir=$withval]) 109AC_SUBST(zonesdir) 110AC_DEFINE_UNQUOTED(ZONESDIR, ["`eval echo $zonesdir`"], [NSD default location for zone files. Empty string or NULL to disable.]) 111 112# default xfrd file location. 113xfrdfile=${dbdir}/xfrd.state 114AC_ARG_WITH([xfrdfile], AC_HELP_STRING([--with-xfrdfile=path], 115 [Pathname to the NSD xfrd zone timer state file]), [xfrdfile=$withval]) 116AC_DEFINE_UNQUOTED(XFRDFILE, ["`eval echo $xfrdfile`"], [Pathname to the NSD xfrd zone timer state file.]) 117AC_SUBST(xfrdfile) 118 119# default zonelist file location. 120zonelistfile=${dbdir}/zone.list 121AC_ARG_WITH([zonelistfile], AC_HELP_STRING([--with-zonelistfile=path], 122 [Pathname to the NSD zone list file]), [zonelistfile=$withval]) 123AC_DEFINE_UNQUOTED(ZONELISTFILE, ["`eval echo $zonelistfile`"], [Pathname to the NSD zone list file.]) 124AC_SUBST(zonelistfile) 125 126# default xfr dir location. 127xfrdir="/tmp" 128AC_ARG_WITH([xfrdir], AC_HELP_STRING([--with-xfrdir=path], 129 [Pathname to where the NSD transfer dir is created]), [xfrdir=$withval]) 130AC_DEFINE_UNQUOTED(XFRDIR, ["`eval echo $xfrdir`"], [Pathname to where the NSD transfer dir is created.]) 131AC_SUBST(xfrdir) 132 133# nsd sbin location. tmpinstantiate execprefix with defaults if not yet done. 134if test "x${exec_prefix}" = "xNONE"; then 135 if test "x${prefix}" = "xNONE"; then exec_prefix="$ac_default_prefix" 136 else exec_prefix="${prefix}"; fi 137 nsd_start_path="`eval echo $sbindir`/nsd" 138 exec_prefix="NONE" 139else 140 nsd_start_path="`eval echo $sbindir`/nsd" 141fi 142AC_DEFINE_UNQUOTED(NSD_START_PATH, ["$nsd_start_path"], [Pathname to start nsd from nsd-control]) 143 144# 145# Determine default chroot directory 146# 147AC_ARG_WITH([chroot], 148 AC_HELP_STRING([--with-chroot=dir], [NSD default chroot directory]), 149 [ 150 chrootdir=$withval 151 AC_DEFINE_UNQUOTED(CHROOTDIR, ["`eval echo $chrootdir`"], [NSD default chroot directory]) 152 ]) 153AC_SUBST(chrootdir) 154 155# 156# Determine the user name to drop privileges to 157# 158user=nsd 159AC_ARG_WITH([user], 160 AC_HELP_STRING([--with-user=username], [User name or ID to answer the queries with]), 161 [user=$withval]) 162AC_SUBST(user) 163AC_DEFINE_UNQUOTED(USER, ["$user"], [the user name to drop privileges to]) 164 165# Checks for programs. 166AC_PROG_AWK 167AC_PROG_CC 168AC_PROG_LN_S 169AC_PROG_INSTALL 170AC_PROG_LEX 171AC_PROG_YACC 172 173if test "$LEX" != ":" -a "$LEX" != ""; then 174 # Check if lex defines yy_current_buffer, because 2.4.6 and older use it, 175 # but later could define it as a macro and then we should not redefine it. 176 AC_MSG_CHECKING(if lex defines yy_current_buffer) 177 cat <<EOF >conftest.lex 178%% 179EOF 180 $LEX -i -t conftest.lex >> conftest.c 181 if grep "^#define yy_current_buffer" conftest.c >/dev/null; then 182 AC_DEFINE_UNQUOTED(LEX_DEFINES_YY_CURRENT_BUFFER, 1, [If flex defines yy_current_buffer as a macro]) 183 AC_MSG_RESULT(yes) 184 else 185 AC_MSG_RESULT(no) 186 fi 187 rm -f conftest.lex conftest.c 188fi 189 190AC_DEFUN([AC_CHECK_FORMAT_ATTRIBUTE], 191[AC_REQUIRE([AC_PROG_CC]) 192AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "format" attribute) 193AC_CACHE_VAL(ac_cv_c_format_attribute, 194[ac_cv_c_format_attribute=no 195AC_TRY_COMPILE( 196[#include <stdio.h> 197void f (char *format, ...) __attribute__ ((format (printf, 1, 2))); 198void (*pf) (char *format, ...) __attribute__ ((format (printf, 1, 2))); 199], [ 200 f ("%s", "str"); 201], 202[ac_cv_c_format_attribute="yes"], 203[ac_cv_c_format_attribute="no"]) 204]) 205 206AC_MSG_RESULT($ac_cv_c_format_attribute) 207if test $ac_cv_c_format_attribute = yes; then 208 AC_DEFINE(HAVE_ATTR_FORMAT, 1, [Whether the C compiler accepts the "format" attribute]) 209fi 210])dnl 211 212AC_DEFUN([AC_CHECK_UNUSED_ATTRIBUTE], 213[AC_REQUIRE([AC_PROG_CC]) 214AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts the "unused" attribute) 215AC_CACHE_VAL(ac_cv_c_unused_attribute, 216[ac_cv_c_unused_attribute=no 217AC_TRY_COMPILE( 218[#include <stdio.h> 219void f (char *u __attribute__((unused))); 220], [ 221 f ("x"); 222], 223[ac_cv_c_unused_attribute="yes"], 224[ac_cv_c_unused_attribute="no"]) 225]) 226 227AC_MSG_RESULT($ac_cv_c_unused_attribute) 228if test $ac_cv_c_unused_attribute = yes; then 229 AC_DEFINE(HAVE_ATTR_UNUSED, 1, [Whether the C compiler accepts the "unused" attribute]) 230fi 231])dnl 232 233AC_DEFUN([CHECK_COMPILER_FLAG], 234[ 235AC_REQUIRE([AC_PROG_CC]) 236AC_MSG_CHECKING(whether $CC supports -$1) 237cache=`echo $1 | sed 'y%.=/+-%___p_%'` 238AC_CACHE_VAL(cv_prog_cc_flag_$cache, 239[ 240echo 'void f(){}' >conftest.c 241if test -z "`$CC -$1 -c conftest.c 2>&1`"; then 242eval "cv_prog_cc_flag_$cache=yes" 243else 244eval "cv_prog_cc_flag_$cache=no" 245fi 246rm -f conftest* 247]) 248if eval "test \"`echo '$cv_prog_cc_flag_'$cache`\" = yes"; then 249AC_MSG_RESULT(yes) 250: 251$2 252else 253AC_MSG_RESULT(no) 254: 255$3 256fi 257]) 258 259AC_DEFUN([AC_CHECK_CTIME_R], 260[AC_REQUIRE([AC_PROG_CC]) 261AC_MSG_CHECKING(whether ctime_r works with two arguments) 262AC_CACHE_VAL(ac_cv_c_ctime_c, 263[ac_cv_c_ctime_c=no 264AC_TRY_COMPILE( 265[#include <time.h> 266void testing (void) { time_t clock; char current_time[40]; ctime_r(&clock, current_time); }], 267[ 268 testing(); 269], 270[ac_cv_c_ctime_c="yes"], 271[ac_cv_c_ctime_c="no"]) 272]) 273 274AC_MSG_RESULT($ac_cv_c_ctime_c) 275if test $ac_cv_c_ctime_c = no; then 276 CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS" 277fi 278])dnl 279 280# Checks for typedefs, structures, and compiler characteristics. 281# allow user to override the -g -O2 flags. 282if test "x$CFLAGS" = "x" ; then 283 ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="$CFLAGS -g"]) 284 # we do not use O3 because it causes miscompilations. 285 ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"]) 286 ACX_CHECK_FLTO 287 ACX_CHECK_PIE 288 ACX_CHECK_RELRO_NOW 289fi 290AC_C_CONST 291AC_C_INLINE 292AC_TYPE_UID_T 293AC_TYPE_PID_T 294AC_TYPE_SIZE_T 295AC_TYPE_OFF_T 296 297AC_CHECK_FORMAT_ATTRIBUTE 298AC_CHECK_UNUSED_ATTRIBUTE 299ACX_CHECK_MEMCMP_SIGNED 300AC_CHECK_CTIME_R 301 302# Checks for libraries. 303 304# Check for SSL, original taken from 305# http://www.gnu.org/software/ac-archive/htmldoc/check_ssl.html and 306# modified for NSD. 307AC_DEFUN([CHECK_SSL], [ 308 AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=pathname], 309 [enable SSL (will check /usr/local/ssl 310 /usr/lib/ssl /usr/ssl /usr/pkg /usr/sfw /usr/local /usr)]),[ 311 ],[ 312 withval="yes" 313 ]) 314 if test x_$withval != x_no; then 315 AC_MSG_CHECKING(for SSL) 316 if test x_$withval = x_ -o x_$withval = x_yes; then 317 withval="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/sfw /usr/local /usr" 318 fi 319 for dir in $withval; do 320 ssldir="$dir" 321 if test -f "$dir/include/openssl/ssl.h"; then 322 found_ssl="yes"; 323 AC_DEFINE_UNQUOTED([HAVE_SSL], [], [Define if you have the SSL libraries installed.]) 324 if test x_$ssldir != x_/usr; then 325 CPPFLAGS="$CPPFLAGS -I$ssldir/include"; 326 fi 327 break; 328 fi 329 done 330 if test x_$found_ssl != x_yes; then 331 AC_MSG_ERROR(Cannot find the SSL libraries in $withval) 332 else 333 AC_MSG_RESULT(found in $ssldir) 334 HAVE_SSL=yes 335 if test x_$ssldir != x_/usr; then 336 LDFLAGS="$LDFLAGS -L$ssldir/lib"; 337 fi 338 if test x_$ssldir = x_/usr/sfw; then 339 LDFLAGS="$LDFLAGS -R$ssldir/lib"; 340 fi 341 fi 342 AC_SUBST(HAVE_SSL) 343 fi 344])dnl 345 346# check for libevent 347AC_ARG_WITH(libevent, AC_HELP_STRING([--with-libevent=pathname], 348 [use libevent (will check /usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr or you can specify an explicit path), useful when the zone count is high.]), 349 [ ],[ withval="yes" ]) 350if test x_$withval = x_yes -o x_$withval != x_no; then 351 AC_MSG_CHECKING(for libevent) 352 if test x_$withval = x_ -o x_$withval = x_yes; then 353 withval="/usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr" 354 fi 355 for dir in $withval; do 356 thedir="$dir" 357 if test -f "$dir/include/event.h" -o -f "$dir/include/event2/event.h"; then 358 found_libevent="yes" 359 dnl assume /usr is in default path. 360 if test "$thedir" != "/usr"; then 361 CPPFLAGS="$CPPFLAGS -I$thedir/include" 362 fi 363 break; 364 fi 365 done 366 if test x_$found_libevent != x_yes; then 367 if test -f "$dir/event.h" -a \( -f "$dir/libevent.la" -o -f "$dir/libev.la" \) ; then 368 # libevent source directory 369 AC_MSG_RESULT(found in $thedir) 370 CPPFLAGS="$CPPFLAGS -I$thedir -I$thedir/include" 371 # remove evdns from linking 372 ev_files_o=`ls $thedir/*.o | grep -v evdns\.o | grep -v bufferevent_openssl\.o` 373 cp $ev_files_o . 374 LDFLAGS="$ev_files_o $LDFLAGS -lm" 375 else 376 AC_MSG_ERROR([Cannot find the libevent library. 377You can restart ./configure --with-libevent=no to use a builtin alternative.]) 378 fi 379 else 380 AC_MSG_RESULT(found in $thedir) 381 dnl if event2 exists and no event lib in dir itself, use subdir 382 if test ! -f $thedir/lib/libevent.a -a ! -f $thedir/lib/libevent.so -a -d "$thedir/lib/event2"; then 383 LDFLAGS="$LDFLAGS -L$thedir/lib/event2" 384 ACX_RUNTIME_PATH_ADD([$thedir/lib/event2]) 385 else 386 dnl assume /usr is in default path, do not add "". 387 if test "$thedir" != "/usr" -a "$thedir" != ""; then 388 LDFLAGS="$LDFLAGS -L$thedir/lib" 389 ACX_RUNTIME_PATH_ADD([$thedir/lib]) 390 fi 391 fi 392 fi 393 # check for library used by libevent after 1.3c 394 AC_SEARCH_LIBS([clock_gettime], [rt]) 395 396 # is the event.h header libev or libevent? 397 AC_CHECK_HEADERS([event.h],,, [AC_INCLUDES_DEFAULT]) 398 AC_CHECK_DECL(EV_VERSION_MAJOR, [ 399 AC_SEARCH_LIBS(event_set, [ev]) 400 ],[ 401 AC_SEARCH_LIBS(event_set, [event]) 402 ],[AC_INCLUDES_DEFAULT 403#include <event.h> 404 ]) 405 AC_CHECK_FUNCS([event_base_free]) # only in libevent 1.2 and later 406 AC_CHECK_FUNCS([event_base_once]) # only in libevent 1.4.1 and later 407 AC_CHECK_FUNCS([event_base_new]) # only in libevent 1.4.1 and later 408 AC_CHECK_FUNCS([event_base_get_method]) # only in libevent 1.4.3 and later 409 AC_CHECK_FUNCS([ev_loop]) # only in libev. (tested on 3.51) 410 AC_CHECK_FUNCS([ev_default_loop]) # only in libev. (tested on 4.00) 411else 412 AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events]) 413fi 414 415# Checks for header files. 416AC_HEADER_STDC 417AC_HEADER_SYS_WAIT 418AC_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 syslog.h unistd.h sys/select.h stdarg.h stdint.h netdb.h sys/bitypes.h tcpd.h glob.h grp.h endian.h]) 419 420AC_DEFUN([CHECK_VALIST_DEF], 421[ 422AC_REQUIRE([AC_PROG_CC]) 423AC_MSG_CHECKING(for double definition of struct va_list) 424AC_CACHE_VAL(ac_cv_c_va_list_def, 425[ 426cat >conftest.c <<EOF 427#include <stdio.h> 428#include <stdarg.h> 429int foo(void); 430EOF 431if test -z "`$CC -Werror -D_XOPEN_SOURCE=600 -c conftest.c 2>&1`"; then 432eval "ac_cv_c_va_list_def=no" 433else 434eval "ac_cv_c_va_list_def=yes" 435fi 436rm -f conftest* 437]) 438if test $ac_cv_c_va_list_def = yes; then 439AC_MSG_RESULT(yes) 440: 441AC_DEFINE_UNQUOTED([HAVE_VA_LIST_DOUBLE_DEF], [], [Define this if you have double va_list definitions.]) 442else 443AC_MSG_RESULT(no) 444: 445 446fi 447]) 448 449CHECK_VALIST_DEF 450 451AC_DEFUN([AC_CHECK_STRPTIME], 452[AC_REQUIRE([AC_PROG_CC]) 453AC_MSG_CHECKING(whether strptime needs defines) 454AC_CACHE_VAL(ac_cv_c_strptime_needs_defs, 455[ 456cat >conftest.c <<EOF 457#include <time.h> 458int testing (void) { struct tm t; const char *timestr="201201"; return strptime(timestr, "%Y%m", &t) != 0; } 459EOF 460if test -z "`$CC -Wall -Werror -c conftest.c 2>&1`"; then 461eval "ac_cv_c_strptime_needs_defs=no" 462else 463eval "ac_cv_c_strptime_needs_defs=yes" 464fi 465rm -f conftest* 466]) 467 468AC_MSG_RESULT($ac_cv_c_strptime_needs_defs) 469if test $ac_cv_c_strptime_needs_defs = yes; then 470AC_DEFINE_UNQUOTED([STRPTIME_NEEDS_DEFINES], 1, [strptime is available from time.h with some defines.]) 471fi 472])dnl 473 474AC_CHECK_STRPTIME 475 476# check wether strptime also works 477AC_DEFUN([AC_CHECK_STRPTIME_WORKS], 478[AC_REQUIRE([AC_PROG_CC]) 479AC_MSG_CHECKING(whether strptime works) 480if test c${cross_compiling} = cno; then 481AC_RUN_IFELSE([AC_LANG_SOURCE([[ 482#define _XOPEN_SOURCE 600 483#include <time.h> 484int main(void) { struct tm tm; char *res; 485res = strptime("20070207111842", "%Y%m%d%H%M%S", &tm); 486if (!res) return 1; return 0; } 487]])] , [eval "ac_cv_c_strptime_works=yes"], [eval "ac_cv_c_strptime_works=no"]) 488else 489eval "ac_cv_c_strptime_works=maybe" 490fi 491AC_MSG_RESULT($ac_cv_c_strptime_works) 492if test $ac_cv_c_strptime_works = no; then 493AC_LIBOBJ(strptime) 494else 495AC_DEFINE_UNQUOTED([STRPTIME_WORKS], 1, [use default strptime.]) 496fi 497])dnl 498 499AC_SEARCH_LIBS(inet_pton, [nsl]) 500AC_SEARCH_LIBS(socket, [socket]) 501 502AC_CHECK_STRPTIME_WORKS 503ACX_CHECK_NONBLOCKING_BROKEN 504ACX_MKDIR_ONE_ARG 505 506# set -I. and -Isrcdir 507if test -n "$CPPFLAGS"; then 508 CPPFLAGS="$CPPFLAGS -I." 509else 510 CPPFLAGS="-I." 511fi 512if test "$srcdir" != "."; then 513 CPPFLAGS="$CPPFLAGS -I$srcdir" 514 if test -f $srcdir/config.h; then 515 AC_ERROR([$srcdir/config.h is in the way, please remove it]) 516 fi 517fi 518 519dnl LIBGTOP_CHECK_TYPE 520dnl Stolen from Gnome's anjuta 521dnl Improved version of AC_CHECK_TYPE which takes into account 522dnl that we need to #include some other header files on some 523dnl systems to get some types. 524 525dnl AC_LIBGTOP_CHECK_TYPE(TYPE, DEFAULT) 526AC_DEFUN([AC_LIBGTOP_CHECK_TYPE], 527[AC_REQUIRE([AC_HEADER_STDC])dnl 528AC_MSG_CHECKING(for $1) 529AC_CACHE_VAL(ac_cv_type_$1, 530[AC_EGREP_CPP(dnl 531changequote(<<,>>)dnl 532<<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl 533changequote([,]), [ 534#include <sys/types.h> 535#if STDC_HEADERS 536#include <stdlib.h> 537#include <stddef.h> 538#endif 539 540#ifdef HAVE_STDINT_H 541#include <stdint.h> 542#endif 543 544#ifdef HAVE_SYS_SOCKET_H 545#include <sys/socket.h> 546#endif 547 548#ifdef HAVE_ARPA_INET_H 549#include <arpa/inet.h> 550#endif 551 552#ifdef HAVE_SIGNAL_H 553#include <signal.h> 554#endif 555 556/* For Tru64 */ 557#ifdef HAVE_SYS_BITYPES_H 558#include <sys/bitypes.h> 559#endif 560], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl 561AC_MSG_RESULT($ac_cv_type_$1) 562if test $ac_cv_type_$1 = no; then 563 AC_DEFINE($1, $2, Define "$1" to "$2" if "$1" is missing) 564fi 565]) 566 567AC_LIBGTOP_CHECK_TYPE(int8_t, char) 568AC_LIBGTOP_CHECK_TYPE(int16_t, short) 569AC_LIBGTOP_CHECK_TYPE(int32_t, int) 570AC_LIBGTOP_CHECK_TYPE(int64_t, long long) 571AC_LIBGTOP_CHECK_TYPE(uint8_t, unsigned char) 572AC_LIBGTOP_CHECK_TYPE(uint16_t, unsigned short) 573AC_LIBGTOP_CHECK_TYPE(uint32_t, unsigned int) 574AC_LIBGTOP_CHECK_TYPE(uint64_t, unsigned long long) 575AC_LIBGTOP_CHECK_TYPE(socklen_t, int) 576AC_LIBGTOP_CHECK_TYPE(sig_atomic_t, int) 577AC_LIBGTOP_CHECK_TYPE(ssize_t, int) 578AC_LIBGTOP_CHECK_TYPE(suseconds_t, time_t) 579 580AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [ 581#if HAVE_SYS_TYPES_H 582# include <sys/types.h> 583#endif 584#if HAVE_NETINET_IN_H 585# include <netinet/in.h> 586#endif]) 587ACX_CHECK_SS_FAMILY 588AC_CHECK_MEMBERS([struct stat.st_mtimensec, struct stat.st_mtim.tv_nsec]) 589 590# Checks for library functions. 591AC_FUNC_CHOWN 592AC_FUNC_FORK 593AC_FUNC_MALLOC 594AC_TYPE_SIGNAL 595AC_FUNC_FSEEKO 596AC_SYS_LARGEFILE 597AC_CHECK_SIZEOF(void*) 598AC_CHECK_SIZEOF(off_t) 599AC_CHECK_FUNCS([arc4random arc4random_uniform]) 600AC_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]) 601 602AC_ARG_ENABLE(recvmmsg, AC_HELP_STRING([--enable-recvmmsg], [Enable recvmmsg and sendmmsg compilation, faster but some kernel versions may have implementation problems for IPv6])) 603case "$enable_recvmmsg" in 604 yes) 605 AC_CHECK_FUNC([recvmmsg], [ 606AC_RUN_IFELSE([AC_LANG_SOURCE([[ 607#include <sys/socket.h> 608#include <errno.h> 609int main(void) 610{ 611 int s = socket(AF_INET, SOCK_DGRAM, 0); 612 int r = recvmmsg(s, 0, 0, 0, 0) == -1 && errno == ENOSYS; 613 close(s); 614 return r; 615} 616]])], [ 617AC_DEFINE([HAVE_RECVMMSG], [1], [Define if recvmmsg is implemented])], [ 618], [ 619AC_DEFINE([HAVE_RECVMMSG], [1], [Define if recvmmsg exists])] 620)]) 621 AC_CHECK_FUNC([sendmmsg], [ 622AC_RUN_IFELSE([AC_LANG_SOURCE([[ 623#include <sys/socket.h> 624#include <errno.h> 625int main(void) 626{ 627 int s = socket(AF_INET, SOCK_DGRAM, 0); 628 int r = sendmmsg(s, 0, 0, 0) == -1 && errno == ENOSYS; 629 close(s); 630 return r; 631} 632]])], [ 633AC_DEFINE([HAVE_SENDMMSG], [1], [Define if sendmmsg is implemented])], [ 634], [ 635AC_DEFINE([HAVE_SENDMMSG], [1], [Define if sendmmsg exists])] 636)]) 637 638 ;; 639 no|*) 640 ;; 641esac 642 643# check if setreuid en setregid fail, on MacOSX10.4(darwin8). 644if echo $build_os | grep darwin8 > /dev/null; then 645 AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work]) 646fi 647 648# 649# Checking for missing functions we can replace 650# 651AC_REPLACE_FUNCS(basename) 652AC_REPLACE_FUNCS(inet_aton) 653AC_REPLACE_FUNCS(inet_pton) 654AC_REPLACE_FUNCS(inet_ntop) 655AC_REPLACE_FUNCS(snprintf) 656AC_REPLACE_FUNCS(strlcat) 657AC_REPLACE_FUNCS(strlcpy) 658AC_REPLACE_FUNCS(strptime) 659AC_REPLACE_FUNCS(b64_pton) 660AC_REPLACE_FUNCS(b64_ntop) 661AC_REPLACE_FUNCS(pselect) 662AC_REPLACE_FUNCS(memmove) 663AC_REPLACE_FUNCS(reallocarray) 664 665AC_MSG_CHECKING(for pselect prototype in sys/select.h) 666AC_EGREP_HEADER([[^a-zA-Z_]*pselect[^a-zA-Z_]], sys/select.h, AC_DEFINE(HAVE_PSELECT_PROTO, 1, 667 [if sys/select.h provides pselect prototype]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) 668 669AC_MSG_CHECKING(for ctime_r prototype in time.h) 670AC_EGREP_HEADER([[^a-zA-Z_]*ctime_r[^a-zA-Z_]], time.h, AC_DEFINE(HAVE_CTIME_R_PROTO, 1, 671 [if time.h provides ctime_r prototype]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) 672 673AC_CHECK_TYPE([struct timespec], AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1, [If time.h has a struct timespec (for pselect).]), [], [ 674AC_INCLUDES_DEFAULT 675#ifdef HAVE_SIGNAL_H 676#include <signal.h> 677#endif 678#ifdef HAVE_TIME_H 679#include <time.h> 680#endif 681]) 682 683dnl 684dnl Some random defines's 685dnl 686AC_DEFINE_UNQUOTED([IDENTITY], ["unidentified server"], [Define to the default nsd identity.]) 687AC_DEFINE_UNQUOTED([VERSION], [PACKAGE_STRING], [Define to the NSD version to answer version.server query.]) 688AC_DEFINE_UNQUOTED([TCP_BACKLOG], [256], [Define to the backlog to be used with listen.]) 689AC_DEFINE_UNQUOTED([TCP_PORT], ["53"], [Define to the default tcp port.]) 690AC_DEFINE_UNQUOTED([TCP_MAX_MESSAGE_LEN], [65535], [Define to the default maximum message length.]) 691AC_DEFINE_UNQUOTED([UDP_PORT], ["53"], [Define to the default udp port.]) 692AC_DEFINE_UNQUOTED([UDP_MAX_MESSAGE_LEN], [512], [Define to the default maximum udp message length.]) 693AC_DEFINE_UNQUOTED([EDNS_MAX_MESSAGE_LEN], [4096], [Define to the default maximum message length with EDNS.]) 694AC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [512], [Define to the maximum message length to pass to syslog.]) 695AC_DEFINE_UNQUOTED([NSD_CONTROL_PORT], [8952], [Define to the default nsd-control port.]) 696AC_DEFINE_UNQUOTED([NSD_CONTROL_VERSION], [1], [Define to nsd-control proto version.]) 697 698dnl 699dnl Determine the syslog facility to use 700dnl 701facility=LOG_DAEMON 702AC_ARG_WITH([facility], 703 AC_HELP_STRING([--with-facility=name], [Syslog default facility (LOG_DAEMON)]), 704 [facility=$withval]) 705AC_DEFINE_UNQUOTED([FACILITY], $facility, [Define to the default facility for syslog.]) 706 707dnl 708dnl Determine the default tcp timeout 709dnl 710tcp_timeout=120 711AC_ARG_WITH([tcp_timeout], 712 AC_HELP_STRING([--with-tcp-timeout=number], [Limit the default tcp timeout]), 713 [tcp_timeout=$withval]) 714AC_DEFINE_UNQUOTED([TCP_TIMEOUT], $tcp_timeout, [Define to the default tcp timeout.]) 715 716dnl 717dnl Features 718dnl 719AC_ARG_ENABLE(root-server, AC_HELP_STRING([--enable-root-server], [Configure NSD as a root server])) 720case "$enable_root_server" in 721 yes) 722 AC_DEFINE_UNQUOTED([ROOT_SERVER], [], [Define this to configure as a root server.]) 723 ;; 724 no|*) 725 ;; 726esac 727 728AC_ARG_ENABLE(ipv6, AC_HELP_STRING([--disable-ipv6], [Disables IPv6 support])) 729case "$enable_ipv6" in 730 no) 731 ;; 732 yes|*) 733 AC_DEFINE_UNQUOTED([INET6], [], [Define this to enable IPv6 support.]) 734 ;; 735esac 736 737AC_ARG_ENABLE(bind8-stats, AC_HELP_STRING([--enable-bind8-stats], [Enables BIND8 like NSTATS & XSTATS and statistics in nsd-control])) 738 739case "$enable_bind8_stats" in 740 yes|'') 741 AC_DEFINE_UNQUOTED([BIND8_STATS], [], [Define this to enable BIND8 like NSTATS & XSTATS.]) 742 ;; 743 no|*) 744 ;; 745esac 746 747AC_ARG_ENABLE(zone-stats, AC_HELP_STRING([--enable-zone-stats], [Enable per-zone statistics gathering (needs --enable-bind8-stats)])) 748case "$enable_zone_stats" in 749 yes) 750 AC_DEFINE_UNQUOTED([USE_ZONE_STATS], [], [Define this to enable per-zone statistics gathering.]) 751 AC_DEFINE_UNQUOTED([BIND8_STATS], [], [Define this to enable BIND8 like NSTATS & XSTATS.]) 752 ;; 753 no|''|*) 754 ;; 755esac 756 757AC_ARG_ENABLE(checking, AC_HELP_STRING([--enable-checking], [Enable internal runtime checks])) 758case "$enable_checking" in 759 yes) 760 CHECK_COMPILER_FLAG(W, [ CFLAGS="$CFLAGS -W" ]) 761 CHECK_COMPILER_FLAG(Wall, [ CFLAGS="$CFLAGS -Wall" ]) 762 CHECK_COMPILER_FLAG(Wextra, [ CFLAGS="$CFLAGS -Wextra" ]) 763 CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [ CFLAGS="$CFLAGS -Wdeclaration-after-statement" ]) 764 ;; 765 no|*) 766 AC_DEFINE([NDEBUG], [], [Undefine this to enable internal runtime checks.]) 767 ;; 768esac 769 770AC_ARG_ENABLE(ratelimit, AC_HELP_STRING([--enable-ratelimit], [Enable rate limiting])) 771case "$enable_ratelimit" in 772 yes) 773 AC_DEFINE_UNQUOTED([RATELIMIT], [], [Define this to enable rate limiting.]) 774 dnl causes awk to not match the exclusion start marker. 775 ratelimit="xx" 776 ;; 777 no|*) 778 ratelimit="" 779 ;; 780esac 781AC_SUBST(ratelimit) 782 783AC_ARG_ENABLE(ratelimit-default-is-off, AC_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])) 784case "$enable_ratelimit_default_is_off" in 785 yes) 786 AC_DEFINE_UNQUOTED([RATELIMIT_DEFAULT_OFF], [], [Define this to set ratelimit to off by default.]) 787 ratelimit_default="off" 788 ;; 789 no|*) 790 ratelimit_default="on" 791 ;; 792esac 793AC_SUBST(ratelimit_default) 794 795# we need SSL for TSIG (and maybe also for NSEC3). 796CHECK_SSL 797if test x$HAVE_SSL = x"yes"; then 798 ACX_LIB_SSL 799 800 # Check for -pthread 801 BAKLIBS="$LIBS" 802 LIBS="-lcrypto $LIBS" 803 AC_TRY_LINK([], [ 804 int HMAC_Update(void); 805 (void)HMAC_Update(); 806 ], [],[ 807 dnl so link fails for HMAC_Update, try with -pthread. 808 BAKCFLAGS="$CFLAGS" 809 CFLAGS="$CFLAGS -pthread" 810 AC_MSG_CHECKING([if libcrypto needs -pthread]) 811 AC_TRY_LINK_FUNC([HMAC_Update], [ 812 AC_MSG_RESULT([yes]) 813 ] , [ 814 AC_MSG_RESULT([no]) 815 dnl restore the nonpthread value 816 CFLAGS="$BAKCFLAGS" 817 ]) 818 ]) 819 LIBS="$BAKLIBS" 820 821 if test -n "$ssldir"; then 822 AC_CHECK_LIB(crypto, HMAC_Update,, [ 823 AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required]) 824 ]) 825 fi 826 SSL_LIBS="-lssl" 827 AC_SUBST(SSL_LIBS) 828 AC_CHECK_HEADERS([openssl/ssl.h],,, [AC_INCLUDES_DEFAULT]) 829 AC_CHECK_HEADERS([openssl/err.h],,, [AC_INCLUDES_DEFAULT]) 830 AC_CHECK_HEADERS([openssl/rand.h],,, [AC_INCLUDES_DEFAULT]) 831 AC_CHECK_FUNCS([HMAC_CTX_reset HMAC_CTX_new EVP_cleanup ERR_load_crypto_strings OPENSSL_init_crypto]) 832 833 BAKLIBS="$LIBS" 834 LIBS="-lssl $LIBS" 835 AC_CHECK_FUNCS([OPENSSL_init_ssl]) 836 LIBS="$BAKLIBS" 837 838else 839 AC_MSG_WARN([No SSL, therefore remote-control is disabled]) 840fi 841 842AC_ARG_ENABLE(nsec3, AC_HELP_STRING([--disable-nsec3], [Disable NSEC3 support])) 843case "$enable_nsec3" in 844 no) 845 ;; 846 yes) 847 AC_DEFINE_UNQUOTED([NSEC3], [], [Define this to enable NSEC3 support.]) 848 ;; 849 *) 850 if test x$HAVE_SSL = x"yes"; then 851 AC_DEFINE_UNQUOTED([NSEC3], [], [Define this to enable NSEC3 support.]) 852 else 853 AC_MSG_WARN([No SSL, therefore NSEC3 is disabled]) 854 fi 855 ;; 856esac 857 858AC_ARG_ENABLE(minimal-responses, AC_HELP_STRING([--disable-minimal-responses], [Disable response minimization. More truncation.])) 859case "$enable_minimal_responses" in 860 no) 861 ;; 862 yes|*) 863 AC_DEFINE_UNQUOTED([MINIMAL_RESPONSES], [], [Define this to enable response minimalization to reduce truncation.]) 864 ;; 865esac 866 867AC_ARG_ENABLE(mmap, AC_HELP_STRING([--enable-mmap], [Use mmap instead of malloc. Experimental.])) 868case "$enable_mmap" in 869 yes) 870 AC_CHECK_HEADERS([sys/mman.h]) 871 AC_LIBGTOP_CHECK_TYPE(uintptr_t, void*) 872 AC_CHECK_FUNCS([mmap munmap]) 873 AC_DEFINE_UNQUOTED([USE_MMAP_ALLOC], [], [Define this to enable mmap instead of malloc. Experimental.]) 874 ;; 875 no|*) 876 ;; 877esac 878 879AC_ARG_ENABLE(radix-tree, AC_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.])) 880case "$enable_radix_tree" in 881 no) 882 ;; 883 yes|*) 884 AC_DEFINE_UNQUOTED([USE_RADIX_TREE], [], [Define this to configure to use the radix tree.]) 885 ;; 886esac 887 888AC_ARG_ENABLE(packed, AC_HELP_STRING([--enable-packed], [Enable packed structure alignment, uses less memory, but unaligned reads.])) 889case "$enable_packed" in 890 yes) 891 AC_DEFINE_UNQUOTED([PACKED_STRUCTS], [], [Define this to use packed structure alignment.]) 892 ACX_CHECK_COMPILER_FLAG(Wno-address-of-packed-member, [CFLAGS="$CFLAGS -Wno-address-of-packed-member"]) 893 ;; 894 no|*) 895 ;; 896esac 897 898AH_BOTTOM([ 899/* define before includes as it specifies what standard to use. */ 900#if (defined(HAVE_PSELECT) && !defined (HAVE_PSELECT_PROTO)) \ 901 || !defined (HAVE_CTIME_R_PROTO) \ 902 || defined (STRPTIME_NEEDS_DEFINES) 903# ifndef _XOPEN_SOURCE 904# define _XOPEN_SOURCE 600 905# endif 906# ifndef _POSIX_C_SOURCE 907# define _POSIX_C_SOURCE 200112 908# endif 909# ifndef _BSD_SOURCE 910# define _BSD_SOURCE 1 911# endif 912# ifndef _DEFAULT_SOURCE 913# define _DEFAULT_SOURCE 1 914# endif 915# ifndef __EXTENSIONS__ 916# define __EXTENSIONS__ 1 917# endif 918# ifndef _STDC_C99 919# define _STDC_C99 1 920# endif 921# ifndef _ALL_SOURCE 922# define _ALL_SOURCE 1 923# endif 924#endif 925]) 926 927AH_BOTTOM([ 928#ifdef HAVE_VA_LIST_DOUBLE_DEF 929/* workaround double va_list definition on some platforms */ 930# ifndef _VA_LIST_DEFINED 931# define _VA_LIST_DEFINED 932# endif 933#endif 934]) 935 936AH_BOTTOM([ 937#include <sys/types.h> 938#if STDC_HEADERS 939#include <stdlib.h> 940#include <stddef.h> 941#endif 942 943#ifdef HAVE_TIME_H 944#include <time.h> 945#endif 946 947#ifdef HAVE_STDINT_H 948#include <stdint.h> 949#endif 950 951#ifdef HAVE_SYS_SOCKET_H 952#include <sys/socket.h> 953#endif 954 955#ifdef HAVE_NETINET_IN_H 956#include <netinet/in.h> 957#endif 958 959#ifdef HAVE_NETINET_TCP_H 960#include <netinet/tcp.h> 961#endif 962 963#ifdef HAVE_ARPA_INET_H 964#include <arpa/inet.h> 965#endif 966 967/* For Tru64 */ 968#ifdef HAVE_SYS_BITYPES_H 969#include <sys/bitypes.h> 970#endif 971]) 972 973AH_BOTTOM([ 974#ifdef HAVE_ATTR_FORMAT 975#define ATTR_FORMAT(archetype, string_index, first_to_check) \ 976 __attribute__ ((format (archetype, string_index, first_to_check))) 977#else /* !HAVE_ATTR_FORMAT */ 978#define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */ 979#endif /* !HAVE_ATTR_FORMAT */ 980#if defined(__cplusplus) 981#define ATTR_UNUSED(x) 982#elif defined(HAVE_ATTR_UNUSED) 983#define ATTR_UNUSED(x) x __attribute__((unused)) 984#else /* !HAVE_ATTR_UNUSED */ 985#define ATTR_UNUSED(x) x 986#endif /* !HAVE_ATTR_UNUSED */ 987]) 988 989AH_BOTTOM([ 990#ifndef IPV6_MIN_MTU 991#define IPV6_MIN_MTU 1280 992#endif /* IPV6_MIN_MTU */ 993 994#ifndef AF_INET6 995#define AF_INET6 28 996#endif /* AF_INET6 */ 997]) 998 999if test $ac_cv_func_getaddrinfo = no; then 1000AC_LIBOBJ([fake-rfc2553]) 1001fi 1002 1003AH_BOTTOM([ 1004/* maximum nesting of included files */ 1005#define MAXINCLUDES 10 1006]) 1007 1008AH_BOTTOM([ 1009#ifndef HAVE_B64_NTOP 1010int b64_ntop(uint8_t const *src, size_t srclength, 1011 char *target, size_t targsize); 1012#endif /* !HAVE_B64_NTOP */ 1013#ifndef HAVE_B64_PTON 1014int b64_pton(char const *src, uint8_t *target, size_t targsize); 1015#endif /* !HAVE_B64_PTON */ 1016#ifndef HAVE_FSEEKO 1017#define fseeko fseek 1018#define ftello ftell 1019#endif /* HAVE_FSEEKO */ 1020#ifndef HAVE_SNPRINTF 1021#include <stdarg.h> 1022int snprintf (char *str, size_t count, const char *fmt, ...); 1023int vsnprintf (char *str, size_t count, const char *fmt, va_list arg); 1024#endif /* HAVE_SNPRINTF */ 1025#ifndef HAVE_INET_PTON 1026int inet_pton(int af, const char* src, void* dst); 1027#endif /* HAVE_INET_PTON */ 1028#ifndef HAVE_INET_NTOP 1029const char *inet_ntop(int af, const void *src, char *dst, size_t size); 1030#endif 1031#ifndef HAVE_INET_ATON 1032int inet_aton(const char *cp, struct in_addr *addr); 1033#endif 1034#ifndef HAVE_MEMMOVE 1035void *memmove(void *dest, const void *src, size_t n); 1036#endif 1037#ifndef HAVE_STRLCAT 1038size_t strlcat(char *dst, const char *src, size_t siz); 1039#endif 1040#ifndef HAVE_STRLCPY 1041size_t strlcpy(char *dst, const char *src, size_t siz); 1042#endif 1043#ifndef HAVE_REALLOCARRAY 1044void* reallocarray(void *ptr, size_t nmemb, size_t size); 1045#endif 1046#ifndef HAVE_GETADDRINFO 1047#include "compat/fake-rfc2553.h" 1048#endif 1049#ifndef HAVE_STRPTIME 1050#define HAVE_STRPTIME 1 1051char *strptime(const char *s, const char *format, struct tm *tm); 1052#endif 1053#ifndef STRPTIME_WORKS 1054#define STRPTIME_WORKS 1 1055char *nsd_strptime(const char *s, const char *format, struct tm *tm); 1056#define strptime(a,b,c) nsd_strptime((a),(b),(c)) 1057#endif 1058]) 1059AH_BOTTOM( 1060AHX_MEMCMP_BROKEN(nsd) 1061AHX_CONFIG_MAXHOSTNAMELEN 1062) 1063AH_BOTTOM([ 1064 1065/* provide timespec def if not available */ 1066#ifndef CONFIG_DEFINES 1067#define CONFIG_DEFINES 1068#ifndef HAVE_STRUCT_TIMESPEC 1069#ifndef __timespec_defined 1070#define __timespec_defined 1 1071 struct timespec { 1072 long tv_sec; /* seconds */ 1073 long tv_nsec; /* nanoseconds */ 1074 }; 1075#endif /* !__timespec_defined */ 1076#endif /* !HAVE_STRUCT_TIMESPEC */ 1077#endif /* !CONFIG_DEFINES */ 1078 1079#ifdef PACKED_STRUCTS 1080#define ATTR_PACKED __attribute__((packed)) 1081#else 1082#define ATTR_PACKED 1083#endif 1084]) 1085 1086# big fat warning 1087if test "$enable_checking" = "yes"; then 1088 echo "************************************************" 1089 echo "* You have activated \"--enable-checking\" *" 1090 echo "* *" 1091 echo "* This will instruct NSD to be stricter *" 1092 echo "* when validating its input. This could lead *" 1093 echo "* to a reduced service level. *" 1094 echo "* *" 1095 echo "************************************************" 1096fi 1097 1098AC_CONFIG_FILES([Makefile]) 1099AC_OUTPUT 1100