configure.ac revision 1.1.1.3
1dnl 2dnl Some global settings 3dnl 4 5sinclude(acx_nlnetlabs.m4) 6 7AC_INIT(NSD,4.1.24,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 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]) 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]) 589AC_CHECK_MEMBERS([struct sockaddr_un.sun_len],,,[ 590AC_INCLUDES_DEFAULT 591#ifdef HAVE_SYS_UN_H 592#include <sys/un.h> 593#endif 594]) 595 596# Checks for library functions. 597AC_FUNC_CHOWN 598AC_FUNC_FORK 599AC_FUNC_MALLOC 600AC_TYPE_SIGNAL 601AC_FUNC_FSEEKO 602AC_SYS_LARGEFILE 603AC_CHECK_SIZEOF(void*) 604AC_CHECK_SIZEOF(off_t) 605AC_CHECK_FUNCS([arc4random arc4random_uniform]) 606AC_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]) 607 608AC_ARG_ENABLE(recvmmsg, AC_HELP_STRING([--enable-recvmmsg], [Enable recvmmsg and sendmmsg compilation, faster but some kernel versions may have implementation problems for IPv6])) 609case "$enable_recvmmsg" in 610 yes) 611 AC_CHECK_FUNC([recvmmsg], [ 612AC_RUN_IFELSE([AC_LANG_SOURCE([[ 613#include <sys/socket.h> 614#include <errno.h> 615int main(void) 616{ 617 int s = socket(AF_INET, SOCK_DGRAM, 0); 618 int r = recvmmsg(s, 0, 0, 0, 0) == -1 && errno == ENOSYS; 619 close(s); 620 return r; 621} 622]])], [ 623AC_DEFINE([HAVE_RECVMMSG], [1], [Define if recvmmsg is implemented])], [ 624], [ 625AC_DEFINE([HAVE_RECVMMSG], [1], [Define if recvmmsg exists])] 626)]) 627 AC_CHECK_FUNC([sendmmsg], [ 628AC_RUN_IFELSE([AC_LANG_SOURCE([[ 629#include <sys/socket.h> 630#include <errno.h> 631int main(void) 632{ 633 int s = socket(AF_INET, SOCK_DGRAM, 0); 634 int r = sendmmsg(s, 0, 0, 0) == -1 && errno == ENOSYS; 635 close(s); 636 return r; 637} 638]])], [ 639AC_DEFINE([HAVE_SENDMMSG], [1], [Define if sendmmsg is implemented])], [ 640], [ 641AC_DEFINE([HAVE_SENDMMSG], [1], [Define if sendmmsg exists])] 642)]) 643 644 ;; 645 no|*) 646 ;; 647esac 648 649# check if setreuid en setregid fail, on MacOSX10.4(darwin8). 650if echo $target_os | grep darwin8 > /dev/null; then 651 AC_DEFINE(DARWIN_BROKEN_SETREUID, 1, [Define this if on macOSX10.4-darwin8 and setreuid and setregid do not work]) 652fi 653 654# 655# Checking for missing functions we can replace 656# 657AC_REPLACE_FUNCS(basename) 658AC_REPLACE_FUNCS(inet_aton) 659AC_REPLACE_FUNCS(inet_pton) 660AC_REPLACE_FUNCS(inet_ntop) 661AC_REPLACE_FUNCS(snprintf) 662AC_REPLACE_FUNCS(strlcat) 663AC_REPLACE_FUNCS(strlcpy) 664AC_REPLACE_FUNCS(strptime) 665AC_REPLACE_FUNCS(b64_pton) 666AC_REPLACE_FUNCS(b64_ntop) 667AC_REPLACE_FUNCS(pselect) 668AC_REPLACE_FUNCS(memmove) 669AC_REPLACE_FUNCS(reallocarray) 670 671AC_MSG_CHECKING(for pselect prototype in sys/select.h) 672AC_EGREP_HEADER([[^a-zA-Z_]*pselect[^a-zA-Z_]], sys/select.h, AC_DEFINE(HAVE_PSELECT_PROTO, 1, 673 [if sys/select.h provides pselect prototype]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) 674 675AC_MSG_CHECKING(for ctime_r prototype in time.h) 676AC_EGREP_HEADER([[^a-zA-Z_]*ctime_r[^a-zA-Z_]], time.h, AC_DEFINE(HAVE_CTIME_R_PROTO, 1, 677 [if time.h provides ctime_r prototype]) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) 678 679AC_CHECK_TYPE([struct timespec], AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1, [If time.h has a struct timespec (for pselect).]), [], [ 680AC_INCLUDES_DEFAULT 681#ifdef HAVE_SIGNAL_H 682#include <signal.h> 683#endif 684#ifdef HAVE_TIME_H 685#include <time.h> 686#endif 687]) 688 689dnl 690dnl Some random defines's 691dnl 692AC_DEFINE_UNQUOTED([IDENTITY], ["unidentified server"], [Define to the default nsd identity.]) 693AC_DEFINE_UNQUOTED([VERSION], [PACKAGE_STRING], [Define to the NSD version to answer version.server query.]) 694AC_DEFINE_UNQUOTED([TCP_BACKLOG], [256], [Define to the backlog to be used with listen.]) 695AC_DEFINE_UNQUOTED([TCP_PORT], ["53"], [Define to the default tcp port.]) 696AC_DEFINE_UNQUOTED([TCP_MAX_MESSAGE_LEN], [65535], [Define to the default maximum message length.]) 697AC_DEFINE_UNQUOTED([UDP_PORT], ["53"], [Define to the default udp port.]) 698AC_DEFINE_UNQUOTED([UDP_MAX_MESSAGE_LEN], [512], [Define to the default maximum udp message length.]) 699AC_DEFINE_UNQUOTED([EDNS_MAX_MESSAGE_LEN], [4096], [Define to the default maximum message length with EDNS.]) 700AC_DEFINE_UNQUOTED([MAXSYSLOGMSGLEN], [512], [Define to the maximum message length to pass to syslog.]) 701AC_DEFINE_UNQUOTED([NSD_CONTROL_PORT], [8952], [Define to the default nsd-control port.]) 702AC_DEFINE_UNQUOTED([NSD_CONTROL_VERSION], [1], [Define to nsd-control proto version.]) 703 704dnl 705dnl Determine the syslog facility to use 706dnl 707facility=LOG_DAEMON 708AC_ARG_WITH([facility], 709 AC_HELP_STRING([--with-facility=name], [Syslog default facility (LOG_DAEMON)]), 710 [facility=$withval]) 711AC_DEFINE_UNQUOTED([FACILITY], $facility, [Define to the default facility for syslog.]) 712 713dnl 714dnl Determine the default tcp timeout 715dnl 716tcp_timeout=120 717AC_ARG_WITH([tcp_timeout], 718 AC_HELP_STRING([--with-tcp-timeout=number], [Limit the default tcp timeout]), 719 [tcp_timeout=$withval]) 720AC_DEFINE_UNQUOTED([TCP_TIMEOUT], $tcp_timeout, [Define to the default tcp timeout.]) 721 722dnl 723dnl Features 724dnl 725AC_ARG_ENABLE(root-server, AC_HELP_STRING([--enable-root-server], [Configure NSD as a root server])) 726case "$enable_root_server" in 727 yes) 728 AC_DEFINE_UNQUOTED([ROOT_SERVER], [], [Define this to configure as a root server.]) 729 ;; 730 no|*) 731 ;; 732esac 733 734AC_ARG_ENABLE(ipv6, AC_HELP_STRING([--disable-ipv6], [Disables IPv6 support])) 735case "$enable_ipv6" in 736 no) 737 ;; 738 yes|*) 739 AC_DEFINE_UNQUOTED([INET6], [], [Define this to enable IPv6 support.]) 740 ;; 741esac 742 743AC_ARG_ENABLE(bind8-stats, AC_HELP_STRING([--enable-bind8-stats], [Enables BIND8 like NSTATS & XSTATS and statistics in nsd-control])) 744 745case "$enable_bind8_stats" in 746 yes|'') 747 AC_DEFINE_UNQUOTED([BIND8_STATS], [], [Define this to enable BIND8 like NSTATS & XSTATS.]) 748 ;; 749 no|*) 750 ;; 751esac 752 753AC_ARG_ENABLE(zone-stats, AC_HELP_STRING([--enable-zone-stats], [Enable per-zone statistics gathering (needs --enable-bind8-stats)])) 754case "$enable_zone_stats" in 755 yes) 756 AC_DEFINE_UNQUOTED([USE_ZONE_STATS], [], [Define this to enable per-zone statistics gathering.]) 757 AC_DEFINE_UNQUOTED([BIND8_STATS], [], [Define this to enable BIND8 like NSTATS & XSTATS.]) 758 ;; 759 no|''|*) 760 ;; 761esac 762 763AC_ARG_ENABLE(checking, AC_HELP_STRING([--enable-checking], [Enable internal runtime checks])) 764case "$enable_checking" in 765 yes) 766 CHECK_COMPILER_FLAG(W, [ CFLAGS="$CFLAGS -W" ]) 767 CHECK_COMPILER_FLAG(Wall, [ CFLAGS="$CFLAGS -Wall" ]) 768 CHECK_COMPILER_FLAG(Wextra, [ CFLAGS="$CFLAGS -Wextra" ]) 769 CHECK_COMPILER_FLAG(Wdeclaration-after-statement, [ CFLAGS="$CFLAGS -Wdeclaration-after-statement" ]) 770 ;; 771 no|*) 772 AC_DEFINE([NDEBUG], [], [Undefine this to enable internal runtime checks.]) 773 ;; 774esac 775 776AC_ARG_ENABLE(memclean, AC_HELP_STRING([--enable-memclean], [Cleanup memory (at exit) for eg. valgrind, memcheck])) 777if test "$enable_memclean" = "yes"; then AC_DEFINE_UNQUOTED([MEMCLEAN], [1], [Define this to cleanup memory at exit (eg. for valgrind, etc.)]) 778fi 779 780AC_ARG_ENABLE(ratelimit, AC_HELP_STRING([--enable-ratelimit], [Enable rate limiting])) 781case "$enable_ratelimit" in 782 yes) 783 AC_DEFINE_UNQUOTED([RATELIMIT], [], [Define this to enable rate limiting.]) 784 dnl causes awk to not match the exclusion start marker. 785 ratelimit="xx" 786 ;; 787 no|*) 788 ratelimit="" 789 ;; 790esac 791AC_SUBST(ratelimit) 792 793AC_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])) 794case "$enable_ratelimit_default_is_off" in 795 yes) 796 AC_DEFINE_UNQUOTED([RATELIMIT_DEFAULT_OFF], [], [Define this to set ratelimit to off by default.]) 797 ratelimit_default="off" 798 ;; 799 no|*) 800 ratelimit_default="on" 801 ;; 802esac 803AC_SUBST(ratelimit_default) 804 805# we need SSL for TSIG (and maybe also for NSEC3). 806CHECK_SSL 807if test x$HAVE_SSL = x"yes"; then 808 ACX_LIB_SSL 809 810 # Check for -pthread 811 BAKLIBS="$LIBS" 812 LIBS="-lcrypto $LIBS" 813 AC_TRY_LINK([], [ 814 int HMAC_Update(void); 815 (void)HMAC_Update(); 816 ], [],[ 817 dnl so link fails for HMAC_Update, try with -pthread. 818 BAKCFLAGS="$CFLAGS" 819 CFLAGS="$CFLAGS -pthread" 820 AC_MSG_CHECKING([if libcrypto needs -pthread]) 821 AC_TRY_LINK_FUNC([HMAC_Update], [ 822 AC_MSG_RESULT([yes]) 823 ] , [ 824 AC_MSG_RESULT([no]) 825 dnl restore the nonpthread value 826 CFLAGS="$BAKCFLAGS" 827 ]) 828 ]) 829 LIBS="$BAKLIBS" 830 831 if test -n "$ssldir"; then 832 AC_CHECK_LIB(crypto, HMAC_Update,, [ 833 AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required]) 834 ]) 835 fi 836 SSL_LIBS="-lssl" 837 AC_SUBST(SSL_LIBS) 838 AC_CHECK_HEADERS([openssl/ssl.h],,, [AC_INCLUDES_DEFAULT]) 839 AC_CHECK_HEADERS([openssl/err.h],,, [AC_INCLUDES_DEFAULT]) 840 AC_CHECK_HEADERS([openssl/rand.h],,, [AC_INCLUDES_DEFAULT]) 841 AC_CHECK_FUNCS([HMAC_CTX_reset HMAC_CTX_new EVP_cleanup ERR_load_crypto_strings OPENSSL_init_crypto]) 842 843 BAKLIBS="$LIBS" 844 LIBS="-lssl $LIBS" 845 AC_CHECK_FUNCS([OPENSSL_init_ssl]) 846 LIBS="$BAKLIBS" 847 848else 849 AC_MSG_WARN([No SSL, therefore remote-control is disabled]) 850fi 851 852AC_ARG_ENABLE(nsec3, AC_HELP_STRING([--disable-nsec3], [Disable NSEC3 support])) 853case "$enable_nsec3" in 854 no) 855 ;; 856 yes) 857 AC_DEFINE_UNQUOTED([NSEC3], [], [Define this to enable NSEC3 support.]) 858 ;; 859 *) 860 if test x$HAVE_SSL = x"yes"; then 861 AC_DEFINE_UNQUOTED([NSEC3], [], [Define this to enable NSEC3 support.]) 862 else 863 AC_MSG_WARN([No SSL, therefore NSEC3 is disabled]) 864 fi 865 ;; 866esac 867 868AC_ARG_ENABLE(minimal-responses, AC_HELP_STRING([--disable-minimal-responses], [Disable response minimization. More truncation.])) 869case "$enable_minimal_responses" in 870 no) 871 ;; 872 yes|*) 873 AC_DEFINE_UNQUOTED([MINIMAL_RESPONSES], [], [Define this to enable response minimalization to reduce truncation.]) 874 ;; 875esac 876 877AC_ARG_ENABLE(mmap, AC_HELP_STRING([--enable-mmap], [Use mmap instead of malloc. Experimental.])) 878case "$enable_mmap" in 879 yes) 880 AC_CHECK_HEADERS([sys/mman.h]) 881 AC_LIBGTOP_CHECK_TYPE(uintptr_t, void*) 882 AC_CHECK_FUNCS([mmap munmap]) 883 AC_DEFINE_UNQUOTED([USE_MMAP_ALLOC], [], [Define this to enable mmap instead of malloc. Experimental.]) 884 ;; 885 no|*) 886 ;; 887esac 888 889AC_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.])) 890case "$enable_radix_tree" in 891 no) 892 ;; 893 yes|*) 894 AC_DEFINE_UNQUOTED([USE_RADIX_TREE], [], [Define this to configure to use the radix tree.]) 895 ;; 896esac 897 898AC_ARG_ENABLE(packed, AC_HELP_STRING([--enable-packed], [Enable packed structure alignment, uses less memory, but unaligned reads.])) 899case "$enable_packed" in 900 yes) 901 AC_DEFINE_UNQUOTED([PACKED_STRUCTS], [], [Define this to use packed structure alignment.]) 902 ACX_CHECK_COMPILER_FLAG(Wno-address-of-packed-member, [CFLAGS="$CFLAGS -Wno-address-of-packed-member"]) 903 ;; 904 no|*) 905 ;; 906esac 907 908# Include systemd.m4 - begin 909sinclude(systemd.m4) 910# Include systemd.m4 - end 911 912AH_BOTTOM([ 913/* define before includes as it specifies what standard to use. */ 914#if (defined(HAVE_PSELECT) && !defined (HAVE_PSELECT_PROTO)) \ 915 || !defined (HAVE_CTIME_R_PROTO) \ 916 || defined (STRPTIME_NEEDS_DEFINES) 917# ifndef _XOPEN_SOURCE 918# define _XOPEN_SOURCE 600 919# endif 920# ifndef _POSIX_C_SOURCE 921# define _POSIX_C_SOURCE 200112 922# endif 923# ifndef _BSD_SOURCE 924# define _BSD_SOURCE 1 925# endif 926# ifndef _DEFAULT_SOURCE 927# define _DEFAULT_SOURCE 1 928# endif 929# ifndef __EXTENSIONS__ 930# define __EXTENSIONS__ 1 931# endif 932# ifndef _STDC_C99 933# define _STDC_C99 1 934# endif 935# ifndef _ALL_SOURCE 936# define _ALL_SOURCE 1 937# endif 938#endif 939]) 940 941AH_BOTTOM([ 942#ifdef HAVE_VA_LIST_DOUBLE_DEF 943/* workaround double va_list definition on some platforms */ 944# ifndef _VA_LIST_DEFINED 945# define _VA_LIST_DEFINED 946# endif 947#endif 948]) 949 950AH_BOTTOM([ 951#include <sys/types.h> 952#if STDC_HEADERS 953#include <stdlib.h> 954#include <stddef.h> 955#endif 956 957#ifdef HAVE_TIME_H 958#include <time.h> 959#endif 960 961#ifdef HAVE_STDINT_H 962#include <stdint.h> 963#endif 964 965#ifdef HAVE_SYS_SOCKET_H 966#include <sys/socket.h> 967#endif 968 969#ifdef HAVE_NETINET_IN_H 970#include <netinet/in.h> 971#endif 972 973#ifdef HAVE_NETINET_TCP_H 974#include <netinet/tcp.h> 975#endif 976 977#ifdef HAVE_ARPA_INET_H 978#include <arpa/inet.h> 979#endif 980 981/* For Tru64 */ 982#ifdef HAVE_SYS_BITYPES_H 983#include <sys/bitypes.h> 984#endif 985]) 986 987AH_BOTTOM([ 988#ifdef HAVE_ATTR_FORMAT 989#define ATTR_FORMAT(archetype, string_index, first_to_check) \ 990 __attribute__ ((format (archetype, string_index, first_to_check))) 991#else /* !HAVE_ATTR_FORMAT */ 992#define ATTR_FORMAT(archetype, string_index, first_to_check) /* empty */ 993#endif /* !HAVE_ATTR_FORMAT */ 994#if defined(__cplusplus) 995#define ATTR_UNUSED(x) 996#elif defined(HAVE_ATTR_UNUSED) 997#define ATTR_UNUSED(x) x __attribute__((unused)) 998#else /* !HAVE_ATTR_UNUSED */ 999#define ATTR_UNUSED(x) x 1000#endif /* !HAVE_ATTR_UNUSED */ 1001]) 1002 1003AH_BOTTOM([ 1004#ifndef IPV6_MIN_MTU 1005#define IPV6_MIN_MTU 1280 1006#endif /* IPV6_MIN_MTU */ 1007 1008#ifndef AF_INET6 1009#define AF_INET6 28 1010#endif /* AF_INET6 */ 1011]) 1012 1013if test $ac_cv_func_getaddrinfo = no; then 1014AC_LIBOBJ([fake-rfc2553]) 1015fi 1016 1017AH_BOTTOM([ 1018/* maximum nesting of included files */ 1019#define MAXINCLUDES 10 1020]) 1021 1022AH_BOTTOM([ 1023#ifndef HAVE_B64_NTOP 1024int b64_ntop(uint8_t const *src, size_t srclength, 1025 char *target, size_t targsize); 1026#endif /* !HAVE_B64_NTOP */ 1027#ifndef HAVE_B64_PTON 1028int b64_pton(char const *src, uint8_t *target, size_t targsize); 1029#endif /* !HAVE_B64_PTON */ 1030#ifndef HAVE_FSEEKO 1031#define fseeko fseek 1032#define ftello ftell 1033#endif /* HAVE_FSEEKO */ 1034#ifndef HAVE_SNPRINTF 1035#include <stdarg.h> 1036int snprintf (char *str, size_t count, const char *fmt, ...); 1037int vsnprintf (char *str, size_t count, const char *fmt, va_list arg); 1038#endif /* HAVE_SNPRINTF */ 1039#ifndef HAVE_INET_PTON 1040int inet_pton(int af, const char* src, void* dst); 1041#endif /* HAVE_INET_PTON */ 1042#ifndef HAVE_INET_NTOP 1043const char *inet_ntop(int af, const void *src, char *dst, size_t size); 1044#endif 1045#ifndef HAVE_INET_ATON 1046int inet_aton(const char *cp, struct in_addr *addr); 1047#endif 1048#ifndef HAVE_MEMMOVE 1049void *memmove(void *dest, const void *src, size_t n); 1050#endif 1051#ifndef HAVE_STRLCAT 1052size_t strlcat(char *dst, const char *src, size_t siz); 1053#endif 1054#ifndef HAVE_STRLCPY 1055size_t strlcpy(char *dst, const char *src, size_t siz); 1056#endif 1057#ifndef HAVE_REALLOCARRAY 1058void* reallocarray(void *ptr, size_t nmemb, size_t size); 1059#endif 1060#ifndef HAVE_GETADDRINFO 1061#include "compat/fake-rfc2553.h" 1062#endif 1063#ifndef HAVE_STRPTIME 1064#define HAVE_STRPTIME 1 1065char *strptime(const char *s, const char *format, struct tm *tm); 1066#endif 1067#ifndef STRPTIME_WORKS 1068#define STRPTIME_WORKS 1 1069char *nsd_strptime(const char *s, const char *format, struct tm *tm); 1070#define strptime(a,b,c) nsd_strptime((a),(b),(c)) 1071#endif 1072]) 1073AH_BOTTOM( 1074AHX_MEMCMP_BROKEN(nsd) 1075AHX_CONFIG_MAXHOSTNAMELEN 1076) 1077AH_BOTTOM([ 1078 1079/* provide timespec def if not available */ 1080#ifndef CONFIG_DEFINES 1081#define CONFIG_DEFINES 1082#ifndef HAVE_STRUCT_TIMESPEC 1083#ifndef __timespec_defined 1084#define __timespec_defined 1 1085 struct timespec { 1086 long tv_sec; /* seconds */ 1087 long tv_nsec; /* nanoseconds */ 1088 }; 1089#endif /* !__timespec_defined */ 1090#endif /* !HAVE_STRUCT_TIMESPEC */ 1091#endif /* !CONFIG_DEFINES */ 1092 1093#ifdef PACKED_STRUCTS 1094#define ATTR_PACKED __attribute__((packed)) 1095#else 1096#define ATTR_PACKED 1097#endif 1098]) 1099 1100# big fat warning 1101if test "$enable_checking" = "yes"; then 1102 echo "************************************************" 1103 echo "* You have activated \"--enable-checking\" *" 1104 echo "* *" 1105 echo "* This will instruct NSD to be stricter *" 1106 echo "* when validating its input. This could lead *" 1107 echo "* to a reduced service level. *" 1108 echo "* *" 1109 echo "************************************************" 1110fi 1111 1112AC_CONFIG_FILES([Makefile]) 1113AC_OUTPUT 1114