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