xref: /minix/external/bsd/bind/dist/configure.in (revision 00b67f09)
1# Copyright (C) 2004-2015  Internet Systems Consortium, Inc. ("ISC")
2# Copyright (C) 1998-2003  Internet Software Consortium.
3#
4# Permission to use, copy, modify, and/or distribute this software for any
5# purpose with or without fee is hereby granted, provided that the above
6# copyright notice and this permission notice appear in all copies.
7#
8# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14# PERFORMANCE OF THIS SOFTWARE.
15
16# Copyright (C) 1998-2003  Internet Software Consortium.
17#
18# Permission to use, copy, modify, and/or distribute this software for any
19# purpose with or without fee is hereby granted, provided that the above
20# copyright notice and this permission notice appear in all copies.
21#
22# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
23# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
24# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
25# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
26# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
27# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28# PERFORMANCE OF THIS SOFTWARE.
29
30dnl
31AC_DIVERT_PUSH(1)dnl
32esyscmd([sed -e 's/^/# /' -e '/Portions of this code/,$d' COPYRIGHT])dnl
33AC_DIVERT_POP()dnl
34
35AC_INIT(BIND, [9.10], [bind9-bugs@isc.org], [], [https://www.isc.org/downloads/BIND/])
36AC_PREREQ(2.59)
37
38AC_CONFIG_HEADER(config.h)
39AC_CONFIG_MACRO_DIR([m4])
40
41AC_CANONICAL_HOST
42
43AC_PROG_MAKE_SET
44
45#
46# GNU libtool support
47#
48case $build_os in
49sunos*)
50    # Just set the maximum command line length for sunos as it otherwise
51    # takes a exceptionally long time to work it out. Required for libtool.
52
53    lt_cv_sys_max_cmd_len=4096;
54    ;;
55esac
56
57AC_PROG_LIBTOOL
58AC_PROG_INSTALL
59AC_PROG_LN_S
60
61AC_SUBST(STD_CINCLUDES)
62AC_SUBST(STD_CDEFINES)
63AC_SUBST(STD_CWARNINGS)
64AC_SUBST(CCOPT)
65AC_SUBST(CCNOOPT)
66AC_SUBST(BACKTRACECFLAGS)
67
68# Warn if the user specified libbind, which is now deprecated
69AC_ARG_ENABLE(libbind, [  --enable-libbind	  deprecated])
70
71case "$enable_libbind" in
72	yes)
73		AC_MSG_ERROR(['libbind' is no longer part of the BIND 9 distribution.
74It is available from http://www.isc.org as a separate download.])
75		;;
76	no|'')
77		;;
78esac
79
80AC_ARG_ENABLE(warn_shadow, [  --enable-warn-shadow	  turn on -Wshadow when compiling])
81
82AC_ARG_ENABLE(warn_error, [  --enable-warn-error	  turn on -Werror when compiling])
83
84AC_ARG_ENABLE(developer, [  --enable-developer      enable developer build settings])
85case "$enable_developer" in
86yes)
87	STD_CDEFINES="$STD_CDEFINES -DISC_LIST_CHECKINIT=1"
88	test "${enable_fixed_rrset+set}" = set || enable_fixed_rrset=yes
89	test "${with_atf+set}" = set || with_atf=yes
90	test "${enable_filter_aaaa+set}" = set || enable_filter_aaaa=yes
91	test "${with_dlz_filesystem+set}" = set || with_dlz_filesystem=yes
92	test "${enable_symtable+set}" = set || enable_symtable=all
93	test "${enable_sit+set}" = set || enable_sit=yes
94	test "${enable_warn_error+set}" = set || enable_warn_error=yes
95	test "${enable_warn_shadow+set}" = set || enable_warn_shadow=yes
96	;;
97esac
98
99#libseccomp sandboxing
100AC_ARG_ENABLE(seccomp,
101	AS_HELP_STRING([--enable-seccomp],[enable support for libseccomp system call filtering [default=no]]))
102case "$enable_seccomp" in
103	yes)
104	case $host_os in
105	linux*)
106		;;
107	*)
108		AC_MSG_WARN([seccomp is not supported on non-linux platforms; disabling it])
109		enable_seccomp=no
110		;;
111	esac
112	AC_SEARCH_LIBS(seccomp_init, [seccomp])
113	if test "$ac_cv_search_seccomp_init" = "-lseccomp" ; then
114		AC_TRY_RUN([
115		#include <stdio.h>
116		#include <stdlib.h>
117		#include <errno.h>
118		#include <sys/prctl.h>
119		#include <linux/seccomp.h>
120
121		int main(void)
122		{
123			int ret;
124
125			ret = prctl(PR_GET_SECCOMP, 0, 0, 0, 0);
126			if (ret < 0) {
127				switch (errno) {
128				case ENOSYS:
129					return 1;
130				case EINVAL:
131					return 1;
132				default:
133					return 1;
134				}
135			}
136			ret =
137			prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0);
138			if (ret < 0) {
139				switch (errno) {
140				case EINVAL:
141					return 1;
142				case EFAULT:
143					return 0;
144				default:
145					return 1;
146			}
147		}
148	return 1;
149	}
150	]
151	, AC_DEFINE([HAVE_LIBSECCOMP], 1,
152	[Define to use libseccomp system call filtering.])
153	, []
154	)
155	fi
156		;;
157	*)
158		;;
159esac
160
161#
162# Make very sure that these are the first files processed by
163# config.status, since we use the processed output as the input for
164# AC_SUBST_FILE() substitutions in other files.
165#
166AC_CONFIG_FILES([make/rules make/includes])
167
168AC_PATH_PROG(AR, ar)
169ARFLAGS="cruv"
170AC_SUBST(AR)
171AC_SUBST(ARFLAGS)
172
173# The POSIX ln(1) program.  Non-POSIX systems may substitute
174# "copy" or something.
175LN=ln
176AC_SUBST(LN)
177
178case "$AR" in
179	"")
180		AC_MSG_ERROR([
181ar program not found.  Please fix your PATH to include the directory in
182which ar resides, or set AR in the environment with the full path to ar.
183])
184
185		;;
186esac
187
188#
189# Etags.
190#
191AC_PATH_PROGS(ETAGS, etags emacs-etags)
192
193#
194# Some systems, e.g. RH7, have the Exuberant Ctags etags instead of
195# GNU emacs etags, and it requires the -L flag.
196#
197if test "X$ETAGS" != "X"; then
198	AC_MSG_CHECKING(for Exuberant Ctags etags)
199	if $ETAGS --version 2>&1 | grep 'Exuberant Ctags' >/dev/null 2>&1; then
200		AC_MSG_RESULT(yes)
201		ETAGS="$ETAGS -L"
202	else
203		AC_MSG_RESULT(no)
204	fi
205fi
206AC_SUBST(ETAGS)
207
208#
209# Perl is optional; it is used only by some of the system test scripts.
210# Note: the backtrace feature (see below) uses perl to build the symbol table,
211# but it still compiles without perl, in which case an empty table will be used.
212#
213AC_PATH_PROGS(PERL, perl5 perl)
214AC_SUBST(PERL)
215
216#
217# Python is also optional; it is used by the tools in bin/python.
218# If python is unavailable, we simply don't build those.
219#
220AC_ARG_WITH(python,
221[  --with-python=PATH      specify path to python interpreter],
222    use_python="$withval", use_python="unspec")
223
224python="python python3 python3.4 python3.3 python3.2 python3.1 python3.0 python2 python2.7 python2.6 python2.5 python2.4"
225testscript='try: import argparse
226except: exit(1)'
227case "$use_python" in
228	no)
229		AC_MSG_CHECKING([for python support])
230		AC_MSG_RESULT(disabled)
231		;;
232	unspec|yes|*)
233		case "$use_python" in
234		unspec|yes|'')
235			for p in $python
236			do
237				AC_PATH_PROGS(PYTHON, $p)
238				if test "X$PYTHON" == "X"; then
239					continue;
240				fi
241				AC_MSG_CHECKING([python module 'argparse'])
242				if ${PYTHON:-false} -c "$testscript"; then
243					AC_MSG_RESULT([found, using $PYTHON])
244					break
245				fi
246				AC_MSG_RESULT([not found])
247				unset ac_cv_path_PYTHON
248				unset PYTHON
249			done
250			if test "X$PYTHON" == "X"
251			then
252				AC_MSG_CHECKING([for python support])
253				case "$use_python" in
254				unspec)
255					AC_MSG_RESULT(disabled)
256					;;
257				yes)
258					AC_MSG_ERROR([missing python])
259					;;
260				esac
261			fi
262			;;
263		*)
264			case "$use_python" in
265			/*)
266				PYTHON="$use_python"
267				;;
268			*)
269				AC_PATH_PROGS(PYTHON, $use_python)
270				;;
271			esac
272			AC_MSG_CHECKING([python module 'argparse'])
273			if ${PYTHON:-false} -c "$testscript"; then
274				AC_MSG_RESULT([found, using $PYTHON])
275				break
276			else
277				AC_MSG_ERROR([not found])
278			fi
279			;;
280		esac
281		;;
282esac
283
284PYTHON_TOOLS=''
285CHECKDS=''
286COVERAGE=''
287if test "X$PYTHON" != "X"; then
288	PYTHON_TOOLS=python
289	CHECKDS=checkds
290	COVERAGE=coverage
291fi
292AC_SUBST(CHECKDS)
293AC_SUBST(COVERAGE)
294AC_SUBST(PYTHON_TOOLS)
295
296#
297# Special processing of paths depending on whether --prefix,
298# --sysconfdir or --localstatedir arguments were given.  What's
299# desired is some compatibility with the way previous versions
300# of BIND built; they defaulted to /usr/local for most parts of
301# the installation, but named.boot/named.conf was in /etc
302# and named.pid was in /var/run.
303#
304# So ... if none of --prefix, --sysconfdir or --localstatedir are
305# specified, set things up that way.  If --prefix is given, use
306# it for sysconfdir and localstatedir the way configure normally
307# would.  To change the prefix for everything but leave named.conf
308# in /etc or named.pid in /var/run, then do this the usual configure way:
309# ./configure --prefix=/somewhere --sysconfdir=/etc
310# ./configure --prefix=/somewhere --localstatedir=/var
311#
312# To put named.conf and named.pid in /usr/local with everything else,
313# set the prefix explicitly to /usr/local even though that's the default:
314# ./configure --prefix=/usr/local
315#
316case "$prefix" in
317	NONE)
318		case "$sysconfdir" in
319			'${prefix}/etc')
320				sysconfdir=/etc
321				;;
322		esac
323		case "$localstatedir" in
324			'${prefix}/var')
325				localstatedir=/var
326				;;
327		esac
328		;;
329esac
330
331#
332# Make sure INSTALL uses an absolute path, else it will be wrong in all
333# Makefiles, since they use make/rules.in and INSTALL will be adjusted by
334# configure based on the location of the file where it is substituted.
335# Since in BIND9 INSTALL is only substituted into make/rules.in, an immediate
336# subdirectory of install-sh, This relative path will be wrong for all
337# directories more than one level down from install-sh.
338#
339case "$INSTALL" in
340	/*)
341		;;
342	*)
343		#
344		# Not all systems have dirname.
345		#
346		changequote({, })
347		ac_dir="`echo $INSTALL | sed 's%/[^/]*$%%'`"
348		changequote([, ])
349
350		ac_prog="`echo $INSTALL | sed 's%.*/%%'`"
351		test "$ac_dir" = "$ac_prog" && ac_dir=.
352		test -d "$ac_dir" && ac_dir="`(cd \"$ac_dir\" && pwd)`"
353		INSTALL="$ac_dir/$ac_prog"
354		;;
355esac
356
357#
358# On these hosts, we really want to use cc, not gcc, even if it is
359# found.  The gcc that these systems have will not correctly handle
360# pthreads.
361#
362# However, if the user sets $CC to be something, let that override
363# our change.
364#
365if test "X$CC" = "X" ; then
366	case "$host" in
367		*-dec-osf*)
368			CC="cc"
369			;;
370		*-solaris*)
371			# Use Sun's cc if it is available, but watch
372			# out for /usr/ucb/cc; it will never be the right
373			# compiler to use.
374			#
375			# If setting CC here fails, the AC_PROG_CC done
376			# below might still find gcc.
377			IFS="${IFS=	}"; ac_save_ifs="$IFS"; IFS=":"
378			for ac_dir in $PATH; do
379				test -z "$ac_dir" && ac_dir=.
380				case "$ac_dir" in
381				/usr/ucb)
382					# exclude
383					;;
384				*)
385					if test -f "$ac_dir/cc"; then
386						CC="$ac_dir/cc"
387						break
388					fi
389					;;
390				esac
391			done
392			IFS="$ac_save_ifs"
393			;;
394		*-hp-hpux*)
395			CC="cc"
396			;;
397		mips-sgi-irix*)
398			CC="cc"
399			;;
400	esac
401fi
402
403AC_PROG_CC
404
405#
406# gcc's optimiser is broken at -02 for ultrasparc
407#
408if test "$ac_env_CFLAGS_set" != set -a "X$GCC" = "Xyes"; then
409	case "$host" in
410	sparc-*)
411		CCFLAGS="-g -O1"
412		;;
413	esac
414fi
415
416#
417# OS dependent CC flags
418#
419case "$host" in
420	# OSF 5.0: recv/send are only available with -D_POSIX_PII_SOCKET or
421	# -D_XOPEN_SOURCE_EXTENDED.
422	*-dec-osf*)
423		STD_CDEFINES="$STD_CDEFINES -D_POSIX_PII_SOCKET"
424		CPPFLAGS="$CPPFLAGS -D_POSIX_PII_SOCKET"
425		;;
426	#HP-UX: need -D_XOPEN_SOURCE_EXTENDED and -lxnet for CMSG macros
427	*-hp-hpux*)
428		STD_CDEFINES="$STD_CDEFINES -D_XOPEN_SOURCE_EXTENDED"
429		CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
430		LIBS="-lxnet $LIBS"
431		;;
432	# Solaris: need -D_XPG4_2 and -D__EXTENSIONS__ for CMSG macros
433	*-solaris*)
434		STD_CDEFINES="$STD_CDEFINES -D_XPG4_2 -D__EXTENSIONS__"
435		CPPFLAGS="$CPPFLAGS -D_XPG4_2 -D__EXTENSIONS__"
436		;;
437	# POSIX doesn't include the IPv6 Advanced Socket API and glibc hides
438	# parts of the IPv6 Advanced Socket API as a result.  This is stupid
439	# as it breaks how the two halves (Basic and Advanced) of the IPv6
440	# Socket API were designed to be used but we have to live with it.
441	# Define _GNU_SOURCE to pull in the IPv6 Advanced Socket API.
442	*-linux* | *-kfreebsd*-gnu*)
443		STD_CDEFINES="$STD_CDEFINES -D_GNU_SOURCE"
444		CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
445		;;
446	#
447	# Starting with OSX 10.7 (Lion) we must choose which IPv6 API to use.
448	# Setting this is sufficient to select the correct behavior for BIND 9.
449	#
450	*-darwin*)
451	  STD_CDEFINES="$STD_CDEFINES -D__APPLE_USE_RFC_3542"
452	  CPPFLAGS="$CPPFLAGS -D__APPLE_USE_RFC_3542"
453	  ;;
454esac
455
456#
457# CCNOOPT defaults to -O0 on gcc and disables optimization when is last
458#
459if test "X$CCNOOPT" = "X" -a "X$GCC" = "Xyes"; then
460	CCNOOPT="-O0"
461fi
462
463AC_HEADER_STDC
464
465AC_CHECK_HEADERS(fcntl.h regex.h sys/time.h unistd.h sys/mman.h sys/sockio.h sys/select.h sys/param.h sys/sysctl.h net/if6.h sys/socket.h net/route.h linux/netlink.h linux/rtnetlink.h,,,
466[$ac_includes_default
467#ifdef HAVE_SYS_PARAM_H
468# include <sys/param.h>
469#endif
470#ifdef HAVE_SYS_SOCKET_H
471# include <sys/socket.h>
472#endif
473])
474
475AC_C_CONST
476AC_C_INLINE
477AC_C_VOLATILE
478AC_CHECK_FUNC(sysctlbyname, AC_DEFINE(HAVE_SYSCTLBYNAME))
479AC_C_FLEXIBLE_ARRAY_MEMBER
480
481#
482# Check for the existence of mmap to enable the fast format zones
483#
484AC_CHECK_FUNCS(mmap)
485
486#
487# Older versions of HP/UX don't define seteuid() and setegid()
488#
489AC_CHECK_FUNCS(seteuid setresuid)
490AC_CHECK_FUNCS(setegid setresgid)
491
492# BSDI doesn't have ftello fseeko
493AC_CHECK_FUNCS(ftello fseeko)
494
495#
496# UnixWare 7.1.1 with the feature supplement to the UDK compiler
497# is reported to not support "static inline" (RT #1212).
498#
499AC_MSG_CHECKING(for static inline breakage)
500AC_TRY_COMPILE([
501	static inline int foo1() {
502		return 0;
503	}
504
505	static inline int foo2() {
506		return foo1();
507	}
508	], [foo1();],
509	[AC_MSG_RESULT(no)],
510	[AC_MSG_RESULT(yes)
511	 AC_DEFINE(inline, ,[Define to empty if your compiler does not support "static inline".])])
512
513AC_TYPE_SIZE_T
514AC_CHECK_TYPE(ssize_t, int)
515AC_CHECK_TYPE(uintptr_t,unsigned long)
516AC_CHECK_TYPE(socklen_t,
517[AC_DEFINE(ISC_SOCKADDR_LEN_T, socklen_t)],
518[
519AC_TRY_COMPILE(
520[
521#include <sys/types.h>
522#include <sys/socket.h>
523int getsockname(int, struct sockaddr *, size_t *);
524],[],
525[AC_DEFINE(ISC_SOCKADDR_LEN_T, size_t)],
526[AC_DEFINE(ISC_SOCKADDR_LEN_T, int)])
527],
528[
529#include <sys/types.h>
530#include <sys/socket.h>
531])
532AC_SUBST(ISC_SOCKADDR_LEN_T)
533AC_HEADER_TIME
534AC_MSG_CHECKING(for long long)
535AC_TRY_COMPILE([],[long long i = 0; return (0);],
536	[AC_MSG_RESULT(yes)
537		ISC_PLATFORM_HAVELONGLONG="#define ISC_PLATFORM_HAVELONGLONG 1"],
538	[AC_MSG_RESULT(no)
539		ISC_PLATFORM_HAVELONGLONG="#undef ISC_PLATFORM_HAVELONGLONG"])
540AC_SUBST(ISC_PLATFORM_HAVELONGLONG)
541
542#
543# check for GCC noreturn attribute
544#
545AC_MSG_CHECKING(for GCC noreturn attribute)
546AC_TRY_COMPILE([],[void foo() __attribute__((noreturn));],
547	[AC_MSG_RESULT(yes)
548		ISC_PLATFORM_NORETURN_PRE="#define ISC_PLATFORM_NORETURN_PRE"
549		ISC_PLATFORM_NORETURN_POST="#define ISC_PLATFORM_NORETURN_POST __attribute__((noreturn))"],
550	[AC_MSG_RESULT(no)
551		ISC_PLATFORM_NORETURN_PRE="#define ISC_PLATFORM_NORETURN_PRE"
552		ISC_PLATFORM_NORETURN_POST="#define ISC_PLATFORM_NORETURN_POST"])
553AC_SUBST(ISC_PLATFORM_NORETURN_PRE)
554AC_SUBST(ISC_PLATFORM_NORETURN_POST)
555
556#
557# check if we have lifconf
558#
559AC_MSG_CHECKING(for struct lifconf)
560AC_TRY_COMPILE([
561#include <sys/types.h>
562#include <sys/socket.h>
563#include <net/if.h>
564],
565[
566struct lifconf lifconf;
567lifconf.lifc_len = 0;
568]
569,
570	[AC_MSG_RESULT(yes)
571		ISC_PLATFORM_HAVELIFCONF="#define ISC_PLATFORM_HAVELIFCONF 1"],
572	[AC_MSG_RESULT(no)
573		ISC_PLATFORM_HAVELIFCONF="#undef ISC_PLATFORM_HAVELIFCONF"])
574AC_SUBST(ISC_PLATFORM_HAVELIFCONF)
575
576#
577# check if we have kqueue
578#
579AC_ARG_ENABLE(kqueue,
580	[  --enable-kqueue         use BSD kqueue when available [[default=yes]]],
581	      want_kqueue="$enableval",  want_kqueue="yes")
582case $want_kqueue in
583yes)
584	AC_CHECK_FUNC(kqueue, ac_cv_have_kqueue=yes, ac_cv_have_kqueue=no)
585	case $ac_cv_have_kqueue in
586	yes)
587		ISC_PLATFORM_HAVEKQUEUE="#define ISC_PLATFORM_HAVEKQUEUE 1"
588		;;
589	*)
590		ISC_PLATFORM_HAVEKQUEUE="#undef ISC_PLATFORM_HAVEKQUEUE"
591		;;
592	esac
593	;;
594*)
595	ISC_PLATFORM_HAVEKQUEUE="#undef ISC_PLATFORM_HAVEKQUEUE"
596	;;
597esac
598AC_SUBST(ISC_PLATFORM_HAVEKQUEUE)
599
600#
601# check if we have epoll.  Linux kernel 2.4 has epoll_create() which fails,
602# so we need to try running the code, not just test its existence.
603#
604AC_ARG_ENABLE(epoll,
605[  --enable-epoll          use Linux epoll when available [[default=auto]]],
606	      want_epoll="$enableval",  want_epoll="auto")
607case $want_epoll in
608auto)
609	AC_MSG_CHECKING(epoll support)
610	AC_TRY_RUN([
611#include <sys/epoll.h>
612int main() {
613	if (epoll_create(1) < 0)
614		return (1);
615	return (0);
616}
617],
618	[AC_MSG_RESULT(yes)
619	ISC_PLATFORM_HAVEEPOLL="#define ISC_PLATFORM_HAVEEPOLL 1"],
620	[AC_MSG_RESULT(no)
621	ISC_PLATFORM_HAVEEPOLL="#undef ISC_PLATFORM_HAVEEPOLL"],
622	[AC_MSG_RESULT(no)
623	ISC_PLATFORM_HAVEEPOLL="#undef ISC_PLATFORM_HAVEEPOLL"])
624	;;
625yes)
626	ISC_PLATFORM_HAVEEPOLL="#define ISC_PLATFORM_HAVEEPOLL 1"
627	;;
628*)
629	ISC_PLATFORM_HAVEEPOLL="#undef ISC_PLATFORM_HAVEEPOLL"
630	;;
631esac
632AC_SUBST(ISC_PLATFORM_HAVEEPOLL)
633
634#
635# check if we support /dev/poll
636#
637AC_ARG_ENABLE(devpoll,
638	[  --enable-devpoll        use /dev/poll when available [[default=yes]]],
639	      want_devpoll="$enableval",  want_devpoll="yes")
640case $want_devpoll in
641yes)
642	AC_CHECK_HEADERS(sys/devpoll.h devpoll.h,
643	ISC_PLATFORM_HAVEDEVPOLL="#define ISC_PLATFORM_HAVEDEVPOLL 1"
644	,
645	ISC_PLATFORM_HAVEDEVPOLL="#undef ISC_PLATFORM_HAVEDEVPOLL"
646	)
647	;;
648*)
649	ISC_PLATFORM_HAVEDEVPOLL="#undef ISC_PLATFORM_HAVEDEVPOLL"
650	;;
651esac
652AC_SUBST(ISC_PLATFORM_HAVEDEVPOLL)
653
654#
655# check if we need to #include sys/select.h explicitly
656#
657case $ac_cv_header_unistd_h in
658yes)
659AC_MSG_CHECKING(if unistd.h or sys/types.h defines fd_set)
660AC_TRY_COMPILE([
661#include <sys/types.h> /* Ultrix */
662#include <unistd.h>],
663[fd_set read_set; return (0);],
664	[AC_MSG_RESULT(yes)
665	 ISC_PLATFORM_NEEDSYSSELECTH="#undef ISC_PLATFORM_NEEDSYSSELECTH"
666	 LWRES_PLATFORM_NEEDSYSSELECTH="#undef LWRES_PLATFORM_NEEDSYSSELECTH"],
667	[AC_MSG_RESULT(no)
668	case $ac_cv_header_sys_select_h in
669	yes)
670	 ISC_PLATFORM_NEEDSYSSELECTH="#define ISC_PLATFORM_NEEDSYSSELECTH 1"
671	 LWRES_PLATFORM_NEEDSYSSELECTH="#define LWRES_PLATFORM_NEEDSYSSELECTH 1"
672		;;
673	no)
674		AC_MSG_ERROR([need either working unistd.h or sys/select.h])
675		;;
676	esac
677	])
678	;;
679no)
680	case $ac_cv_header_sys_select_h in
681	yes)
682	     ISC_PLATFORM_NEEDSYSSELECTH="#define ISC_PLATFORM_NEEDSYSSELECTH 1"
683	     LWRES_PLATFORM_NEEDSYSSELECTH="#define LWRES_PLATFORM_NEEDSYSSELECTH 1"
684		;;
685	no)
686		AC_MSG_ERROR([need either unistd.h or sys/select.h])
687		;;
688	esac
689	;;
690esac
691AC_SUBST(ISC_PLATFORM_NEEDSYSSELECTH)
692AC_SUBST(LWRES_PLATFORM_NEEDSYSSELECTH)
693
694#
695# Find the machine's endian flavor.
696#
697AC_C_BIGENDIAN
698
699#
700# GeoIP support?
701#
702GEOIPLINKSRCS=
703GEOIPLINKOBJS=
704AC_ARG_WITH(geoip,
705[  --with-geoip=PATH       Build with GeoIP support (yes|no|path)],
706    use_geoip="$withval", use_geoip="no")
707
708if test "$use_geoip" = "yes"
709then
710	for d in /usr /usr/local /opt/local
711	do
712		if test -f $d/include/GeoIP.h
713		then
714			use_geoip=$d
715			break
716		fi
717	done
718fi
719
720case "$use_geoip" in
721	no|'')
722		AC_MSG_CHECKING([for GeoIP support])
723		AC_MSG_RESULT([disabled])
724		;;
725	*)
726		if test -d "$use_geoip" -o -L "$use_geoip"
727		then
728			CFLAGS="$CFLAGS -I$use_geoip/include"
729			CPPFLAGS="$CPPFLAGS -I$use_geoip/include"
730			LIBS="$LIBS -L$use_geoip/lib"
731			case "$host_os" in
732				netbsd*|openbsd*|solaris*)
733					LIBS="$LIBS -Wl,-rpath=$use_geoip/lib"
734					;;
735			esac
736		elif test "$use_geoip" = "yes"
737		then
738			AC_MSG_ERROR([GeoIP path not found])
739		else
740			AC_MSG_ERROR([GeoIP path $use_geoip does not exist])
741		fi
742		AC_CHECK_HEADER(GeoIP.h, [],
743			[AC_MSG_ERROR([GeoIP header file not found])]
744		)
745		AC_SEARCH_LIBS(GeoIP_open, GeoIP, [],
746			[AC_MSG_ERROR([GeoIP library not found])]
747		)
748		AC_SEARCH_LIBS(fabsf, m, [],
749			[AC_MSG_ERROR([Math library not found])]
750		)
751		AC_DEFINE(HAVE_GEOIP, 1, Build with GeoIP support)
752		GEOIPLINKSRCS='${GEOIPLINKSRCS}'
753		GEOIPLINKOBJS='${GEOIPLINKOBJS}'
754		AC_MSG_CHECKING([for GeoIP support])
755		AC_MSG_RESULT([yes])
756
757		AC_MSG_CHECKING([for GeoIP Country IPv6 support])
758		AC_COMPILE_IFELSE(
759			[AC_LANG_PROGRAM([
760				#include <GeoIP.h>
761				#include <netinet/in.h>
762			], [
763				struct in6_addr in6;
764				GeoIP_country_name_by_ipnum_v6(NULL, in6);
765			])],
766			[
767				AC_MSG_RESULT([yes])
768				AC_DEFINE(HAVE_GEOIP_V6, 1, Build with GeoIP Country IPv6 support)
769			],
770			[AC_MSG_RESULT([no])]
771		)
772
773		AC_MSG_CHECKING([for GeoIP City IPv6 support])
774		AC_COMPILE_IFELSE(
775			[AC_LANG_PROGRAM([
776				#include <GeoIP.h>
777				#include <GeoIPCity.h>
778				#include <netinet/in.h>
779			], [
780				struct in6_addr in6;
781				int i = GEOIP_CITY_EDITION_REV0_V6;
782				GeoIP_record_by_ipnum_v6(NULL, in6);
783			])],
784			[
785				AC_MSG_RESULT([yes])
786				AC_DEFINE(HAVE_GEOIP_CITY_V6, 1, Build with GeoIP City IPv6 support)
787			],
788			[AC_MSG_RESULT([no])]
789		)
790		;;
791esac
792AC_SUBST(GEOIPLINKSRCS)
793AC_SUBST(GEOIPLINKOBJS)
794
795AC_MSG_CHECKING(for GSSAPI library)
796AC_ARG_WITH(gssapi,
797[  --with-gssapi=PATH      Specify path for system-supplied GSSAPI [[default=yes]]],
798    use_gssapi="$withval", use_gssapi="yes")
799
800# gssapi is just the framework, we really require kerberos v5, so
801# look for those headers (the gssapi headers must be there, too)
802# The problem with this implementation is that it doesn't allow
803# for the specification of gssapi and krb5 headers in different locations,
804# which probably ought to be fixed although fixing might raise the issue of
805# trying to build with incompatible versions of gssapi and krb5.
806if test "$use_gssapi" = "yes"
807then
808	# first, deal with the obvious
809	if test \( -f /usr/include/kerberosv5/krb5.h -o \
810		   -f /usr/include/krb5/krb5.h -o \
811		   -f /usr/include/krb5.h \)   -a \
812		\( -f /usr/include/gssapi.h -o \
813		   -f /usr/include/gssapi/gssapi.h \)
814	then
815		use_gssapi=/usr
816	else
817	    krb5dirs="/usr/local /usr/local/krb5 /usr/local/kerberosv5 /usr/local/kerberos /usr/pkg /usr/krb5 /usr/kerberosv5 /usr/kerberos /usr"
818	    for d in $krb5dirs
819	    do
820		if test -f $d/include/gssapi/gssapi_krb5.h -o \
821			-f $d/include/krb5.h
822		then
823			if test -f $d/include/gssapi/gssapi.h -o \
824				-f $d/include/gssapi.h
825			then
826				use_gssapi=$d
827				break
828			fi
829		fi
830		use_gssapi="no"
831	    done
832	fi
833fi
834
835case "$use_gssapi" in
836	no)
837		AC_MSG_RESULT(disabled)
838		USE_GSSAPI=''
839		;;
840	yes)
841		AC_MSG_ERROR([--with-gssapi must specify a path])
842		;;
843	*)
844		AC_MSG_RESULT(looking in $use_gssapi/lib)
845		USE_GSSAPI='-DGSSAPI'
846		saved_cppflags="$CPPFLAGS"
847		CPPFLAGS="-I$use_gssapi/include $CPPFLAGS"
848		AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h,
849		    [ISC_PLATFORM_GSSAPIHEADER="#define ISC_PLATFORM_GSSAPIHEADER <$ac_header>"
850		     gssapi_hack="#include <$ac_header>"])
851
852		if test "$ISC_PLATFORM_GSSAPIHEADER" = ""; then
853		    AC_MSG_ERROR([gssapi.h not found])
854		fi
855
856		AC_CHECK_HEADERS(gssapi_krb5.h gssapi/gssapi_krb5.h,
857		    [ISC_PLATFORM_GSSAPI_KRB5_HEADER="#define ISC_PLATFORM_GSSAPI_KRB5_HEADER <$ac_header>"
858		     gssapi_krb5_hack="#include <$ac_header>"])
859
860		AC_CHECK_HEADERS(krb5.h krb5/krb5.h kerberosv5/krb5.h,
861		    [ISC_PLATFORM_KRB5HEADER="#define ISC_PLATFORM_KRB5HEADER <$ac_header>"
862		    krb5_hack="#include <$ac_header>"])
863
864		if test "$ISC_PLATFORM_KRB5HEADER" = ""; then
865		    AC_MSG_ERROR([krb5.h not found])
866		fi
867
868		#
869		# XXXDCL This probably doesn't work right on all systems.
870		# It will need to be worked on as problems become evident.
871		#
872		# Essentially the problems here relate to two different
873		# areas.  The first area is building with either KTH
874		# or MIT Kerberos, particularly when both are present on
875		# the machine.  The other is static versus dynamic linking.
876		#
877		# On the KTH vs MIT issue, Both have libkrb5 that can mess
878		# up the works if one implementation ends up trying to
879		# use the other's krb.  This is unfortunately a situation
880		# that very easily arises.
881		#
882		# Dynamic linking when the dependency information is built
883		# into MIT's libgssapi_krb5 or KTH's libgssapi magically makes
884		# all such problems go away, but when that setup is not
885		# present, because either the dynamic libraries lack
886		# dependencies or static linking is being done, then the
887		# problems start to show up.
888		saved_libs="$LIBS"
889		for TRY_LIBS in \
890		    "-lgssapi_krb5" \
891		    "-lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err" \
892		    "-lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lresolv" \
893		    "-lgssapi" \
894		    "-lgssapi -lkrb5 -ldes -lcrypt -lasn1 -lroken -lcom_err" \
895		    "-lgssapi -lkrb5 -lcrypto -lcrypt -lasn1 -lroken -lcom_err" \
896		    "-lgssapi -lkrb5 -lgssapi_krb5 -lcrypto -lcrypt -lasn1 -lroken -lcom_err" \
897		    "-lgssapi -lkrb5 -lhx509 -lcrypto -lcrypt -lasn1 -lroken -lcom_err" \
898		    "-lgss -lkrb5"
899		do
900		    # Note that this does not include $saved_libs, because
901		    # on FreeBSD machines this configure script has added
902		    # -L/usr/local/lib to LIBS, which can make the
903		    # -lgssapi_krb5 test succeed with shared libraries even
904		    # when you are trying to build with KTH in /usr/lib.
905		    if test "$use_gssapi" = "/usr"
906		    then
907			    LIBS="$TRY_LIBS"
908		    else
909			    LIBS="-L$use_gssapi/lib $TRY_LIBS"
910		    fi
911		    AC_MSG_CHECKING(linking as $TRY_LIBS)
912		    AC_TRY_LINK([
913#include <sys/types.h>
914$gssapi_hack
915$gssapi_krb5_hack
916$krb5_hack
917				] , [gss_acquire_cred(NULL, NULL, 0, NULL, 0, NULL, NULL, NULL);krb5_init_context(NULL);
918#if defined(HAVE_GSSAPI_KRB5_H) || defined(HAVE_GSSAPI_GSSAPI_KRB5_H)
919gsskrb5_register_acceptor_identity(NULL);
920#endif],
921				gssapi_linked=yes, gssapi_linked=no)
922		    case $gssapi_linked in
923		    yes) AC_MSG_RESULT(yes); break ;;
924		    no)  AC_MSG_RESULT(no) ;;
925		    esac
926		done
927
928		CPPFLAGS="$saved_cppflags"
929
930		case $gssapi_linked in
931		no) AC_MSG_ERROR(could not determine proper GSSAPI linkage) ;;
932		esac
933
934		#
935		# XXXDCL Major kludge.  Tries to cope with KTH in /usr/lib
936		# but MIT in /usr/local/lib and trying to build with KTH.
937		# /usr/local/lib can end up earlier on the link lines.
938		# Like most kludges, this one is not only inelegant it
939		# is also likely to be the wrong thing to do at least as
940		# many times as it is the right thing.  Something better
941		# needs to be done.
942		#
943		if test "$use_gssapi" = "/usr" -a \
944			-f /usr/local/lib/libkrb5.a; then
945		    FIX_KTH_VS_MIT=yes
946		fi
947
948		case "$FIX_KTH_VS_MIT" in
949		yes)
950		    case "$enable_static_linking" in
951		    yes) gssapi_lib_suffix=".a"  ;;
952		    *)   gssapi_lib_suffix=".so" ;;
953		    esac
954
955		    for lib in $LIBS; do
956			case $lib in
957			-L*)
958			    ;;
959			-l*)
960			    new_lib=`echo $lib |
961				     sed -e s%^-l%$use_gssapi/lib/lib% \
962					 -e s%$%$gssapi_lib_suffix%`
963			    NEW_LIBS="$NEW_LIBS $new_lib"
964			    ;;
965			*)
966			   AC_MSG_ERROR([KTH vs MIT Kerberos confusion!])
967			    ;;
968			esac
969		    done
970		    LIBS="$NEW_LIBS"
971		    ;;
972		esac
973
974		DST_GSSAPI_INC="-I$use_gssapi/include"
975		DNS_GSSAPI_LIBS="$LIBS"
976
977		AC_MSG_RESULT(using GSSAPI from $use_gssapi/lib and $use_gssapi/include)
978		LIBS="$saved_libs"
979		;;
980esac
981
982AC_SUBST(ISC_PLATFORM_HAVEGSSAPI)
983AC_SUBST(ISC_PLATFORM_GSSAPIHEADER)
984AC_SUBST(ISC_PLATFORM_GSSAPI_KRB5_HEADER)
985AC_SUBST(ISC_PLATFORM_KRB5HEADER)
986
987AC_SUBST(USE_GSSAPI)
988AC_SUBST(DST_GSSAPI_INC)
989AC_SUBST(DNS_GSSAPI_LIBS)
990DNS_CRYPTO_LIBS="$DNS_GSSAPI_LIBS $DNS_CRYPTO_LIBS"
991
992#
993# Applications linking with libdns also need to link with these libraries.
994#
995
996AC_SUBST(DNS_CRYPTO_LIBS)
997
998#
999# was --with-randomdev specified?
1000#
1001AC_MSG_CHECKING(for random device)
1002AC_ARG_WITH(randomdev,
1003[  --with-randomdev=PATH   Specify path for random device],
1004    use_randomdev="$withval", use_randomdev="unspec")
1005
1006case "$use_randomdev" in
1007	unspec)
1008		case "$cross_compiling" in
1009		yes)
1010			AC_MSG_RESULT(unspecified)
1011			AC_MSG_ERROR([ need --with-randomdev=PATH or --with-randomdev=no])
1012		esac
1013		case "$host" in
1014			*-openbsd*)
1015				devrandom=/dev/arandom
1016				;;
1017			*)
1018				devrandom=/dev/urandom
1019				;;
1020		esac
1021		AC_MSG_RESULT($devrandom)
1022		AC_CHECK_FILE($devrandom,
1023			      AC_DEFINE_UNQUOTED(PATH_RANDOMDEV,
1024						 "$devrandom"),)
1025
1026		;;
1027	yes)
1028		AC_MSG_ERROR([--with-randomdev must specify a path])
1029		;;
1030	no)
1031		AC_MSG_RESULT(disabled)
1032		;;
1033	*)
1034		AC_DEFINE_UNQUOTED(PATH_RANDOMDEV, "$use_randomdev")
1035		AC_MSG_RESULT(using "$use_randomdev")
1036		;;
1037esac
1038
1039#
1040# Only check dsa signature generation on these platforms when performing
1041# system tests.
1042#
1043CHECK_DSA=0
1044if grep "#define PATH_RANDOMDEV " confdefs.h > /dev/null
1045then
1046	case "$host" in
1047	*darwin*|*freebsd*)
1048		CHECK_DSA=1
1049		;;
1050	esac
1051fi
1052AC_SUBST(CHECK_DSA)
1053
1054#
1055# Do we have arc4random(), etc ? arc4random_addrandom() has been removed
1056# from OpenBSD 5.5 onwards.
1057#
1058AC_CHECK_FUNC(arc4random, AC_DEFINE(HAVE_ARC4RANDOM))
1059AC_CHECK_FUNC(arc4random_addrandom, AC_DEFINE(HAVE_ARC4RANDOM_ADDRANDOM))
1060
1061sinclude(config.threads.in)dnl
1062
1063if $use_threads
1064then
1065	if test "X$GCC" = "Xyes"; then
1066		case "$host" in
1067		*-freebsd*)
1068			CC="$CC -pthread"
1069			CCOPT="$CCOPT -pthread"
1070			CCNOOPT="$CCNOOPT -pthread"
1071			STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
1072			;;
1073		*-openbsd*)
1074			CC="$CC -pthread"
1075			CCOPT="$CCOPT -pthread"
1076			CCNOOPT="$CCNOOPT -pthread"
1077			;;
1078		*-solaris*)
1079			LIBS="$LIBS -lthread"
1080			;;
1081		*-ibm-aix*)
1082			STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
1083			;;
1084		esac
1085	else
1086		case $host in
1087		*-dec-osf*)
1088			CC="$CC -pthread"
1089			CCOPT="$CCOPT -pthread"
1090			CCNOOPT="$CCNOOPT -pthread"
1091			;;
1092		*-solaris*)
1093			CC="$CC -mt"
1094			CCOPT="$CCOPT -mt"
1095			CCNOOPT="$CCNOOPT -mt"
1096			;;
1097		*-ibm-aix*)
1098			STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
1099			;;
1100		*-sco-sysv*uw*|*-*-sysv*UnixWare*)
1101			CC="$CC -Kthread"
1102			CCOPT="$CCOPT -Kthread"
1103			CCNOOPT="$CCNOOPT -Kthread"
1104			;;
1105		*-*-sysv*OpenUNIX*)
1106			CC="$CC -Kpthread"
1107			CCOPT="$CCOPT -Kpthread"
1108			CCNOOPT="$CCNOOPT -Kpthread"
1109			;;
1110		esac
1111	fi
1112	ALWAYS_DEFINES="-D_REENTRANT"
1113	ISC_PLATFORM_USETHREADS="#define ISC_PLATFORM_USETHREADS 1"
1114	THREADOPTOBJS='${THREADOPTOBJS}'
1115	THREADOPTSRCS='${THREADOPTSRCS}'
1116	thread_dir=pthreads
1117	#
1118	# We'd like to use sigwait() too
1119	#
1120	AC_CHECK_FUNC(sigwait,
1121		      AC_DEFINE(HAVE_SIGWAIT),
1122		      AC_CHECK_LIB(c, sigwait,
1123		      AC_DEFINE(HAVE_SIGWAIT),
1124		      AC_CHECK_LIB(pthread, sigwait,
1125				   AC_DEFINE(HAVE_SIGWAIT),
1126				   AC_CHECK_LIB(pthread, _Psigwait,
1127						AC_DEFINE(HAVE_SIGWAIT),))))
1128
1129	AC_CHECK_FUNC(pthread_attr_getstacksize,
1130		      AC_DEFINE(HAVE_PTHREAD_ATTR_GETSTACKSIZE),)
1131
1132	AC_CHECK_FUNC(pthread_attr_setstacksize,
1133		      AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACKSIZE),)
1134
1135        AC_ARG_WITH(locktype,
1136                [  --with-locktype=ARG     Specify mutex lock type (adaptive or standard)],
1137                locktype="$withval", locktype="adaptive")
1138
1139        case "$locktype" in
1140                adaptive)
1141                        AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1142
1143                        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1144                          #define _GNU_SOURCE
1145                          #include <pthread.h>
1146                        ]], [[
1147                          return (PTHREAD_MUTEX_ADAPTIVE_NP);
1148                        ]])],
1149                        [ AC_MSG_RESULT(using adaptive lock type)
1150                          AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1151                                    [Support for PTHREAD_MUTEX_ADAPTIVE_NP]) ],
1152                        [ AC_MSG_RESULT(using standard lock type) ])
1153                        ;;
1154                standard)
1155                        AC_MSG_RESULT(using standard lock type)
1156                        ;;
1157                *)
1158                        AC_MSG_ERROR([You must specify "adaptive" or "standard" for --with-locktype.])
1159                        ;;
1160        esac
1161
1162	AC_CHECK_HEADERS(sched.h)
1163
1164	case "$host" in
1165	*solaris-*)
1166		AC_CHECK_LIB(rt, sched_yield)
1167		;;
1168	esac
1169
1170	AC_CHECK_FUNCS(sched_yield pthread_yield pthread_yield_np)
1171
1172	#
1173	# Additional OS-specific issues related to pthreads and sigwait.
1174	#
1175	case "$host" in
1176		#
1177		# One more place to look for sigwait.
1178		#
1179		*-freebsd*)
1180			AC_CHECK_LIB(c_r, sigwait, AC_DEFINE(HAVE_SIGWAIT),)
1181			case $host in
1182			*-freebsd5.[[012]]|*-freebsd5.[[012]].*);;
1183			*-freebsd5.[[3456789]]|*-freebsd5.[[3456789]].*)
1184				AC_DEFINE(NEED_PTHREAD_SCOPE_SYSTEM)
1185				;;
1186			*-freebsd6.*)
1187				AC_DEFINE(NEED_PTHREAD_SCOPE_SYSTEM)
1188				;;
1189			esac
1190			;;
1191		#
1192		# BSDI 3.0 through 4.0.1 needs pthread_init() to be
1193		# called before certain pthreads calls.	 This is deprecated
1194		# in BSD/OS 4.1.
1195		#
1196		*-bsdi3.*|*-bsdi4.0*)
1197			AC_DEFINE(NEED_PTHREAD_INIT)
1198			;;
1199		#
1200		# LinuxThreads requires some changes to the way we
1201		# deal with signals.
1202		#
1203		*-linux*)
1204			AC_DEFINE(HAVE_LINUXTHREADS)
1205			;;
1206		#
1207		# Ensure the right sigwait() semantics on Solaris and make
1208		# sure we call pthread_setconcurrency.
1209		#
1210		*-solaris*)
1211			AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
1212			AC_CHECK_FUNC(pthread_setconcurrency,
1213				      AC_DEFINE(CALL_PTHREAD_SETCONCURRENCY))
1214			;;
1215		#
1216		# UnixWare does things its own way.
1217		#
1218		*-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
1219			AC_DEFINE(HAVE_UNIXWARE_SIGWAIT)
1220			;;
1221	esac
1222
1223	#
1224	# Look for sysconf to allow detection of the number of processors.
1225	#
1226	AC_CHECK_FUNC(sysconf, AC_DEFINE(HAVE_SYSCONF),)
1227
1228else
1229	ISC_PLATFORM_USETHREADS="#undef ISC_PLATFORM_USETHREADS"
1230	thread_dir=nothreads
1231	THREADOPTOBJS=""
1232	THREADOPTSRCS=""
1233	ALWAYS_DEFINES=""
1234fi
1235
1236AC_SUBST(ALWAYS_DEFINES)
1237AC_SUBST(ISC_PLATFORM_USETHREADS)
1238AC_SUBST(THREADOPTOBJS)
1239AC_SUBST(THREADOPTSRCS)
1240ISC_THREAD_DIR=$thread_dir
1241AC_SUBST(ISC_THREAD_DIR)
1242
1243AC_MSG_CHECKING(for libtool)
1244AC_ARG_WITH(libtool,
1245	    [  --with-libtool          use GNU libtool],
1246	    use_libtool="$withval", use_libtool="no")
1247
1248case $use_libtool in
1249	yes)
1250		AC_MSG_RESULT(yes)
1251		AM_PROG_LIBTOOL
1252		O=lo
1253		A=la
1254		LIBTOOL_MKDEP_SED='s;\.o;\.lo;'
1255		LIBTOOL_MODE_COMPILE='--mode=compile --tag=CC'
1256		LIBTOOL_MODE_INSTALL='--mode=install --tag=CC'
1257		LIBTOOL_MODE_LINK='--mode=link --tag=CC'
1258		INSTALL_LIBRARY='${INSTALL_PROGRAM}'
1259		case "$host" in
1260		*) LIBTOOL_ALLOW_UNDEFINED= ;;
1261		esac
1262		case "$host" in
1263		*-ibm-aix*) LIBTOOL_IN_MAIN="-Wl,-bI:T_testlist.imp" ;;
1264		*) LIBTOOL_IN_MAIN= ;;
1265		esac;
1266		;;
1267	*)
1268		AC_MSG_RESULT(no)
1269		O=o
1270		A=a
1271		LIBTOOL=
1272		AC_SUBST(LIBTOOL)
1273		LIBTOOL_MKDEP_SED=
1274		LIBTOOL_MODE_COMPILE=
1275		LIBTOOL_MODE_INSTALL=
1276		LIBTOOL_MODE_LINK=
1277		LIBTOOL_ALLOW_UNDEFINED=
1278		LIBTOOL_IN_MAIN=
1279		INSTALL_LIBRARY='${INSTALL_DATA}'
1280		;;
1281esac
1282AC_SUBST(INSTALL_LIBRARY)
1283
1284#
1285# was --enable-native-pkcs11 specified?
1286#  (note it implies both --without-openssl and --with-pkcs11)
1287#
1288AC_ARG_ENABLE(native-pkcs11,
1289	[  --enable-native-pkcs11  use native PKCS11 for all crypto [[default=no]]],
1290	want_native_pkcs11="$enableval", want_native_pkcs11="no")
1291
1292#
1293# was --with-openssl specified?
1294#
1295AC_ARG_WITH(openssl,
1296[  --with-openssl[=PATH]     Build with OpenSSL [yes|no|path].
1297			  (Crypto is required for DNSSEC)],
1298    use_openssl="$withval", use_openssl="auto")
1299
1300#
1301# was --with-pkcs11 specified?
1302#
1303AC_ARG_WITH(pkcs11,
1304[  --with-pkcs11[=PATH]      Build with PKCS11 support [yes|no|path]
1305			  (PATH is for the PKCS11 provider)],
1306   use_pkcs11="$withval", use_pkcs11="auto")
1307
1308#
1309# were --with-ecdsa, --with-gost, --with-aes specified
1310#
1311AC_ARG_WITH(ecdsa, [  --with-ecdsa            Crypto ECDSA],
1312	    with_ecdsa="$withval", with_ecdsa="auto")
1313AC_ARG_WITH(gost, [  --with-gost             Crypto GOST [yes|no|raw|asn1].],
1314	    with_gost="$withval", with_gost="auto")
1315AC_ARG_WITH(aes, [  --with-aes              Crypto AES],
1316	    with_aes="$withval", with_aes="checksit")
1317
1318#
1319# was --enable-openssl-hash specified?
1320#
1321AC_ARG_ENABLE(openssl-hash,
1322	[  --enable-openssl-hash   use OpenSSL for hash functions [[default=no]]],
1323	want_openssl_hash="$enableval", want_openssl_hash="checksit")
1324
1325#
1326# Enable Source Identity Token support
1327#
1328AC_MSG_CHECKING(for Source Identity Token support)
1329AC_ARG_ENABLE(sit,
1330	[  --enable-sit            enable source identity token [[default=no]]],
1331	enable_sit="$enableval", enable_sit="no")
1332HAVE_SIT=
1333ISC_PLATFORM_USESIT="#undef ISC_PLATFORM_USESIT"
1334
1335case "$enable_sit" in
1336yes)
1337	AC_MSG_RESULT(yes)
1338	ISC_PLATFORM_USESIT="#define ISC_PLATFORM_USESIT 1"
1339	HAVE_SIT=1
1340	;;
1341no)
1342	AC_MSG_RESULT(no)
1343	;;
1344*)
1345	AC_MSG_ERROR("enable-sit requires yes or no")
1346	;;
1347esac
1348AC_SUBST(ISC_PLATFORM_USESIT)
1349AC_SUBST(HAVE_SIT)
1350
1351#
1352# Source Identity Token algorithm choice
1353#
1354AC_ARG_WITH(sit-alg,
1355	[  --with-sit-alg=ALG      choose the algorithm for SIT [[aes|sha1|sha256]]],
1356	with_sit_alg="$withval", with_sit_alg="auto")
1357
1358if test "$enable_sit" = "yes"
1359then
1360	case $with_sit_alg in
1361		*1)
1362			with_sit_alg="sha1"
1363			;;
1364		*2*)
1365			with_sit_alg="sha256"
1366			;;
1367		auto)
1368			if test "$with_aes" != "no"
1369			then
1370				with_aes="yes"
1371			fi
1372			;;
1373		*)
1374			with_sit_alg="aes"
1375			if test "$with_aes" != "no"
1376			then
1377				with_aes="yes"
1378			fi
1379			;;
1380	esac
1381fi
1382if test "with_aes" = "checksit"
1383then
1384	with_aes="no"
1385fi
1386
1387AC_MSG_CHECKING(for OpenSSL library)
1388OPENSSL_WARNING=
1389openssldirs="/usr /usr/local /usr/local/ssl /usr/pkg /usr/sfw"
1390if test "$use_openssl" = "auto"
1391then
1392	if test "$want_native_pkcs11" = "yes"
1393	then
1394		use_openssl="native_pkcs11"
1395	else
1396		for d in $openssldirs
1397		do
1398			if test -f $d/include/openssl/opensslv.h
1399			then
1400				use_openssl=$d
1401				break
1402			fi
1403		done
1404	fi
1405fi
1406OPENSSL_ECDSA=""
1407OPENSSL_GOST=""
1408gosttype="raw"
1409case "$with_gost" in
1410	raw)
1411		with_gost="yes"
1412		;;
1413	asn1)
1414		AC_DEFINE(PREFER_GOSTASN1, 1,
1415			  [Define if GOST private keys are encoded in ASN.1.])
1416		gosttype="asn1"
1417		with_gost="yes"
1418		;;
1419	auto|yes|no)
1420		;;
1421	*)
1422		AC_MSG_ERROR(unknown GOST private key encoding)
1423		;;
1424esac
1425
1426case "$use_openssl" in
1427	native_pkcs11)
1428		AC_MSG_RESULT(disabled because of native PKCS11)
1429		DST_OPENSSL_INC=""
1430		CRYPTO="-DPKCS11CRYPTO"
1431		OPENSSLGOSTLINKOBJS=""
1432		OPENSSLGOSTLINKSRS=""
1433		OPENSSLLINKOBJS=""
1434		OPENSSLLINKSRCS=""
1435		;;
1436	no)
1437		AC_MSG_RESULT(no)
1438		DST_OPENSSL_INC=""
1439		CRYPTO=""
1440		OPENSSLGOSTLINKOBJS=""
1441		OPENSSLGOSTLINKSRS=""
1442		OPENSSLLINKOBJS=""
1443		OPENSSLLINKSRCS=""
1444		;;
1445	auto)
1446		DST_OPENSSL_INC=""
1447		CRYPTO=""
1448		OPENSSLGOSTLINKOBJS=""
1449		OPENSSLGOSTLINKSRS=""
1450		OPENSSLLINKOBJS=""
1451		OPENSSLLINKSRCS=""
1452		AC_MSG_ERROR(
1453[OpenSSL was not found in any of $openssldirs; use --with-openssl=/path
1454If you don't want OpenSSL, use --without-openssl])
1455		;;
1456	*)
1457		if test "$want_native_pkcs11" = "yes"
1458		then
1459                        AC_MSG_RESULT()
1460			AC_MSG_ERROR([OpenSSL and native PKCS11 cannot be used together.])
1461		fi
1462		if test "$use_openssl" = "yes"
1463		then
1464			# User did not specify a path - guess it
1465			for d in $openssldirs
1466			do
1467				if test -f $d/include/openssl/opensslv.h
1468				then
1469					use_openssl=$d
1470					break
1471				fi
1472			done
1473			if test "$use_openssl" = "yes"
1474			then
1475				AC_MSG_RESULT(not found)
1476				AC_MSG_ERROR(
1477[OpenSSL was not found in any of $openssldirs; use --with-openssl=/path])
1478			fi
1479		elif ! test -f "$use_openssl"/include/openssl/opensslv.h
1480		then
1481			AC_MSG_ERROR(["$use_openssl/include/openssl/opensslv.h" not found])
1482		fi
1483		CRYPTO='-DOPENSSL'
1484		if test "$use_openssl" = "/usr"
1485		then
1486			DST_OPENSSL_INC=""
1487			DST_OPENSSL_LIBS="-lcrypto"
1488		else
1489			DST_OPENSSL_INC="-I$use_openssl/include"
1490			case $host in
1491			*-solaris*)
1492				DST_OPENSSL_LIBS="-L$use_openssl/lib -R$use_openssl/lib -lcrypto"
1493				;;
1494			*-hp-hpux*)
1495				DST_OPENSSL_LIBS="-L$use_openssl/lib -Wl,+b: -lcrypto"
1496				;;
1497			*-apple-darwin*)
1498				#
1499				# Apple's ld seaches for serially for dynamic
1500				# then static libraries.  This means you can't
1501				# use -L to override dynamic system libraries
1502				# with static ones when linking.  Instead
1503				# we specify a absolute path.
1504				#
1505				if test -f "$use_openssl/lib/libcrypto.dylib"
1506				then
1507					DST_OPENSSL_LIBS="-L$use_openssl/lib -lcrypto"
1508				else
1509					DST_OPENSSL_LIBS="$use_openssl/lib/libcrypto.a"
1510				fi
1511				;;
1512			*)
1513				DST_OPENSSL_LIBS="-L$use_openssl/lib -lcrypto"
1514				;;
1515			esac
1516		fi
1517		AC_MSG_RESULT(using OpenSSL from $use_openssl/lib and $use_openssl/include)
1518
1519		saved_cc="$CC"
1520		saved_cflags="$CFLAGS"
1521		saved_libs="$LIBS"
1522		CFLAGS="$CFLAGS $DST_OPENSSL_INC"
1523		LIBS="$LIBS $DST_OPENSSL_LIBS"
1524		AC_MSG_CHECKING(whether linking with OpenSSL works)
1525		AC_TRY_RUN([
1526#include <openssl/err.h>
1527int main() {
1528	ERR_clear_error();
1529	return (0);
1530}
1531],
1532		[AC_MSG_RESULT(yes)],
1533		[AC_MSG_RESULT(no)
1534		 AC_MSG_ERROR(Could not run test program using OpenSSL from
1535$use_openssl/lib and $use_openssl/include.
1536Please check the argument to --with-openssl and your
1537shared library configuration (e.g., LD_LIBRARY_PATH).)],
1538		[AC_MSG_RESULT(assuming it does work on target platform)])
1539
1540		AC_MSG_CHECKING(whether linking with OpenSSL requires -ldl)
1541		AC_TRY_LINK([
1542#include <openssl/err.h>],
1543[ DSO_METHOD_dlfcn(); ],
1544		[AC_MSG_RESULT(no)],
1545		[LIBS="$LIBS -ldl"
1546		AC_TRY_LINK([
1547#include <openssl/err.h>
1548],[ DSO_METHOD_dlfcn(); ],
1549		[AC_MSG_RESULT(yes)
1550		DST_OPENSSL_LIBS="$DST_OPENSSL_LIBS -ldl"
1551		],
1552		 [AC_MSG_RESULT(unknown)
1553		 AC_MSG_ERROR(OpenSSL has unsupported dynamic loading)],
1554		[AC_MSG_RESULT(assuming it does work on target platform)])
1555		],
1556		[AC_MSG_RESULT(assuming it does work on target platform)]
1557		)
1558
1559AC_ARG_ENABLE(openssl-version-check,
1560[AC_HELP_STRING([--enable-openssl-version-check],
1561	[check OpenSSL version @<:@default=yes@:>@])])
1562case "$enable_openssl_version_check" in
1563yes|'')
1564		AC_MSG_CHECKING(OpenSSL library version)
1565		AC_TRY_RUN([
1566#include <stdio.h>
1567#include <openssl/opensslv.h>
1568int main() {
1569	if ((OPENSSL_VERSION_NUMBER >= 0x009070cfL &&
1570	     OPENSSL_VERSION_NUMBER < 0x00908000L) ||
1571	     OPENSSL_VERSION_NUMBER >= 0x0090804fL)
1572		return (0);
1573	printf("\n\nFound   OPENSSL_VERSION_NUMBER %#010x\n",
1574		OPENSSL_VERSION_NUMBER);
1575	printf("Require OPENSSL_VERSION_NUMBER 0x009070cf or greater (0.9.7l)\n"
1576	       "Require OPENSSL_VERSION_NUMBER 0x0090804f or greater (0.9.8d)\n\n");
1577	return (1);
1578}
1579		],
1580		[AC_MSG_RESULT(ok)],
1581		[AC_MSG_RESULT(not compatible)
1582		 OPENSSL_WARNING=yes
1583		],
1584		[AC_MSG_RESULT(assuming target platform has compatible version)])
1585;;
1586no)
1587	AC_MSG_RESULT(Skipped OpenSSL version check)
1588;;
1589esac
1590
1591	AC_MSG_CHECKING(for OpenSSL DSA support)
1592	if test -f $use_openssl/include/openssl/dsa.h
1593	then
1594		AC_DEFINE(HAVE_OPENSSL_DSA)
1595		AC_MSG_RESULT(yes)
1596	else
1597		AC_MSG_RESULT(no)
1598	fi
1599
1600	AC_CHECK_FUNCS(EVP_sha256 EVP_sha384 EVP_sha512)
1601
1602	AC_MSG_CHECKING(for OpenSSL ECDSA support)
1603	have_ecdsa=""
1604	AC_TRY_RUN([
1605#include <openssl/ecdsa.h>
1606#include <openssl/objects.h>
1607int main() {
1608	EC_KEY *ec256, *ec384;
1609
1610#if !defined(HAVE_EVP_SHA256) || !defined(HAVE_EVP_SHA384)
1611	return (1);
1612#endif
1613	ec256 = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
1614	ec384 = EC_KEY_new_by_curve_name(NID_secp384r1);
1615	if (ec256 == NULL || ec384 == NULL)
1616		return (2);
1617	return (0);
1618}
1619],
1620	[AC_MSG_RESULT(yes)
1621	have_ecdsa="yes"],
1622	[AC_MSG_RESULT(no)
1623	have_ecdsa="no"],
1624	[AC_MSG_RESULT(using --with-ecdsa)])
1625	case "$with_ecdsa" in
1626	yes)
1627	    case "$have_ecdsa" in
1628	    no)  AC_MSG_ERROR([ecdsa not supported]) ;;
1629	    *)  have_ecdsa=yes ;;
1630	    esac
1631	    ;;
1632	no)
1633	    have_ecdsa=no ;;
1634	*)
1635	    case "$have_ecdsa" in
1636	    yes|no) ;;
1637	    *) AC_MSG_ERROR([need --with-ecdsa=[[yes or no]]]) ;;
1638	    esac
1639	    ;;
1640	esac
1641	case $have_ecdsa in
1642	yes)
1643		OPENSSL_ECDSA="yes"
1644		AC_DEFINE(HAVE_OPENSSL_ECDSA, 1,
1645			  [Define if your OpenSSL version supports ECDSA.])
1646		;;
1647	*)
1648		;;
1649	esac
1650
1651	AC_MSG_CHECKING(for OpenSSL GOST support)
1652	have_gost=""
1653	case "$use_pkcs11" in
1654		auto|no)
1655			;;
1656		*)
1657			if $use_threads; then
1658				CC="$CC -pthread"
1659			fi
1660			;;
1661	esac
1662	AC_TRY_RUN([
1663#include <openssl/conf.h>
1664#include <openssl/engine.h>
1665int main() {
1666#if (OPENSSL_VERSION_NUMBER >= 0x10000000L)
1667	ENGINE *e;
1668	EC_KEY *ek;
1669
1670	ek = NULL;
1671	OPENSSL_config(NULL);
1672
1673	e = ENGINE_by_id("gost");
1674	if (e == NULL)
1675		return (1);
1676	if (ENGINE_init(e) <= 0)
1677		return (1);
1678	return (0);
1679#else
1680	return (1);
1681#endif
1682}
1683],
1684	[AC_MSG_RESULT(yes)
1685	have_gost="yes"],
1686	[AC_MSG_RESULT(no)
1687	have_gost="no"],
1688	[AC_MSG_RESULT(using --with-gost)])
1689	case "$with_gost" in
1690	yes)
1691	    case "$have_gost" in
1692	    no)  AC_MSG_ERROR([gost not supported]) ;;
1693	    *)  have_gost=yes ;;
1694	    esac
1695	    ;;
1696	no)
1697	    have_gost=no ;;
1698	*)
1699	    case "$have_gost" in
1700	    yes|no) ;;
1701	    *) AC_MSG_ERROR([need --with-gost=[[yes, no, raw or asn1]]]) ;;
1702	    esac
1703	    ;;
1704	esac
1705	case $have_gost in
1706	yes)
1707		OPENSSL_GOST="yes"
1708		OPENSSLGOSTLINKOBJS='${OPENSSLGOSTLINKOBJS}'
1709		OPENSSLGOSTLINKSRCS='${OPENSSLGOSTLINKSRCS}'
1710		AC_DEFINE(HAVE_OPENSSL_GOST, 1,
1711			  [Define if your OpenSSL version supports GOST.])
1712		;;
1713	*)
1714		;;
1715	esac
1716
1717	have_aes="no"
1718	AC_MSG_CHECKING(for OpenSSL AES support)
1719	AC_TRY_RUN([
1720#include <openssl/evp.h>
1721int main() {
1722	EVP_CIPHER *aes128, *aes192, *aes256;
1723
1724	aes128 = EVP_aes_128_ecb();
1725	aes192 = EVP_aes_192_ecb();
1726	aes256 = EVP_aes_256_ecb();
1727	if (aes128 == NULL || aes192 == NULL || aes256 == NULL)
1728		return (1);
1729	return (0);
1730}
1731],
1732	[AC_MSG_RESULT(yes)
1733	 have_aes="evp"],
1734	[AC_CHECK_FUNC(AES_encrypt,
1735	[AC_MSG_RESULT(yes)
1736	 have_aes="yes"],
1737	[AC_MSG_RESULT(no)])],
1738	[AC_MSG_RESULT(using --with-aes)])
1739
1740	ISC_OPENSSL_INC=""
1741	ISC_OPENSSL_LIBS=""
1742	if test "$with_aes" = "yes"
1743	then
1744		case "$have_aes" in
1745		evp)
1746			AC_DEFINE(HAVE_OPENSSL_EVP_AES, 1,
1747				  [Define if your OpenSSL version supports EVP AES])
1748			ISC_OPENSSL_INC="$DST_OPENSSL_INC"
1749			ISC_OPENSSL_LIBS="$DST_OPENSSL_LIBS"
1750			;;
1751		yes)
1752			AC_DEFINE(HAVE_OPENSSL_AES, 1,
1753				  [Define if your OpenSSL version supports AES])
1754			ISC_OPENSSL_INC="$DST_OPENSSL_INC"
1755			ISC_OPENSSL_LIBS="$DST_OPENSSL_LIBS"
1756			;;
1757		*)
1758			;;
1759		esac
1760	fi
1761
1762	CC="$saved_cc"
1763	CFLAGS="$saved_cflags"
1764	LIBS="$saved_libs"
1765	OPENSSLLINKOBJS='${OPENSSLLINKOBJS}'
1766	OPENSSLLINKSRCS='${OPENSSLLINKSRCS}'
1767
1768	;;
1769esac
1770
1771#
1772# This would include the system openssl path (and linker options to use
1773# it as needed) if it is found.
1774#
1775
1776AC_SUBST(DST_OPENSSL_INC)
1777AC_SUBST(OPENSSLGOSTLINKOBJS)
1778AC_SUBST(OPENSSLGOSTLINKSRCS)
1779AC_SUBST(OPENSSLLINKOBJS)
1780AC_SUBST(OPENSSLLINKSRCS)
1781AC_SUBST(OPENSSL_ECDSA)
1782AC_SUBST(OPENSSL_GOST)
1783
1784DNS_CRYPTO_LIBS="$DNS_CRYPTO_LIBS $DST_OPENSSL_LIBS"
1785
1786ISC_PLATFORM_WANTAES="#undef ISC_PLATFORM_WANTAES"
1787if test "$with_aes" = "yes"
1788then
1789	if test "X$CRYPTO" = "X"
1790	then
1791		with_aes="no"
1792	fi
1793fi
1794if test "$with_aes" = "yes"
1795then
1796	ISC_PLATFORM_WANTAES="#define ISC_PLATFORM_WANTAES 1"
1797fi
1798AC_SUBST(ISC_PLATFORM_WANTAES)
1799
1800#
1801# Choose SIT algorithm
1802#
1803
1804if test "$enable_sit" = "yes"
1805then
1806	AC_MSG_CHECKING(for the Algorithm for SIT)
1807	if test "$with_sit_alg" = "auto"
1808	then
1809		if test "$with_aes" = "yes"
1810		then
1811			with_sit_alg="aes"
1812		else
1813			with_sit_alg="sha256"
1814		fi
1815	fi
1816fi
1817case $with_sit_alg in
1818	sha1)
1819		if test "$enable_sit" != "yes"
1820		then
1821			AC_MSG_ERROR("with-sit-alg requires enable-sit");
1822		fi
1823		AC_MSG_RESULT(sha1)
1824		if test "$CRYPTO" = "-DOPENSSL"
1825		then
1826			if test "$want_openssl_hash" = "checksit"
1827			then
1828				want_openssl_hash="yes"
1829			fi
1830		fi
1831		AC_DEFINE(HMAC_SHA1_SIT, 1,
1832			  [Use HMAC-SHA1 for Source Identity Token generation])
1833		;;
1834	sha256)
1835		if test "$enable_sit" != "yes"
1836		then
1837			AC_MSG_ERROR("with-sit-alg requires enable-sit");
1838		fi
1839		AC_MSG_RESULT(sha256)
1840		if test "$CRYPTO" = "-DOPENSSL"
1841		then
1842			if test "$want_openssl_hash" = "checksit"
1843			then
1844				want_openssl_hash="yes"
1845			fi
1846		fi
1847		AC_DEFINE(HMAC_SHA256_SIT, 1,
1848			  [Use HMAC-SHA256 for Source Identity Token generation])
1849		;;
1850	aes)
1851		if test "$enable_sit" != "yes"
1852		then
1853			AC_MSG_ERROR("with-sit-alg requires enable-sit");
1854		fi
1855		AC_MSG_RESULT(aes)
1856		if test "$with_aes" != "yes"
1857		then
1858			AC_MSG_ERROR("SIT wants to use unavailable AES");
1859		fi
1860		AC_DEFINE(AES_SIT, 1,
1861			  [Use AES for Source Identity Token generation])
1862		;;
1863esac
1864if test "$want_openssl_hash" = "checksit"
1865then
1866	want_openssl_hash="no"
1867fi
1868
1869#
1870# Use OpenSSL for hash functions
1871#
1872
1873AC_MSG_CHECKING(for using OpenSSL for hash functions)
1874ISC_PLATFORM_OPENSSLHASH="#undef ISC_PLATFORM_OPENSSLHASH"
1875case $want_openssl_hash in
1876	yes)
1877		if test "$CRYPTO" != "-DOPENSSL"
1878		then
1879			AC_MSG_ERROR([No OpenSSL for hash functions])
1880		fi
1881		AC_MSG_RESULT(yes)
1882		ISC_PLATFORM_OPENSSLHASH="#define ISC_PLATFORM_OPENSSLHASH 1"
1883		ISC_OPENSSL_INC="$DST_OPENSSL_INC"
1884		ISC_OPENSSL_LIBS="$DST_OPENSSL_LIBS"
1885		saved_cflags="$CFLAGS"
1886		save_libs="$LIBS"
1887		CFLAGS="$CFLAGS $ISC_OPENSSL_INC"
1888		LIBS="$LIBS $ISC_OPENSSL_LIBS"
1889		AC_MSG_CHECKING([HMAC_Init() return type])
1890		AC_TRY_COMPILE([
1891		#include <openssl/hmac.h>],[
1892		HMAC_CTX ctx;
1893		int n = HMAC_Init(&ctx, NULL, 0, NULL);
1894		n += HMAC_Update(&ctx, NULL, 0);
1895		n += HMAC_Final(&ctx, NULL, NULL);],[
1896		AC_MSG_RESULT(int)
1897		AC_DEFINE(HMAC_RETURN_INT, 1, [HMAC_*() return ints])],[
1898		AC_MSG_RESULT(void)])
1899		CFLAGS="$saved_cflags"
1900		LIBS="$save_libs"
1901		;;
1902	no)
1903		AC_MSG_RESULT(no)
1904		;;
1905esac
1906AC_SUBST(ISC_PLATFORM_OPENSSLHASH)
1907AC_SUBST(ISC_OPENSSL_INC)
1908AC_SUBST(ISC_OPENSSL_LIBS)
1909
1910#
1911# PKCS11 (aka crypto hardware) support (--with moved just after openssl)
1912#
1913AC_MSG_CHECKING(for PKCS11 support)
1914
1915if test "$use_pkcs11" = "auto"
1916then
1917	if test "$want_native_pkcs11" = "yes"
1918	then
1919		use_pkcs11="yes"
1920	else
1921		use_pkcs11="no"
1922	fi
1923fi
1924
1925case "$use_pkcs11" in
1926	no)
1927		AC_MSG_RESULT(no)
1928		USE_PKCS11=""
1929		PKCS11_TEST=""
1930		PKCS11_TOOLS=""
1931		ISC_PK11_C=""
1932		ISC_PK11_O=""
1933		ISC_PK11_API_C=""
1934		ISC_PK11_API_O=""
1935		ISC_PK11_RESULT_C=""
1936		ISC_PK11_RESULT_O=""
1937		ISC_ISCPK11_API_C=""
1938		ISC_ISCPK11_API_O=""
1939		;;
1940	yes|*)
1941		AC_MSG_RESULT(yes)
1942		if ! $use_threads; then
1943			AC_MSG_ERROR([PKCS11 requires thread support])
1944		fi
1945		if test "$CRYPTO" = "-DOPENSSL"
1946		then
1947			AC_MSG_CHECKING(for OpenSSL with PKCS11 support)
1948			saved_cc="$CC"
1949			saved_cflags="$CFLAGS"
1950			saved_libs="$LIBS"
1951			CC="$CC -pthread"
1952			CFLAGS="$CFLAGS $DST_OPENSSL_INC"
1953			LIBS="$LIBS $DST_OPENSSL_LIBS"
1954			AC_TRY_RUN([
1955#include <openssl/conf.h>
1956#include <openssl/engine.h>
1957int main() {
1958	ENGINE *e;
1959
1960	OPENSSL_config(NULL);
1961	e = ENGINE_by_id("pkcs11");
1962	if (e == NULL)
1963		return (1);
1964	if (ENGINE_init(e) <= 0)
1965		return (1);
1966	return (0);
1967}
1968],
1969			[AC_MSG_RESULT(yes)
1970			PKCS11_TEST=pkcs11ssl
1971			PKCS11_ENGINE='-DPKCS11_ENGINE="\"pkcs11\""'],
1972			[AC_MSG_RESULT(no)
1973			PKCS11_TEST=''
1974			PKCS11_ENGINE='-DPKCS11_ENGINE=NULL'],
1975			[AC_MSG_RESULT(cross compile, defaulting to no)
1976			PKCS11_TEST=''
1977			PKCS11_ENGINE='-DPKCS11_ENGINE=NULL'])
1978			CC="$saved_cc"
1979			CFLAGS="$saved_cflags"
1980			LIBS="$saved_libs"
1981		else
1982			PKCS11_TEST=''
1983			PKCS11_ENGINE='-DPKCS11_ENGINE=NULL'
1984
1985		fi
1986		USE_PKCS11='-DUSE_PKCS11'
1987		PKCS11_TOOLS=pkcs11
1988		AC_CHECK_FUNC(getpassphrase, AC_DEFINE(HAVE_GETPASSPHRASE),)
1989		ISC_PK11_C="pk11.c"
1990		ISC_PK11_O="pk11.$O"
1991		ISC_PK11_API_C="pk11_api.c"
1992		ISC_PK11_API_O="pk11_api.$O"
1993		ISC_PK11_RESULT_C="pk11_result.c"
1994		ISC_PK11_RESULT_O="pk11_result.$O"
1995		ISC_ISCPK11_API_C="unix/pk11_api.c"
1996		ISC_ISCPK11_API_O="unix/pk11_api.$O"
1997		;;
1998esac
1999AC_SUBST(USE_PKCS11)
2000AC_SUBST(PKCS11_TOOLS)
2001AC_SUBST(PKCS11_ENGINE)
2002AC_SUBST(ISC_PK11_C)
2003AC_SUBST(ISC_PK11_O)
2004AC_SUBST(ISC_PK11_API_C)
2005AC_SUBST(ISC_PK11_API_O)
2006AC_SUBST(ISC_PK11_RESULT_C)
2007AC_SUBST(ISC_PK11_RESULT_O)
2008AC_SUBST(ISC_ISCPK11_API_C)
2009AC_SUBST(ISC_ISCPK11_API_O)
2010
2011AC_MSG_CHECKING(for PKCS11 tools)
2012case "$use_pkcs11" in
2013	no)
2014		PKCS11_PROVIDER="undefined"
2015		AC_MSG_RESULT(disabled)
2016		;;
2017	yes|'')
2018		PKCS11_PROVIDER="undefined"
2019		AC_MSG_RESULT(enabled)
2020		;;
2021	*)
2022		PKCS11_PROVIDER="$use_pkcs11"
2023		AC_MSG_RESULT([enabled, PKCS11 provider is $PKCS11_PROVIDER])
2024		;;
2025esac
2026
2027AC_SUBST(PKCS11_PROVIDER)
2028
2029PKCS11_ECDSA=""
2030PKCS11_GOST=""
2031AC_MSG_CHECKING(for native PKCS11)
2032
2033case "$want_native_pkcs11" in
2034	yes)
2035		AC_MSG_RESULT(using native PKCS11 crypto)
2036		PKCS11LINKOBJS='${PKCS11LINKOBJS}'
2037		PKCS11LINKSRCS='${PKCS11LINKSRCS}'
2038		PKCS11_TEST=pkcs11
2039		AC_MSG_CHECKING(for PKCS11 ECDSA)
2040		case "$with_ecdsa" in
2041		no)
2042			AC_MSG_RESULT(disabled)
2043			;;
2044		*)
2045			AC_MSG_RESULT(enabled)
2046			PKCS11_ECDSA="yes"
2047			AC_DEFINE(HAVE_PKCS11_ECDSA, 1,
2048				  [Define if your PKCS11 provider supports ECDSA.])
2049			;;
2050		esac
2051		AC_MSG_CHECKING(for PKCS11 GOST)
2052		case "$with_gost" in
2053		yes)
2054			AC_MSG_RESULT(enabled)
2055			PKCS11_GOST="yes"
2056			AC_DEFINE(HAVE_PKCS11_GOST, 1,
2057				  [Define if your PKCS11 provider supports GOST.])
2058			;;
2059		*)
2060			AC_MSG_RESULT(disabled)
2061			;;
2062		esac
2063		;;
2064	no|'')
2065		AC_MSG_RESULT(disabled)
2066		;;
2067esac
2068
2069AC_SUBST(PKCS11LINKOBJS)
2070AC_SUBST(PKCS11LINKSRCS)
2071AC_SUBST(CRYPTO)
2072AC_SUBST(PKCS11_ECDSA)
2073AC_SUBST(PKCS11_GOST)
2074AC_SUBST(PKCS11_TEST)
2075
2076# for PKCS11 benchmarks
2077
2078have_clock_gt=no
2079AC_CHECK_FUNC(clock_gettime,have_clock_gt=yes,)
2080if test "$have_clock_gt" = "no"; then
2081	AC_CHECK_LIB(rt,clock_gettime,have_clock_gt=rt,)
2082fi
2083
2084if test "$have_clock_gt" != "no"; then
2085	AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if clock_gettime is available.])
2086fi
2087
2088if test "$have_clock_gt" = "rt"; then
2089	LIBS="-lrt $LIBS"
2090fi
2091
2092#
2093# was --with-libxml2 specified?
2094#
2095AC_MSG_CHECKING(for libxml2 library)
2096AC_ARG_WITH(libxml2,
2097[  --with-libxml2[=PATH]     build with libxml2 library [yes|no|path]],
2098    use_libxml2="$withval", use_libxml2="auto")
2099
2100case "$use_libxml2" in
2101	no)
2102		DST_LIBXML2_INC=""
2103		;;
2104	auto|yes)
2105		case X`(xml2-config --version) 2>/dev/null` in
2106		X2.[[6789]].*)
2107			libxml2_libs=`xml2-config --libs`
2108			libxml2_cflags=`xml2-config --cflags`
2109			;;
2110		*)
2111			libxml2_libs=
2112			libxml2_cflags=
2113			;;
2114		esac
2115		;;
2116	*)
2117		if test -f "$use_libxml2/bin/xml2-config" ; then
2118			libxml2_libs=`$use_libxml2/bin/xml2-config --libs`
2119			libxml2_cflags=`$use_libxml2/bin/xml2-config --cflags`
2120		fi
2121		;;
2122esac
2123
2124if test "X$libxml2_libs" != "X"
2125then
2126	CFLAGS="$CFLAGS $libxml2_cflags"
2127	LIBS="$LIBS $libxml2_libs"
2128	#
2129	# Sanity check xml2-config output.
2130	#
2131	AC_TRY_LINK([#include <libxml/xmlwriter.h>],
2132		    [return(xmlTextWriterStartElement(NULL, NULL));],
2133		    AC_MSG_RESULT(yes),
2134		    AC_MSG_ERROR(xml2-config returns badness))
2135	AC_DEFINE(HAVE_LIBXML2, 1, [Define if libxml2 was found])
2136else
2137	AC_MSG_RESULT(no)
2138fi
2139
2140#
2141# was --with-libjson specified?
2142#
2143AC_MSG_CHECKING(for json library)
2144AC_ARG_WITH(libjson,
2145[  --with-libjson[=PATH]     build with libjson0 library [yes|no|path]],
2146    use_libjson="$withval", use_libjson="auto")
2147
2148have_libjson=""
2149case "$use_libjson" in
2150	no)
2151		libjson_libs=""
2152		;;
2153	auto|yes)
2154		for d in /usr /usr/local /opt/local
2155		do
2156			if test -f "${d}/include/json/json.h"
2157			then
2158				libjson_cflags="-I ${d}/include/json"
2159				if test ${d} != /usr
2160				then
2161					LIBS="$LIBS -L${d}/lib"
2162				fi
2163				have_libjson="yes"
2164			elif test -f "${d}/include/json-c/json.h"
2165			then
2166				libjson_cflags="-I ${d}/include/json-c"
2167				if test ${d} != /usr
2168				then
2169					LIBS="$LIBS -L${d}/lib"
2170				fi
2171				have_libjson="yes"
2172			fi
2173		done
2174		;;
2175	*)
2176		if test -f "${use_libjson}/include/json/json.h"
2177		then
2178			libjson_cflags="-I${use_libjson}/include/json"
2179			LIBS="$LIBS -L${use_libjson}/lib"
2180			have_libjson="yes"
2181		elif test -f "${use_libjson}/include/json-c/json.h"
2182		then
2183			libjson_cflags="-I${use_libjson}/include/json-c"
2184			LIBS="$LIBS -L${use_libjson}/lib"
2185			have_libjson="yes"
2186		else
2187			AC_MSG_ERROR([$use_libjson/include/json{,-c}/json.h not found.])
2188		fi
2189		;;
2190esac
2191
2192if test "X${have_libjson}" != "X"
2193then
2194	AC_MSG_RESULT(yes)
2195	AC_SEARCH_LIBS([json_object_new_int64], [json json-c], [],
2196		       [AC_MSG_ERROR([found libjson include but not library.])
2197			have_libjson=""])
2198elif test "X$use_libjson" = Xyes
2199then
2200	AC_MSG_ERROR([include/json{,-c}/json.h not found.])
2201else
2202	AC_MSG_RESULT(no)
2203fi
2204
2205if test "X${have_libjson}" != "X"
2206then
2207	CFLAGS="$CFLAGS $libjson_cflags"
2208	AC_DEFINE(HAVE_JSON, 1, [Define if libjson was found])
2209fi
2210
2211#
2212# In solaris 10, SMF can manage named service
2213#
2214AC_CHECK_LIB(scf, smf_enable_instance)
2215
2216#
2217# flockfile is usually provided by pthreads, but we may want to use it
2218# even if compiled with --disable-threads.  getc_unlocked might also not
2219# be defined.
2220#
2221AC_CHECK_FUNC(flockfile, AC_DEFINE(HAVE_FLOCKFILE),)
2222AC_CHECK_FUNC(getc_unlocked, AC_DEFINE(HAVE_GETCUNLOCKED),)
2223
2224#
2225# Indicate what the final decision was regarding threads.
2226#
2227AC_MSG_CHECKING(whether to build with threads)
2228if $use_threads; then
2229	AC_MSG_RESULT(yes)
2230else
2231	AC_MSG_RESULT(no)
2232fi
2233
2234#
2235# End of pthreads stuff.
2236#
2237
2238#
2239# Large File
2240#
2241AC_ARG_ENABLE(largefile, [  --enable-largefile	  64-bit file support],
2242	      want_largefile="yes", want_largefile="no")
2243case $want_largefile in
2244	yes)
2245		ALWAYS_DEFINES="$ALWAYS_DEFINES -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
2246		;;
2247	*)
2248		;;
2249esac
2250
2251#
2252# Additional compiler settings.
2253#
2254MKDEPCC="$CC"
2255MKDEPCFLAGS="-M"
2256IRIX_DNSSEC_WARNINGS_HACK=""
2257
2258if test "X$GCC" = "Xyes"; then
2259	STD_CWARNINGS="$STD_CWARNINGS -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -Wpointer-arith"
2260	AC_MSG_CHECKING(if "$CC" supports -fno-strict-aliasing)
2261	SAVE_CFLAGS="$CFLAGS"
2262	CFLAGS="$CFLAGS -fno-strict-aliasing"
2263	AC_TRY_COMPILE(,, [FNOSTRICTALIASING=yes],[FNOSTRICTALIASING=no])
2264	CFLAGS="$SAVE_CFLAGS"
2265	if test "$FNOSTRICTALIASING" = "yes"; then
2266		AC_MSG_RESULT(yes)
2267		STD_CWARNINGS="$STD_CWARNINGS -fno-strict-aliasing"
2268	else
2269		AC_MSG_RESULT(no)
2270	fi
2271	#
2272	# turn off delete null pointer checks
2273	#
2274	AC_MSG_CHECKING(if "$CC" supports -fno-delete-null-pointer-checks)
2275	SAVE_CFLAGS="$CFLAGS"
2276	CFLAGS="$CFLAGS -fno-delete-null-pointer-checks"
2277	AC_TRY_COMPILE(,, [FNODELETENULLPOINTERCHECKS=yes],
2278			  [FNODELETENULLPOINTERCHECKS=no])
2279	CFLAGS="$SAVE_CFLAGS"
2280	if test "$FNODELETENULLPOINTERCHECKS" = "yes"; then
2281		AC_MSG_RESULT(yes)
2282		STD_CWARNINGS="$STD_CWARNINGS -fno-delete-null-pointer-checks"
2283	else
2284		AC_MSG_RESULT(no)
2285	fi
2286	case "$host" in
2287	*-hp-hpux*)
2288		CFLAGS="$CFLAGS -Wl,+vnocompatwarnings"
2289		BACKTRACECFLAGS="$BACKTRACECFLAGS -Wl,+vnocompatwarnings"
2290		;;
2291	esac
2292	if test "X$enable_warn_shadow" = Xyes; then
2293		STD_CWARNINGS="$STD_CWARNINGS -Wshadow"
2294	fi
2295	if test "X$enable_warn_error" = Xyes; then
2296		STD_CWARNINGS="$STD_CWARNINGS -Werror"
2297	fi
2298else
2299	case $host in
2300	*-dec-osf*)
2301		CC="$CC -std"
2302		CCOPT="$CCOPT -std"
2303		CCNOOPT="$CCNOOPT -std"
2304		MKDEPCC="$CC"
2305		;;
2306	*-hp-hpux*)
2307		CC="$CC -Ae -z"
2308		# The version of the C compiler that constantly warns about
2309		# 'const' as well as alignment issues is unfortunately not
2310		# able to be discerned via the version of the operating
2311		# system, nor does cc have a version flag.
2312		case "`$CC +W 123 2>&1`" in
2313		*Unknown?option*)
2314			STD_CWARNINGS="+w1"
2315			;;
2316		*)
2317			# Turn off the pointlessly noisy warnings.
2318			STD_CWARNINGS="+w1 +W 474,530,2193,2236"
2319			;;
2320		esac
2321		CCOPT="$CCOPT -Ae -z"
2322		CCNOOPT="$CCNOOPT -Ae -z"
2323		CFLAGS="$CFLAGS -Wl,+vnocompatwarnings"
2324		BACKTRACECFLAGS="$BACKTRACECFLAGS -Wl,+vnocompatwarnings"
2325		MKDEPPROG='cc -Ae -E -Wp,-M >/dev/null 2>>$TMP'
2326		;;
2327	*-sgi-irix*)
2328		STD_CWARNINGS="-fullwarn -woff 1209"
2329		#
2330		# Silence more than 250 instances of
2331		#   "prototyped function redeclared without prototype"
2332		# and 11 instances of
2333		#   "variable ... was set but never used"
2334		# from lib/dns/sec/openssl.
2335		#
2336		IRIX_DNSSEC_WARNINGS_HACK="-woff 1692,1552"
2337		;;
2338	*-solaris*)
2339		MKDEPCFLAGS="-xM"
2340		;;
2341	*-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
2342		# UnixWare
2343		CC="$CC -w"
2344		;;
2345	esac
2346fi
2347
2348AC_SUBST(MKDEPCC)
2349AC_SUBST(MKDEPCFLAGS)
2350AC_SUBST(MKDEPPROG)
2351AC_SUBST(IRIX_DNSSEC_WARNINGS_HACK)
2352
2353#
2354# NLS
2355#
2356AC_CHECK_FUNC(catgets, AC_DEFINE(HAVE_CATGETS),)
2357
2358#
2359# -lxnet buys us one big porting headache...  standards, gotta love 'em.
2360#
2361# AC_CHECK_LIB(xnet, socket, ,
2362#    AC_CHECK_LIB(socket, socket)
2363# )
2364#
2365# Use this for now, instead:
2366#
2367case "$host" in
2368	mips-sgi-irix*)
2369		;;
2370	*-linux*)
2371		;;
2372	*)
2373		AC_CHECK_LIB(socket, socket)
2374		AC_CHECK_LIB(nsl, inet_addr)
2375		;;
2376esac
2377
2378#
2379# Work around Solaris's select() limitations.
2380#
2381case "$host" in
2382	*-solaris2.[[89]]|*-solaris2.1?)
2383	AC_DEFINE(FD_SETSIZE, 65536,
2384		  [Solaris hack to get select_large_fdset.])
2385	;;
2386esac
2387
2388#
2389# Purify support
2390#
2391AC_MSG_CHECKING(whether to use purify)
2392AC_ARG_WITH(purify,
2393	[  --with-purify[=PATH]      use Rational purify],
2394	use_purify="$withval", use_purify="no")
2395
2396case "$use_purify" in
2397	no)
2398		;;
2399	yes)
2400		AC_PATH_PROG(purify_path, purify, purify)
2401		;;
2402	*)
2403		purify_path="$use_purify"
2404		;;
2405esac
2406
2407case "$use_purify" in
2408	no)
2409		AC_MSG_RESULT(no)
2410		PURIFY=""
2411		;;
2412	*)
2413		if test -f $purify_path || test $purify_path = purify; then
2414			AC_MSG_RESULT($purify_path)
2415			PURIFYFLAGS="`echo $PURIFYOPTIONS`"
2416			PURIFY="$purify_path $PURIFYFLAGS"
2417		else
2418			AC_MSG_ERROR([$purify_path not found.
2419
2420Please choose the proper path with the following command:
2421
2422    configure --with-purify=PATH
2423])
2424		fi
2425		;;
2426esac
2427
2428AC_SUBST(PURIFY)
2429
2430#
2431# Google/Great Performance Tools CPU Profiler
2432#
2433AC_MSG_CHECKING(whether to use gperftools profiler)
2434AC_ARG_WITH(gperftools-profiler,
2435	[  --with-gperftools-profiler  use gperftools CPU profiler],
2436	use_profiler="$withval", use_profiler="no")
2437
2438case $use_profiler in
2439	yes)
2440		AC_MSG_RESULT(yes)
2441		AC_DEFINE([HAVE_GPERFTOOLS_PROFILER], 1,
2442		[Define to use gperftools CPU profiler.])
2443		LIBS="$LIBS -lprofiler"
2444		;;
2445	*)
2446		AC_MSG_RESULT(no)
2447		;;
2448esac
2449
2450#
2451# enable/disable dumping stack backtrace.  Also check if the system supports
2452# glibc-compatible backtrace() function.
2453#
2454AC_ARG_ENABLE(backtrace,
2455[  --enable-backtrace      log stack backtrace on abort [[default=yes]]],
2456	      want_backtrace="$enableval",  want_backtrace="yes")
2457case $want_backtrace in
2458yes)
2459	ISC_PLATFORM_USEBACKTRACE="#define ISC_PLATFORM_USEBACKTRACE 1"
2460	AC_TRY_LINK([#include <execinfo.h>],
2461	[return (backtrace((void **)0, 0));],
2462	[AC_DEFINE([HAVE_LIBCTRACE], [], [if system have backtrace function])],)
2463	;;
2464*)
2465	ISC_PLATFORM_USEBACKTRACE="#undef ISC_PLATFORM_USEBACKTRACE"
2466	;;
2467esac
2468AC_SUBST(ISC_PLATFORM_USEBACKTRACE)
2469
2470AC_ARG_ENABLE(symtable,
2471[  --enable-symtable       use internal symbol table for backtrace
2472			  [[all|minimal(default)|none]]],
2473		want_symtable="$enableval",  want_symtable="minimal")
2474case $want_symtable in
2475yes|all|minimal)     # "yes" is a hidden value equivalent to "minimal"
2476	if test "$PERL" = ""
2477	then
2478		AC_MSG_ERROR([Internal symbol table requires perl but no perl is found.
2479Install perl or explicitly disable the feature by --disable-symtable.])
2480	fi
2481	if test "$use_libtool" = "yes"; then
2482		AC_MSG_WARN([Internal symbol table does not work with libtool.  Disabling symbol table.])
2483	else
2484		# we generate the internal symbol table only for those systems
2485		# known to work to avoid unexpected build failure.  Also, warn
2486		# about unsupported systems when the feature is enabled
2487		#  manually.
2488		case $host_os in
2489		freebsd*|netbsd*|openbsd*|linux*|solaris*|darwin*)
2490			MKSYMTBL_PROGRAM="$PERL"
2491			if test $want_symtable = all; then
2492				ALWAYS_MAKE_SYMTABLE="yes"
2493			fi
2494			;;
2495		*)
2496			if test $want_symtable = yes -o $want_symtable = all
2497			then
2498				AC_MSG_WARN([this system is not known to generate internal symbol table safely; disabling it])
2499			fi
2500		esac
2501	fi
2502	;;
2503*)
2504	;;
2505esac
2506AC_SUBST(MKSYMTBL_PROGRAM)
2507AC_SUBST(ALWAYS_MAKE_SYMTABLE)
2508
2509#
2510# File name extension for static archive files, for those few places
2511# where they are treated differently from dynamic ones.
2512#
2513SA=a
2514
2515AC_SUBST(O)
2516AC_SUBST(A)
2517AC_SUBST(SA)
2518AC_SUBST(LIBTOOL_MKDEP_SED)
2519AC_SUBST(LIBTOOL_MODE_COMPILE)
2520AC_SUBST(LIBTOOL_MODE_INSTALL)
2521AC_SUBST(LIBTOOL_MODE_LINK)
2522AC_SUBST(LIBTOOL_ALLOW_UNDEFINED)
2523AC_SUBST(LIBTOOL_IN_MAIN)
2524
2525BIND9_CO_RULE=".c.$O:"
2526AC_SUBST(BIND9_CO_RULE)
2527
2528#
2529# Here begins a very long section to determine the system's networking
2530# capabilities.  The order of the tests is significant.
2531#
2532
2533#
2534# IPv6
2535#
2536AC_ARG_ENABLE(ipv6,
2537	[  --enable-ipv6           use IPv6 [default=autodetect]])
2538
2539case "$enable_ipv6" in
2540	yes|''|autodetect)
2541		AC_DEFINE(WANT_IPV6)
2542		;;
2543	no)
2544		;;
2545esac
2546
2547#
2548# We do the IPv6 compilation checking after libtool so that we can put
2549# the right suffix on the files.
2550#
2551AC_MSG_CHECKING(for IPv6 structures)
2552AC_TRY_COMPILE([
2553#include <sys/types.h>
2554#include <sys/socket.h>
2555#include <netinet/in.h>],
2556[struct sockaddr_in6 sin6; return (0);],
2557	[AC_MSG_RESULT(yes)
2558	 found_ipv6=yes],
2559	[AC_MSG_RESULT(no)
2560	 found_ipv6=no])
2561
2562#
2563# See whether IPv6 support is provided via a Kame add-on.
2564# This is done before other IPv6 linking tests to LIBS is properly set.
2565#
2566AC_MSG_CHECKING(for Kame IPv6 support)
2567AC_ARG_WITH(kame,
2568	[  --with-kame[=PATH]	  use Kame IPv6 [default path /usr/local/v6]],
2569	use_kame="$withval", use_kame="no")
2570
2571case "$use_kame" in
2572	no)
2573		;;
2574	yes)
2575		kame_path=/usr/local/v6
2576		;;
2577	*)
2578		kame_path="$use_kame"
2579		;;
2580esac
2581
2582case "$use_kame" in
2583	no)
2584		AC_MSG_RESULT(no)
2585		;;
2586	*)
2587		if test -f $kame_path/lib/libinet6.a; then
2588			AC_MSG_RESULT($kame_path/lib/libinet6.a)
2589			LIBS="-L$kame_path/lib -linet6 $LIBS"
2590		else
2591			AC_MSG_ERROR([$kame_path/lib/libinet6.a not found.
2592
2593Please choose the proper path with the following command:
2594
2595    configure --with-kame=PATH
2596])
2597		fi
2598		;;
2599esac
2600
2601#
2602# Whether netinet6/in6.h is needed has to be defined in isc/platform.h.
2603# Including it on Kame-using platforms is very bad, though, because
2604# Kame uses #error against direct inclusion.   So include it on only
2605# the platform that is otherwise broken without it -- BSD/OS 4.0 through 4.1.
2606# This is done before the in6_pktinfo check because that's what
2607# netinet6/in6.h is needed for.
2608#
2609changequote({, })
2610case "$host" in
2611*-bsdi4.[01]*)
2612	ISC_PLATFORM_NEEDNETINET6IN6H="#define ISC_PLATFORM_NEEDNETINET6IN6H 1"
2613	LWRES_PLATFORM_NEEDNETINET6IN6H="#define LWRES_PLATFORM_NEEDNETINET6IN6H 1"
2614	isc_netinet6in6_hack="#include <netinet6/in6.h>"
2615	;;
2616*)
2617	ISC_PLATFORM_NEEDNETINET6IN6H="#undef ISC_PLATFORM_NEEDNETINET6IN6H"
2618	LWRES_PLATFORM_NEEDNETINET6IN6H="#undef LWRES_PLATFORM_NEEDNETINET6IN6H"
2619	isc_netinet6in6_hack=""
2620	;;
2621esac
2622changequote([, ])
2623
2624#
2625# This is similar to the netinet6/in6.h issue.
2626#
2627case "$host" in
2628*-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
2629	# UnixWare
2630	ISC_PLATFORM_NEEDNETINETIN6H="#define ISC_PLATFORM_NEEDNETINETIN6H 1"
2631	LWRES_PLATFORM_NEEDNETINETIN6H="#define LWRES_PLATFORM_NEEDNETINETIN6H 1"
2632	ISC_PLATFORM_FIXIN6ISADDR="#define ISC_PLATFORM_FIXIN6ISADDR 1"
2633	isc_netinetin6_hack="#include <netinet/in6.h>"
2634	;;
2635*)
2636	ISC_PLATFORM_NEEDNETINETIN6H="#undef ISC_PLATFORM_NEEDNETINETIN6H"
2637	LWRES_PLATFORM_NEEDNETINETIN6H="#undef LWRES_PLATFORM_NEEDNETINETIN6H"
2638	ISC_PLATFORM_FIXIN6ISADDR="#undef ISC_PLATFORM_FIXIN6ISADDR"
2639	isc_netinetin6_hack=""
2640	;;
2641esac
2642
2643#
2644# Now delve deeper into the suitability of the IPv6 support.
2645#
2646case "$found_ipv6" in
2647	yes)
2648		ISC_PLATFORM_HAVEIPV6="#define ISC_PLATFORM_HAVEIPV6 1"
2649		LWRES_PLATFORM_HAVEIPV6="#define LWRES_PLATFORM_HAVEIPV6 1"
2650
2651		AC_MSG_CHECKING(for in6_addr)
2652		AC_TRY_COMPILE([
2653#include <sys/types.h>
2654#include <sys/socket.h>
2655#include <netinet/in.h>
2656$isc_netinetin6_hack
2657$isc_netinet6in6_hack
2658],
2659[struct in6_addr in6; return (0);],
2660		[AC_MSG_RESULT(yes)
2661		 ISC_PLATFORM_HAVEINADDR6="#undef ISC_PLATFORM_HAVEINADDR6"
2662		 LWRES_PLATFORM_HAVEINADDR6="#undef LWRES_PLATFORM_HAVEINADDR6"
2663		 isc_in_addr6_hack=""],
2664		[AC_MSG_RESULT(no)
2665		 ISC_PLATFORM_HAVEINADDR6="#define ISC_PLATFORM_HAVEINADDR6 1"
2666		 LWRES_PLATFORM_HAVEINADDR6="#define LWRES_PLATFORM_HAVEINADDR6 1"
2667		 isc_in_addr6_hack="#define in6_addr in_addr6"])
2668
2669		AC_MSG_CHECKING(for in6addr_any)
2670		AC_TRY_LINK([
2671#include <sys/types.h>
2672#include <sys/socket.h>
2673#include <netinet/in.h>
2674$isc_netinetin6_hack
2675$isc_netinet6in6_hack
2676$isc_in_addr6_hack
2677],
2678		[struct in6_addr in6; in6 = in6addr_any; return (in6.s6_addr[0]);],
2679			[AC_MSG_RESULT(yes)
2680			 ISC_PLATFORM_NEEDIN6ADDRANY="#undef ISC_PLATFORM_NEEDIN6ADDRANY"
2681			 LWRES_PLATFORM_NEEDIN6ADDRANY="#undef LWRES_PLATFORM_NEEDIN6ADDRANY"],
2682			[AC_MSG_RESULT(no)
2683			 ISC_PLATFORM_NEEDIN6ADDRANY="#define ISC_PLATFORM_NEEDIN6ADDRANY 1"
2684			 LWRES_PLATFORM_NEEDIN6ADDRANY="#define LWRES_PLATFORM_NEEDIN6ADDRANY 1"])
2685
2686		AC_MSG_CHECKING(for in6addr_loopback)
2687		AC_TRY_LINK([
2688#include <sys/types.h>
2689#include <sys/socket.h>
2690#include <netinet/in.h>
2691$isc_netinetin6_hack
2692$isc_netinet6in6_hack
2693$isc_in_addr6_hack
2694],
2695		[struct in6_addr in6; in6 = in6addr_loopback; return (in6.s6_addr[0]);],
2696			[AC_MSG_RESULT(yes)
2697			 ISC_PLATFORM_NEEDIN6ADDRLOOPBACK="#undef ISC_PLATFORM_NEEDIN6ADDRLOOPBACK"
2698			 LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK="#undef LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK"],
2699			[AC_MSG_RESULT(no)
2700			 ISC_PLATFORM_NEEDIN6ADDRLOOPBACK="#define ISC_PLATFORM_NEEDIN6ADDRLOOPBACK 1"
2701			 LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK="#define LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK 1"])
2702
2703		AC_MSG_CHECKING(for sin6_scope_id in struct sockaddr_in6)
2704		AC_TRY_COMPILE([
2705#include <sys/types.h>
2706#include <sys/socket.h>
2707#include <netinet/in.h>
2708$isc_netinetin6_hack
2709$isc_netinet6in6_hack
2710],
2711		[struct sockaddr_in6 xyzzy; xyzzy.sin6_scope_id = 0; return (0);],
2712			[AC_MSG_RESULT(yes)
2713			 ISC_PLATFORM_HAVESCOPEID="#define ISC_PLATFORM_HAVESCOPEID 1"
2714			 result="#define LWRES_HAVE_SIN6_SCOPE_ID 1"],
2715			[AC_MSG_RESULT(no)
2716			 ISC_PLATFORM_HAVESCOPEID="#undef ISC_PLATFORM_HAVESCOPEID"
2717			 result="#undef LWRES_HAVE_SIN6_SCOPE_ID"])
2718		LWRES_HAVE_SIN6_SCOPE_ID="$result"
2719
2720		AC_MSG_CHECKING(for in6_pktinfo)
2721		AC_TRY_COMPILE([
2722#include <sys/types.h>
2723#include <sys/socket.h>
2724#include <netinet/in.h>
2725$isc_netinetin6_hack
2726$isc_netinet6in6_hack
2727],
2728		[struct in6_pktinfo xyzzy; return (0);],
2729			[AC_MSG_RESULT(yes)
2730			 ISC_PLATFORM_HAVEIN6PKTINFO="#define ISC_PLATFORM_HAVEIN6PKTINFO 1"],
2731			[AC_MSG_RESULT(no -- disabling runtime ipv6 support)
2732			 ISC_PLATFORM_HAVEIN6PKTINFO="#undef ISC_PLATFORM_HAVEIN6PKTINFO"])
2733		;;
2734	no)
2735		ISC_PLATFORM_HAVEIPV6="#undef ISC_PLATFORM_HAVEIPV6"
2736		LWRES_PLATFORM_HAVEIPV6="#undef LWRES_PLATFORM_HAVEIPV6"
2737		ISC_PLATFORM_NEEDIN6ADDRANY="#undef ISC_PLATFORM_NEEDIN6ADDRANY"
2738		LWRES_PLATFORM_NEEDIN6ADDRANY="#undef LWRES_PLATFORM_NEEDIN6ADDRANY"
2739		ISC_PLATFORM_HAVEIN6PKTINFO="#undef ISC_PLATFORM_HAVEIN6PKTINFO"
2740		LWRES_HAVE_SIN6_SCOPE_ID="#define LWRES_HAVE_SIN6_SCOPE_ID 1"
2741		ISC_PLATFORM_HAVESCOPEID="#define ISC_PLATFORM_HAVESCOPEID 1"
2742		ISC_IPV6_H="ipv6.h"
2743		ISC_IPV6_O="ipv6.$O"
2744		ISC_ISCIPV6_O="unix/ipv6.$O"
2745		ISC_IPV6_C="ipv6.c"
2746		;;
2747esac
2748
2749AC_MSG_CHECKING(for struct sockaddr_storage)
2750AC_TRY_COMPILE([
2751#include <sys/types.h>
2752#include <sys/socket.h>
2753$isc_netinetin6_hack
2754$isc_netinet6in6_hack
2755],
2756[struct sockaddr_storage storage; return (0);],
2757[AC_MSG_RESULT(yes)
2758ISC_PLATFORM_HAVESOCKADDRSTORAGE="#define ISC_PLATFORM_HAVESOCKADDRSTORAGE 1"],
2759[AC_MSG_RESULT(no)
2760ISC_PLATFORM_HAVESOCKADDRSTORAGE="#undef ISC_PLATFORM_HAVESOCKADDRSTORAGE"])
2761
2762AC_SUBST(ISC_PLATFORM_HAVEIPV6)
2763AC_SUBST(LWRES_PLATFORM_HAVEIPV6)
2764AC_SUBST(ISC_PLATFORM_NEEDNETINETIN6H)
2765AC_SUBST(LWRES_PLATFORM_NEEDNETINETIN6H)
2766AC_SUBST(ISC_PLATFORM_NEEDNETINET6IN6H)
2767AC_SUBST(LWRES_PLATFORM_NEEDNETINET6IN6H)
2768AC_SUBST(ISC_PLATFORM_HAVEINADDR6)
2769AC_SUBST(LWRES_PLATFORM_HAVEINADDR6)
2770AC_SUBST(ISC_PLATFORM_NEEDIN6ADDRANY)
2771AC_SUBST(LWRES_PLATFORM_NEEDIN6ADDRANY)
2772AC_SUBST(ISC_PLATFORM_NEEDIN6ADDRLOOPBACK)
2773AC_SUBST(LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK)
2774AC_SUBST(ISC_PLATFORM_HAVEIN6PKTINFO)
2775AC_SUBST(ISC_PLATFORM_FIXIN6ISADDR)
2776AC_SUBST(ISC_PLATFORM_HAVESOCKADDRSTORAGE)
2777AC_SUBST(ISC_IPV6_H)
2778AC_SUBST(ISC_IPV6_O)
2779AC_SUBST(ISC_ISCIPV6_O)
2780AC_SUBST(ISC_IPV6_C)
2781AC_SUBST(LWRES_HAVE_SIN6_SCOPE_ID)
2782AC_SUBST(ISC_PLATFORM_HAVESCOPEID)
2783
2784AC_MSG_CHECKING([for struct if_laddrreq])
2785AC_TRY_LINK([
2786#include <sys/types.h>
2787#include <net/if6.h>
2788],[ struct if_laddrreq a; ],
2789	[AC_MSG_RESULT(yes)
2790	ISC_PLATFORM_HAVEIF_LADDRREQ="#define ISC_PLATFORM_HAVEIF_LADDRREQ 1"],
2791	[AC_MSG_RESULT(no)
2792	ISC_PLATFORM_HAVEIF_LADDRREQ="#undef ISC_PLATFORM_HAVEIF_LADDRREQ"])
2793AC_SUBST(ISC_PLATFORM_HAVEIF_LADDRREQ)
2794
2795AC_MSG_CHECKING([for struct if_laddrconf])
2796AC_TRY_LINK([
2797#include <sys/types.h>
2798#include <net/if6.h>
2799],[ struct if_laddrconf a; ],
2800	[AC_MSG_RESULT(yes)
2801	ISC_PLATFORM_HAVEIF_LADDRCONF="#define ISC_PLATFORM_HAVEIF_LADDRCONF 1"],
2802	[AC_MSG_RESULT(no)
2803	ISC_PLATFORM_HAVEIF_LADDRCONF="#undef ISC_PLATFORM_HAVEIF_LADDRCONF"])
2804AC_SUBST(ISC_PLATFORM_HAVEIF_LADDRCONF)
2805
2806#
2807# Check for network functions that are often missing.  We do this
2808# after the libtool checking, so we can put the right suffix on
2809# the files.  It also needs to come after checking for a Kame add-on,
2810# which provides some (all?) of the desired functions.
2811#
2812
2813AC_MSG_CHECKING([for inet_ntop with IPv6 support])
2814AC_TRY_RUN([
2815#include <sys/types.h>
2816#include <sys/socket.h>
2817#include <netinet/in.h>
2818#include <arpa/inet.h>
2819main() {
2820char a[16],b[64]; return(inet_ntop(AF_INET6, a, b, sizeof(b)) == (char*)0);}],
2821	[AC_MSG_RESULT(yes)
2822	ISC_PLATFORM_NEEDNTOP="#undef ISC_PLATFORM_NEEDNTOP"],
2823
2824	[AC_MSG_RESULT(no)
2825	ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_ntop.$O"
2826	ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_ntop.c"
2827	ISC_PLATFORM_NEEDNTOP="#define ISC_PLATFORM_NEEDNTOP 1"],
2828	[AC_MSG_RESULT(assuming inet_ntop not needed)
2829	ISC_PLATFORM_NEEDNTOP="#undef ISC_PLATFORM_NEEDNTOP"])
2830
2831
2832# On NetBSD 1.4.2 and maybe others, inet_pton() incorrectly accepts
2833# addresses with less than four octets, like "1.2.3".  Also leading
2834# zeros should also be rejected.
2835
2836AC_MSG_CHECKING([for working inet_pton with IPv6 support])
2837AC_TRY_RUN([
2838#include <sys/types.h>
2839#include <sys/socket.h>
2840#include <netinet/in.h>
2841#include <arpa/inet.h>
2842main() { char a[16]; return (inet_pton(AF_INET, "1.2.3", a) == 1 ? 1 :
2843			     inet_pton(AF_INET, "1.2.3.04", a) == 1 ? 1 :
2844			     (inet_pton(AF_INET6, "::1.2.3.4", a) != 1)); }],
2845	[AC_MSG_RESULT(yes)
2846	ISC_PLATFORM_NEEDPTON="#undef ISC_PLATFORM_NEEDPTON"],
2847	[AC_MSG_RESULT(no)
2848	ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_pton.$O"
2849	ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_pton.c"
2850	ISC_PLATFORM_NEEDPTON="#define ISC_PLATFORM_NEEDPTON 1"],
2851	[AC_MSG_RESULT(assuming inet_pton needed)
2852	ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_pton.$O"
2853	ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_pton.c"
2854	ISC_PLATFORM_NEEDPTON="#define ISC_PLATFORM_NEEDPTON 1"])
2855
2856AC_SUBST(ISC_PLATFORM_NEEDNTOP)
2857AC_SUBST(ISC_PLATFORM_NEEDPTON)
2858
2859#
2860# Look for a 4.4BSD-style sa_len member in struct sockaddr.
2861#
2862case "$host" in
2863	*-dec-osf*)
2864		# Turn on 4.4BSD style sa_len support.
2865		AC_DEFINE(_SOCKADDR_LEN)
2866		;;
2867esac
2868
2869AC_MSG_CHECKING(for sa_len in struct sockaddr)
2870AC_TRY_COMPILE([
2871#include <sys/types.h>
2872#include <sys/socket.h>],
2873[struct sockaddr sa; sa.sa_len = 0; return (0);],
2874	[AC_MSG_RESULT(yes)
2875	ISC_PLATFORM_HAVESALEN="#define ISC_PLATFORM_HAVESALEN 1"
2876	LWRES_PLATFORM_HAVESALEN="#define LWRES_PLATFORM_HAVESALEN 1"],
2877	[AC_MSG_RESULT(no)
2878	ISC_PLATFORM_HAVESALEN="#undef ISC_PLATFORM_HAVESALEN"
2879	LWRES_PLATFORM_HAVESALEN="#undef LWRES_PLATFORM_HAVESALEN"])
2880AC_SUBST(ISC_PLATFORM_HAVESALEN)
2881AC_SUBST(LWRES_PLATFORM_HAVESALEN)
2882
2883#
2884# Look for a 4.4BSD or 4.3BSD struct msghdr
2885#
2886AC_MSG_CHECKING(for struct msghdr flavor)
2887AC_TRY_COMPILE([
2888#include <sys/types.h>
2889#include <sys/socket.h>],
2890[struct msghdr msg; msg.msg_flags = 0; return (0);],
2891	[AC_MSG_RESULT(4.4BSD)
2892	ISC_PLATFORM_MSGHDRFLAVOR="#define ISC_NET_BSD44MSGHDR 1"],
2893	[AC_MSG_RESULT(4.3BSD)
2894	ISC_PLATFORM_MSGHDRFLAVOR="#define ISC_NET_BSD43MSGHDR 1"])
2895AC_SUBST(ISC_PLATFORM_MSGHDRFLAVOR)
2896
2897#
2898# Look for in_port_t.
2899#
2900AC_MSG_CHECKING(for type in_port_t)
2901AC_TRY_COMPILE([
2902#include <sys/types.h>
2903#include <netinet/in.h>],
2904[in_port_t port = 25; return (0);],
2905	[AC_MSG_RESULT(yes)
2906	ISC_PLATFORM_NEEDPORTT="#undef ISC_PLATFORM_NEEDPORTT"],
2907	[AC_MSG_RESULT(no)
2908	ISC_PLATFORM_NEEDPORTT="#define ISC_PLATFORM_NEEDPORTT 1"])
2909AC_SUBST(ISC_PLATFORM_NEEDPORTT)
2910
2911#
2912# Check for addrinfo
2913#
2914AC_MSG_CHECKING(for struct addrinfo)
2915AC_TRY_COMPILE([
2916#include <netdb.h>],
2917[struct addrinfo a; return (0);],
2918	[AC_MSG_RESULT(yes)
2919	ISC_LWRES_NEEDADDRINFO="#undef ISC_LWRES_NEEDADDRINFO"
2920	ISC_IRS_NEEDADDRINFO="#undef ISC_IRS_NEEDADDRINFO"
2921	AC_DEFINE(HAVE_ADDRINFO)],
2922	[AC_MSG_RESULT(no)
2923	ISC_LWRES_NEEDADDRINFO="#define ISC_LWRES_NEEDADDRINFO 1"
2924	ISC_IRS_NEEDADDRINFO="#define ISC_IRS_NEEDADDRINFO 1"])
2925AC_SUBST(ISC_LWRES_NEEDADDRINFO)
2926AC_SUBST(ISC_IRS_NEEDADDRINFO)
2927
2928#
2929# Check for rrsetinfo
2930#
2931AC_MSG_CHECKING(for struct rrsetinfo)
2932AC_TRY_COMPILE([
2933#include <netdb.h>],
2934[struct rrsetinfo r; return (0);],
2935	[AC_MSG_RESULT(yes)
2936	ISC_LWRES_NEEDRRSETINFO="#undef ISC_LWRES_NEEDRRSETINFO"],
2937	[AC_MSG_RESULT(no)
2938	ISC_LWRES_NEEDRRSETINFO="#define ISC_LWRES_NEEDRRSETINFO 1"])
2939AC_SUBST(ISC_LWRES_NEEDRRSETINFO)
2940
2941AC_MSG_CHECKING(for int sethostent)
2942AC_TRY_COMPILE([
2943#include <netdb.h>],
2944[int i = sethostent(0); return(0);],
2945	[AC_MSG_RESULT(yes)
2946	ISC_LWRES_SETHOSTENTINT="#define ISC_LWRES_SETHOSTENTINT 1"],
2947	[AC_MSG_RESULT(no)
2948	ISC_LWRES_SETHOSTENTINT="#undef ISC_LWRES_SETHOSTENTINT"])
2949AC_SUBST(ISC_LWRES_SETHOSTENTINT)
2950
2951AC_MSG_CHECKING(for int endhostent)
2952AC_TRY_COMPILE([
2953#include <netdb.h>],
2954[int i = endhostent(); return(0);],
2955	[AC_MSG_RESULT(yes)
2956	ISC_LWRES_ENDHOSTENTINT="#define ISC_LWRES_ENDHOSTENTINT 1"],
2957	[AC_MSG_RESULT(no)
2958	ISC_LWRES_ENDHOSTENTINT="#undef ISC_LWRES_ENDHOSTENTINT"])
2959AC_SUBST(ISC_LWRES_ENDHOSTENTINT)
2960
2961AC_MSG_CHECKING(for getnetbyaddr(in_addr_t, ...))
2962AC_TRY_COMPILE([
2963#include <netdb.h>
2964struct netent *getnetbyaddr(in_addr_t, int);],
2965[],
2966	[AC_MSG_RESULT(yes)
2967	ISC_LWRES_GETNETBYADDRINADDR="#define ISC_LWRES_GETNETBYADDRINADDR 1"],
2968	[AC_MSG_RESULT(no)
2969	ISC_LWRES_GETNETBYADDRINADDR="#undef ISC_LWRES_GETNETBYADDRINADDR"])
2970AC_SUBST(ISC_LWRES_GETNETBYADDRINADDR)
2971
2972AC_MSG_CHECKING(for int setnetent)
2973AC_TRY_COMPILE([
2974#include <netdb.h>],
2975[int i = setnetent(0); return(0);],
2976	[AC_MSG_RESULT(yes)
2977	ISC_LWRES_SETNETENTINT="#define ISC_LWRES_SETNETENTINT 1"],
2978	[AC_MSG_RESULT(no)
2979	ISC_LWRES_SETNETENTINT="#undef ISC_LWRES_SETNETENTINT"])
2980AC_SUBST(ISC_LWRES_SETNETENTINT)
2981
2982AC_MSG_CHECKING(for int endnetent)
2983AC_TRY_COMPILE([
2984#include <netdb.h>],
2985[int i = endnetent(); return(0);],
2986	[AC_MSG_RESULT(yes)
2987	ISC_LWRES_ENDNETENTINT="#define ISC_LWRES_ENDNETENTINT 1"],
2988	[AC_MSG_RESULT(no)
2989	ISC_LWRES_ENDNETENTINT="#undef ISC_LWRES_ENDNETENTINT"])
2990AC_SUBST(ISC_LWRES_ENDNETENTINT)
2991
2992AC_MSG_CHECKING(for gethostbyaddr(const void *, size_t, ...))
2993AC_TRY_COMPILE([
2994#include <netdb.h>
2995struct hostent *gethostbyaddr(const void *, size_t, int);],
2996[return(0);],
2997	[AC_MSG_RESULT(yes)
2998	ISC_LWRES_GETHOSTBYADDRVOID="#define ISC_LWRES_GETHOSTBYADDRVOID 1"],
2999	[AC_MSG_RESULT(no)
3000	ISC_LWRES_GETHOSTBYADDRVOID="#undef ISC_LWRES_GETHOSTBYADDRVOID"])
3001AC_SUBST(ISC_LWRES_GETHOSTBYADDRVOID)
3002
3003AC_MSG_CHECKING(for h_errno in netdb.h)
3004AC_TRY_COMPILE([
3005#include <netdb.h>],
3006[h_errno = 1; return(0);],
3007	[AC_MSG_RESULT(yes)
3008	ISC_LWRES_NEEDHERRNO="#undef ISC_LWRES_NEEDHERRNO"],
3009	[AC_MSG_RESULT(no)
3010	ISC_LWRES_NEEDHERRNO="#define ISC_LWRES_NEEDHERRNO 1"])
3011AC_SUBST(ISC_LWRES_NEEDHERRNO)
3012
3013#
3014# Sadly, the definitions of system-supplied getnameinfo(3) vary.  Try to catch
3015# known variations here:
3016#
3017AC_MSG_CHECKING(for getnameinfo prototype definitions)
3018AC_TRY_COMPILE([
3019#include <sys/types.h>
3020#include <sys/socket.h>
3021#include <netdb.h>
3022int getnameinfo(const struct sockaddr *, socklen_t, char *,
3023		socklen_t, char *, socklen_t, unsigned int);],
3024[ return (0);],
3025	[AC_MSG_RESULT(socklen_t for buflen; u_int for flags)
3026	 AC_DEFINE(IRS_GETNAMEINFO_SOCKLEN_T, socklen_t,
3027		   [Define to the sockaddr length type used by getnameinfo(3).])
3028	 AC_DEFINE(IRS_GETNAMEINFO_BUFLEN_T, socklen_t,
3029		   [Define to the buffer length type used by getnameinfo(3).])
3030	 AC_DEFINE(IRS_GETNAMEINFO_FLAGS_T, unsigned int,
3031		   [Define to the flags type used by getnameinfo(3).])],
3032[AC_TRY_COMPILE([
3033#include <sys/types.h>
3034#include <sys/socket.h>
3035#include <netdb.h>
3036int getnameinfo(const struct sockaddr *, socklen_t, char *,
3037		size_t, char *, size_t, int);],
3038[ return (0);],
3039	[AC_MSG_RESULT(size_t for buflen; int for flags)
3040	 AC_DEFINE(IRS_GETNAMEINFO_SOCKLEN_T, socklen_t)
3041	 AC_DEFINE(IRS_GETNAMEINFO_BUFLEN_T, size_t)
3042	 AC_DEFINE(IRS_GETNAMEINFO_FLAGS_T, int)],
3043[AC_TRY_COMPILE([
3044#include <sys/types.h>
3045#include <sys/socket.h>
3046#include <netdb.h>
3047int getnameinfo(const struct sockaddr *, size_t, char *,
3048		size_t, char *, size_t, int);],
3049[ return (0);],
3050	[AC_MSG_RESULT(size_t for buflen; int for flags)
3051	 AC_DEFINE(IRS_GETNAMEINFO_SOCKLEN_T, size_t)
3052	 AC_DEFINE(IRS_GETNAMEINFO_BUFLEN_T, size_t)
3053	 AC_DEFINE(IRS_GETNAMEINFO_FLAGS_T, int)],
3054[AC_MSG_RESULT(not match any subspecies; assume standard definition)
3055AC_DEFINE(IRS_GETNAMEINFO_SOCKLEN_T, socklen_t)
3056AC_DEFINE(IRS_GETNAMEINFO_BUFLEN_T, socklen_t)
3057AC_DEFINE(IRS_GETNAMEINFO_FLAGS_T, int)])])])
3058
3059#
3060# ...and same for gai_strerror().
3061#
3062AC_MSG_CHECKING(for gai_strerror prototype definitions)
3063AC_TRY_COMPILE([
3064#include <sys/types.h>
3065#include <sys/socket.h>
3066#include <netdb.h>
3067char *gai_strerror(int ecode);],
3068[ return (0); ],
3069	[AC_MSG_RESULT(returning char *)
3070	 AC_DEFINE([IRS_GAISTRERROR_RETURN_T], [char *],
3071	 [return type of gai_strerror])],
3072[AC_MSG_RESULT(not match any subspecies; assume standard definition)
3073AC_DEFINE([IRS_GAISTRERROR_RETURN_T], [const char *])])
3074
3075AC_CHECK_FUNC(getipnodebyname,
3076	[ISC_LWRES_GETIPNODEPROTO="#undef ISC_LWRES_GETIPNODEPROTO"],
3077	[ISC_LWRES_GETIPNODEPROTO="#define ISC_LWRES_GETIPNODEPROTO 1"])
3078AC_CHECK_FUNC(getnameinfo,
3079	[ISC_LWRES_GETNAMEINFOPROTO="#undef ISC_LWRES_GETNAMEINFOPROTO"],
3080	[ISC_LWRES_GETNAMEINFOPROTO="#define ISC_LWRES_GETNAMEINFOPROTO 1"])
3081AC_CHECK_FUNC(getaddrinfo,
3082	[ISC_LWRES_GETADDRINFOPROTO="#undef ISC_LWRES_GETADDRINFOPROTO"
3083	AC_DEFINE(HAVE_GETADDRINFO)],
3084	[ISC_LWRES_GETADDRINFOPROTO="#define ISC_LWRES_GETADDRINFOPROTO 1"])
3085AC_CHECK_FUNC(gai_strerror, AC_DEFINE(HAVE_GAISTRERROR))
3086AC_SUBST(ISC_LWRES_GETIPNODEPROTO)
3087AC_SUBST(ISC_LWRES_GETADDRINFOPROTO)
3088AC_SUBST(ISC_LWRES_GETNAMEINFOPROTO)
3089AC_SUBST(ISC_IRS_GETNAMEINFOSOCKLEN)
3090
3091AC_ARG_ENABLE(getifaddrs,
3092[  --enable-getifaddrs     enable the use of getifaddrs() [[yes|no]].],
3093    want_getifaddrs="$enableval",  want_getifaddrs="yes")
3094
3095#
3096# This interface iteration code for getifaddrs() will fall back to using
3097# /proc/net/if_inet6 if getifaddrs() in glibc doesn't return any IPv6
3098# addresses.
3099#
3100case $want_getifaddrs in
3101glibc)
3102AC_MSG_WARN("--enable-getifaddrs=glibc is no longer required")
3103AC_CHECK_FUNC(getifaddrs, AC_DEFINE(HAVE_GETIFADDRS))
3104;;
3105yes)
3106AC_CHECK_FUNC(getifaddrs, AC_DEFINE(HAVE_GETIFADDRS))
3107;;
3108no)
3109;;
3110esac
3111
3112#
3113# Look for a sysctl call to get the list of network interfaces.
3114#
3115case $ac_cv_header_sys_sysctl_h in
3116yes)
3117AC_MSG_CHECKING(for interface list sysctl)
3118AC_EGREP_CPP(found_rt_iflist, [
3119#include <sys/param.h>
3120#include <sys/sysctl.h>
3121#include <sys/socket.h>
3122#ifdef NET_RT_IFLIST
3123found_rt_iflist
3124#endif
3125],
3126	[AC_MSG_RESULT(yes)
3127	 AC_DEFINE(HAVE_IFLIST_SYSCTL)],
3128	[AC_MSG_RESULT(no)])
3129;;
3130esac
3131
3132#
3133# Check for some other useful functions that are not ever-present.
3134#
3135
3136# We test for strsep() using AC_TRY_LINK instead of AC_CHECK_FUNC
3137# because AIX 4.3.3 with patches for bos.adt.include to version 4.3.3.77
3138# reportedly defines strsep() without declaring it in <string.h> when
3139# -D_LINUX_SOURCE_COMPAT is not defined [RT #2190], and
3140# AC_CHECK_FUNC() incorrectly succeeds because it declares
3141# the function itself.
3142AC_MSG_CHECKING(for correctly declared strsep())
3143AC_TRY_LINK([#include <string.h>], [char *sp; char *foo = strsep(&sp, ".");],
3144	[AC_MSG_RESULT(yes); ISC_PLATFORM_NEEDSTRSEP="#undef ISC_PLATFORM_NEEDSTRSEP"],
3145	[AC_MSG_RESULT(no); ISC_PLATFORM_NEEDSTRSEP="#define ISC_PLATFORM_NEEDSTRSEP 1"])
3146AC_SUBST(ISC_PLATFORM_NEEDSTRSEP)
3147
3148AC_CHECK_FUNC(memmove,
3149	[ISC_PLATFORM_NEEDMEMMOVE="#undef ISC_PLATFORM_NEEDMEMMOVE"],
3150	[ISC_PLATFORM_NEEDMEMMOVE="#define ISC_PLATFORM_NEEDMEMMOVE 1"])
3151AC_SUBST(ISC_PLATFORM_NEEDMEMMOVE)
3152
3153AC_CHECK_FUNC(strtoul,
3154	[ISC_PLATFORM_NEEDSTRTOUL="#undef ISC_PLATFORM_NEEDSTRTOUL"
3155	 LWRES_PLATFORM_NEEDSTRTOUL="#undef LWRES_PLATFORM_NEEDSTRTOUL"
3156	 GENRANDOMLIB=""],
3157	[ISC_PLATFORM_NEEDSTRTOUL="#define ISC_PLATFORM_NEEDSTRTOUL 1"
3158	 LWRES_PLATFORM_NEEDSTRTOUL="#define LWRES_PLATFORM_NEEDSTRTOUL 1"
3159	 GENRANDOMLIB='${ISCLIBS}'])
3160AC_SUBST(ISC_PLATFORM_NEEDSTRTOUL)
3161AC_SUBST(LWRES_PLATFORM_NEEDSTRTOUL)
3162AC_SUBST(GENRANDOMLIB)
3163
3164AC_CHECK_FUNC(strlcpy,
3165	[ISC_PLATFORM_NEEDSTRLCPY="#undef ISC_PLATFORM_NEEDSTRLCPY"
3166         LWRES_PLATFORM_NEEDSTRLCPY="#undef LWRES_PLATFORM_NEEDSTRLCPY"],
3167	[ISC_PLATFORM_NEEDSTRLCPY="#define ISC_PLATFORM_NEEDSTRLCPY 1"
3168         LWRES_PLATFORM_NEEDSTRLCPY="#define LWRES_PLATFORM_NEEDSTRLCPY 1"])
3169AC_SUBST(ISC_PLATFORM_NEEDSTRLCPY)
3170AC_SUBST(LWRES_PLATFORM_NEEDSTRLCPY)
3171
3172AC_CHECK_FUNC(strlcat,
3173	[ISC_PLATFORM_NEEDSTRLCAT="#undef ISC_PLATFORM_NEEDSTRLCAT"],
3174	[ISC_PLATFORM_NEEDSTRLCAT="#define ISC_PLATFORM_NEEDSTRLCAT 1"])
3175AC_SUBST(ISC_PLATFORM_NEEDSTRLCAT)
3176
3177AC_CHECK_FUNC(strcasestr,
3178	[ISC_PLATFORM_NEEDSTRCASESTR="#undef ISC_PLATFORM_NEEDSTRCASESTR"],
3179	[ISC_PLATFORM_NEEDSTRCASESTR="#define ISC_PLATFORM_NEEDSTRCASESTR 1"])
3180AC_SUBST(ISC_PLATFORM_NEEDSTRCASESTR)
3181
3182AC_SUBST(READLINE_LIB)
3183AC_ARG_WITH(readline,
3184	[  --with-readline[=LIBSPEC]    specify readline library [default -lreadline]],
3185	readline="$withval", readline="-lreadline")
3186case "$readline" in
3187no)	;;
3188*)
3189	if test "x$readline" = "xyes"
3190	then
3191		readline=-lreadline
3192	fi
3193	saved_LIBS="$LIBS"
3194	LIBS="$readline"
3195	AC_CHECK_FUNCS(readline)
3196	if test "$ac_cv_func_readline" = "yes"
3197	then
3198		READLINE_LIB="$readline"
3199	fi
3200	LIBS="$saved_LIBS"
3201	;;
3202esac
3203
3204
3205ISC_PRINT_OBJS=
3206ISC_PRINT_SRCS=
3207AC_MSG_CHECKING(sprintf)
3208AC_TRY_COMPILE([
3209#include <stdio.h>
3210],
3211[ char buf[2]; return(*sprintf(buf,"x"));],
3212[
3213ISC_PRINT_OBJS="print.$O"
3214ISC_PRINT_SRCS="print.c"
3215ISC_PLATFORM_NEEDSPRINTF="#define ISC_PLATFORM_NEEDSPRINTF"
3216LWRES_PLATFORM_NEEDSPRINTF="#define LWRES_PLATFORM_NEEDSPRINTF"
3217],
3218[ISC_PLATFORM_NEEDSPRINTF="#undef ISC_PLATFORM_NEEDSPRINTF"
3219 LWRES_PLATFORM_NEEDSPRINTF="#undef LWRES_PLATFORM_NEEDSPRINTF"]
3220)
3221AC_SUBST(ISC_PLATFORM_NEEDSPRINTF)
3222AC_SUBST(LWRES_PLATFORM_NEEDSPRINTF)
3223
3224AC_CHECK_FUNC(vsnprintf,
3225	[ISC_PLATFORM_NEEDVSNPRINTF="#undef ISC_PLATFORM_NEEDVSNPRINTF"
3226	 LWRES_PLATFORM_NEEDVSNPRINTF="#undef LWRES_PLATFORM_NEEDVSNPRINTF"],
3227	[ISC_PRINT_OBJS="print.$O"
3228	 ISC_PRINT_SRCS="print.c"
3229	 ISC_PLATFORM_NEEDVSNPRINTF="#define ISC_PLATFORM_NEEDVSNPRINTF 1"
3230	 LWRES_PLATFORM_NEEDVSNPRINTF="#define LWRES_PLATFORM_NEEDVSNPRINTF 1"])
3231AC_SUBST(ISC_PLATFORM_NEEDVSNPRINTF)
3232AC_SUBST(LWRES_PLATFORM_NEEDVSNPRINTF)
3233ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS $ISC_PRINT_OBJS"
3234ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS $ISC_PRINT_SRCS"
3235
3236AC_CHECK_FUNC(strerror, AC_DEFINE(HAVE_STRERROR))
3237
3238AC_SUBST(ISC_EXTRA_OBJS)
3239AC_SUBST(ISC_EXTRA_SRCS)
3240
3241#
3242# Use our own SPNEGO implementation?
3243#
3244AC_ARG_ENABLE(isc-spnego,
3245	[  --disable-isc-spnego    use SPNEGO from GSSAPI library])
3246
3247if test -n "$USE_GSSAPI"
3248then
3249	case "$enable_isc_spnego" in
3250		yes|'')
3251			USE_ISC_SPNEGO='-DUSE_ISC_SPNEGO'
3252			DST_EXTRA_OBJS="$DST_EXTRA_OBJS spnego.$O"
3253			DST_EXTRA_SRCS="$DST_EXTRA_SRCS spnego.c"
3254			AC_MSG_RESULT(using SPNEGO from lib/dns)
3255			;;
3256		no)
3257			AC_MSG_RESULT(using SPNEGO from GSSAPI library)
3258			;;
3259	esac
3260fi
3261
3262AC_SUBST(USE_ISC_SPNEGO)
3263
3264AC_SUBST(DST_EXTRA_OBJS)
3265AC_SUBST(DST_EXTRA_SRCS)
3266
3267# Determine the printf format characters to use when printing
3268# values of type isc_int64_t. This will normally be "ll", but where
3269# the compiler treats "long long" as a alias for "long" and printf
3270# doesn't know about "long long" use "l".  Hopefully the sprintf
3271# will produce a inconsistent result in the later case.  If the compiler
3272# fails due to seeing "%lld" we fall back to "l".
3273#
3274# Digital Unix 4.0 (gcc?) (long long) is 64 bits as is its long. It uses
3275# %ld even for (long long)/
3276#
3277# Win32 uses "%I64d", but that's defined elsewhere since we don't use
3278# configure on Win32.
3279#
3280AC_MSG_CHECKING(printf format modifier for 64-bit integers)
3281AC_TRY_RUN([
3282#include <stdio.h>
3283main() {
3284	long long int j = 0;
3285	char buf[100];
3286	buf[0] = 0;
3287	sprintf(buf, "%lld", j);
3288	exit((sizeof(long long int) != sizeof(long int))? 0 :
3289	     (strcmp(buf, "0") != 0));
3290}
3291],
3292	[AC_MSG_RESULT(ll)
3293	ISC_PLATFORM_QUADFORMAT='#define ISC_PLATFORM_QUADFORMAT "ll"'
3294	LWRES_PLATFORM_QUADFORMAT='#define LWRES_PLATFORM_QUADFORMAT "ll"'],
3295	[AC_MSG_RESULT(l)
3296	ISC_PLATFORM_QUADFORMAT='#define ISC_PLATFORM_QUADFORMAT "l"'
3297	LWRES_PLATFORM_QUADFORMAT='#define LWRES_PLATFORM_QUADFORMAT "l"'],
3298	[AC_MSG_RESULT(assuming target platform uses ll)
3299	ISC_PLATFORM_QUADFORMAT='#define ISC_PLATFORM_QUADFORMAT "ll"'
3300	LWRES_PLATFORM_QUADFORMAT='#define LWRES_PLATFORM_QUADFORMAT "ll"'])
3301AC_SUBST(ISC_PLATFORM_QUADFORMAT)
3302AC_SUBST(LWRES_PLATFORM_QUADFORMAT)
3303
3304#
3305# Security Stuff
3306#
3307# Note it is very recommended to *not* disable chroot(),
3308# this is only because chroot() was made obsolete by Posix.
3309AC_ARG_ENABLE(chroot,
3310	[  --disable-chroot        disable chroot])
3311case "$enable_chroot" in
3312	yes|'')
3313		AC_CHECK_FUNCS(chroot)
3314		;;
3315	no)
3316		;;
3317esac
3318AC_ARG_ENABLE(linux-caps,
3319	[  --disable-linux-caps	  disable linux capabilities])
3320case "$enable_linux_caps" in
3321	yes|'')
3322		AC_CHECK_HEADERS(linux/types.h)
3323		AC_CHECK_HEADERS([sys/capability.h])
3324		AC_CHECK_HEADERS([linux/capability.h], [], [],
3325				 [#ifdef HAVE_LINUX_TYPES_H
3326				  #include <linux/types.h>
3327				  #endif
3328				 ])
3329		AC_CHECK_LIB(cap, cap_set_proc)
3330		;;
3331	no)
3332		;;
3333esac
3334AC_CHECK_HEADERS(sys/prctl.h)
3335
3336AC_CHECK_HEADERS(sys/un.h,
3337ISC_PLATFORM_HAVESYSUNH="#define ISC_PLATFORM_HAVESYSUNH 1"
3338,
3339ISC_PLATFORM_HAVESYSUNH="#undef ISC_PLATFORM_HAVESYSUNH"
3340)
3341AC_SUBST(ISC_PLATFORM_HAVESYSUNH)
3342
3343case "$host" in
3344*-solaris*)
3345	AC_DEFINE(NEED_SECURE_DIRECTORY, 1,
3346		  [Define if connect does not honour the permission on the UNIX domain socket.])
3347	;;
3348*-sunos*)
3349	AC_DEFINE(NEED_SECURE_DIRECTORY, 1,
3350		  [Define if connect does not honour the permission on the UNIX domain socket.])
3351	;;
3352esac
3353
3354#
3355# Time Zone Stuff
3356#
3357AC_CHECK_FUNC(tzset, AC_DEFINE(HAVE_TZSET))
3358
3359AC_MSG_CHECKING(for optarg declaration)
3360AC_TRY_COMPILE([
3361#include <unistd.h>
3362],
3363[optarg = 0;],
3364[AC_MSG_RESULT(yes)],
3365[AC_MSG_RESULT(no)
3366GEN_NEED_OPTARG="-DNEED_OPTARG=1"
3367AC_DEFINE(NEED_OPTARG, 1, [Defined if extern char *optarg is not declared.])])
3368
3369#
3370# BSD/OS, and perhaps some others, don't define rlim_t.
3371#
3372AC_MSG_CHECKING(for type rlim_t)
3373AC_TRY_COMPILE([
3374#include <sys/types.h>
3375#include <sys/time.h>
3376#include <sys/resource.h>],
3377[rlim_t rl = 19671212; return (0);],
3378[AC_MSG_RESULT(yes)
3379 ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE rlim_t"],
3380[AC_MSG_RESULT(no)
3381
3382AC_MSG_CHECKING(type of rlim_cur)
3383AC_TRY_RUN([
3384#include <sys/types.h>
3385#include <sys/time.h>
3386#include <sys/resource.h>
3387main() { struct rlimit r; exit(!(sizeof(r.rlim_cur) == sizeof(int)));}],
3388[AC_MSG_RESULT(int)
3389ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE int"],
3390[
3391AC_TRY_RUN([
3392#include <sys/types.h>
3393#include <sys/time.h>
3394#include <sys/resource.h>
3395main() { struct rlimit r; exit(!(sizeof(r.rlim_cur) == sizeof(long int)));}],
3396[AC_MSG_RESULT(long int)
3397ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE long int"],
3398[
3399AC_TRY_RUN([
3400#include <sys/types.h>
3401#include <sys/time.h>
3402#include <sys/resource.h>
3403main() { struct rlimit r; exit((!sizeof(r.rlim_cur) == sizeof(long long int)));}],
3404[AC_MSG_RESULT(long long int)
3405ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE long long int"],
3406[AC_MSG_ERROR([unable to determine sizeof rlim_cur])
3407],[AC_MSG_ERROR(this cannot happen)])
3408],[AC_MSG_ERROR(this cannot happen)])
3409],[
3410AC_ARG_WITH(rlimtype, , rlimtype="$withval", rlimtype="long long int")
3411ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE $rlimtype"
3412AC_MSG_RESULT(cannot determine type of rlim_cur when cross compiling - assuming $rlimtype)])
3413])
3414AC_SUBST(ISC_PLATFORM_RLIMITTYPE)
3415
3416#
3417# Older HP-UX doesn't have gettune
3418#
3419case "$host" in
3420	*-hp-hpux*)
3421		AC_CHECK_HEADERS(sys/dyntune.h)
3422		;;
3423	*)
3424		;;
3425esac
3426
3427
3428#
3429# Compaq TruCluster requires more code for handling cluster IP aliases
3430#
3431case "$host" in
3432	*-dec-osf*)
3433		AC_CHECK_LIB(clua, clua_getaliasaddress, LIBS="-lclua $LIBS")
3434		AC_CHECK_FUNC(clua_getaliasaddress,
3435				AC_DEFINE(HAVE_TRUCLUSTER, 1,
3436					[Define if running under Compaq TruCluster]))
3437		;;
3438	*)
3439		;;
3440esac
3441
3442#
3443# Some hosts need msg_namelen to match the size of the socket structure.
3444# Some hosts don't set msg_namelen appropriately on return from recvmsg().
3445#
3446case $host in
3447*os2*|*hp-mpeix*)
3448	AC_DEFINE(BROKEN_RECVMSG, 1,
3449		  [Define if recvmsg() does not meet all of the BSD socket API specifications.])
3450	;;
3451esac
3452
3453#
3454# Microsoft has their own way of handling shared libraries that requires
3455# additional qualifiers on extern variables.  Unix systems don't need it.
3456#
3457AC_SUBST(ISC_PLATFORM_USEDECLSPEC)
3458ISC_PLATFORM_USEDECLSPEC="#undef ISC_PLATFORM_USEDECLSPEC"
3459AC_SUBST(LWRES_PLATFORM_USEDECLSPEC)
3460LWRES_PLATFORM_USEDECLSPEC="#undef LWRES_PLATFORM_USEDECLSPEC"
3461AC_SUBST(IRS_PLATFORM_USEDECLSPEC)
3462IRS_PLATFORM_USEDECLSPEC="#undef IRS_PLATFORM_USEDECLSPEC"
3463
3464#
3465# Random remaining OS-specific issues involving compiler warnings.
3466# XXXDCL print messages to indicate some compensation is being done?
3467#
3468AC_SUBST(ISC_PLATFORM_BRACEPTHREADONCEINIT)
3469ISC_PLATFORM_BRACEPTHREADONCEINIT="#undef ISC_PLATFORM_BRACEPTHREADONCEINIT"
3470
3471case "$host" in
3472	*-aix5.[[123]].*)
3473		hack_shutup_pthreadonceinit=yes
3474		;;
3475	*-bsdi3.1*)
3476		hack_shutup_sputaux=yes
3477		;;
3478	*-bsdi4.0*)
3479		hack_shutup_sigwait=yes
3480		hack_shutup_sputaux=yes
3481		;;
3482	[*-bsdi4.[12]*])
3483		hack_shutup_stdargcast=yes
3484		;;
3485	[*-solaris2.[89]])
3486		hack_shutup_pthreadonceinit=yes
3487		;;
3488	*-solaris2.1[[0-9]])
3489		AC_TRY_COMPILE([ #include <pthread.h> ], [ static pthread_once_t once_test = { PTHREAD_ONCE_INIT }; ], [hack_shutup_pthreadonceinit=yes], )
3490		;;
3491esac
3492
3493case "$hack_shutup_pthreadonceinit" in
3494	yes)
3495		#
3496		# Shut up PTHREAD_ONCE_INIT unbraced initializer warnings.
3497		#
3498		ISC_PLATFORM_BRACEPTHREADONCEINIT="#define ISC_PLATFORM_BRACEPTHREADONCEINIT 1"
3499		;;
3500esac
3501
3502case "$hack_shutup_sigwait" in
3503	yes)
3504		#
3505		# Shut up a -Wmissing-prototypes warning for sigwait().
3506		#
3507		AC_DEFINE(SHUTUP_SIGWAIT)
3508		;;
3509esac
3510
3511case "$hack_shutup_sputaux" in
3512	yes)
3513		#
3514		# Shut up a -Wmissing-prototypes warning from <stdio.h>.
3515		#
3516		AC_DEFINE(SHUTUP_SPUTAUX)
3517		;;
3518esac
3519
3520case "$hack_shutup_stdargcast" in
3521	yes)
3522		#
3523		# Shut up a -Wcast-qual warning from va_start().
3524		#
3525		AC_DEFINE(SHUTUP_STDARG_CAST)
3526		;;
3527esac
3528
3529AC_CHECK_HEADERS(strings.h,
3530  ISC_PLATFORM_HAVESTRINGSH="#define ISC_PLATFORM_HAVESTRINGSH 1"
3531,
3532  ISC_PLATFORM_HAVESTRINGSH="#undef ISC_PLATFORM_HAVESTRINGSH"
3533)
3534AC_SUBST(ISC_PLATFORM_HAVESTRINGSH)
3535
3536#
3537# Check for if_nametoindex() for IPv6 scoped addresses support
3538#
3539AC_CHECK_FUNC(if_nametoindex, ac_cv_have_if_nametoindex=yes,
3540		ac_cv_have_if_nametoindex=no)
3541case $ac_cv_have_if_nametoindex in
3542no)
3543	case "$host" in
3544	*-hp-hpux*)
3545		AC_CHECK_LIB(ipv6, if_nametoindex,
3546				ac_cv_have_if_nametoindex=yes
3547				LIBS="-lipv6 $LIBS",)
3548	;;
3549	esac
3550esac
3551case $ac_cv_have_if_nametoindex in
3552yes)
3553	ISC_PLATFORM_HAVEIFNAMETOINDEX="#define ISC_PLATFORM_HAVEIFNAMETOINDEX 1"
3554        AC_DEFINE(HAVE_IF_NAMETOINDEX, 1,
3555                  [Define to 1 if you have the if_nametoindex function.])
3556
3557	;;
3558*)
3559	ISC_PLATFORM_HAVEIFNAMETOINDEX="#undef ISC_PLATFORM_HAVEIFNAMETOINDEX"
3560	;;
3561esac
3562AC_SUBST(ISC_PLATFORM_HAVEIFNAMETOINDEX)
3563
3564AC_CHECK_FUNCS(nanosleep usleep)
3565
3566#
3567# Machine architecture dependent features
3568#
3569AC_ARG_ENABLE(atomic,
3570	[  --enable-atomic	  enable machine specific atomic operations
3571			  [[default=autodetect]]],
3572			enable_atomic="$enableval",
3573			enable_atomic="autodetect")
3574case "$enable_atomic" in
3575	yes|''|autodetect)
3576		case "$host" in
3577		powerpc-ibm-aix*)
3578			if test "X$GCC" = "Xyes"; then
3579				AC_MSG_CHECKING([if asm("isc"); works])
3580				AC_TRY_COMPILE(,[
3581				main() { asm("ics"); exit(0); }
3582				],
3583				[AC_MSG_RESULT(yes)
3584				 use_atomic=yes],
3585				[
3586				saved_cflags="$CFLAGS"
3587				CFLAGS="$CFLAGS -Wa,-many"
3588				AC_TRY_RUN([
3589				main() { asm("ics"); exit(0); }
3590				],
3591				[AC_MSG_RESULT([yes, required -Wa,-many])
3592				 use_atomic=yes],
3593				[AC_MSG_RESULT([no, use_atomic disabled])
3594				 CFLAGS="$saved_cflags"
3595				 use_atomic=no],
3596				[AC_MSG_RESULT([cross compile, assume yes])
3597				 CFLAGS="$saved_cflags"
3598				 use_atomic=yes])
3599				]
3600				)
3601			else
3602				use_atomic=yes
3603			fi
3604			;;
3605		*)
3606			use_atomic=yes
3607			;;
3608		esac
3609		;;
3610	no)
3611		use_atomic=no
3612		arch=noatomic
3613		;;
3614esac
3615
3616ISC_PLATFORM_USEOSFASM="#undef ISC_PLATFORM_USEOSFASM"
3617if test "$use_atomic" = "yes"; then
3618	AC_MSG_CHECKING([architecture type for atomic operations])
3619	have_atomic=yes		# set default
3620	case "$host" in
3621	[i[3456]86-*])
3622		# XXX: some old x86 architectures actually do not support
3623		#      (some of) these operations.  Do we need stricter checks?
3624		AC_CHECK_SIZEOF([void *])
3625		if test $ac_cv_sizeof_void_p = 8; then
3626			arch=x86_64
3627			have_xaddq=yes
3628		else
3629			arch=x86_32
3630		fi
3631	;;
3632	x86_64-*|amd64-*)
3633		AC_CHECK_SIZEOF([void *])
3634		if test $ac_cv_sizeof_void_p = 8; then
3635			arch=x86_64
3636			have_xaddq=yes
3637		else
3638			arch=x86_32
3639		fi
3640	;;
3641	alpha*-*)
3642		arch=alpha
3643	;;
3644	powerpc-*|powerpc64-*)
3645		arch=powerpc
3646	;;
3647	mips-*|mipsel-*|mips64-*|mips64el-*)
3648		arch=mips
3649	;;
3650	ia64-*)
3651		arch=ia64
3652	;;
3653	*)
3654		have_atomic=no
3655		arch=noatomic
3656	;;
3657	esac
3658	AC_MSG_RESULT($arch)
3659fi
3660
3661if test "$have_atomic" = "yes"; then
3662	AC_MSG_CHECKING([compiler support for inline assembly code])
3663
3664	compiler=generic
3665	# Check whether the compiler supports the assembly syntax we provide.
3666	if test "X$GCC" = "Xyes"; then
3667		# GCC's ASM extension always works
3668		compiler=gcc
3669		if test $arch = "x86_64"; then
3670			# We can share the same code for gcc with x86_32
3671			arch=x86_32
3672		fi
3673		if test $arch = "powerpc"; then
3674			#
3675			# The MacOS (and maybe others) uses "r0" for register
3676			# zero. Under linux/ibm it is "0" for register 0.
3677			# Probe to see if we have a MacOS style assembler.
3678			#
3679			AC_MSG_CHECKING([Checking for MacOS style assembler syntax])
3680			AC_TRY_COMPILE(, [
3681			__asm__ volatile ("li r0, 0x0\n"::);
3682			], [
3683			AC_MSG_RESULT(yes)
3684			compiler="mac"
3685			ISC_PLATFORM_USEMACASM="#define ISC_PLATFORM_USEMACASM 1"
3686			], [AC_MSG_RESULT(no)])
3687		fi
3688	else
3689		case "$host" in
3690		alpha*-dec-osf*)
3691			# Tru64 compiler has its own syntax for inline
3692			# assembly.
3693			AC_TRY_COMPILE(, [
3694#ifndef __DECC
3695#error "unexpected compiler"
3696#endif
3697				return (0);],
3698				[compiler=osf],)
3699		;;
3700		powerpc-ibm-aix*)
3701			compiler=aix
3702		;;
3703		esac
3704	fi
3705	case "$compiler" in
3706	gcc)
3707		ISC_PLATFORM_USEGCCASM="#define ISC_PLATFORM_USEGCCASM 1"
3708		;;
3709	osf)
3710		ISC_PLATFORM_USEOSFASM="#define ISC_PLATFORM_USEOSFASM 1"
3711		;;
3712	aix)
3713		;;
3714	mac)
3715		;;
3716	*)
3717		# See if the generic __asm function works.  If not,
3718		# we need to disable the atomic operations.
3719		AC_TRY_LINK(, [
3720					__asm("nop")
3721				],
3722		[compiler="standard"
3723		ISC_PLATFORM_USESTDASM="#define ISC_PLATFORM_USESTDASM 1"],
3724		[compiler="not supported (atomic operations disabled)"
3725		have_atomic=no
3726		arch=noatomic ]);
3727		;;
3728	esac
3729
3730	AC_MSG_RESULT($compiler)
3731fi
3732
3733if test "$have_atomic" = "yes"; then
3734	ISC_PLATFORM_HAVEXADD="#define ISC_PLATFORM_HAVEXADD 1"
3735	ISC_PLATFORM_HAVECMPXCHG="#define ISC_PLATFORM_HAVECMPXCHG 1"
3736	ISC_PLATFORM_HAVEATOMICSTORE="#define ISC_PLATFORM_HAVEATOMICSTORE 1"
3737else
3738	ISC_PLATFORM_HAVEXADD="#undef ISC_PLATFORM_HAVEXADD"
3739	ISC_PLATFORM_HAVECMPXCHG="#undef ISC_PLATFORM_HAVECMPXCHG"
3740	ISC_PLATFORM_HAVEATOMICSTORE="#undef ISC_PLATFORM_HAVEATOMICSTORE"
3741fi
3742
3743if test "$have_xaddq" = "yes"; then
3744	ISC_PLATFORM_HAVEXADDQ="#define ISC_PLATFORM_HAVEXADDQ 1"
3745else
3746	ISC_PLATFORM_HAVEXADDQ="#undef ISC_PLATFORM_HAVEXADDQ"
3747fi
3748
3749AC_SUBST(ISC_PLATFORM_HAVEXADD)
3750AC_SUBST(ISC_PLATFORM_HAVEXADDQ)
3751AC_SUBST(ISC_PLATFORM_HAVECMPXCHG)
3752AC_SUBST(ISC_PLATFORM_HAVEATOMICSTORE)
3753
3754AC_SUBST(ISC_PLATFORM_USEGCCASM)
3755AC_SUBST(ISC_PLATFORM_USEOSFASM)
3756AC_SUBST(ISC_PLATFORM_USESTDASM)
3757AC_SUBST(ISC_PLATFORM_USEMACASM)
3758
3759ISC_ARCH_DIR=$arch
3760AC_SUBST(ISC_ARCH_DIR)
3761
3762#
3763# Activate "rrset-order fixed" or not?
3764#
3765AC_ARG_ENABLE(fixed-rrset,
3766	[  --enable-fixed-rrset    enable fixed rrset ordering [[default=no]]],
3767			enable_fixed="$enableval",
3768			enable_fixed="no")
3769case "$enable_fixed" in
3770	yes)
3771		AC_DEFINE(DNS_RDATASET_FIXED, 1,
3772			  [Define to enable "rrset-order fixed" syntax.])
3773		;;
3774	no)
3775		;;
3776	*)
3777		;;
3778esac
3779
3780#
3781# Enable response policy rewriting using NS IP addresses
3782#
3783AC_ARG_ENABLE(rpz-nsip,
3784	[  --disable-rpz-nsip	  disable rpz-nsip rules [[default=enabled]]],
3785			enable_nsip="$enableval",
3786			enable_nsip="yes")
3787case "$enable_nsip" in
3788	yes)
3789		AC_DEFINE(ENABLE_RPZ_NSIP, 1,
3790			  [Define to enable rpz-nsip rules.])
3791		;;
3792	no)
3793		;;
3794	*)
3795		;;
3796esac
3797
3798#
3799# Enable response policy rewriting using NS name
3800#
3801AC_ARG_ENABLE(rpz-nsdname,
3802	[  --disable-rpz-nsdname	  disable rpz-nsdname rules [[default=enabled]]],
3803			enable_nsdname="$enableval",
3804			enable_nsdname="yes")
3805case "$enable_nsdname" in
3806	yes)
3807		AC_DEFINE(ENABLE_RPZ_NSDNAME, 1,
3808			  [Define to enable rpz-nsdname rules.])
3809		;;
3810	no)
3811		;;
3812	*)
3813		;;
3814esac
3815
3816#
3817# Activate "filter-aaaa-on-v4/v6" or not?
3818#
3819AC_ARG_ENABLE(filter-aaaa,
3820	[  --enable-filter-aaaa    enable filtering of AAAA records [[default=no]]],
3821			enable_filter="$enableval",
3822			enable_filter="no")
3823case "$enable_filter" in
3824	yes)
3825		AC_DEFINE(ALLOW_FILTER_AAAA, 1,
3826			  [Define to enable the "filter-aaaa-on-v4" and "filter-aaaa-on-v6" options.])
3827		;;
3828	no)
3829		;;
3830	*)
3831		;;
3832esac
3833
3834#
3835#  The following sets up how non-blocking i/o is established.
3836#  Sunos, cygwin and solaris 2.x (x<5) require special handling.
3837#
3838case "$host" in
3839*-sunos*) AC_DEFINE(PORT_NONBLOCK, O_NDELAY);;
3840*-cygwin*) AC_DEFINE(PORT_NONBLOCK, O_NDELAY);;
3841*-solaris2.[[01234]])
3842	AC_DEFINE(PORT_NONBLOCK, O_NONBLOCK)
3843	AC_DEFINE(USE_FIONBIO_IOCTL, 1,
3844		  [Defined if you need to use ioctl(FIONBIO) instead a fcntl call to make non-blocking.])
3845	;;
3846*) AC_DEFINE(PORT_NONBLOCK, O_NONBLOCK,
3847	     [Sets which flag to pass to open/fcntl to make non-blocking (O_NDELAY/O_NONBLOCK).])
3848	;;
3849esac
3850#
3851# Solaris 2.5.1 and earlier cannot bind() then connect() a TCP socket.
3852# This prevents the source address being set.
3853#
3854case "$host" in
3855*-solaris2.[[012345]]|*-solaris2.5.1)
3856	AC_DEFINE(BROKEN_TCP_BIND_BEFORE_CONNECT, 1,
3857		  [Define if you cannot bind() before connect() for TCP sockets.])
3858	;;
3859esac
3860#
3861# The following sections deal with tools used for formatting
3862# the documentation.  They are all optional, unless you are
3863# a developer editing the documentation source.
3864#
3865
3866#
3867# Look for TeX.
3868#
3869
3870AC_PATH_PROGS(LATEX, latex, latex)
3871AC_SUBST(LATEX)
3872
3873AC_PATH_PROGS(PDFLATEX, pdflatex, pdflatex)
3874AC_SUBST(PDFLATEX)
3875
3876#
3877# Look for w3m
3878#
3879
3880AC_PATH_PROGS(W3M, w3m, w3m)
3881AC_SUBST(W3M)
3882
3883#
3884# Look for xsltproc (libxslt)
3885#
3886
3887AC_PATH_PROG(XSLTPROC, xsltproc, xsltproc)
3888AC_SUBST(XSLTPROC)
3889
3890#
3891# Look for xmllint (libxml2)
3892#
3893
3894AC_PATH_PROG(XMLLINT, xmllint, xmllint)
3895AC_SUBST(XMLLINT)
3896
3897#
3898# Look for Doxygen
3899#
3900
3901AC_PATH_PROG(DOXYGEN, doxygen, doxygen)
3902AC_SUBST(DOXYGEN)
3903
3904#
3905# Subroutine for searching for an ordinary file (e.g., a stylesheet)
3906# in a number of directories:
3907#
3908#   NOM_PATH_FILE(VARIABLE, FILENAME, DIRECTORIES)
3909#
3910# If the file FILENAME is found in one of the DIRECTORIES, the shell
3911# variable VARIABLE is defined to its absolute pathname.  Otherwise,
3912# it is set to FILENAME, with no directory prefix (that's not terribly
3913# useful, but looks less confusing in substitutions than leaving it
3914# empty).  The variable VARIABLE will be substituted into output files.
3915#
3916
3917AC_DEFUN(NOM_PATH_FILE, [
3918$1=""
3919AC_MSG_CHECKING(for $2)
3920for d in $3
3921do
3922	f=$d/$2
3923	if test -f $f
3924	then
3925		$1=$f
3926		AC_MSG_RESULT($f)
3927		break
3928	fi
3929done
3930if test "X[$]$1" = "X"
3931then
3932	AC_MSG_RESULT("not found");
3933	$1=$2
3934fi
3935AC_SUBST($1)
3936])
3937
3938#
3939# Look for Docbook-XSL stylesheets.  Location probably varies by system.
3940# If it's not explicitly specified, guess where it might be found, based on
3941# where SGML stuff lives on some systems (FreeBSD is the only one we're sure
3942# of at the moment).
3943#
3944AC_MSG_CHECKING(for Docbook-XSL path)
3945AC_ARG_WITH(docbook-xsl,
3946[  --with-docbook-xsl=PATH specify path for Docbook-XSL stylesheets],
3947   docbook_path="$withval", docbook_path="auto")
3948case "$docbook_path" in
3949auto)
3950	AC_MSG_RESULT(auto)
3951	docbook_xsl_trees="/usr/pkg/share/xsl/docbook /usr/local/share/xsl/docbook /usr/share/xsl/docbook /opt/local/share/xsl/docbook-xsl"
3952	;;
3953*)
3954	docbook_xsl_trees="$withval"
3955	AC_MSG_RESULT($docbook_xsl_trees)
3956	;;
3957esac
3958
3959#
3960# Look for stylesheets we need.
3961#
3962
3963NOM_PATH_FILE(XSLT_DOCBOOK_STYLE_HTML, html/docbook.xsl, $docbook_xsl_trees)
3964NOM_PATH_FILE(XSLT_DOCBOOK_STYLE_XHTML, xhtml/docbook.xsl, $docbook_xsl_trees)
3965NOM_PATH_FILE(XSLT_DOCBOOK_STYLE_MAN, manpages/docbook.xsl, $docbook_xsl_trees)
3966NOM_PATH_FILE(XSLT_DOCBOOK_CHUNK_HTML, html/chunk.xsl, $docbook_xsl_trees)
3967NOM_PATH_FILE(XSLT_DOCBOOK_CHUNK_XHTML, xhtml/chunk.xsl, $docbook_xsl_trees)
3968NOM_PATH_FILE(XSLT_DOCBOOK_CHUNKTOC_HTML, html/chunktoc.xsl, $docbook_xsl_trees)
3969NOM_PATH_FILE(XSLT_DOCBOOK_CHUNKTOC_XHTML, xhtml/chunktoc.xsl, $docbook_xsl_trees)
3970NOM_PATH_FILE(XSLT_DOCBOOK_MAKETOC_HTML, html/maketoc.xsl, $docbook_xsl_trees)
3971NOM_PATH_FILE(XSLT_DOCBOOK_MAKETOC_XHTML, xhtml/maketoc.xsl, $docbook_xsl_trees)
3972
3973#
3974# Same dance for db2latex
3975#
3976
3977db2latex_xsl_trees="/usr/local/share/db2latex/xsl /usr/pkg/share/xsl/db2latex"
3978
3979#
3980# Look for stylesheets we need.
3981#
3982
3983NOM_PATH_FILE(XSLT_DB2LATEX_STYLE, docbook.xsl, $db2latex_xsl_trees)
3984
3985#
3986# Look for "admonition" image directory.  Can't use NOM_PATH_FILE()
3987# because it's a directory, so just do the same things, inline.
3988#
3989
3990AC_MSG_CHECKING(for db2latex xsl figures)
3991for d in $db2latex_xsl_trees
3992do
3993	if test -d $d/figures
3994	then
3995		XSLT_DB2LATEX_ADMONITIONS=$d/figures
3996		AC_MSG_RESULT($d/figures)
3997		break
3998	fi
3999done
4000if test "X$XSLT_DB2LATEX_ADMONITIONS" = "X"
4001then
4002	AC_MSG_RESULT(not found)
4003	XSLT_DB2LATEX_ADMONITIONS=db2latex/xsl/figures
4004fi
4005AC_SUBST(XSLT_DB2LATEX_ADMONITIONS)
4006
4007#
4008# IDN support
4009#
4010AC_ARG_WITH(idn,
4011	[  --with-idn[=MPREFIX]      enable IDN support using idnkit [default PREFIX]],
4012	use_idn="$withval", use_idn="no")
4013case "$use_idn" in
4014yes)
4015	if test X$prefix = XNONE ; then
4016		idn_path=/usr/local
4017	else
4018		idn_path=$prefix
4019	fi
4020	;;
4021no)
4022	;;
4023*)
4024	idn_path="$use_idn"
4025	;;
4026esac
4027
4028iconvinc=
4029iconvlib=
4030AC_ARG_WITH(libiconv,
4031	[  --with-libiconv[=IPREFIX] GNU libiconv are in IPREFIX [default PREFIX]],
4032	use_libiconv="$withval", use_libiconv="no")
4033case "$use_libiconv" in
4034yes)
4035	if test X$prefix = XNONE ; then
4036		iconvlib="-L/usr/local/lib -R/usr/local/lib -liconv"
4037	else
4038		iconvlib="-L$prefix/lib -R$prefix/lib -liconv"
4039	fi
4040	;;
4041no)
4042	iconvlib=
4043	;;
4044*)
4045	iconvlib="-L$use_libiconv/lib -R$use_libiconv/lib -liconv"
4046	;;
4047esac
4048
4049AC_ARG_WITH(iconv,
4050	[  --with-iconv[=LIBSPEC]    specify iconv library [default -liconv]],
4051	iconvlib="$withval")
4052case "$iconvlib" in
4053no)
4054	iconvlib=
4055	;;
4056yes)
4057	iconvlib=-liconv
4058	;;
4059esac
4060
4061AC_ARG_WITH(idnlib,
4062	[  --with-idnlib=ARG       specify libidnkit],
4063	idnlib="$withval", idnlib="no")
4064if test "$idnlib" = yes; then
4065	AC_MSG_ERROR([You must specify ARG for --with-idnlib.])
4066fi
4067
4068IDNLIBS=
4069if test "$use_idn" != no; then
4070	AC_DEFINE(WITH_IDN, 1, [define if idnkit support is to be included.])
4071	STD_CINCLUDES="$STD_CINCLUDES -I$idn_path/include"
4072	if test "$idnlib" != no; then
4073		IDNLIBS="$idnlib $iconvlib"
4074	else
4075		IDNLIBS="-L$idn_path/lib -lidnkit $iconvlib"
4076	fi
4077fi
4078AC_SUBST(IDNLIBS)
4079
4080#
4081# Check whether to build Automated Test Framework unit tests
4082#
4083AC_ARG_WITH(atf,
4084	[  --with-atf=ARG          support Automated Test Framework],
4085	atf="$withval", atf="no")
4086if test "$atf" = yes; then
4087	atf=`pwd`/unit/atf
4088	ATFBUILD=atf-src
4089	AC_SUBST(ATFBUILD)
4090	AC_CONFIG_COMMANDS([atf-config],
4091		[(
4092		 mkdir -p unit/atf-src;
4093		 cd unit/atf-src;
4094		 case "$srcdir" in
4095		 /*) ;;
4096		 *) srcdir="../../$srcdir";;
4097		 esac
4098		 ${SHELL} "${srcdir}${srcdir:+/unit/atf-src/}./configure" --enable-tools --disable-shared MISSING=: --prefix $atfdir;
4099		) ],
4100		[atfdir=`pwd`/unit/atf])
4101	AC_MSG_RESULT(building ATF from bind9/unit/atf-src)
4102fi
4103
4104ATFLIBS=
4105if test "$atf" != no; then
4106	AC_DEFINE(ATF_TEST, 1, [define if ATF unit tests are to be built.])
4107	STD_CINCLUDES="$STD_CINCLUDES -I$atf/include"
4108	ATFBIN="$atf/bin"
4109	ATFLIBS="-L$atf/lib -latf-c"
4110	UNITTESTS=tests
4111fi
4112AC_SUBST(ATFBIN)
4113AC_SUBST(ATFLIBS)
4114AC_SUBST(UNITTESTS)
4115
4116AC_CHECK_HEADERS(locale.h)
4117AC_CHECK_FUNCS(setlocale)
4118
4119#
4120# was --with-tuning specified?
4121#
4122AC_ARG_WITH(tuning,
4123	[  --with-tuning=ARG       Specify server tuning (large or default)],
4124	use_tuning="$withval", use_tuning="no")
4125
4126case "$use_tuning" in
4127	large)
4128		if ! $use_threads; then
4129			AC_MSG_ERROR([Large-system tuning requires threads.])
4130		fi
4131		AC_DEFINE(TUNE_LARGE, 1, [Define to use large-system tuning.])
4132		AC_MSG_RESULT(using large-system tuning)
4133		;;
4134	no|default)
4135		AC_MSG_RESULT(using default tuning)
4136		;;
4137	yes|*)
4138		AC_MSG_ERROR([You must specify "large" or "default" for --with-tuning.])
4139		;;
4140esac
4141
4142#
4143# Substitutions
4144#
4145AC_SUBST(BIND9_TOP_BUILDDIR)
4146BIND9_TOP_BUILDDIR=`pwd`
4147
4148AC_SUBST(BIND9_ISC_BUILDINCLUDE)
4149AC_SUBST(BIND9_ISCCC_BUILDINCLUDE)
4150AC_SUBST(BIND9_ISCCFG_BUILDINCLUDE)
4151AC_SUBST(BIND9_DNS_BUILDINCLUDE)
4152AC_SUBST(BIND9_LWRES_BUILDINCLUDE)
4153AC_SUBST(BIND9_BIND9_BUILDINCLUDE)
4154AC_SUBST(BIND9_IRS_BUILDINCLUDE)
4155if test "X$srcdir" != "X"; then
4156	BIND9_ISC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isc/include"
4157	BIND9_ISCCC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isccc/include"
4158	BIND9_ISCCFG_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isccfg/include"
4159	BIND9_DNS_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/dns/include"
4160	BIND9_LWRES_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/lwres/include"
4161	BIND9_BIND9_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/bind9/include"
4162	BIND9_IRS_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/irs/include"
4163else
4164	BIND9_ISC_BUILDINCLUDE=""
4165	BIND9_ISCCC_BUILDINCLUDE=""
4166	BIND9_ISCCFG_BUILDINCLUDE=""
4167	BIND9_DNS_BUILDINCLUDE=""
4168	BIND9_LWRES_BUILDINCLUDE=""
4169	BIND9_BIND9_BUILDINCLUDE=""
4170	BIND9_IRS_BUILDINCLUDE=""
4171fi
4172
4173AC_SUBST_FILE(BIND9_MAKE_INCLUDES)
4174BIND9_MAKE_INCLUDES=$BIND9_TOP_BUILDDIR/make/includes
4175
4176AC_SUBST_FILE(BIND9_MAKE_RULES)
4177BIND9_MAKE_RULES=$BIND9_TOP_BUILDDIR/make/rules
4178
4179. "$srcdir/version"
4180BIND9_PRODUCT="PRODUCT=\"${PRODUCT}\""
4181AC_SUBST(BIND9_PRODUCT)
4182BIND9_DESCRIPTION="DESCRIPTION=\"${DESCRIPTION}\""
4183AC_SUBST(BIND9_DESCRIPTION)
4184BIND9_VERSION="VERSION=${MAJORVER}.${MINORVER}${PATCHVER:+.}${PATCHVER}${RELEASETYPE}${RELEASEVER}${EXTENSIONS}"
4185AC_SUBST(BIND9_VERSION)
4186BIND9_MAJOR="MAJOR=${MAJORVER}.${MINORVER}"
4187AC_SUBST(BIND9_MAJOR)
4188BIND9_VERSIONSTRING="${PRODUCT} ${MAJORVER}.${MINORVER}${PATCHVER:+.}${PATCHVER}${RELEASETYPE}${RELEASEVER}${EXTENSIONS}${DESCRIPTION:+ }${DESCRIPTION}"
4189AC_SUBST(BIND9_VERSIONSTRING)
4190
4191BIND9_SRCID="SRCID=unset"
4192if test -f "${srcdir}/srcid"; then
4193	. "${srcdir}/srcid"
4194	BIND9_SRCID="SRCID=$SRCID"
4195elif test -d "${srcdir}/.git"; then
4196	BIND9_SRCID="SRCID="`(cd "${srcdir}";git rev-parse --short HEAD)`
4197fi
4198
4199AC_SUBST(BIND9_SRCID)
4200
4201if test -z "$ac_configure_args"; then
4202	BIND9_CONFIGARGS="defaults"
4203else
4204	for a in $ac_configure_args
4205	do
4206		BIND9_CONFIGARGS="$BIND9_CONFIGARGS $a"
4207	done
4208fi
4209BIND9_CONFIGARGS="`echo $BIND9_CONFIGARGS | sed 's/^ //'`"
4210BIND9_CONFIGARGS="CONFIGARGS=${BIND9_CONFIGARGS}"
4211AC_SUBST(BIND9_CONFIGARGS)
4212
4213AC_SUBST_FILE(LIBISC_API)
4214LIBISC_API="$srcdir/lib/isc/api"
4215
4216AC_SUBST_FILE(LIBISCCC_API)
4217LIBISCCC_API="$srcdir/lib/isccc/api"
4218
4219AC_SUBST_FILE(LIBISCCFG_API)
4220LIBISCCFG_API="$srcdir/lib/isccfg/api"
4221
4222AC_SUBST_FILE(LIBDNS_API)
4223LIBDNS_API="$srcdir/lib/dns/api"
4224
4225AC_SUBST_FILE(LIBDNS_MAPAPI)
4226LIBDNS_MAPAPI="$srcdir/lib/dns/mapapi"
4227
4228AC_SUBST_FILE(LIBBIND9_API)
4229LIBBIND9_API="$srcdir/lib/bind9/api"
4230
4231AC_SUBST_FILE(LIBLWRES_API)
4232LIBLWRES_API="$srcdir/lib/lwres/api"
4233
4234AC_SUBST_FILE(LIBIRS_API)
4235LIBIRS_API="$srcdir/lib/irs/api"
4236
4237#
4238# Configure any DLZ drivers.
4239#
4240# If config.dlz.in selects one or more DLZ drivers, it will set
4241# CONTRIB_DLZ to a non-empty value, which will be our clue to
4242# build DLZ drivers in contrib.
4243#
4244# This section has to come after the libtool stuff because it needs to
4245# know how to name the driver object files.
4246#
4247
4248CONTRIB_DLZ=""
4249DLZ_DRIVER_INCLUDES=""
4250DLZ_DRIVER_LIBS=""
4251DLZ_DRIVER_SRCS=""
4252DLZ_DRIVER_OBJS=""
4253DLZ_SYSTEM_TEST=""
4254
4255#
4256# Configure support for building a shared library object
4257#
4258# Even when libtool is available it can't always be relied upon
4259# to build an object that can be dlopen()'ed, but this is necessary
4260# for building the dlzexternal system test, so we'll try it the
4261# old-fashioned way.
4262#
4263SO="so"
4264SO_CFLAGS=""
4265SO_LDFLAGS=""
4266SO_LD=""
4267SO_TARGETS=""
4268
4269AC_ARG_WITH(dlopen,
4270	[  --with-dlopen=ARG       support dynamically loadable DLZ drivers],
4271	dlopen="$withval", dlopen="yes")
4272
4273case $host in
4274	*-sunos*) dlopen="no"
4275		;;
4276esac
4277
4278if test "$dlopen" = "yes"; then
4279	AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
4280	if test "$have_dl" = "yes"; then
4281		LIBS="-ldl $LIBS"
4282	fi
4283	AC_CHECK_FUNCS(dlopen dlclose dlsym,,dlopen=no)
4284fi
4285
4286if test "$dlopen" = "yes"; then
4287	case $host in
4288		*-linux*|*-gnu*)
4289			SO_CFLAGS="-fPIC"
4290			SO_LDFLAGS=""
4291			if test "$have_dl" = "yes"
4292			then
4293				if test "$use_libtool" = "yes"; then
4294					SO_LDFLAGS="-Xcompiler -shared"
4295					SO_LD="${CC}"
4296				else
4297					SO_LDFLAGS="-shared"
4298					SO_LD="${CC}"
4299				fi
4300			else
4301				SO_LDFLAGS="-shared"
4302				SO_LD="ld"
4303			fi
4304			;;
4305		*-freebsd*|*-openbsd*|*-netbsd*)
4306			SO_CFLAGS="-fpic"
4307			SO_LDFLAGS="-Bshareable -x"
4308			SO_LD="ld"
4309			;;
4310		*-solaris*)
4311			SO_CFLAGS="-KPIC"
4312			SO_LDFLAGS="-G -z text"
4313			SO_LD="ld"
4314			;;
4315		*-hp-hpux*)
4316			SO=sl
4317			SO_CFLAGS="+z"
4318			SO_LDFLAGS="-b +vnocompatwarnings"
4319			SO_LD="ld"
4320			;;
4321		*)
4322			SO_CFLAGS="-fPIC"
4323			;;
4324	esac
4325
4326	if test "X$GCC" = "Xyes"; then
4327		SO_CFLAGS="-fPIC"
4328		if test -z "$SO_LD"
4329		then
4330			if test "$use_libtool" = "yes"; then
4331				SO_LDFLAGS="-Xcompiler -shared"
4332				SO_LD="${CC}"
4333			else
4334				SO_LDFLAGS="-shared"
4335				SO_LD="${CC}"
4336			fi
4337		fi
4338	fi
4339
4340	# If we still don't know how to make shared objects, don't make any.
4341	if test -n "$SO_LD"; then
4342		SO_TARGETS="\${SO_TARGETS}"
4343		AC_DEFINE(ISC_DLZ_DLOPEN, 1,
4344			  [Define to allow building of objects for dlopen().])
4345	fi
4346fi
4347
4348AC_SUBST(SO)
4349AC_SUBST(SO_CFLAGS)
4350AC_SUBST(SO_LDFLAGS)
4351AC_SUBST(SO_LD)
4352AC_SUBST(SO_TARGETS)
4353
4354sinclude(contrib/dlz/config.dlz.in)
4355AC_MSG_CHECKING(contributed DLZ drivers)
4356
4357if test -n "$CONTRIB_DLZ"
4358then
4359	AC_MSG_RESULT(yes)
4360	DLZ_DRIVER_RULES=contrib/dlz/drivers/rules
4361	AC_CONFIG_FILES([$DLZ_DRIVER_RULES])
4362else
4363	AC_MSG_RESULT(no)
4364	DLZ_DRIVER_RULES=/dev/null
4365fi
4366
4367AC_SUBST(CONTRIB_DLZ)
4368AC_SUBST(DLZ_DRIVER_INCLUDES)
4369AC_SUBST(DLZ_DRIVER_LIBS)
4370AC_SUBST(DLZ_DRIVER_SRCS)
4371AC_SUBST(DLZ_DRIVER_OBJS)
4372AC_SUBST(DLZ_SYSTEM_TEST)
4373AC_SUBST_FILE(DLZ_DRIVER_RULES)
4374
4375if test "$cross_compiling" = "yes"; then
4376	if test -z "$BUILD_CC"; then
4377		AC_MSG_ERROR([BUILD_CC not set])
4378	fi
4379	BUILD_CFLAGS="$BUILD_CFLAGS"
4380	BUILD_CPPFLAGS="$BUILD_CPPFLAGS"
4381	BUILD_LDFLAGS="$BUILD_LDFLAGS"
4382	BUILD_LIBS="$BUILD_LIBS"
4383else
4384	BUILD_CC="$CC"
4385	BUILD_CFLAGS="$CFLAGS"
4386	BUILD_CPPFLAGS="$CPPFLAGS $GEN_NEED_OPTARG"
4387	BUILD_LDFLAGS="$LDFLAGS"
4388	BUILD_LIBS="$LIBS"
4389fi
4390
4391NEWFLAGS=""
4392for e in $BUILD_LDFLAGS ; do
4393    case $e in
4394	-L*)
4395	    case $host_os in
4396		netbsd*)
4397		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
4398		    NEWFLAGS="$NEWFLAGS $e $ee"
4399		    ;;
4400		freebsd*)
4401		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
4402		    NEWFLAGS="$NEWFLAGS $e $ee"
4403		    ;;
4404		solaris*)
4405		    ee=`echo $e | sed -e 's%^-L%-R%'`
4406		    NEWFLAGS="$NEWFLAGS $e $ee"
4407		    ;;
4408		*)
4409		    NEWFLAGS="$NEWFLAGS $e"
4410		    ;;
4411		esac
4412	    ;;
4413	*)
4414	    NEWFLAGS="$NEWFLAGS $e"
4415	    ;;
4416    esac
4417done
4418BUILD_LDFLAGS="$NEWFLAGS"
4419
4420NEWFLAGS=""
4421for e in $DNS_GSSAPI_LIBS ; do
4422    case $e in
4423	-L*)
4424	    case $host_os in
4425		netbsd*)
4426		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
4427		    NEWFLAGS="$NEWFLAGS $e $ee"
4428		    ;;
4429		freebsd*)
4430		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
4431		    NEWFLAGS="$NEWFLAGS $e $ee"
4432		    ;;
4433		solaris*)
4434		    ee=`echo $e | sed -e 's%^-L%-R%'`
4435		    NEWFLAGS="$NEWFLAGS $e $ee"
4436		    ;;
4437		*)
4438		    NEWFLAGS="$NEWFLAGS $e"
4439		    ;;
4440		esac
4441	    ;;
4442	*)
4443	    NEWFLAGS="$NEWFLAGS $e"
4444	    ;;
4445    esac
4446done
4447DNS_GSSAPI_LIBS="$NEWFLAGS"
4448
4449NEWFLAGS=""
4450for e in $ISC_OPENSSL_LIBS ; do
4451    case $e in
4452	-L*)
4453	    case $host_os in
4454		netbsd*)
4455		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
4456		    NEWFLAGS="$NEWFLAGS $e $ee"
4457		    ;;
4458		freebsd*)
4459		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
4460		    NEWFLAGS="$NEWFLAGS $e $ee"
4461		    ;;
4462		solaris*)
4463		    ee=`echo $e | sed -e 's%^-L%-R%'`
4464		    NEWFLAGS="$NEWFLAGS $e $ee"
4465		    ;;
4466		*)
4467		    NEWFLAGS="$NEWFLAGS $e"
4468		    ;;
4469		esac
4470	    ;;
4471	*)
4472	    NEWFLAGS="$NEWFLAGS $e"
4473	    ;;
4474    esac
4475done
4476ISC_OPENSSL_LIBS="$NEWFLAGS"
4477
4478NEWFLAGS=""
4479for e in $DNS_CRYPTO_LIBS ; do
4480    case $e in
4481	-L*)
4482	    case $host_os in
4483		netbsd*)
4484		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
4485		    NEWFLAGS="$NEWFLAGS $e $ee"
4486		    ;;
4487		freebsd*)
4488		    ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
4489		    NEWFLAGS="$NEWFLAGS $e $ee"
4490		    ;;
4491		solaris*)
4492		    ee=`echo $e | sed -e 's%^-L%-R%'`
4493		    NEWFLAGS="$NEWFLAGS $e $ee"
4494		    ;;
4495		*)
4496		    NEWFLAGS="$NEWFLAGS $e"
4497		    ;;
4498		esac
4499	    ;;
4500	*)
4501	    NEWFLAGS="$NEWFLAGS $e"
4502	    ;;
4503    esac
4504done
4505DNS_CRYPTO_LIBS="$NEWFLAGS"
4506
4507AC_SUBST(BUILD_CC)
4508AC_SUBST(BUILD_CFLAGS)
4509AC_SUBST(BUILD_CPPFLAGS)
4510AC_SUBST(BUILD_LDFLAGS)
4511AC_SUBST(BUILD_LIBS)
4512
4513#
4514# Commands to run at the end of config.status.
4515# Don't just put these into configure, it won't work right if somebody
4516# runs config.status directly (which autoconf allows).
4517#
4518
4519AC_CONFIG_COMMANDS(
4520	[chmod],
4521	[chmod a+x isc-config.sh doc/doxygen/doxygen-input-filter])
4522
4523#
4524# Files to configure.  These are listed here because we used to
4525# specify them as arguments to AC_OUTPUT.  It's (now) ok to move these
4526# elsewhere if there's a good reason for doing so.
4527#
4528
4529AC_CONFIG_FILES([
4530  make/Makefile
4531  make/mkdep
4532	Makefile
4533	bin/Makefile
4534	bin/check/Makefile
4535	bin/confgen/Makefile
4536	bin/confgen/unix/Makefile
4537	bin/delv/Makefile
4538	bin/dig/Makefile
4539	bin/dnssec/Makefile
4540	bin/named/Makefile
4541	bin/named/unix/Makefile
4542	bin/nsupdate/Makefile
4543	bin/pkcs11/Makefile
4544	bin/python/Makefile
4545	bin/python/dnssec-checkds.py
4546	bin/python/dnssec-coverage.py
4547	bin/rndc/Makefile
4548	bin/tests/Makefile
4549	bin/tests/atomic/Makefile
4550	bin/tests/db/Makefile
4551	bin/tests/dst/Makefile
4552	bin/tests/dst/Kdh.+002+18602.key
4553	bin/tests/dst/Kdh.+002+18602.private
4554	bin/tests/dst/Kdh.+002+48957.key
4555	bin/tests/dst/Kdh.+002+48957.private
4556	bin/tests/dst/Ktest.+001+00002.key
4557	bin/tests/dst/Ktest.+001+54622.key
4558	bin/tests/dst/Ktest.+001+54622.private
4559	bin/tests/dst/Ktest.+003+23616.key
4560	bin/tests/dst/Ktest.+003+23616.private
4561	bin/tests/dst/Ktest.+003+49667.key
4562	bin/tests/dst/dst_2_data
4563	bin/tests/dst/t2_data_1
4564	bin/tests/dst/t2_data_2
4565	bin/tests/dst/t2_dsasig
4566	bin/tests/dst/t2_rsasig
4567	bin/tests/hashes/Makefile
4568	bin/tests/headerdep_test.sh
4569	bin/tests/master/Makefile
4570	bin/tests/mem/Makefile
4571	bin/tests/names/Makefile
4572	bin/tests/net/Makefile
4573	bin/tests/pkcs11/Makefile
4574	bin/tests/pkcs11/benchmarks/Makefile
4575	bin/tests/rbt/Makefile
4576	bin/tests/resolver/Makefile
4577	bin/tests/sockaddr/Makefile
4578	bin/tests/system/Makefile
4579	bin/tests/system/conf.sh
4580	bin/tests/system/builtin/Makefile
4581	bin/tests/system/dlz/prereq.sh
4582	bin/tests/system/dlzexternal/Makefile
4583	bin/tests/system/dlzexternal/ns1/named.conf
4584	bin/tests/system/dlzredir/prereq.sh
4585	bin/tests/system/filter-aaaa/Makefile
4586	bin/tests/system/geoip/Makefile
4587	bin/tests/system/inline/checkdsa.sh
4588	bin/tests/system/lwresd/Makefile
4589	bin/tests/system/sit/prereq.sh
4590	bin/tests/system/rpz/Makefile
4591	bin/tests/system/rsabigexponent/Makefile
4592	bin/tests/system/tkey/Makefile
4593	bin/tests/system/tsiggss/Makefile
4594	bin/tests/tasks/Makefile
4595	bin/tests/timers/Makefile
4596	bin/tests/virtual-time/Makefile
4597	bin/tests/virtual-time/conf.sh
4598	bin/tools/Makefile
4599	contrib/scripts/check-secure-delegation.pl
4600	contrib/scripts/zone-edit.sh
4601	doc/Makefile
4602	doc/arm/Makefile
4603	doc/doxygen/Doxyfile
4604	doc/doxygen/Makefile
4605	doc/doxygen/doxygen-input-filter
4606	doc/misc/Makefile
4607	doc/xsl/Makefile
4608	doc/xsl/isc-docbook-chunk.xsl
4609	doc/xsl/isc-docbook-html.xsl
4610	doc/xsl/isc-docbook-latex.xsl
4611	doc/xsl/isc-manpage.xsl
4612	doc/xsl/isc-notes-html.xsl
4613	doc/xsl/isc-notes-latex.xsl
4614	isc-config.sh
4615	lib/Makefile
4616	lib/bind9/Makefile
4617	lib/bind9/include/Makefile
4618	lib/bind9/include/bind9/Makefile
4619	lib/dns/Makefile
4620	lib/dns/include/Makefile
4621	lib/dns/include/dns/Makefile
4622	lib/dns/include/dst/Makefile
4623	lib/dns/tests/Makefile
4624	lib/irs/Makefile
4625	lib/irs/include/Makefile
4626	lib/irs/include/irs/Makefile
4627	lib/irs/include/irs/netdb.h
4628	lib/irs/include/irs/platform.h
4629	lib/isc/$arch/Makefile
4630	lib/isc/$arch/include/Makefile
4631	lib/isc/$arch/include/isc/Makefile
4632	lib/isc/$thread_dir/Makefile
4633	lib/isc/$thread_dir/include/Makefile
4634	lib/isc/$thread_dir/include/isc/Makefile
4635	lib/isc/Makefile
4636	lib/isc/include/Makefile
4637	lib/isc/include/isc/Makefile
4638	lib/isc/include/isc/platform.h
4639	lib/isc/include/pk11/Makefile
4640	lib/isc/include/pkcs11/Makefile
4641	lib/isc/tests/Makefile
4642	lib/isc/nls/Makefile
4643	lib/isc/unix/Makefile
4644	lib/isc/unix/include/Makefile
4645	lib/isc/unix/include/isc/Makefile
4646	lib/isc/unix/include/pkcs11/Makefile
4647	lib/isccc/Makefile
4648	lib/isccc/include/Makefile
4649	lib/isccc/include/isccc/Makefile
4650	lib/isccfg/Makefile
4651	lib/isccfg/include/Makefile
4652	lib/isccfg/include/isccfg/Makefile
4653	lib/lwres/Makefile
4654	lib/lwres/include/Makefile
4655	lib/lwres/include/lwres/Makefile
4656	lib/lwres/include/lwres/netdb.h
4657	lib/lwres/include/lwres/platform.h
4658	lib/lwres/man/Makefile
4659	lib/lwres/tests/Makefile
4660	lib/lwres/unix/Makefile
4661	lib/lwres/unix/include/Makefile
4662	lib/lwres/unix/include/lwres/Makefile
4663	lib/tests/Makefile
4664	lib/tests/include/Makefile
4665	lib/tests/include/tests/Makefile
4666	lib/samples/Makefile
4667	lib/samples/Makefile-postinstall
4668	unit/Makefile
4669	unit/unittest.sh
4670])
4671
4672#
4673# Do it
4674#
4675
4676AC_OUTPUT
4677
4678#
4679# Now that the Makefiles exist we can ensure that everything is rebuilt.
4680#
4681AC_ARG_WITH(make-clean,
4682[  --with-make-clean       run "make clean" at end of configure [[yes|no]]],
4683    make_clean="$withval", make_clean="yes")
4684case "$make_clean" in
4685yes)
4686	make clean
4687	;;
4688esac
4689
4690AC_ARG_ENABLE(full-report,
4691	[  --enable-full-report	  report values of all configure options])
4692
4693echo "========================================================================"
4694echo "Configuration summary:"
4695echo "------------------------------------------------------------------------"
4696echo "Optional features enabled:"
4697if $use_threads; then
4698    echo "    Multiprocessing support (--enable-threads)"
4699    if test "$enable_full_report" = "yes" -o "$locktype" = "standard"; then
4700        echo "        Mutex lock type: $locktype"
4701    fi
4702fi
4703test "$use_tuning" = "large" && echo "    Large-system tuning (--with-tuning)"
4704test "$use_geoip" = "no" || echo "    GeoIP access control (--with-geoip)"
4705test "$use_gssapi" = "no" || echo "    GSS-API (--with-gssapi)"
4706if test "$enable_sit" != "no"; then
4707    echo "    Source Identity Token support (--enable-sit)"
4708    if test "$enable_full_report" = "yes" -o "$with_sit_alg" != "aes"; then
4709	echo "        Algorithm: $with_sit_alg"
4710    fi
4711fi
4712
4713# these lines are only printed if run with --enable-full-report
4714if test "$enable_full_report" = "yes"; then
4715    test "$enable_ipv6" = "no" -o "$found_ipv6" = "no" || \
4716	echo "    IPv6 support (--enable-ipv6)"
4717    test "X$CRYPTO" = "X" -o "$want_native_pkcs11" = "yes" || \
4718	    echo "    OpenSSL cryptography/DNSSEC (--with-openssl)"
4719    test "X$PYTHON" = "X" || echo "    Python tools (--with-python)"
4720    test "X$libxml2_libs" = "X" || echo "    XML statistics (--with-libxml2)"
4721    test "X$have_libjson" = "X" || echo "    JSON statistics (--with-libjson)"
4722fi
4723
4724if test "$use_pkcs11" != "no"; then
4725    if test "$want_native_pkcs11" = "yes"; then
4726	echo "    Native PKCS#11/Cryptoki support (--enable-native-pkcs11)"
4727    else
4728	echo "    PKCS#11/Cryptoki support using OpenSSL (--with-pkcs11)"
4729    fi
4730    echo "        Provider library: $PKCS11_PROVIDER"
4731fi
4732if test "$OPENSSL_GOST" = "yes" -o "$PKCS11_GOST" = "yes"; then
4733    echo "    GOST algorithm support (encoding: $gosttype) (--with-gost)"
4734fi
4735test "$OPENSSL_ECDSA" = "yes" -o "$PKCS11_ECDSA" = "yes" && \
4736    echo "    ECDSA algorithm support (--with-ecdsa)"
4737test "$enable_fixed" = "yes" && \
4738    echo "    Allow 'fixed' rrset-order (--enable-fixed-rrset)"
4739test "$enable_filter" = "yes" && \
4740    echo "    AAAA filtering (--enable-filter-aaaa)"
4741test "$enable_seccomp" = yes && \
4742    echo "    Use libseccomp system call filtering (--enable-seccomp)"
4743test "$want_backtrace" = "yes" && \
4744    echo "    Print backtrace on crash (--enable-backtrace)"
4745test "$want_symtable" = "minimal" && \
4746    echo "    Use symbol table for backtrace, named only (--enable-symtable)"
4747test "$want_symtable" = "yes" -o "$want_symtable" = "all" && \
4748    echo "    Use symbol table for backtrace, all binaries (--enable-symtable=all)"
4749test "$use_libtool" = "no" || echo "    Use GNU libtool (--with-libtool)"
4750test "$atf" = "no" || echo "    Automated Testing Framework (--with-atf)"
4751
4752echo "    Dynamically loadable zone (DLZ) drivers:"
4753test "$use_dlz_bdb" = "no" || \
4754    echo "        Berkeley DB (--with-dlz-bdb)"
4755test "$use_dlz_ldap" = "no" || \
4756    echo "        LDAP (--with-dlz-ldap)"
4757test "$use_dlz_mysql" = "no" || \
4758    echo "        MySQL (--with-dlz-mysql)"
4759test "$use_dlz_odbc" = "no" || \
4760    echo "        ODBC (--with-dlz-odbc)"
4761test "$use_dlz_postgres" = "no" || \
4762    echo "        Postgres (--with-dlz-postgres)"
4763test "$use_dlz_filesystem" = "no" || \
4764    echo "        Filesystem (--with-dlz-filesystem)"
4765test "$use_dlz_stub" = "no" || \
4766    echo "        Stub (--with-dlz-stub)"
4767test "$use_dlz_bdb $use_dlz_ldap $use_dlz_mysql $use_dlz_odbc $use_dlz_postgres $use_dlz_filesystem $use_dlz_stub" = "no no no no no no no" && echo "        None"
4768echo
4769
4770echo "Features disabled or unavailable on this platform:"
4771$use_threads || echo "    Multiprocessing support (--enable-threads)"
4772test "$enable_ipv6" = "no" -o "$found_ipv6" = "no" && \
4773	echo "    IPv6 support (--enable-ipv6)"
4774test "$use_tuning" = "large" || echo "    Large-system tuning (--with-tuning)"
4775
4776test "$use_geoip" = "no" && echo "    GeoIP access control (--with-geoip)"
4777test "$use_gssapi" = "no" && echo "    GSS-API (--with-gssapi)"
4778test "$enable_sit" = "no" && echo "    Source Identity Token support (--enable-sit)"
4779
4780test "$enable_fixed" = "yes" || \
4781    echo "    Allow 'fixed' rrset-order (--enable-fixed-rrset)"
4782
4783if test "X$CRYPTO" = "X" -o "$want_native_pkcs11" = "yes"
4784then
4785    echo "    OpenSSL cryptography/DNSSEC (--with-openssl)"
4786elif test "$use_pkcs11" = "no"; then
4787    echo "    PKCS#11/Cryptoki support (--with-pkcs11)"
4788fi
4789test "$want_native_pkcs11" = "yes" ||
4790    echo "    Native PKCS#11/Cryptoki support (--enable-native-pkcs11)"
4791test "X$CRYPTO" = "X" -o "$OPENSSL_GOST" = "yes" -o "$PKCS11_GOST" = "yes" || \
4792    echo "    GOST algorithm support (--with-gost)"
4793test "X$CRYPTO" = "X" -o "$OPENSSL_ECDSA" = "yes" -o "$PKCS11_ECDSA" = "yes" || \
4794    echo "    ECDSA algorithm support (--with-ecdsa)"
4795
4796test "$enable_seccomp" = yes || \
4797    echo "    Use libseccomp system call filtering (--enable-seccomp)"
4798test "$want_backtrace" = "yes" || \
4799    echo "    Print backtrace on crash (--enable-backtrace)"
4800test "$use_libtool" = "yes" || echo "    Use GNU libtool (--with-libtool)"
4801test "$atf" = "no" && echo "    Automated Testing Framework (--with-atf)"
4802
4803test "X$PYTHON" = "X" && echo "    Python tools (--with-python)"
4804test "X$libxml2_libs" = "X" && echo "    XML statistics (--with-libxml2)"
4805test "X$have_libjson" = "X" && echo "    JSON statistics (--with-libjson)"
4806
4807if test "X$ac_unrecognized_opts" != "X"; then
4808    echo
4809    echo "Unrecognized options:"
4810    echo "    $ac_unrecognized_opts"
4811fi
4812echo "========================================================================"
4813
4814if test "X$CRYPTO" = "X"; then
4815cat << \EOF
4816BIND 9 is being built without cryptography support. This means it will
4817not have DNSSEC support. Use --with-openssl, or --with-pkcs11 and
4818--enable-native-pkcs11 to enable cryptography.
4819EOF
4820fi
4821
4822if test "X$OPENSSL_WARNING" != "X"; then
4823cat << \EOF
4824WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
4825WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
4826WARNING                                                                 WARNING
4827WARNING         Your OpenSSL crypto library may be vulnerable to        WARNING
4828WARNING         one or more of the the following known security         WARNING
4829WARNING         flaws:                                                  WARNING
4830WARNING                                                                 WARNING
4831WARNING         CAN-2002-0659, CAN-2006-4339, CVE-2006-2937 and         WARNING
4832WARNING         CVE-2006-2940.                                          WARNING
4833WARNING                                                                 WARNING
4834WARNING         It is recommended that you upgrade to OpenSSL           WARNING
4835WARNING         version 0.9.8d/0.9.7l (or greater).                     WARNING
4836WARNING                                                                 WARNING
4837WARNING         You can disable this warning by specifying:             WARNING
4838WARNING                                                                 WARNING
4839WARNING               --disable-openssl-version-check          	        WARNING
4840WARNING                                                                 WARNING
4841WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
4842WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
4843EOF
4844fi
4845
4846# Tell Emacs to edit this file in shell mode.
4847# Local Variables:
4848# mode: sh
4849# End:
4850