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