]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - contrib/bind9/configure.in
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / contrib / bind9 / configure.in
1 # Copyright (C) 2004-2010  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 "s/^/# /" COPYRIGHT])dnl
19 AC_DIVERT_POP()dnl
20
21 AC_REVISION($Revision: 1.457.26.16 $)
22
23 AC_INIT(lib/dns/name.c)
24 AC_PREREQ(2.59)
25
26 AC_CONFIG_HEADER(config.h)
27
28 AC_CANONICAL_HOST
29
30 AC_PROG_MAKE_SET
31
32 #
33 # GNU libtool support
34 #
35 case $build_os in
36 sunos*)
37     # Just set the maximum command line length for sunos as it otherwise
38     # takes a exceptionally long time to work it out. Required for libtool.
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
52 # Warn if the user specified libbind, which is now deprecated
53 AC_ARG_ENABLE(libbind, [  --enable-libbind        deprecated])
54
55 case "$enable_libbind" in
56         yes)
57                 AC_MSG_ERROR(['libbind' is no longer part of the BIND 9 distribution.
58 It is available from http://www.isc.org as a separate download.])
59                 ;;
60         no|'')
61                 ;;
62 esac
63
64
65 #
66 # Make very sure that these are the first files processed by
67 # config.status, since we use the processed output as the input for
68 # AC_SUBST_FILE() substitutions in other files.
69 #
70 AC_CONFIG_FILES([make/rules make/includes])
71
72 AC_PATH_PROG(AR, ar)
73 ARFLAGS="cruv"
74 AC_SUBST(AR)
75 AC_SUBST(ARFLAGS)
76
77 # The POSIX ln(1) program.  Non-POSIX systems may substitute
78 # "copy" or something.
79 LN=ln
80 AC_SUBST(LN)
81
82 case "$AR" in
83         "")
84                 AC_MSG_ERROR([
85 ar program not found.  Please fix your PATH to include the directory in
86 which ar resides, or set AR in the environment with the full path to ar.
87 ])
88
89                 ;;
90 esac
91
92 #
93 # Etags.
94 #
95 AC_PATH_PROGS(ETAGS, etags emacs-etags)
96
97 #
98 # Some systems, e.g. RH7, have the Exuberant Ctags etags instead of
99 # GNU emacs etags, and it requires the -L flag.
100 #
101 if test "X$ETAGS" != "X"; then
102         AC_MSG_CHECKING(for Exuberant Ctags etags)
103         if $ETAGS --version 2>&1 | grep 'Exuberant Ctags' >/dev/null 2>&1; then
104                 AC_MSG_RESULT(yes)
105                 ETAGS="$ETAGS -L"
106         else
107                 AC_MSG_RESULT(no)
108         fi
109 fi
110 AC_SUBST(ETAGS)
111
112 #
113 # Perl is optional; it is used only by some of the system test scripts.
114 #
115 AC_PATH_PROGS(PERL, perl5 perl)
116 AC_SUBST(PERL)
117
118 #
119 # Special processing of paths depending on whether --prefix,
120 # --sysconfdir or --localstatedir arguments were given.  What's
121 # desired is some compatibility with the way previous versions
122 # of BIND built; they defaulted to /usr/local for most parts of
123 # the installation, but named.boot/named.conf was in /etc
124 # and named.pid was in /var/run.
125 #
126 # So ... if none of --prefix, --sysconfdir or --localstatedir are
127 # specified, set things up that way.  If --prefix is given, use
128 # it for sysconfdir and localstatedir the way configure normally
129 # would.  To change the prefix for everything but leave named.conf
130 # in /etc or named.pid in /var/run, then do this the usual configure way:
131 # ./configure --prefix=/somewhere --sysconfdir=/etc
132 # ./configure --prefix=/somewhere --localstatedir=/var
133 #
134 # To put named.conf and named.pid in /usr/local with everything else,
135 # set the prefix explicitly to /usr/local even though that's the default:
136 # ./configure --prefix=/usr/local
137 #
138 case "$prefix" in
139         NONE)
140                 case "$sysconfdir" in
141                         '${prefix}/etc')
142                                 sysconfdir=/etc
143                                 ;;
144                 esac
145                 case "$localstatedir" in
146                         '${prefix}/var')
147                                 localstatedir=/var
148                                 ;;
149                 esac
150                 ;;
151 esac
152
153 #
154 # Make sure INSTALL uses an absolute path, else it will be wrong in all
155 # Makefiles, since they use make/rules.in and INSTALL will be adjusted by
156 # configure based on the location of the file where it is substituted.
157 # Since in BIND9 INSTALL is only substituted into make/rules.in, an immediate
158 # subdirectory of install-sh, This relative path will be wrong for all
159 # directories more than one level down from install-sh.
160 #
161 case "$INSTALL" in
162         /*)
163                 ;;
164         *)
165                 #
166                 # Not all systems have dirname.
167                 #
168                 changequote({, })
169                 ac_dir="`echo $INSTALL | sed 's%/[^/]*$%%'`"
170                 changequote([, ])
171
172                 ac_prog="`echo $INSTALL | sed 's%.*/%%'`"
173                 test "$ac_dir" = "$ac_prog" && ac_dir=.
174                 test -d "$ac_dir" && ac_dir="`(cd \"$ac_dir\" && pwd)`"
175                 INSTALL="$ac_dir/$ac_prog"
176                 ;;
177 esac
178
179 #
180 # On these hosts, we really want to use cc, not gcc, even if it is
181 # found.  The gcc that these systems have will not correctly handle
182 # pthreads.
183 #
184 # However, if the user sets $CC to be something, let that override
185 # our change.
186 #
187 if test "X$CC" = "X" ; then
188         case "$host" in
189                 *-dec-osf*)
190                         CC="cc"
191                         ;;
192                 *-solaris*)
193                         # Use Sun's cc if it is available, but watch
194                         # out for /usr/ucb/cc; it will never be the right
195                         # compiler to use.
196                         #
197                         # If setting CC here fails, the AC_PROG_CC done
198                         # below might still find gcc.
199                         IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS=":"
200                         for ac_dir in $PATH; do
201                                 test -z "$ac_dir" && ac_dir=.
202                                 case "$ac_dir" in
203                                 /usr/ucb)
204                                         # exclude
205                                         ;;
206                                 *)
207                                         if test -f "$ac_dir/cc"; then
208                                                 CC="$ac_dir/cc"
209                                                 break
210                                         fi
211                                         ;;
212                                 esac
213                         done
214                         IFS="$ac_save_ifs"
215                         ;;
216                 *-hp-hpux*)
217                         CC="cc"
218                         ;;
219                 mips-sgi-irix*)
220                         CC="cc"
221                         ;;
222         esac
223 fi
224
225 AC_PROG_CC
226
227 #
228 # gcc's optimiser is broken at -02 for ultrasparc
229 #
230 if test "$ac_env_CFLAGS_set" != set -a "X$GCC" = "Xyes"; then
231         case "$host" in
232         sparc-*)
233                 CCFLAGS="-g -O1"
234                 ;;
235         esac
236 fi
237
238 #
239 # OS dependent CC flags
240 #
241 case "$host" in
242         # OSF 5.0: recv/send are only available with -D_POSIX_PII_SOCKET or
243         # -D_XOPEN_SOURCE_EXTENDED.
244         *-dec-osf*)
245                 STD_CDEFINES="$STD_CDEFINES -D_POSIX_PII_SOCKET"
246                 CPPFLAGS="$CPPFLAGS -D_POSIX_PII_SOCKET"
247                 ;;
248         #HP-UX: need -D_XOPEN_SOURCE_EXTENDED and -lxnet for CMSG macros
249         *-hp-hpux*)
250                 STD_CDEFINES="$STD_CDEFINES -D_XOPEN_SOURCE_EXTENDED"
251                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
252                 LIBS="-lxnet $LIBS"
253                 ;;
254         # Solaris: need -D_XPG4_2 and -D__EXTENSIONS__ for CMSG macros
255         *-solaris*)
256                 STD_CDEFINES="$STD_CDEFINES -D_XPG4_2 -D__EXTENSIONS__"
257                 CPPFLAGS="$CPPFLAGS -D_XPG4_2 -D__EXTENSIONS__"
258                 ;;
259         # POSIX doesn't include the IPv6 Advanced Socket API and glibc hides
260         # parts of the IPv6 Advanced Socket API as a result.  This is stupid
261         # as it breaks how the two halves (Basic and Advanced) of the IPv6
262         # Socket API were designed to be used but we have to live with it.
263         # Define _GNU_SOURCE to pull in the IPv6 Advanced Socket API.
264         *-linux*)
265                 STD_CDEFINES="$STD_CDEFINES -D_GNU_SOURCE"
266                 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
267                 ;;
268 esac
269
270 AC_HEADER_STDC
271
272 AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h sys/sockio.h sys/select.h sys/param.h sys/sysctl.h net/if6.h,,,
273 [$ac_includes_default
274 #ifdef HAVE_SYS_PARAM_H
275 # include <sys/param.h>
276 #endif
277 ])
278
279 AC_C_CONST
280 AC_C_INLINE
281 AC_C_VOLATILE
282 AC_CHECK_FUNC(sysctlbyname, AC_DEFINE(HAVE_SYSCTLBYNAME))
283
284 #
285 # UnixWare 7.1.1 with the feature supplement to the UDK compiler
286 # is reported to not support "static inline" (RT #1212).
287 #
288 AC_MSG_CHECKING(for static inline breakage)
289 AC_TRY_COMPILE(, [
290                 foo1();
291         }
292
293         static inline int foo1() {
294                 return 0;
295         }
296
297         static inline int foo2() {
298                 return foo1();
299         ],
300         [AC_MSG_RESULT(no)],
301         [AC_MSG_RESULT(yes)
302          AC_DEFINE(inline, )])
303
304 AC_TYPE_SIZE_T
305 AC_CHECK_TYPE(ssize_t, int)
306 AC_CHECK_TYPE(uintptr_t,unsigned long)
307 AC_CHECK_TYPE(socklen_t,
308 [AC_DEFINE(ISC_SOCKADDR_LEN_T, socklen_t)],
309 [
310 AC_TRY_COMPILE(
311 [
312 #include <sys/types.h>
313 #include <sys/socket.h>
314 int getsockname(int, struct sockaddr *, size_t *);
315 ],[],
316 [AC_DEFINE(ISC_SOCKADDR_LEN_T, size_t)],
317 [AC_DEFINE(ISC_SOCKADDR_LEN_T, int)])
318 ],
319 [
320 #include <sys/types.h>
321 #include <sys/socket.h>
322 ])
323 AC_SUBST(ISC_SOCKADDR_LEN_T)
324 AC_HEADER_TIME
325 AC_MSG_CHECKING(for long long)
326 AC_TRY_COMPILE([],[long long i = 0; return (0);],
327         [AC_MSG_RESULT(yes)
328                 ISC_PLATFORM_HAVELONGLONG="#define ISC_PLATFORM_HAVELONGLONG 1"],
329         [AC_MSG_RESULT(no)
330                 ISC_PLATFORM_HAVELONGLONG="#undef ISC_PLATFORM_HAVELONGLONG"])
331 AC_SUBST(ISC_PLATFORM_HAVELONGLONG)
332
333 #
334 # check if we have lifconf
335 #
336 AC_MSG_CHECKING(for struct lifconf)
337 AC_TRY_COMPILE([
338 #include <sys/types.h>
339 #include <sys/socket.h>
340 #include <net/if.h>
341 ],
342 [
343 struct lifconf lifconf;
344 lifconf.lifc_len = 0;
345 ]
346 ,
347         [AC_MSG_RESULT(yes)
348                 ISC_PLATFORM_HAVELIFCONF="#define ISC_PLATFORM_HAVELIFCONF 1"],
349         [AC_MSG_RESULT(no)
350                 ISC_PLATFORM_HAVELIFCONF="#undef ISC_PLATFORM_HAVELIFCONF"])
351 AC_SUBST(ISC_PLATFORM_HAVELIFCONF)
352
353 #
354 # check if we have kqueue
355 #
356 AC_ARG_ENABLE(kqueue,
357         [  --enable-kqueue         use BSD kqueue when available [[default=yes]]],
358               want_kqueue="$enableval",  want_kqueue="yes")
359 case $want_kqueue in
360 yes)
361         AC_CHECK_FUNC(kqueue, ac_cv_have_kqueue=yes, ac_cv_have_kqueue=no)
362         case $ac_cv_have_kqueue in
363         yes)
364                 ISC_PLATFORM_HAVEKQUEUE="#define ISC_PLATFORM_HAVEKQUEUE 1"
365                 ;;
366         *)
367                 ISC_PLATFORM_HAVEKQUEUE="#undef ISC_PLATFORM_HAVEKQUEUE"
368                 ;;
369         esac
370         ;;
371 *)
372         ISC_PLATFORM_HAVEKQUEUE="#undef ISC_PLATFORM_HAVEKQUEUE"
373         ;;
374 esac
375 AC_SUBST(ISC_PLATFORM_HAVEKQUEUE)
376
377 #
378 # check if we have epoll.  Linux kernel 2.4 has epoll_create() which fails,
379 # so we need to try running the code, not just test its existence.
380 #
381 AC_ARG_ENABLE(epoll,
382 [  --enable-epoll          use Linux epoll when available [[default=auto]]],
383               want_epoll="$enableval",  want_epoll="auto")
384 case $want_epoll in
385 auto)
386         AC_MSG_CHECKING(epoll support)
387         AC_TRY_RUN([
388 #include <sys/epoll.h>
389 int main() {
390         if (epoll_create(1) < 0)
391                 return (1);
392         return (0);
393 }
394 ],
395         [AC_MSG_RESULT(yes)
396         ISC_PLATFORM_HAVEEPOLL="#define ISC_PLATFORM_HAVEEPOLL 1"],
397         [AC_MSG_RESULT(no)
398         ISC_PLATFORM_HAVEEPOLL="#undef ISC_PLATFORM_HAVEEPOLL"])
399         ;;
400 yes)
401         ISC_PLATFORM_HAVEEPOLL="#define ISC_PLATFORM_HAVEEPOLL 1"
402         ;;
403 *)
404         ISC_PLATFORM_HAVEEPOLL="#undef ISC_PLATFORM_HAVEEPOLL"
405         ;;
406 esac
407 AC_SUBST(ISC_PLATFORM_HAVEEPOLL)
408
409 #
410 # check if we support /dev/poll
411 #
412 AC_ARG_ENABLE(devpoll,
413         [  --enable-devpoll        use /dev/poll when available [[default=yes]]],
414               want_devpoll="$enableval",  want_devpoll="yes")
415 case $want_devpoll in
416 yes)
417         AC_CHECK_HEADERS(sys/devpoll.h,
418         ISC_PLATFORM_HAVEDEVPOLL="#define ISC_PLATFORM_HAVEDEVPOLL 1"
419         ,
420         ISC_PLATFORM_HAVEDEVPOLL="#undef ISC_PLATFORM_HAVEDEVPOLL"
421         )
422         ;;
423 *)
424         ISC_PLATFORM_HAVEDEVPOLL="#undef ISC_PLATFORM_HAVEDEVPOLL"
425         ;;
426 esac
427 AC_SUBST(ISC_PLATFORM_HAVEDEVPOLL)
428
429 #
430 # check if we need to #include sys/select.h explicitly
431 #
432 case $ac_cv_header_unistd_h in
433 yes)
434 AC_MSG_CHECKING(if unistd.h or sys/types.h defines fd_set)
435 AC_TRY_COMPILE([
436 #include <sys/types.h> /* Ultrix */
437 #include <unistd.h>],
438 [fd_set read_set; return (0);],
439         [AC_MSG_RESULT(yes)
440          ISC_PLATFORM_NEEDSYSSELECTH="#undef ISC_PLATFORM_NEEDSYSSELECTH"
441          LWRES_PLATFORM_NEEDSYSSELECTH="#undef LWRES_PLATFORM_NEEDSYSSELECTH"],
442         [AC_MSG_RESULT(no)
443         case $ac_cv_header_sys_select_h in
444         yes)
445          ISC_PLATFORM_NEEDSYSSELECTH="#define ISC_PLATFORM_NEEDSYSSELECTH 1"
446          LWRES_PLATFORM_NEEDSYSSELECTH="#define LWRES_PLATFORM_NEEDSYSSELECTH 1"
447                 ;;
448         no)
449                 AC_MSG_ERROR([need either working unistd.h or sys/select.h])
450                 ;;
451         esac
452         ])
453         ;;
454 no)
455         case $ac_cv_header_sys_select_h in
456         yes)
457              ISC_PLATFORM_NEEDSYSSELECTH="#define ISC_PLATFORM_NEEDSYSSELECTH 1"
458              LWRES_PLATFORM_NEEDSYSSELECTH="#define LWRES_PLATFORM_NEEDSYSSELECTH 1"
459                 ;;
460         no)
461                 AC_MSG_ERROR([need either unistd.h or sys/select.h])
462                 ;;
463         esac
464         ;;
465 esac
466 AC_SUBST(ISC_PLATFORM_NEEDSYSSELECTH)
467 AC_SUBST(LWRES_PLATFORM_NEEDSYSSELECTH)
468
469 #
470 # Find the machine's endian flavor.
471 #
472 AC_C_BIGENDIAN
473
474
475 #
476 # was --with-openssl specified?
477 #
478 OPENSSL_WARNING=
479 AC_MSG_CHECKING(for OpenSSL library)
480 AC_ARG_WITH(openssl,
481 [  --with-openssl[=PATH]     Build with OpenSSL [yes|no|path].
482                           (Required for DNSSEC)],
483     use_openssl="$withval", use_openssl="auto")
484
485 openssldirs="/usr /usr/local /usr/local/ssl /usr/pkg /usr/sfw"
486 if test "$use_openssl" = "auto"
487 then
488         for d in $openssldirs
489         do
490                 if test -f $d/include/openssl/opensslv.h
491                 then
492                         use_openssl=$d
493                         break
494                 fi
495         done
496 fi
497 case "$use_openssl" in
498         no)
499                 AC_MSG_RESULT(no)
500                 DST_OPENSSL_INC=""
501                 USE_OPENSSL=""
502                 ;;
503         auto)
504                 DST_OPENSSL_INC=""
505                 USE_OPENSSL=""
506                 AC_MSG_ERROR(
507 [OpenSSL was not found in any of $openssldirs; use --with-openssl=/path
508 If you don't want OpenSSL, use --without-openssl])
509                 ;;
510         *)
511                 if test "$use_openssl" = "yes"
512                 then
513                         # User did not specify a path - guess it
514                         for d in $openssldirs
515                         do
516                                 if test -f $d/include/openssl/opensslv.h
517                                 then
518                                         use_openssl=$d
519                                         break
520                                 fi
521                         done
522                         if test "$use_openssl" = "yes"
523                         then
524                                 AC_MSG_RESULT(not found)
525                                 AC_MSG_ERROR(
526 [OpenSSL was not found in any of $openssldirs; use --with-openssl=/path])
527                         fi
528                 elif ! test -f "$use_openssl"/include/openssl/opensslv.h
529                 then
530                         AC_MSG_ERROR(["$use_openssl/include/openssl/opensslv.h" not found])
531                 fi
532                 USE_OPENSSL='-DOPENSSL'
533                 if test "$use_openssl" = "/usr"
534                 then
535                         DST_OPENSSL_INC=""
536                         DNS_OPENSSL_LIBS="-lcrypto"
537                 else
538                         DST_OPENSSL_INC="-I$use_openssl/include"
539                         case $host in
540                         *-solaris*)
541                                 DNS_OPENSSL_LIBS="-L$use_openssl/lib -R$use_openssl/lib -lcrypto"
542                                 ;;
543                         *-hp-hpux*)
544                                 DNS_OPENSSL_LIBS="-L$use_openssl/lib -Wl,+b: -lcrypto"
545                                 ;;
546                         *-apple-darwin*)
547                                 #
548                                 # Apple's ld seaches for serially for dynamic
549                                 # then static libraries.  This means you can't
550                                 # use -L to override dynamic system libraries
551                                 # with static ones when linking.  Instead
552                                 # we specify a absolute path.
553                                 #
554                                 if test -f "$use_openssl/lib/libcrypto.dylib"
555                                 then
556                                         DNS_OPENSSL_LIBS="-L$use_openssl/lib -lcrypto"
557                                 else
558                                         DNS_OPENSSL_LIBS="$use_openssl/lib/libcrypto.a"
559                                 fi
560                                 ;;
561                         *)
562                                 DNS_OPENSSL_LIBS="-L$use_openssl/lib -lcrypto"
563                                 ;;
564                         esac
565                 fi
566                 AC_MSG_RESULT(using OpenSSL from $use_openssl/lib and $use_openssl/include)
567
568                 saved_cflags="$CFLAGS"
569                 saved_libs="$LIBS"
570                 CFLAGS="$CFLAGS $DST_OPENSSL_INC"
571                 LIBS="$LIBS $DNS_OPENSSL_LIBS"
572                 AC_MSG_CHECKING(whether linking with OpenSSL works)
573                 AC_TRY_RUN([
574 #include <openssl/err.h>
575 int main() {
576         ERR_clear_error();
577         return (0);
578 }
579 ],
580                 [AC_MSG_RESULT(yes)],
581                 [AC_MSG_RESULT(no)
582                  AC_MSG_ERROR(Could not run test program using OpenSSL from
583 $use_openssl/lib and $use_openssl/include.
584 Please check the argument to --with-openssl and your
585 shared library configuration (e.g., LD_LIBRARY_PATH).)],
586                 [AC_MSG_RESULT(assuming it does work on target platform)])
587
588                 AC_MSG_CHECKING(whether linking with OpenSSL requires -ldl)
589                 AC_TRY_LINK([
590 #include <openssl/err.h>],
591 [ DSO_METHOD_dlfcn(); ],
592                 [AC_MSG_RESULT(no)],
593                 [LIBS="$LIBS -ldl"
594                 AC_TRY_LINK([
595 #include <openssl/err.h>
596 ],[ DSO_METHOD_dlfcn(); ],
597                 [AC_MSG_RESULT(yes)
598                 DNS_OPENSSL_LIBS="$DNS_OPENSSL_LIBS -ldl"
599                 ],
600                  [AC_MSG_RESULT(unknown)
601                  AC_MSG_ERROR(OpenSSL has unsupported dynamic loading)],
602                 [AC_MSG_RESULT(assuming it does work on target platform)])
603                 ],
604                 [AC_MSG_RESULT(assuming it does work on target platform)]
605                 )
606                  
607 AC_ARG_ENABLE(openssl-version-check,
608 [AC_HELP_STRING([--enable-openssl-version-check],
609         [Check OpenSSL Version @<:@default=yes@:>@])])
610 case "$enable_openssl_version_check" in
611 yes|'')
612                 AC_MSG_CHECKING(OpenSSL library version)
613                 AC_TRY_RUN([
614 #include <stdio.h>
615 #include <openssl/opensslv.h>
616 int main() {
617         if ((OPENSSL_VERSION_NUMBER >= 0x009070cfL &&
618              OPENSSL_VERSION_NUMBER < 0x00908000L) ||
619              OPENSSL_VERSION_NUMBER >= 0x0090804fL)
620                 return (0);
621         printf("\n\nFound   OPENSSL_VERSION_NUMBER %#010x\n",
622                 OPENSSL_VERSION_NUMBER);
623         printf("Require OPENSSL_VERSION_NUMBER 0x009070cf or greater (0.9.7l)\n"
624                "Require OPENSSL_VERSION_NUMBER 0x0090804f or greater (0.9.8d)\n\n");
625         return (1);
626 }
627                 ],
628                 [AC_MSG_RESULT(ok)],
629                 [AC_MSG_RESULT(not compatible)
630                  OPENSSL_WARNING=yes
631                 ],
632                 [AC_MSG_RESULT(assuming target platform has compatible version)])
633 ;;
634 no)
635         AC_MSG_RESULT(Skipped OpenSSL version check)
636 ;;
637 esac
638
639                 AC_MSG_CHECKING(for OpenSSL DSA support)
640                 if test -f $use_openssl/include/openssl/dsa.h
641                 then
642                         AC_DEFINE(HAVE_OPENSSL_DSA)
643                         AC_MSG_RESULT(yes)
644                 else
645                         AC_MSG_RESULT(no)
646                 fi
647                 AC_CHECK_FUNCS(EVP_sha256 EVP_sha512)
648                 CFLAGS="$saved_cflags"
649                 LIBS="$saved_libs"
650
651                 ;;
652 esac
653
654 #
655 # This would include the system openssl path (and linker options to use
656 # it as needed) if it is found.
657 #
658
659 AC_SUBST(USE_OPENSSL)
660 AC_SUBST(DST_OPENSSL_INC)
661 DNS_CRYPTO_LIBS="$DNS_CRYPTO_LIBS $DNS_OPENSSL_LIBS"
662
663 #
664 # PKCS11 (aka crypto hardware) support
665 #
666 # This works only with the right OpenSSL with PKCS11 engine!
667 #
668
669 AC_MSG_CHECKING(for PKCS11 support)
670 AC_ARG_WITH(pkcs11,
671 [  --with-pkcs11           Build with PKCS11 support],
672    use_pkcs11="yes", use_pkcs11="no")
673
674 case "$use_pkcs11" in
675         no)
676                 AC_MSG_RESULT(disabled)
677                 USE_PKCS11=""
678                 ;;
679         yes)
680                 AC_MSG_RESULT(using OpenSSL with PKCS11 support)
681                 USE_PKCS11='-DUSE_PKCS11'
682                 ;;
683 esac
684
685 AC_SUBST(USE_PKCS11)
686
687 AC_MSG_CHECKING(for GSSAPI library)
688 AC_ARG_WITH(gssapi,
689 [  --with-gssapi=PATH      Specify path for system-supplied GSSAPI],
690     use_gssapi="$withval", use_gssapi="no")
691
692 gssapidirs="/usr/local /usr/pkg /usr/kerberos /usr"
693 if test "$use_gssapi" = "yes"
694 then
695         for d in $gssapidirs
696         do
697                 if test -f $d/include/gssapi/gssapi.h -o -f $d/include/gssapi.h
698                 then
699                         use_gssapi=$d
700                         break
701                 fi
702         done
703 fi
704
705 case "$use_gssapi" in
706         no)
707                 AC_MSG_RESULT(disabled)
708                 USE_GSSAPI=''
709                 ;;
710         yes)
711                 AC_MSG_ERROR([--with-gssapi must specify a path])
712                 ;;
713         *)
714                 AC_MSG_RESULT(looking in $use_gssapi/lib)
715                 USE_GSSAPI='-DGSSAPI'
716                 saved_cppflags="$CPPFLAGS"
717                 CPPFLAGS="-I$use_gssapi/include $CPPFLAGS"
718                 AC_CHECK_HEADERS(gssapi.h gssapi/gssapi.h,
719                     [ISC_PLATFORM_GSSAPIHEADER="#define ISC_PLATFORM_GSSAPIHEADER <$ac_header>"])
720
721                 if test "$ISC_PLATFORM_GSSAPIHEADER" = ""; then
722                     AC_MSG_ERROR([gssapi.h not found])
723                 fi
724
725                 CPPFLAGS="$saved_cppflags"
726
727                 #
728                 # XXXDCL This probably doesn't work right on all systems.
729                 # It will need to be worked on as problems become evident.
730                 #
731                 # Essentially the problems here relate to two different
732                 # areas.  The first area is building with either KTH
733                 # or MIT Kerberos, particularly when both are present on
734                 # the machine.  The other is static versus dynamic linking.
735                 #
736                 # On the KTH vs MIT issue, Both have libkrb5 that can mess
737                 # up the works if one implementation ends up trying to
738                 # use the other's krb.  This is unfortunately a situation
739                 # that very easily arises.
740                 #
741                 # Dynamic linking when the dependency information is built
742                 # into MIT's libgssapi_krb5 or KTH's libgssapi magically makes
743                 # all such problems go away, but when that setup is not
744                 # present, because either the dynamic libraries lack
745                 # dependencies or static linking is being done, then the
746                 # problems start to show up.
747                 saved_libs="$LIBS"
748                 for TRY_LIBS in \
749                     "-lgssapi_krb5" \
750                     "-lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err" \
751                     "-lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lresolv" \
752                     "-lgssapi" \
753                     "-lgssapi -lkrb5 -ldes -lcrypt -lasn1 -lroken -lcom_err" \
754                     "-lgssapi -lkrb5 -lcrypto -lcrypt -lasn1 -lroken -lcom_err" \
755                     "-lgss"
756                 do
757                     # Note that this does not include $saved_libs, because
758                     # on FreeBSD machines this configure script has added
759                     # -L/usr/local/lib to LIBS, which can make the
760                     # -lgssapi_krb5 test succeed with shared libraries even
761                     # when you are trying to build with KTH in /usr/lib.
762                     LIBS="-L$use_gssapi/lib $TRY_LIBS"
763                     AC_MSG_CHECKING(linking as $TRY_LIBS)
764                     AC_TRY_LINK( , [gss_acquire_cred();],
765                                 gssapi_linked=yes, gssapi_linked=no)
766                     case $gssapi_linked in
767                     yes) AC_MSG_RESULT(yes); break ;;
768                     no)  AC_MSG_RESULT(no) ;;
769                     esac
770                 done
771
772                 case $gssapi_linked in
773                 no) AC_MSG_ERROR(could not determine proper GSSAPI linkage) ;;
774                 esac
775
776                 #
777                 # XXXDCL Major kludge.  Tries to cope with KTH in /usr/lib
778                 # but MIT in /usr/local/lib and trying to build with KTH.
779                 # /usr/local/lib can end up earlier on the link lines.
780                 # Like most kludges, this one is not only inelegant it
781                 # is also likely to be the wrong thing to do at least as
782                 # many times as it is the right thing.  Something better
783                 # needs to be done.
784                 #
785                 if test "$use_gssapi" = "/usr" -a \
786                         -f /usr/local/lib/libkrb5.a; then
787                     FIX_KTH_VS_MIT=yes
788                 fi
789
790                 case "$FIX_KTH_VS_MIT" in
791                 yes)
792                     case "$enable_static_linking" in
793                     yes) gssapi_lib_suffix=".a"  ;;
794                     *)   gssapi_lib_suffix=".so" ;;
795                     esac
796
797                     for lib in $LIBS; do
798                         case $lib in
799                         -L*)
800                             ;;
801                         -l*)
802                             new_lib=`echo $lib |
803                                      sed -e s%^-l%$use_gssapi/lib/lib% \
804                                          -e s%$%$gssapi_lib_suffix%`
805                             NEW_LIBS="$NEW_LIBS $new_lib"
806                             ;;
807                         *)
808                            AC_MSG_ERROR([KTH vs MIT Kerberos confusion!])
809                             ;;
810                         esac
811                     done
812                     LIBS="$NEW_LIBS"
813                     ;;
814                 esac
815
816                 DST_GSSAPI_INC="-I$use_gssapi/include"
817                 DNS_GSSAPI_LIBS="$LIBS"
818
819                 AC_MSG_RESULT(using GSSAPI from $use_gssapi/lib and $use_gssapi/include)
820                 LIBS="$saved_libs"
821                 ;;
822 esac
823
824 AC_SUBST(ISC_PLATFORM_HAVEGSSAPI)
825 AC_SUBST(ISC_PLATFORM_GSSAPIHEADER)
826
827 AC_SUBST(USE_GSSAPI)
828 AC_SUBST(DST_GSSAPI_INC)
829 AC_SUBST(DNS_GSSAPI_LIBS)
830 DNS_CRYPTO_LIBS="$DNS_GSSAPI_LIBS $DNS_CRYPTO_LIBS"
831
832 #
833 # Applications linking with libdns also need to link with these libraries.
834 #
835
836 AC_SUBST(DNS_CRYPTO_LIBS)
837
838 #
839 # was --with-randomdev specified?
840 #
841 AC_MSG_CHECKING(for random device)
842 AC_ARG_WITH(randomdev,
843 [  --with-randomdev=PATH   Specify path for random device],
844     use_randomdev="$withval", use_randomdev="unspec")
845
846 case "$use_randomdev" in
847         unspec)
848                 case "$host" in
849                         *-openbsd*)
850                                 devrandom=/dev/arandom
851                                 ;;
852                         *)
853                                 devrandom=/dev/random
854                                 ;;
855                 esac
856                 AC_MSG_RESULT($devrandom)
857                 AC_CHECK_FILE($devrandom,
858                               AC_DEFINE_UNQUOTED(PATH_RANDOMDEV,
859                                                  "$devrandom"),)
860                 ;;
861         yes)
862                 AC_MSG_ERROR([--with-randomdev must specify a path])
863                 ;;
864         no)
865                 AC_MSG_RESULT(disabled)
866                 ;;
867         *)
868                 AC_DEFINE_UNQUOTED(PATH_RANDOMDEV, "$use_randomdev")
869                 AC_MSG_RESULT(using "$use_randomdev")
870                 ;;
871 esac
872
873 #
874 # Do we have arc4random() ?
875 #
876 AC_CHECK_FUNC(arc4random, AC_DEFINE(HAVE_ARC4RANDOM))
877
878 sinclude(config.threads.in)dnl
879
880 if $use_threads
881 then
882         if test "X$GCC" = "Xyes"; then
883                 case "$host" in
884                 *-freebsd*)
885                         CC="$CC -pthread"
886                         CCOPT="$CCOPT -pthread"
887                         STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
888                         ;;
889                 *-openbsd*)
890                         CC="$CC -pthread"
891                         CCOPT="$CCOPT -pthread"
892                         ;;
893                 *-solaris*)
894                         LIBS="$LIBS -lthread"
895                         ;;
896                 *-ibm-aix*)
897                         STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
898                         ;;
899                 esac
900         else
901                 case $host in
902                 *-dec-osf*)
903                         CC="$CC -pthread"
904                         CCOPT="$CCOPT -pthread"
905                         ;;
906                 *-solaris*)
907                         CC="$CC -mt"
908                         CCOPT="$CCOPT -mt"
909                         ;;
910                 *-ibm-aix*)
911                         STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
912                         ;;
913                 *-sco-sysv*uw*|*-*-sysv*UnixWare*)
914                         CC="$CC -Kthread"
915                         CCOPT="$CCOPT -Kthread"
916                         ;;
917                 *-*-sysv*OpenUNIX*)
918                         CC="$CC -Kpthread"
919                         CCOPT="$CCOPT -Kpthread"
920                         ;;
921                 esac
922         fi
923         ALWAYS_DEFINES="-D_REENTRANT"
924         ISC_PLATFORM_USETHREADS="#define ISC_PLATFORM_USETHREADS 1"
925         thread_dir=pthreads
926         #
927         # We'd like to use sigwait() too
928         #
929         AC_CHECK_FUNC(sigwait,
930                       AC_DEFINE(HAVE_SIGWAIT),
931                       AC_CHECK_LIB(c, sigwait,
932                       AC_DEFINE(HAVE_SIGWAIT),
933                       AC_CHECK_LIB(pthread, sigwait,
934                                    AC_DEFINE(HAVE_SIGWAIT),
935                                    AC_CHECK_LIB(pthread, _Psigwait,
936                                                 AC_DEFINE(HAVE_SIGWAIT),))))
937
938         AC_CHECK_FUNC(pthread_attr_getstacksize,
939                       AC_DEFINE(HAVE_PTHREAD_ATTR_GETSTACKSIZE),)
940
941         AC_CHECK_FUNC(pthread_attr_setstacksize,
942                       AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACKSIZE),)
943
944         #
945         # Additional OS-specific issues related to pthreads and sigwait.
946         #
947         case "$host" in
948                 #
949                 # One more place to look for sigwait.
950                 #
951                 *-freebsd*)
952                         AC_CHECK_LIB(c_r, sigwait, AC_DEFINE(HAVE_SIGWAIT),)
953                         case $host in
954                         *-freebsd5.[[012]]|*-freebsd5.[[012]].*);;
955                         *-freebsd5.[[3456789]]|*-freebsd5.[[3456789]].*)
956                                 AC_DEFINE(NEED_PTHREAD_SCOPE_SYSTEM)
957                                 ;;
958                         *-freebsd6.*)
959                                 AC_DEFINE(NEED_PTHREAD_SCOPE_SYSTEM)
960                                 ;;
961                         esac
962                         ;;
963                 #
964                 # BSDI 3.0 through 4.0.1 needs pthread_init() to be
965                 # called before certain pthreads calls.  This is deprecated
966                 # in BSD/OS 4.1.
967                 #
968                 *-bsdi3.*|*-bsdi4.0*)
969                         AC_DEFINE(NEED_PTHREAD_INIT)
970                         ;;
971                 #
972                 # LinuxThreads requires some changes to the way we
973                 # deal with signals.
974                 #
975                 *-linux*)
976                         AC_DEFINE(HAVE_LINUXTHREADS)
977                         ;;
978                 #
979                 # Ensure the right sigwait() semantics on Solaris and make
980                 # sure we call pthread_setconcurrency.
981                 #
982                 *-solaris*)
983                         AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
984                         AC_CHECK_FUNC(pthread_setconcurrency,
985                                       AC_DEFINE(CALL_PTHREAD_SETCONCURRENCY))
986                         ;;
987                 #
988                 # UnixWare does things its own way.
989                 #
990                 *-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
991                         AC_DEFINE(HAVE_UNIXWARE_SIGWAIT)
992                         ;;
993         esac
994
995         #
996         # Look for sysconf to allow detection of the number of processors.
997         #
998         AC_CHECK_FUNC(sysconf, AC_DEFINE(HAVE_SYSCONF),)
999
1000 else
1001         ISC_PLATFORM_USETHREADS="#undef ISC_PLATFORM_USETHREADS"
1002         thread_dir=nothreads
1003         ALWAYS_DEFINES=""
1004 fi
1005
1006 AC_SUBST(ALWAYS_DEFINES)
1007 AC_SUBST(ISC_PLATFORM_USETHREADS)
1008 ISC_THREAD_DIR=$thread_dir
1009 AC_SUBST(ISC_THREAD_DIR)
1010
1011 #
1012 # was --with-libxml2 specified?
1013 #
1014 AC_MSG_CHECKING(for libxml2 library)
1015 AC_ARG_WITH(libxml2,
1016 [  --with-libxml2[=PATH]     Build with libxml2 library [yes|no|path]],
1017     use_libxml2="$withval", use_libxml2="auto")
1018
1019 case "$use_libxml2" in
1020         no)
1021                 DST_LIBXML2_INC=""
1022                 ;;
1023         auto|yes)
1024                 case X`(xml2-config --version) 2>/dev/null` in
1025                 X2.[[67]].*)
1026                         libxml2_libs=`xml2-config --libs`
1027                         libxml2_cflags=`xml2-config --cflags`
1028                         ;;
1029                 *)
1030                         libxml2_libs=
1031                         libxml2_cflags=
1032                         ;;
1033                 esac
1034                 ;;
1035         *)
1036                 if test -f "$use_libxml2/bin/xml2-config" ; then
1037                         libxml2_libs=`$use_libxml2/bin/xml2-config --libs`
1038                         libxml2_cflags=`$use_libxml2/bin/xml2-config --cflags`
1039                 fi
1040                 ;;
1041 esac
1042
1043 if test "X$libxml2_libs" != "X"
1044 then
1045         AC_MSG_RESULT(yes)
1046         CFLAGS="$CFLAGS $libxml2_cflags"
1047         LIBS="$LIBS $libxml2_libs"
1048         AC_DEFINE(HAVE_LIBXML2, 1, [Define if libxml2 was found])
1049 else
1050         AC_MSG_RESULT(no)
1051 fi
1052
1053 #
1054 # In solaris 10, SMF can manage named service
1055 #
1056 AC_CHECK_LIB(scf, smf_enable_instance)
1057
1058 #
1059 # flockfile is usually provided by pthreads, but we may want to use it
1060 # even if compiled with --disable-threads.  getc_unlocked might also not
1061 # be defined.
1062 #
1063 AC_CHECK_FUNC(flockfile, AC_DEFINE(HAVE_FLOCKFILE),)
1064 AC_CHECK_FUNC(getc_unlocked, AC_DEFINE(HAVE_GETCUNLOCKED),)
1065
1066
1067 # Indicate what the final decision was regarding threads.
1068 #
1069 AC_MSG_CHECKING(whether to build with threads)
1070 if $use_threads; then
1071         AC_MSG_RESULT(yes)
1072 else
1073         AC_MSG_RESULT(no)
1074 fi
1075
1076
1077 # End of pthreads stuff.
1078 #
1079
1080 #
1081 # Large File
1082 #
1083 AC_ARG_ENABLE(largefile, [  --enable-largefile    64-bit file support],
1084               want_largefile="yes", want_largefile="no")
1085 case $want_largefile in
1086         yes)
1087                 ALWAYS_DEFINES="$ALWAYS_DEFINES -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
1088                 ;;
1089         *)
1090                 ;;
1091 esac
1092
1093 #
1094 # Additional compiler settings.
1095 #
1096 MKDEPCC="$CC"
1097 MKDEPCFLAGS="-M"
1098 IRIX_DNSSEC_WARNINGS_HACK=""
1099
1100 if test "X$GCC" = "Xyes"; then
1101         AC_MSG_CHECKING(if "$CC" supports -fno-strict-aliasing)
1102         SAVE_CFLAGS=$CFLAGS
1103         CFLAGS=-fno-strict-aliasing
1104         AC_TRY_COMPILE(,, [FNOSTRICTALIASING=yes],[FNOSTRICTALIASING=no])
1105         CFLAGS=$SAVE_CFLAGS
1106         if test "$FNOSTRICTALIASING" = "yes"; then
1107                 AC_MSG_RESULT(yes)
1108         STD_CWARNINGS="$STD_CWARNINGS -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -Wpointer-arith -fno-strict-aliasing"
1109         else
1110                 AC_MSG_RESULT(no)
1111         STD_CWARNINGS="$STD_CWARNINGS -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -Wpointer-arith"
1112         fi
1113         case "$host" in
1114         *-hp-hpux*)
1115                 LDFLAGS="-Wl,+vnocompatwarnings $LDFLAGS"
1116                 ;;
1117         esac
1118 else
1119         case $host in
1120         *-dec-osf*)
1121                 CC="$CC -std"
1122                 CCOPT="$CCOPT -std"
1123                 MKDEPCC="$CC"
1124                 ;;
1125         *-hp-hpux*)
1126                 CC="$CC -Ae -z"
1127                 # The version of the C compiler that constantly warns about
1128                 # 'const' as well as alignment issues is unfortunately not
1129                 # able to be discerned via the version of the operating
1130                 # system, nor does cc have a version flag.
1131                 case "`$CC +W 123 2>&1`" in
1132                 *Unknown?option*)
1133                         STD_CWARNINGS="+w1"
1134                         ;;
1135                 *)
1136                         # Turn off the pointlessly noisy warnings.
1137                         STD_CWARNINGS="+w1 +W 474,530,2193,2236"
1138                         ;;
1139                 esac
1140                 CCOPT="$CCOPT -Ae -z"
1141                 LDFLAGS="-Wl,+vnocompatwarnings $LDFLAGS"
1142                 MKDEPPROG='cc -Ae -E -Wp,-M >/dev/null 2>>$TMP'
1143                 ;;
1144         *-sgi-irix*)
1145                 STD_CWARNINGS="-fullwarn -woff 1209"
1146                 #
1147                 # Silence more than 250 instances of
1148                 #   "prototyped function redeclared without prototype"
1149                 # and 11 instances of
1150                 #   "variable ... was set but never used"
1151                 # from lib/dns/sec/openssl.
1152                 #
1153                 IRIX_DNSSEC_WARNINGS_HACK="-woff 1692,1552"
1154                 ;;
1155         *-solaris*)
1156                 MKDEPCFLAGS="-xM"
1157                 ;;
1158         *-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
1159                 # UnixWare
1160                 CC="$CC -w"
1161                 ;;
1162         esac
1163 fi
1164
1165 AC_SUBST(MKDEPCC)
1166 AC_SUBST(MKDEPCFLAGS)
1167 AC_SUBST(MKDEPPROG)
1168 AC_SUBST(IRIX_DNSSEC_WARNINGS_HACK)
1169
1170 #
1171 # NLS
1172 #
1173 AC_CHECK_FUNC(catgets, AC_DEFINE(HAVE_CATGETS),)
1174
1175 #
1176 # -lxnet buys us one big porting headache...  standards, gotta love 'em.
1177 #
1178 # AC_CHECK_LIB(xnet, socket, ,
1179 #    AC_CHECK_LIB(socket, socket)
1180 # )
1181 #
1182 # Use this for now, instead:
1183 #
1184 case "$host" in
1185         mips-sgi-irix*)
1186                 ;;
1187         *-linux*)
1188                 ;;
1189         *)
1190                 AC_CHECK_LIB(socket, socket)
1191                 AC_CHECK_LIB(nsl, inet_addr)
1192                 ;;
1193 esac
1194
1195 #
1196 # Work around Solaris's select() limitations.
1197 #
1198 case "$host" in
1199         *-solaris2.[[89]]|*-solaris2.1?)
1200         AC_DEFINE(FD_SETSIZE, 65536,
1201                   [Solaris hack to get select_large_fdset.])
1202         ;;
1203 esac
1204
1205 #
1206 # Purify support
1207 #
1208 AC_MSG_CHECKING(whether to use purify)
1209 AC_ARG_WITH(purify,
1210         [  --with-purify[=PATH]      use Rational purify],
1211         use_purify="$withval", use_purify="no")
1212
1213 case "$use_purify" in
1214         no)
1215                 ;;
1216         yes)
1217                 AC_PATH_PROG(purify_path, purify, purify)
1218                 ;;
1219         *)
1220                 purify_path="$use_purify"
1221                 ;;
1222 esac
1223
1224 case "$use_purify" in
1225         no)
1226                 AC_MSG_RESULT(no)
1227                 PURIFY=""
1228                 ;;
1229         *)
1230                 if test -f $purify_path || test $purify_path = purify; then
1231                         AC_MSG_RESULT($purify_path)
1232                         PURIFYFLAGS="`echo $PURIFYOPTIONS`"
1233                         PURIFY="$purify_path $PURIFYFLAGS"
1234                 else
1235                         AC_MSG_ERROR([$purify_path not found.
1236
1237 Please choose the proper path with the following command:
1238
1239     configure --with-purify=PATH
1240 ])
1241                 fi
1242                 ;;
1243 esac
1244
1245 AC_SUBST(PURIFY)
1246
1247
1248 AC_ARG_WITH(libtool,
1249             [  --with-libtool          use GNU libtool],
1250             use_libtool="$withval", use_libtool="no")
1251
1252 case $use_libtool in
1253         yes)
1254                 AM_PROG_LIBTOOL
1255                 O=lo
1256                 A=la
1257                 LIBTOOL_MKDEP_SED='s;\.o;\.lo;'
1258                 LIBTOOL_MODE_COMPILE='--mode=compile'
1259                 LIBTOOL_MODE_INSTALL='--mode=install'
1260                 LIBTOOL_MODE_LINK='--mode=link'
1261                 case "$host" in
1262                 *) LIBTOOL_ALLOW_UNDEFINED= ;;
1263                 esac
1264                 case "$host" in
1265                 *-ibm-aix*) LIBTOOL_IN_MAIN="-Wl,-bI:T_testlist.imp" ;;
1266                 *) LIBTOOL_IN_MAIN= ;;
1267                 esac;
1268                 ;;
1269         *)
1270                 O=o
1271                 A=a
1272                 LIBTOOL=
1273                 AC_SUBST(LIBTOOL)
1274                 LIBTOOL_MKDEP_SED=
1275                 LIBTOOL_MODE_COMPILE=
1276                 LIBTOOL_MODE_INSTALL=
1277                 LIBTOOL_MODE_LINK=
1278                 LIBTOOL_ALLOW_UNDEFINED=
1279                 LIBTOOL_IN_MAIN=
1280                 ;;
1281 esac
1282
1283 #
1284 # File name extension for static archive files, for those few places
1285 # where they are treated differently from dynamic ones.
1286 #
1287 SA=a
1288
1289 AC_SUBST(O)
1290 AC_SUBST(A)
1291 AC_SUBST(SA)
1292 AC_SUBST(LIBTOOL_MKDEP_SED)
1293 AC_SUBST(LIBTOOL_MODE_COMPILE)
1294 AC_SUBST(LIBTOOL_MODE_INSTALL)
1295 AC_SUBST(LIBTOOL_MODE_LINK)
1296 AC_SUBST(LIBTOOL_ALLOW_UNDEFINED)
1297 AC_SUBST(LIBTOOL_IN_MAIN)
1298
1299 #
1300 # Here begins a very long section to determine the system's networking
1301 # capabilities.  The order of the tests is significant.
1302 #
1303
1304 #
1305 # IPv6
1306 #
1307 AC_ARG_ENABLE(ipv6,
1308         [  --enable-ipv6           use IPv6 [default=autodetect]])
1309
1310 case "$enable_ipv6" in
1311         yes|''|autodetect)
1312                 AC_DEFINE(WANT_IPV6)
1313                 ;;
1314         no)
1315                 ;;
1316 esac
1317
1318 #
1319 # We do the IPv6 compilation checking after libtool so that we can put
1320 # the right suffix on the files.
1321 #
1322 AC_MSG_CHECKING(for IPv6 structures)
1323 AC_TRY_COMPILE([
1324 #include <sys/types.h>
1325 #include <sys/socket.h>
1326 #include <netinet/in.h>],
1327 [struct sockaddr_in6 sin6; return (0);],
1328         [AC_MSG_RESULT(yes)
1329          found_ipv6=yes],
1330         [AC_MSG_RESULT(no)
1331          found_ipv6=no])
1332
1333 #
1334 # See whether IPv6 support is provided via a Kame add-on.
1335 # This is done before other IPv6 linking tests to LIBS is properly set.
1336 #
1337 AC_MSG_CHECKING(for Kame IPv6 support)
1338 AC_ARG_WITH(kame,
1339         [  --with-kame[=PATH]     use Kame IPv6 [default path /usr/local/v6]],
1340         use_kame="$withval", use_kame="no")
1341
1342 case "$use_kame" in
1343         no)
1344                 ;;
1345         yes)
1346                 kame_path=/usr/local/v6
1347                 ;;
1348         *)
1349                 kame_path="$use_kame"
1350                 ;;
1351 esac
1352
1353 case "$use_kame" in
1354         no)
1355                 AC_MSG_RESULT(no)
1356                 ;;
1357         *)
1358                 if test -f $kame_path/lib/libinet6.a; then
1359                         AC_MSG_RESULT($kame_path/lib/libinet6.a)
1360                         LIBS="-L$kame_path/lib -linet6 $LIBS"
1361                 else
1362                         AC_MSG_ERROR([$kame_path/lib/libinet6.a not found.
1363
1364 Please choose the proper path with the following command:
1365
1366     configure --with-kame=PATH
1367 ])
1368                 fi
1369                 ;;
1370 esac
1371
1372 #
1373 # Whether netinet6/in6.h is needed has to be defined in isc/platform.h.
1374 # Including it on Kame-using platforms is very bad, though, because
1375 # Kame uses #error against direct inclusion.   So include it on only
1376 # the platform that is otherwise broken without it -- BSD/OS 4.0 through 4.1.
1377 # This is done before the in6_pktinfo check because that's what
1378 # netinet6/in6.h is needed for.
1379 #
1380 changequote({, })
1381 case "$host" in
1382 *-bsdi4.[01]*)
1383         ISC_PLATFORM_NEEDNETINET6IN6H="#define ISC_PLATFORM_NEEDNETINET6IN6H 1"
1384         LWRES_PLATFORM_NEEDNETINET6IN6H="#define LWRES_PLATFORM_NEEDNETINET6IN6H 1"
1385         isc_netinet6in6_hack="#include <netinet6/in6.h>"
1386         ;;
1387 *)
1388         ISC_PLATFORM_NEEDNETINET6IN6H="#undef ISC_PLATFORM_NEEDNETINET6IN6H"
1389         LWRES_PLATFORM_NEEDNETINET6IN6H="#undef LWRES_PLATFORM_NEEDNETINET6IN6H"
1390         isc_netinet6in6_hack=""
1391         ;;
1392 esac
1393 changequote([, ])
1394
1395 #
1396 # This is similar to the netinet6/in6.h issue.
1397 #
1398 case "$host" in
1399 *-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
1400         # UnixWare
1401         ISC_PLATFORM_NEEDNETINETIN6H="#define ISC_PLATFORM_NEEDNETINETIN6H 1"
1402         LWRES_PLATFORM_NEEDNETINETIN6H="#define LWRES_PLATFORM_NEEDNETINETIN6H 1"
1403         ISC_PLATFORM_FIXIN6ISADDR="#define ISC_PLATFORM_FIXIN6ISADDR 1"
1404         isc_netinetin6_hack="#include <netinet/in6.h>"
1405         ;;
1406 *)
1407         ISC_PLATFORM_NEEDNETINETIN6H="#undef ISC_PLATFORM_NEEDNETINETIN6H"
1408         LWRES_PLATFORM_NEEDNETINETIN6H="#undef LWRES_PLATFORM_NEEDNETINETIN6H"
1409         ISC_PLATFORM_FIXIN6ISADDR="#undef ISC_PLATFORM_FIXIN6ISADDR"
1410         isc_netinetin6_hack=""
1411         ;;
1412 esac
1413
1414 #
1415 # Now delve deeper into the suitability of the IPv6 support.
1416 #
1417 case "$found_ipv6" in
1418         yes)
1419                 ISC_PLATFORM_HAVEIPV6="#define ISC_PLATFORM_HAVEIPV6 1"
1420                 LWRES_PLATFORM_HAVEIPV6="#define LWRES_PLATFORM_HAVEIPV6 1"
1421
1422                 AC_MSG_CHECKING(for in6_addr)
1423                 AC_TRY_COMPILE([
1424 #include <sys/types.h>
1425 #include <sys/socket.h>
1426 #include <netinet/in.h>
1427 $isc_netinetin6_hack
1428 $isc_netinet6in6_hack
1429 ],
1430 [struct in6_addr in6; return (0);],
1431                 [AC_MSG_RESULT(yes)
1432                  ISC_PLATFORM_HAVEINADDR6="#undef ISC_PLATFORM_HAVEINADDR6"
1433                  LWRES_PLATFORM_HAVEINADDR6="#undef LWRES_PLATFORM_HAVEINADDR6"
1434                  isc_in_addr6_hack=""],
1435                 [AC_MSG_RESULT(no)
1436                  ISC_PLATFORM_HAVEINADDR6="#define ISC_PLATFORM_HAVEINADDR6 1"
1437                  LWRES_PLATFORM_HAVEINADDR6="#define LWRES_PLATFORM_HAVEINADDR6 1"
1438                  isc_in_addr6_hack="#define in6_addr in_addr6"])
1439
1440                 AC_MSG_CHECKING(for in6addr_any)
1441                 AC_TRY_LINK([
1442 #include <sys/types.h>
1443 #include <sys/socket.h>
1444 #include <netinet/in.h>
1445 $isc_netinetin6_hack
1446 $isc_netinet6in6_hack
1447 $isc_in_addr6_hack
1448 ],
1449                 [struct in6_addr in6; in6 = in6addr_any; return (in6.s6_addr[0]);],
1450                         [AC_MSG_RESULT(yes)
1451                          ISC_PLATFORM_NEEDIN6ADDRANY="#undef ISC_PLATFORM_NEEDIN6ADDRANY"
1452                          LWRES_PLATFORM_NEEDIN6ADDRANY="#undef LWRES_PLATFORM_NEEDIN6ADDRANY"],
1453                         [AC_MSG_RESULT(no)
1454                          ISC_PLATFORM_NEEDIN6ADDRANY="#define ISC_PLATFORM_NEEDIN6ADDRANY 1"
1455                          LWRES_PLATFORM_NEEDIN6ADDRANY="#define LWRES_PLATFORM_NEEDIN6ADDRANY 1"])
1456
1457                 AC_MSG_CHECKING(for in6addr_loopback)
1458                 AC_TRY_LINK([
1459 #include <sys/types.h>
1460 #include <sys/socket.h>
1461 #include <netinet/in.h>
1462 $isc_netinetin6_hack
1463 $isc_netinet6in6_hack
1464 $isc_in_addr6_hack
1465 ],
1466                 [struct in6_addr in6; in6 = in6addr_loopback; return (in6.s6_addr[0]);],
1467                         [AC_MSG_RESULT(yes)
1468                          ISC_PLATFORM_NEEDIN6ADDRLOOPBACK="#undef ISC_PLATFORM_NEEDIN6ADDRLOOPBACK"
1469                          LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK="#undef LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK"],
1470                         [AC_MSG_RESULT(no)
1471                          ISC_PLATFORM_NEEDIN6ADDRLOOPBACK="#define ISC_PLATFORM_NEEDIN6ADDRLOOPBACK 1"
1472                          LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK="#define LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK 1"])
1473
1474                 AC_MSG_CHECKING(for sin6_scope_id in struct sockaddr_in6)
1475                 AC_TRY_COMPILE([
1476 #include <sys/types.h>
1477 #include <sys/socket.h>
1478 #include <netinet/in.h>
1479 $isc_netinetin6_hack
1480 $isc_netinet6in6_hack
1481 ],
1482                 [struct sockaddr_in6 xyzzy; xyzzy.sin6_scope_id = 0; return (0);],
1483                         [AC_MSG_RESULT(yes)
1484                          ISC_PLATFORM_HAVESCOPEID="#define ISC_PLATFORM_HAVESCOPEID 1"
1485                          result="#define LWRES_HAVE_SIN6_SCOPE_ID 1"],
1486                         [AC_MSG_RESULT(no)
1487                          ISC_PLATFORM_HAVESCOPEID="#undef ISC_PLATFORM_HAVESCOPEID"
1488                          result="#undef LWRES_HAVE_SIN6_SCOPE_ID"])
1489                 LWRES_HAVE_SIN6_SCOPE_ID="$result"
1490
1491                 AC_MSG_CHECKING(for in6_pktinfo)
1492                 AC_TRY_COMPILE([
1493 #include <sys/types.h>
1494 #include <sys/socket.h>
1495 #include <netinet/in.h>
1496 $isc_netinetin6_hack
1497 $isc_netinet6in6_hack
1498 ],
1499                 [struct in6_pktinfo xyzzy; return (0);],
1500                         [AC_MSG_RESULT(yes)
1501                          ISC_PLATFORM_HAVEIN6PKTINFO="#define ISC_PLATFORM_HAVEIN6PKTINFO 1"],
1502                         [AC_MSG_RESULT(no -- disabling runtime ipv6 support)
1503                          ISC_PLATFORM_HAVEIN6PKTINFO="#undef ISC_PLATFORM_HAVEIN6PKTINFO"])
1504                 ;;
1505         no)
1506                 ISC_PLATFORM_HAVEIPV6="#undef ISC_PLATFORM_HAVEIPV6"
1507                 LWRES_PLATFORM_HAVEIPV6="#undef LWRES_PLATFORM_HAVEIPV6"
1508                 ISC_PLATFORM_NEEDIN6ADDRANY="#undef ISC_PLATFORM_NEEDIN6ADDRANY"
1509                 LWRES_PLATFORM_NEEDIN6ADDRANY="#undef LWRES_PLATFORM_NEEDIN6ADDRANY"
1510                 ISC_PLATFORM_HAVEIN6PKTINFO="#undef ISC_PLATFORM_HAVEIN6PKTINFO"
1511                 LWRES_HAVE_SIN6_SCOPE_ID="#define LWRES_HAVE_SIN6_SCOPE_ID 1"
1512                 ISC_PLATFORM_HAVESCOPEID="#define ISC_PLATFORM_HAVESCOPEID 1"
1513                 ISC_IPV6_H="ipv6.h"
1514                 ISC_IPV6_O="ipv6.$O"
1515                 ISC_ISCIPV6_O="unix/ipv6.$O"
1516                 ISC_IPV6_C="ipv6.c"
1517                 ;;
1518 esac
1519
1520 AC_SUBST(ISC_PLATFORM_HAVEIPV6)
1521 AC_SUBST(LWRES_PLATFORM_HAVEIPV6)
1522 AC_SUBST(ISC_PLATFORM_NEEDNETINETIN6H)
1523 AC_SUBST(LWRES_PLATFORM_NEEDNETINETIN6H)
1524 AC_SUBST(ISC_PLATFORM_NEEDNETINET6IN6H)
1525 AC_SUBST(LWRES_PLATFORM_NEEDNETINET6IN6H)
1526 AC_SUBST(ISC_PLATFORM_HAVEINADDR6)
1527 AC_SUBST(LWRES_PLATFORM_HAVEINADDR6)
1528 AC_SUBST(ISC_PLATFORM_NEEDIN6ADDRANY)
1529 AC_SUBST(LWRES_PLATFORM_NEEDIN6ADDRANY)
1530 AC_SUBST(ISC_PLATFORM_NEEDIN6ADDRLOOPBACK)
1531 AC_SUBST(LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK)
1532 AC_SUBST(ISC_PLATFORM_HAVEIN6PKTINFO)
1533 AC_SUBST(ISC_PLATFORM_FIXIN6ISADDR)
1534 AC_SUBST(ISC_IPV6_H)
1535 AC_SUBST(ISC_IPV6_O)
1536 AC_SUBST(ISC_ISCIPV6_O)
1537 AC_SUBST(ISC_IPV6_C)
1538 AC_SUBST(LWRES_HAVE_SIN6_SCOPE_ID)
1539 AC_SUBST(ISC_PLATFORM_HAVESCOPEID)
1540
1541 AC_MSG_CHECKING([for struct if_laddrreq])
1542 AC_TRY_LINK([
1543 #include <sys/types.h>
1544 #include <net/if6.h>
1545 ],[ struct if_laddrreq a; ],
1546         [AC_MSG_RESULT(yes)
1547         ISC_PLATFORM_HAVEIF_LADDRREQ="#define ISC_PLATFORM_HAVEIF_LADDRREQ 1"],
1548         [AC_MSG_RESULT(no)
1549         ISC_PLATFORM_HAVEIF_LADDRREQ="#undef ISC_PLATFORM_HAVEIF_LADDRREQ"])
1550 AC_SUBST(ISC_PLATFORM_HAVEIF_LADDRREQ)
1551
1552 AC_MSG_CHECKING([for struct if_laddrconf])
1553 AC_TRY_LINK([
1554 #include <sys/types.h>
1555 #include <net/if6.h>
1556 ],[ struct if_laddrconf a; ],
1557         [AC_MSG_RESULT(yes)
1558         ISC_PLATFORM_HAVEIF_LADDRCONF="#define ISC_PLATFORM_HAVEIF_LADDRCONF 1"],
1559         [AC_MSG_RESULT(no)
1560         ISC_PLATFORM_HAVEIF_LADDRCONF="#undef ISC_PLATFORM_HAVEIF_LADDRCONF"])
1561 AC_SUBST(ISC_PLATFORM_HAVEIF_LADDRCONF)
1562
1563 #
1564 # Check for network functions that are often missing.  We do this
1565 # after the libtool checking, so we can put the right suffix on
1566 # the files.  It also needs to come after checking for a Kame add-on,
1567 # which provides some (all?) of the desired functions.
1568 #
1569
1570 AC_MSG_CHECKING([for inet_ntop with IPv6 support])
1571 AC_TRY_RUN([
1572 #include <sys/types.h>
1573 #include <sys/socket.h>
1574 #include <netinet/in.h>
1575 #include <arpa/inet.h>
1576 main() {
1577 char a[16],b[64]; return(inet_ntop(AF_INET6, a, b, sizeof(b)) == (char*)0);}],
1578         [AC_MSG_RESULT(yes)
1579         ISC_PLATFORM_NEEDNTOP="#undef ISC_PLATFORM_NEEDNTOP"],
1580
1581         [AC_MSG_RESULT(no)
1582         ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_ntop.$O"
1583         ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_ntop.c"
1584         ISC_PLATFORM_NEEDNTOP="#define ISC_PLATFORM_NEEDNTOP 1"],
1585         [AC_MSG_RESULT(assuming inet_ntop needed)
1586         ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_ntop.$O"
1587         ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_ntop.c"
1588         ISC_PLATFORM_NEEDNTOP="#define ISC_PLATFORM_NEEDNTOP 1"])
1589
1590
1591 # On NetBSD 1.4.2 and maybe others, inet_pton() incorrectly accepts
1592 # addresses with less than four octets, like "1.2.3".  Also leading
1593 # zeros should also be rejected.
1594
1595 AC_MSG_CHECKING([for working inet_pton with IPv6 support])
1596 AC_TRY_RUN([
1597 #include <sys/types.h>
1598 #include <sys/socket.h>
1599 #include <netinet/in.h>
1600 #include <arpa/inet.h>
1601 main() { char a[16]; return (inet_pton(AF_INET, "1.2.3", a) == 1 ? 1 :
1602                              inet_pton(AF_INET, "1.2.3.04", a) == 1 ? 1 : 
1603                              (inet_pton(AF_INET6, "::1.2.3.4", a) != 1)); }],
1604         [AC_MSG_RESULT(yes)
1605         ISC_PLATFORM_NEEDPTON="#undef ISC_PLATFORM_NEEDPTON"],
1606         [AC_MSG_RESULT(no)
1607         ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_pton.$O"
1608         ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_pton.c"
1609         ISC_PLATFORM_NEEDPTON="#define ISC_PLATFORM_NEEDPTON 1"],
1610         [AC_MSG_RESULT(assuming target platform has working inet_pton)
1611         ISC_PLATFORM_NEEDPTON="#undef ISC_PLATFORM_NEEDPTON"],
1612         [AC_MSG_RESULT(assuming inet_pton needed)
1613         ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_pton.$O"
1614         ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_pton.c"
1615         ISC_PLATFORM_NEEDPTON="#define ISC_PLATFORM_NEEDPTON 1"],
1616         [AC_MSG_RESULT(assuming target platform has working inet_pton)
1617         ISC_PLATFORM_NEEDPTON="#undef ISC_PLATFORM_NEEDPTON"])
1618
1619 AC_SUBST(ISC_PLATFORM_NEEDNTOP)
1620 AC_SUBST(ISC_PLATFORM_NEEDPTON)
1621
1622 #
1623 # Look for a 4.4BSD-style sa_len member in struct sockaddr.
1624 #
1625 case "$host" in
1626         *-dec-osf*)
1627                 # Turn on 4.4BSD style sa_len support.
1628                 AC_DEFINE(_SOCKADDR_LEN)
1629                 ;;
1630 esac
1631
1632 AC_MSG_CHECKING(for sa_len in struct sockaddr)
1633 AC_TRY_COMPILE([
1634 #include <sys/types.h>
1635 #include <sys/socket.h>],
1636 [struct sockaddr sa; sa.sa_len = 0; return (0);],
1637         [AC_MSG_RESULT(yes)
1638         ISC_PLATFORM_HAVESALEN="#define ISC_PLATFORM_HAVESALEN 1"
1639         LWRES_PLATFORM_HAVESALEN="#define LWRES_PLATFORM_HAVESALEN 1"],
1640         [AC_MSG_RESULT(no)
1641         ISC_PLATFORM_HAVESALEN="#undef ISC_PLATFORM_HAVESALEN"
1642         LWRES_PLATFORM_HAVESALEN="#undef LWRES_PLATFORM_HAVESALEN"])
1643 AC_SUBST(ISC_PLATFORM_HAVESALEN)
1644 AC_SUBST(LWRES_PLATFORM_HAVESALEN)
1645
1646 #
1647 # Look for a 4.4BSD or 4.3BSD struct msghdr
1648 #
1649 AC_MSG_CHECKING(for struct msghdr flavor)
1650 AC_TRY_COMPILE([
1651 #include <sys/types.h>
1652 #include <sys/socket.h>],
1653 [struct msghdr msg; msg.msg_flags = 0; return (0);],
1654         [AC_MSG_RESULT(4.4BSD)
1655         ISC_PLATFORM_MSGHDRFLAVOR="#define ISC_NET_BSD44MSGHDR 1"],
1656         [AC_MSG_RESULT(4.3BSD)
1657         ISC_PLATFORM_MSGHDRFLAVOR="#define ISC_NET_BSD43MSGHDR 1"])
1658 AC_SUBST(ISC_PLATFORM_MSGHDRFLAVOR)
1659
1660 #
1661 # Look for in_port_t.
1662 #
1663 AC_MSG_CHECKING(for type in_port_t)
1664 AC_TRY_COMPILE([
1665 #include <sys/types.h>
1666 #include <netinet/in.h>],
1667 [in_port_t port = 25; return (0);],
1668         [AC_MSG_RESULT(yes)
1669         ISC_PLATFORM_NEEDPORTT="#undef ISC_PLATFORM_NEEDPORTT"],
1670         [AC_MSG_RESULT(no)
1671         ISC_PLATFORM_NEEDPORTT="#define ISC_PLATFORM_NEEDPORTT 1"])
1672 AC_SUBST(ISC_PLATFORM_NEEDPORTT)
1673
1674 #
1675 # Check for addrinfo
1676 #
1677 AC_MSG_CHECKING(for struct addrinfo)
1678 AC_TRY_COMPILE([
1679 #include <netdb.h>],
1680 [struct addrinfo a; return (0);],
1681         [AC_MSG_RESULT(yes)
1682         ISC_LWRES_NEEDADDRINFO="#undef ISC_LWRES_NEEDADDRINFO"
1683         AC_DEFINE(HAVE_ADDRINFO)],
1684         [AC_MSG_RESULT(no)
1685         ISC_LWRES_NEEDADDRINFO="#define ISC_LWRES_NEEDADDRINFO 1"])
1686 AC_SUBST(ISC_LWRES_NEEDADDRINFO)
1687
1688 #
1689 # Check for rrsetinfo
1690 #
1691 AC_MSG_CHECKING(for struct rrsetinfo)
1692 AC_TRY_COMPILE([
1693 #include <netdb.h>],
1694 [struct rrsetinfo r; return (0);],
1695         [AC_MSG_RESULT(yes)
1696         ISC_LWRES_NEEDRRSETINFO="#undef ISC_LWRES_NEEDRRSETINFO"],
1697         [AC_MSG_RESULT(no)
1698         ISC_LWRES_NEEDRRSETINFO="#define ISC_LWRES_NEEDRRSETINFO 1"])
1699 AC_SUBST(ISC_LWRES_NEEDRRSETINFO)
1700
1701 AC_MSG_CHECKING(for int sethostent)
1702 AC_TRY_COMPILE([
1703 #include <netdb.h>],
1704 [int i = sethostent(0); return(0);],
1705         [AC_MSG_RESULT(yes)
1706         ISC_LWRES_SETHOSTENTINT="#define ISC_LWRES_SETHOSTENTINT 1"],
1707         [AC_MSG_RESULT(no)
1708         ISC_LWRES_SETHOSTENTINT="#undef ISC_LWRES_SETHOSTENTINT"])
1709 AC_SUBST(ISC_LWRES_SETHOSTENTINT)
1710
1711 AC_MSG_CHECKING(for int endhostent)
1712 AC_TRY_COMPILE([
1713 #include <netdb.h>],
1714 [int i = endhostent(); return(0);],
1715         [AC_MSG_RESULT(yes)
1716         ISC_LWRES_ENDHOSTENTINT="#define ISC_LWRES_ENDHOSTENTINT 1"],
1717         [AC_MSG_RESULT(no)
1718         ISC_LWRES_ENDHOSTENTINT="#undef ISC_LWRES_ENDHOSTENTINT"])
1719 AC_SUBST(ISC_LWRES_ENDHOSTENTINT)
1720
1721 AC_MSG_CHECKING(for getnetbyaddr(in_addr_t, ...))
1722 AC_TRY_COMPILE([
1723 #include <netdb.h>
1724 struct netent *getnetbyaddr(in_addr_t, int);],
1725 [],
1726         [AC_MSG_RESULT(yes)
1727         ISC_LWRES_GETNETBYADDRINADDR="#define ISC_LWRES_GETNETBYADDRINADDR 1"],
1728         [AC_MSG_RESULT(no)
1729         ISC_LWRES_GETNETBYADDRINADDR="#undef ISC_LWRES_GETNETBYADDRINADDR"])
1730 AC_SUBST(ISC_LWRES_GETNETBYADDRINADDR)
1731
1732 AC_MSG_CHECKING(for int setnetent)
1733 AC_TRY_COMPILE([
1734 #include <netdb.h>],
1735 [int i = setnetent(0); return(0);],
1736         [AC_MSG_RESULT(yes)
1737         ISC_LWRES_SETNETENTINT="#define ISC_LWRES_SETNETENTINT 1"],
1738         [AC_MSG_RESULT(no)
1739         ISC_LWRES_SETNETENTINT="#undef ISC_LWRES_SETNETENTINT"])
1740 AC_SUBST(ISC_LWRES_SETNETENTINT)
1741
1742 AC_MSG_CHECKING(for int endnetent)
1743 AC_TRY_COMPILE([
1744 #include <netdb.h>],
1745 [int i = endnetent(); return(0);],
1746         [AC_MSG_RESULT(yes)
1747         ISC_LWRES_ENDNETENTINT="#define ISC_LWRES_ENDNETENTINT 1"],
1748         [AC_MSG_RESULT(no)
1749         ISC_LWRES_ENDNETENTINT="#undef ISC_LWRES_ENDNETENTINT"])
1750 AC_SUBST(ISC_LWRES_ENDNETENTINT)
1751
1752 AC_MSG_CHECKING(for gethostbyaddr(const void *, size_t, ...))
1753 AC_TRY_COMPILE([
1754 #include <netdb.h>
1755 struct hostent *gethostbyaddr(const void *, size_t, int);],
1756 [return(0);],
1757         [AC_MSG_RESULT(yes)
1758         ISC_LWRES_GETHOSTBYADDRVOID="#define ISC_LWRES_GETHOSTBYADDRVOID 1"],
1759         [AC_MSG_RESULT(no)
1760         ISC_LWRES_GETHOSTBYADDRVOID="#undef ISC_LWRES_GETHOSTBYADDRVOID"])
1761 AC_SUBST(ISC_LWRES_GETHOSTBYADDRVOID)
1762
1763 AC_MSG_CHECKING(for h_errno in netdb.h)
1764 AC_TRY_COMPILE([
1765 #include <netdb.h>],
1766 [h_errno = 1; return(0);],
1767         [AC_MSG_RESULT(yes)
1768         ISC_LWRES_NEEDHERRNO="#undef ISC_LWRES_NEEDHERRNO"],
1769         [AC_MSG_RESULT(no)
1770         ISC_LWRES_NEEDHERRNO="#define ISC_LWRES_NEEDHERRNO 1"])
1771 AC_SUBST(ISC_LWRES_NEEDHERRNO)
1772
1773 AC_CHECK_FUNC(getipnodebyname,
1774         [ISC_LWRES_GETIPNODEPROTO="#undef ISC_LWRES_GETIPNODEPROTO"],
1775         [ISC_LWRES_GETIPNODEPROTO="#define ISC_LWRES_GETIPNODEPROTO 1"])
1776 AC_CHECK_FUNC(getnameinfo,
1777         [ISC_LWRES_GETNAMEINFOPROTO="#undef ISC_LWRES_GETNAMEINFOPROTO"],
1778         [ISC_LWRES_GETNAMEINFOPROTO="#define ISC_LWRES_GETNAMEINFOPROTO 1"])
1779 AC_CHECK_FUNC(getaddrinfo,
1780         [ISC_LWRES_GETADDRINFOPROTO="#undef ISC_LWRES_GETADDRINFOPROTO"
1781         AC_DEFINE(HAVE_GETADDRINFO)],
1782         [ISC_LWRES_GETADDRINFOPROTO="#define ISC_LWRES_GETADDRINFOPROTO 1"])
1783 AC_CHECK_FUNC(gai_strerror, AC_DEFINE(HAVE_GAISTRERROR))
1784 AC_SUBST(ISC_LWRES_GETIPNODEPROTO)
1785 AC_SUBST(ISC_LWRES_GETADDRINFOPROTO)
1786 AC_SUBST(ISC_LWRES_GETNAMEINFOPROTO)
1787
1788 AC_ARG_ENABLE(getifaddrs,
1789 [  --enable-getifaddrs     Enable the use of getifaddrs() [[yes|no]].],
1790     want_getifaddrs="$enableval",  want_getifaddrs="yes")
1791
1792 #
1793 # This interface iteration code for getifaddrs() will fall back to using
1794 # /proc/net/if_inet6 if getifaddrs() in glibc doesn't return any IPv6
1795 # addresses.
1796
1797 case $want_getifaddrs in
1798 glibc)
1799 AC_MSG_WARN("--enable-getifaddrs=glibc is no longer required")
1800 AC_CHECK_FUNC(getifaddrs, AC_DEFINE(HAVE_GETIFADDRS))
1801 ;;
1802 yes)
1803 AC_CHECK_FUNC(getifaddrs, AC_DEFINE(HAVE_GETIFADDRS))
1804 ;;
1805 no)
1806 ;;
1807 esac
1808
1809 #
1810 # Look for a sysctl call to get the list of network interfaces.
1811 #
1812 case $ac_cv_header_sys_sysctl_h in
1813 yes)
1814 AC_MSG_CHECKING(for interface list sysctl)
1815 AC_EGREP_CPP(found_rt_iflist, [
1816 #include <sys/param.h>
1817 #include <sys/sysctl.h>
1818 #include <sys/socket.h>
1819 #ifdef NET_RT_IFLIST
1820 found_rt_iflist
1821 #endif
1822 ],
1823         [AC_MSG_RESULT(yes)
1824          AC_DEFINE(HAVE_IFLIST_SYSCTL)],
1825         [AC_MSG_RESULT(no)])
1826 ;;
1827 esac
1828
1829 #
1830 # Check for some other useful functions that are not ever-present.
1831 #
1832
1833 # We test for strsep() using AC_TRY_LINK instead of AC_CHECK_FUNC
1834 # because AIX 4.3.3 with patches for bos.adt.include to version 4.3.3.77
1835 # reportedly defines strsep() without declaring it in <string.h> when
1836 # -D_LINUX_SOURCE_COMPAT is not defined [RT #2190], and
1837 # AC_CHECK_FUNC() incorrectly succeeds because it declares
1838 # the function itself.
1839 AC_MSG_CHECKING(for correctly declared strsep())
1840 AC_TRY_LINK([#include <string.h>], [char *sp; char *foo = strsep(&sp, ".");],
1841         [AC_MSG_RESULT(yes); ISC_PLATFORM_NEEDSTRSEP="#undef ISC_PLATFORM_NEEDSTRSEP"],
1842         [AC_MSG_RESULT(no); ISC_PLATFORM_NEEDSTRSEP="#define ISC_PLATFORM_NEEDSTRSEP 1"])
1843 AC_SUBST(ISC_PLATFORM_NEEDSTRSEP)
1844
1845 AC_CHECK_FUNC(memmove,
1846         [ISC_PLATFORM_NEEDMEMMOVE="#undef ISC_PLATFORM_NEEDMEMMOVE"],
1847         [ISC_PLATFORM_NEEDMEMMOVE="#define ISC_PLATFORM_NEEDMEMMOVE 1"])
1848 AC_SUBST(ISC_PLATFORM_NEEDMEMMOVE)
1849
1850 AC_CHECK_FUNC(strtoul,
1851         [ISC_PLATFORM_NEEDSTRTOUL="#undef ISC_PLATFORM_NEEDSTRTOUL"
1852          LWRES_PLATFORM_NEEDSTRTOUL="#undef LWRES_PLATFORM_NEEDSTRTOUL"
1853          GENRANDOMLIB=""],
1854         [ISC_PLATFORM_NEEDSTRTOUL="#define ISC_PLATFORM_NEEDSTRTOUL 1"
1855          LWRES_PLATFORM_NEEDSTRTOUL="#define LWRES_PLATFORM_NEEDSTRTOUL 1"
1856          GENRANDOMLIB='${ISCLIBS}'])
1857 AC_SUBST(ISC_PLATFORM_NEEDSTRTOUL)
1858 AC_SUBST(LWRES_PLATFORM_NEEDSTRTOUL)
1859 AC_SUBST(GENRANDOMLIB)
1860
1861 AC_CHECK_FUNC(strlcpy,
1862         [ISC_PLATFORM_NEEDSTRLCPY="#undef ISC_PLATFORM_NEEDSTRLCPY"],
1863         [ISC_PLATFORM_NEEDSTRLCPY="#define ISC_PLATFORM_NEEDSTRLCPY 1"])
1864 AC_SUBST(ISC_PLATFORM_NEEDSTRLCPY)
1865
1866 AC_CHECK_FUNC(strlcat,
1867         [ISC_PLATFORM_NEEDSTRLCAT="#undef ISC_PLATFORM_NEEDSTRLCAT"],
1868         [ISC_PLATFORM_NEEDSTRLCAT="#define ISC_PLATFORM_NEEDSTRLCAT 1"])
1869 AC_SUBST(ISC_PLATFORM_NEEDSTRLCAT)
1870
1871 ISC_PRINT_OBJS=
1872 ISC_PRINT_SRCS=
1873 AC_MSG_CHECKING(sprintf)
1874 AC_TRY_COMPILE([
1875 #include <stdio.h>
1876 ],
1877 [ char buf[2]; return(*sprintf(buf,"x"));],
1878 [
1879 ISC_PRINT_OBJS="print.$O"
1880 ISC_PRINT_SRCS="print.c"
1881 ISC_PLATFORM_NEEDSPRINTF="#define ISC_PLATFORM_NEEDSPRINTF"
1882 LWRES_PLATFORM_NEEDSPRINTF="#define LWRES_PLATFORM_NEEDSPRINTF"
1883 ],
1884 [ISC_PLATFORM_NEEDSPRINTF="#undef ISC_PLATFORM_NEEDSPRINTF"
1885  LWRES_PLATFORM_NEEDSPRINTF="#undef LWRES_PLATFORM_NEEDSPRINTF"]
1886 )
1887 AC_SUBST(ISC_PLATFORM_NEEDSPRINTF)
1888 AC_SUBST(LWRES_PLATFORM_NEEDSPRINTF)
1889
1890 AC_CHECK_FUNC(vsnprintf,
1891         [ISC_PLATFORM_NEEDVSNPRINTF="#undef ISC_PLATFORM_NEEDVSNPRINTF"
1892          LWRES_PLATFORM_NEEDVSNPRINTF="#undef LWRES_PLATFORM_NEEDVSNPRINTF"],
1893         [ISC_PRINT_OBJS="print.$O"
1894          ISC_PRINT_SRCS="print.c"
1895          ISC_PLATFORM_NEEDVSNPRINTF="#define ISC_PLATFORM_NEEDVSNPRINTF 1"
1896          LWRES_PLATFORM_NEEDVSNPRINTF="#define LWRES_PLATFORM_NEEDVSNPRINTF 1"])
1897 AC_SUBST(ISC_PLATFORM_NEEDVSNPRINTF)
1898 AC_SUBST(LWRES_PLATFORM_NEEDVSNPRINTF)
1899 ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS $ISC_PRINT_OBJS"
1900 ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS $ISC_PRINT_SRCS"
1901
1902 AC_CHECK_FUNC(strerror, AC_DEFINE(HAVE_STRERROR))
1903
1904 AC_SUBST(ISC_EXTRA_OBJS)
1905 AC_SUBST(ISC_EXTRA_SRCS)
1906
1907 #
1908 # Use our own SPNEGO implementation?
1909 #
1910 AC_ARG_ENABLE(isc-spnego,
1911         [  --disable-isc-spnego    use SPNEGO from GSSAPI library])
1912
1913 if test -n "$USE_GSSAPI"
1914 then
1915         case "$enable_isc_spnego" in
1916                 yes|'')
1917                         USE_ISC_SPNEGO='-DUSE_ISC_SPNEGO'
1918                         DST_EXTRA_OBJS="$DST_EXTRA_OBJS spnego.$O"
1919                         DST_EXTRA_SRCS="$DST_EXTRA_SRCS spnego.c"
1920                         AC_MSG_RESULT(using SPNEGO from lib/dns)
1921                         ;;
1922                 no)
1923                         AC_MSG_RESULT(using SPNEGO from GSSAPI library)
1924                         ;;
1925         esac
1926 fi
1927
1928 AC_SUBST(USE_ISC_SPNEGO)
1929
1930 AC_SUBST(DST_EXTRA_OBJS)
1931 AC_SUBST(DST_EXTRA_SRCS)
1932
1933 # Determine the printf format characters to use when printing
1934 # values of type isc_int64_t. This will normally be "ll", but where
1935 # the compiler treats "long long" as a alias for "long" and printf
1936 # doesn't know about "long long" use "l".  Hopefully the sprintf
1937 # will produce a inconsistent result in the later case.  If the compiler
1938 # fails due to seeing "%lld" we fall back to "l".
1939 #
1940 # Digital Unix 4.0 (gcc?) (long long) is 64 bits as is its long. It uses
1941 # %ld even for (long long)/
1942 #
1943 # Win32 uses "%I64d", but that's defined elsewhere since we don't use
1944 # configure on Win32.
1945 #
1946 AC_MSG_CHECKING(printf format modifier for 64-bit integers)
1947 AC_TRY_RUN([
1948 #include <stdio.h>
1949 main() {
1950         long long int j = 0;
1951         char buf[100];
1952         buf[0] = 0;
1953         sprintf(buf, "%lld", j);
1954         exit((sizeof(long long int) != sizeof(long int))? 0 :
1955              (strcmp(buf, "0") != 0));
1956
1957 ],
1958         [AC_MSG_RESULT(ll)
1959         ISC_PLATFORM_QUADFORMAT='#define ISC_PLATFORM_QUADFORMAT "ll"'
1960         LWRES_PLATFORM_QUADFORMAT='#define LWRES_PLATFORM_QUADFORMAT "ll"'],
1961         [AC_MSG_RESULT(l)
1962         ISC_PLATFORM_QUADFORMAT='#define ISC_PLATFORM_QUADFORMAT "l"'
1963         LWRES_PLATFORM_QUADFORMAT='#define LWRES_PLATFORM_QUADFORMAT "l"'],
1964         [AC_MSG_RESULT(assuming target platform uses ll)
1965         ISC_PLATFORM_QUADFORMAT='#define ISC_PLATFORM_QUADFORMAT "ll"'
1966         LWRES_PLATFORM_QUADFORMAT='#define LWRES_PLATFORM_QUADFORMAT "ll"'])
1967 AC_SUBST(ISC_PLATFORM_QUADFORMAT)
1968 AC_SUBST(LWRES_PLATFORM_QUADFORMAT)
1969
1970 #
1971 # Security Stuff
1972 #
1973 # Note it is very recommended to *not* disable chroot(),
1974 # this is only because chroot() was made obsolete by Posix.
1975 AC_ARG_ENABLE(chroot,
1976         [  --disable-chroot        disable chroot])
1977 case "$enable_chroot" in
1978         yes|'')
1979                 AC_CHECK_FUNCS(chroot)
1980                 ;;
1981         no)
1982                 ;;
1983 esac
1984 AC_ARG_ENABLE(linux-caps,
1985         [  --disable-linux-caps   disable linux capabilities])
1986 case "$enable_linux_caps" in
1987         yes|'')
1988                 AC_CHECK_HEADERS(linux/capability.h sys/capability.h)
1989                 AC_CHECK_LIB(cap, cap_set_proc)
1990                 ;;
1991         no)
1992                 ;;
1993 esac
1994 AC_CHECK_HEADERS(sys/prctl.h)
1995
1996 AC_CHECK_HEADERS(sys/un.h,
1997 ISC_PLATFORM_HAVESYSUNH="#define ISC_PLATFORM_HAVESYSUNH 1"
1998 ,
1999 ISC_PLATFORM_HAVESYSUNH="#undef ISC_PLATFORM_HAVESYSUNH"
2000 )
2001 AC_SUBST(ISC_PLATFORM_HAVESYSUNH)
2002
2003 case "$host" in
2004 *-solaris*)
2005         AC_DEFINE(NEED_SECURE_DIRECTORY, 1,
2006                   [Define if connect does not honour the permission on the UNIX domain socket.])
2007         ;;
2008 *-sunos*)
2009         AC_DEFINE(NEED_SECURE_DIRECTORY, 1,
2010                   [Define if connect does not honour the permission on the UNIX domain socket.])
2011         ;;
2012 esac
2013
2014 #
2015 # Time Zone Stuff
2016 #
2017 AC_CHECK_FUNC(tzset, AC_DEFINE(HAVE_TZSET))
2018
2019 AC_MSG_CHECKING(for optarg declaration)
2020 AC_TRY_COMPILE([
2021 #include <unistd.h>
2022 ],
2023 [optarg = 0;],
2024 [AC_MSG_RESULT(yes)],
2025 [AC_MSG_RESULT(no)
2026 GEN_NEED_OPTARG="-DNEED_OPTARG=1"
2027 AC_DEFINE(NEED_OPTARG, 1, [Defined if extern char *optarg is not declared.])])
2028
2029 #
2030 # BSD/OS, and perhaps some others, don't define rlim_t.
2031 #
2032 AC_MSG_CHECKING(for type rlim_t)
2033 AC_TRY_COMPILE([
2034 #include <sys/types.h>
2035 #include <sys/time.h>
2036 #include <sys/resource.h>],
2037 [rlim_t rl = 19671212; return (0);],
2038 [AC_MSG_RESULT(yes)
2039  ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE rlim_t"],
2040 [AC_MSG_RESULT(no)
2041
2042 AC_MSG_CHECKING(type of rlim_cur)
2043 AC_TRY_RUN([
2044 #include <sys/types.h>
2045 #include <sys/time.h>
2046 #include <sys/resource.h>
2047 main() { struct rlimit r; exit(!(sizeof(r.rlim_cur) == sizeof(int)));}],
2048 [AC_MSG_RESULT(int)
2049 ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE int"],
2050 [
2051 AC_TRY_RUN([
2052 #include <sys/types.h>
2053 #include <sys/time.h>
2054 #include <sys/resource.h>
2055 main() { struct rlimit r; exit(!(sizeof(r.rlim_cur) == sizeof(long int)));}],
2056 [AC_MSG_RESULT(long int)
2057 ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE long int"],
2058 [
2059 AC_TRY_RUN([
2060 #include <sys/types.h>
2061 #include <sys/time.h>
2062 #include <sys/resource.h>
2063 main() { struct rlimit r; exit((!sizeof(r.rlim_cur) == sizeof(long long int)));}],
2064 [AC_MSG_RESULT(long long int)
2065 ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE long long int"],
2066 [AC_MSG_ERROR([unable to determine sizeof rlim_cur])
2067 ],[AC_MSG_ERROR(this cannot happen)])
2068 ],[AC_MSG_ERROR(this cannot happen)])
2069 ],[
2070 ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE long long int"
2071 AC_MSG_RESULT(cannot determine type of rlim_cur when cross compiling - assuming long long int)])
2072 ])
2073 AC_SUBST(ISC_PLATFORM_RLIMITTYPE)
2074
2075 #
2076 # Older HP-UX doesn't have gettune
2077 #
2078 case "$host" in
2079         *-hp-hpux*)
2080                 AC_CHECK_HEADERS(sys/dyntune.h)
2081                 ;;
2082         *)
2083                 ;;
2084 esac
2085
2086
2087 #
2088 # Compaq TruCluster requires more code for handling cluster IP aliases
2089 #
2090 case "$host" in
2091         *-dec-osf*)
2092                 AC_CHECK_LIB(clua, clua_getaliasaddress, LIBS="-lclua $LIBS")
2093                 AC_CHECK_FUNC(clua_getaliasaddress,
2094                                 AC_DEFINE(HAVE_TRUCLUSTER, 1,
2095                                         [Define if running under Compaq TruCluster]))
2096                 ;;
2097         *)
2098                 ;;
2099 esac
2100
2101 #
2102 # Some hosts need msg_namelen to match the size of the socket structure.
2103 # Some hosts don't set msg_namelen appropriately on return from recvmsg().
2104 #
2105 case $host in
2106 *os2*|*hp-mpeix*)
2107         AC_DEFINE(BROKEN_RECVMSG, 1,
2108                   [Define if recvmsg() does not meet all of the BSD socket API specifications.])
2109         ;;
2110 esac
2111
2112 #
2113 # Microsoft has their own way of handling shared libraries that requires
2114 # additional qualifiers on extern variables.  Unix systems don't need it.
2115 #
2116 AC_SUBST(ISC_PLATFORM_USEDECLSPEC)
2117 ISC_PLATFORM_USEDECLSPEC="#undef ISC_PLATFORM_USEDECLSPEC"
2118 AC_SUBST(LWRES_PLATFORM_USEDECLSPEC)
2119 LWRES_PLATFORM_USEDECLSPEC="#undef LWRES_PLATFORM_USEDECLSPEC"
2120
2121 #
2122 # Random remaining OS-specific issues involving compiler warnings.
2123 # XXXDCL print messages to indicate some compensation is being done?
2124 #
2125 AC_SUBST(ISC_PLATFORM_BRACEPTHREADONCEINIT)
2126 ISC_PLATFORM_BRACEPTHREADONCEINIT="#undef ISC_PLATFORM_BRACEPTHREADONCEINIT"
2127
2128 case "$host" in
2129         *-aix5.[[123]].*)
2130                 hack_shutup_pthreadonceinit=yes
2131                 ;;
2132         *-bsdi3.1*)
2133                 hack_shutup_sputaux=yes
2134                 ;;
2135         *-bsdi4.0*)
2136                 hack_shutup_sigwait=yes
2137                 hack_shutup_sputaux=yes
2138                 ;;
2139         [*-bsdi4.[12]*])
2140                 hack_shutup_stdargcast=yes
2141                 ;;
2142         [*-solaris2.[89]])
2143                 hack_shutup_pthreadonceinit=yes
2144                 ;;
2145         *-solaris2.1[[0-9]])
2146                 AC_TRY_COMPILE([ #include <pthread.h> ], [ static pthread_once_t once_test = { PTHREAD_ONCE_INIT }; ], [hack_shutup_pthreadonceinit=yes], )
2147                 ;;
2148 esac
2149
2150 case "$hack_shutup_pthreadonceinit" in
2151         yes)
2152                 #
2153                 # Shut up PTHREAD_ONCE_INIT unbraced initializer warnings.
2154                 #
2155                 ISC_PLATFORM_BRACEPTHREADONCEINIT="#define ISC_PLATFORM_BRACEPTHREADONCEINIT 1"
2156                 ;;
2157 esac
2158
2159 case "$hack_shutup_sigwait" in
2160         yes)
2161                 #
2162                 # Shut up a -Wmissing-prototypes warning for sigwait().
2163                 #
2164                 AC_DEFINE(SHUTUP_SIGWAIT)
2165                 ;;
2166 esac
2167
2168 case "$hack_shutup_sputaux" in
2169         yes)
2170                 #
2171                 # Shut up a -Wmissing-prototypes warning from <stdio.h>.
2172                 #
2173                 AC_DEFINE(SHUTUP_SPUTAUX)
2174                 ;;
2175 esac
2176
2177 case "$hack_shutup_stdargcast" in
2178         yes)
2179                 #
2180                 # Shut up a -Wcast-qual warning from va_start().
2181                 #
2182                 AC_DEFINE(SHUTUP_STDARG_CAST)
2183                 ;;
2184 esac
2185
2186 AC_CHECK_HEADERS(strings.h,
2187   ISC_PLATFORM_HAVESTRINGSH="#define ISC_PLATFORM_HAVESTRINGSH 1"
2188 ,
2189   ISC_PLATFORM_HAVESTRINGSH="#undef ISC_PLATFORM_HAVESTRINGSH"
2190 )
2191 AC_SUBST(ISC_PLATFORM_HAVESTRINGSH)
2192
2193 #
2194 # Check for if_nametoindex() for IPv6 scoped addresses support
2195 #
2196 AC_CHECK_FUNC(if_nametoindex, ac_cv_have_if_nametoindex=yes,
2197                 ac_cv_have_if_nametoindex=no)
2198 case $ac_cv_have_if_nametoindex in
2199 no)
2200         case "$host" in
2201         *-hp-hpux*)
2202                 AC_CHECK_LIB(ipv6, if_nametoindex,
2203                                 ac_cv_have_if_nametoindex=yes
2204                                 LIBS="-lipv6 $LIBS",)
2205         ;;
2206         esac
2207 esac
2208 case $ac_cv_have_if_nametoindex in
2209 yes)
2210         ISC_PLATFORM_HAVEIFNAMETOINDEX="#define ISC_PLATFORM_HAVEIFNAMETOINDEX 1"
2211         ;;
2212 *)
2213         ISC_PLATFORM_HAVEIFNAMETOINDEX="#undef ISC_PLATFORM_HAVEIFNAMETOINDEX"
2214         ;;
2215 esac
2216 AC_SUBST(ISC_PLATFORM_HAVEIFNAMETOINDEX)
2217
2218 AC_CHECK_FUNCS(nanosleep)
2219
2220 #
2221 # Machine architecture dependent features
2222 #
2223 AC_ARG_ENABLE(atomic,
2224         [  --enable-atomic        enable machine specific atomic operations
2225                           [[default=autodetect]]],
2226                         enable_atomic="$enableval",
2227                         enable_atomic="autodetect")
2228 case "$enable_atomic" in
2229         yes|''|autodetect)
2230                 case "$host" in
2231                 powerpc-ibm-aix*)
2232                         if test "X$GCC" = "Xyes"; then
2233                                 AC_MSG_CHECKING([if asm("isc"); works])
2234                                 AC_TRY_COMPILE(,[
2235                                 main() { asm("ics"); exit(0); }
2236                                 ],
2237                                 [AC_MSG_RESULT(yes)
2238                                  use_atomic=yes],
2239                                 [
2240                                 saved_cflags="$CFLAGS"
2241                                 CFLAGS="$CFLAGS -Wa,-many"
2242                                 AC_TRY_RUN([
2243                                 main() { asm("ics"); exit(0); }
2244                                 ],
2245                                 [AC_MSG_RESULT([yes, required -Wa,-many])
2246                                  use_atomic=yes],
2247                                 [AC_MSG_RESULT([no, use_atomic disabled])
2248                                  CFLAGS="$saved_cflags"
2249                                  use_atomic=no],
2250                                 [AC_MSG_RESULT([cross compile, assume yes])
2251                                  CFLAGS="$saved_cflags"
2252                                  use_atomic=yes])
2253                                 ]
2254                                 )
2255                         fi
2256                         ;;
2257                 *)
2258                         use_atomic=yes
2259                         ;;
2260                 esac
2261                 ;;
2262         no)
2263                 use_atomic=no
2264                 arch=noatomic
2265                 ;;
2266 esac
2267
2268 ISC_PLATFORM_USEOSFASM="#undef ISC_PLATFORM_USEOSFASM"
2269 if test "$use_atomic" = "yes"; then
2270         AC_MSG_CHECKING([architecture type for atomic operations])
2271         have_atomic=yes         # set default
2272         case "$host" in
2273         [i[3456]86-*])
2274                 # XXX: some old x86 architectures actually do not support
2275                 #      (some of) these operations.  Do we need stricter checks?
2276 AC_TRY_RUN([
2277 main() {
2278         exit((sizeof(void *) == 8) ? 0 : 1);
2279 }
2280 ],
2281                 [arch=x86_64
2282                 have_xaddq=yes],
2283                 [arch=x86_32],
2284                 [arch=x86_32])
2285         ;;
2286         x86_64-*|amd64-*)
2287 AC_TRY_RUN([
2288 main() {
2289        exit((sizeof(void *) == 8) ? 0 : 1);
2290 }
2291 ],
2292                [arch=x86_64
2293                have_xaddq=yes],
2294                [arch=x86_32],
2295                [arch=x86_64
2296                have_xaddq=yes])
2297         ;;
2298         alpha*-*)
2299                 arch=alpha
2300         ;;
2301         powerpc-*)
2302                 arch=powerpc
2303         ;;
2304         mips-*|mipsel-*|mips64-*|mips64el-*)
2305                 arch=mips
2306         ;;
2307         ia64-*)
2308                 arch=ia64
2309         ;;
2310         *)
2311                 have_atomic=no
2312                 arch=noatomic
2313         ;;
2314         esac
2315         AC_MSG_RESULT($arch)
2316 fi
2317
2318 if test "$have_atomic" = "yes"; then
2319         AC_MSG_CHECKING([compiler support for inline assembly code])
2320
2321         compiler=generic
2322         # Check whether the compiler supports the assembly syntax we provide.
2323         if test "X$GCC" = "Xyes"; then
2324                 # GCC's ASM extension always works
2325                 compiler=gcc
2326                 if test $arch = "x86_64"; then
2327                         # We can share the same code for gcc with x86_32
2328                         arch=x86_32
2329                 fi
2330                 if test $arch = "powerpc"; then
2331                         #
2332                         # The MacOS (and maybe others) uses "r0" for register
2333                         # zero. Under linux/ibm it is "0" for register 0.
2334                         # Probe to see if we have a MacOS style assembler.
2335                         #
2336                         AC_MSG_CHECKING([Checking for MacOS style assembler syntax])
2337                         AC_TRY_COMPILE(, [
2338                         __asm__ volatile ("li r0, 0x0\n"::);
2339                         ], [
2340                         AC_MSG_RESULT(yes)
2341                         compiler="mac"
2342                         ISC_PLATFORM_USEMACASM="#define ISC_PLATFORM_USEMACASM 1"
2343                         ], [AC_MSG_RESULT(no)])
2344                 fi
2345         else
2346                 case "$host" in
2347                 alpha*-dec-osf*)
2348                         # Tru64 compiler has its own syntax for inline 
2349                         # assembly.
2350                         AC_TRY_COMPILE(, [
2351 #ifndef __DECC
2352 #error "unexpected compiler"
2353 #endif
2354                                 return (0);],
2355                                 [compiler=osf],)
2356                 ;;
2357                 powerpc-ibm-aix*)
2358                         compiler=aix
2359                 ;;
2360                 esac
2361         fi
2362         case "$compiler" in
2363         gcc)
2364                 ISC_PLATFORM_USEGCCASM="#define ISC_PLATFORM_USEGCCASM 1"
2365                 ;;
2366         osf)
2367                 ISC_PLATFORM_USEOSFASM="#define ISC_PLATFORM_USEOSFASM 1"
2368                 ;;
2369         aix)
2370                 ;;
2371         mac)
2372                 ;;
2373         *)
2374                 # See if the generic __asm function works.  If not,
2375                 # we need to disable the atomic operations.
2376                 AC_TRY_LINK(, [
2377                                         __asm("nop")
2378                                 ],
2379                 [compiler="standard"
2380                 ISC_PLATFORM_USESTDASM="#define ISC_PLATFORM_USESTDASM 1"],
2381                 [compiler="not supported (atomic operations disabled)"
2382                 have_atomic=no
2383                 arch=noatomic ]);
2384                 ;;
2385         esac
2386
2387         AC_MSG_RESULT($compiler)
2388 fi
2389
2390 if test "$have_atomic" = "yes"; then
2391         ISC_PLATFORM_HAVEXADD="#define ISC_PLATFORM_HAVEXADD 1"
2392         ISC_PLATFORM_HAVECMPXCHG="#define ISC_PLATFORM_HAVECMPXCHG 1"
2393         ISC_PLATFORM_HAVEATOMICSTORE="#define ISC_PLATFORM_HAVEATOMICSTORE 1"
2394 else
2395         ISC_PLATFORM_HAVEXADD="#undef ISC_PLATFORM_HAVEXADD"
2396         ISC_PLATFORM_HAVECMPXCHG="#undef ISC_PLATFORM_HAVECMPXCHG"
2397         ISC_PLATFORM_HAVEATOMICSTORE="#undef ISC_PLATFORM_HAVEATOMICSTORE"
2398 fi
2399
2400 if test "$have_xaddq" = "yes"; then
2401         ISC_PLATFORM_HAVEXADDQ="#define ISC_PLATFORM_HAVEXADDQ 1"
2402 else
2403         ISC_PLATFORM_HAVEXADDQ="#undef ISC_PLATFORM_HAVEXADDQ"
2404 fi
2405
2406 AC_SUBST(ISC_PLATFORM_HAVEXADD)
2407 AC_SUBST(ISC_PLATFORM_HAVEXADDQ)
2408 AC_SUBST(ISC_PLATFORM_HAVECMPXCHG)
2409 AC_SUBST(ISC_PLATFORM_HAVEATOMICSTORE)
2410
2411 AC_SUBST(ISC_PLATFORM_USEGCCASM)
2412 AC_SUBST(ISC_PLATFORM_USEOSFASM)
2413 AC_SUBST(ISC_PLATFORM_USESTDASM)
2414 AC_SUBST(ISC_PLATFORM_USEMACASM)
2415
2416 ISC_ARCH_DIR=$arch
2417 AC_SUBST(ISC_ARCH_DIR)
2418
2419 #
2420 # Activate "rrset-order fixed" or not?
2421 #
2422 AC_ARG_ENABLE(fixed-rrset,
2423         [  --enable-fixed-rrset    enable fixed rrset ordering
2424                           [[default=no]]],
2425                         enable_fixed="$enableval",
2426                         enable_fixed="no")
2427 case "$enable_fixed" in
2428         yes)
2429                 AC_DEFINE(DNS_RDATASET_FIXED, 1,
2430                           [Define to enable "rrset-order fixed" syntax.])
2431                 ;;
2432         no)
2433                 ;;
2434         *)
2435                 ;;
2436 esac
2437
2438 #
2439 #  The following sets up how non-blocking i/o is established.
2440 #  Sunos, cygwin and solaris 2.x (x<5) require special handling.
2441 #
2442 case "$host" in
2443 *-sunos*) AC_DEFINE(PORT_NONBLOCK, O_NDELAY);;
2444 *-cygwin*) AC_DEFINE(PORT_NONBLOCK, O_NDELAY);;
2445 *-solaris2.[[01234]])
2446         AC_DEFINE(PORT_NONBLOCK, O_NONBLOCK)
2447         AC_DEFINE(USE_FIONBIO_IOCTL, 1,
2448                   [Defined if you need to use ioctl(FIONBIO) instead a fcntl call to make non-blocking.])
2449         ;;
2450 *) AC_DEFINE(PORT_NONBLOCK, O_NONBLOCK,
2451              [Sets which flag to pass to open/fcntl to make non-blocking (O_NDELAY/O_NONBLOCK).])
2452         ;;
2453 esac
2454 #
2455 # Solaris 2.5.1 and earlier cannot bind() then connect() a TCP socket.
2456 # This prevents the source address being set.
2457 #
2458 case "$host" in
2459 *-solaris2.[[012345]]|*-solaris2.5.1)
2460         AC_DEFINE(BROKEN_TCP_BIND_BEFORE_CONNECT, 1,
2461                   [Define if you cannot bind() before connect() for TCP sockets.])
2462         ;;
2463 esac
2464 #
2465 # The following sections deal with tools used for formatting
2466 # the documentation.  They are all optional, unless you are
2467 # a developer editing the documentation source.
2468 #
2469
2470 #
2471 # Look for TeX.
2472 #
2473
2474 AC_PATH_PROGS(LATEX, latex, latex)
2475 AC_SUBST(LATEX)
2476
2477 AC_PATH_PROGS(PDFLATEX, pdflatex, pdflatex)
2478 AC_SUBST(PDFLATEX)
2479
2480 #
2481 # Look for w3m
2482 #
2483
2484 AC_PATH_PROGS(W3M, w3m, w3m)
2485 AC_SUBST(W3M)
2486
2487 #
2488 # Look for xsltproc (libxslt)
2489 #
2490
2491 AC_PATH_PROG(XSLTPROC, xsltproc, xsltproc)
2492 AC_SUBST(XSLTPROC)
2493
2494 #
2495 # Look for xmllint (libxml2)
2496 #
2497
2498 AC_PATH_PROG(XMLLINT, xmllint, xmllint)
2499 AC_SUBST(XMLLINT)
2500
2501 #
2502 # Look for Doxygen
2503 #
2504
2505 AC_PATH_PROG(DOXYGEN, doxygen, doxygen)
2506 AC_SUBST(DOXYGEN)
2507
2508 #
2509 # Subroutine for searching for an ordinary file (e.g., a stylesheet)
2510 # in a number of directories:
2511 #
2512 #   NOM_PATH_FILE(VARIABLE, FILENAME, DIRECTORIES)
2513 #
2514 # If the file FILENAME is found in one of the DIRECTORIES, the shell
2515 # variable VARIABLE is defined to its absolute pathname.  Otherwise, 
2516 # it is set to FILENAME, with no directory prefix (that's not terribly
2517 # useful, but looks less confusing in substitutions than leaving it
2518 # empty).  The variable VARIABLE will be substituted into output files.
2519
2520
2521 AC_DEFUN(NOM_PATH_FILE, [
2522 $1=""
2523 AC_MSG_CHECKING(for $2)
2524 for d in $3
2525 do
2526         f=$d/$2
2527         if test -f $f
2528         then
2529                 $1=$f
2530                 AC_MSG_RESULT($f)
2531                 break
2532         fi
2533 done
2534 if test "X[$]$1" = "X"
2535 then
2536         AC_MSG_RESULT("not found");
2537         $1=$2
2538 fi
2539 AC_SUBST($1)
2540 ])
2541
2542 #
2543 # Look for Docbook-XSL stylesheets.  Location probably varies by system.
2544 # If it's not explicitly specified, guess where it might be found, based on
2545 # where SGML stuff lives on some systems (FreeBSD is the only one we're sure
2546 # of at the moment).
2547 #
2548 AC_MSG_CHECKING(for Docbook-XSL path)
2549 AC_ARG_WITH(docbook-xsl,
2550 [  --with-docbook-xsl=PATH Specify path for Docbook-XSL stylesheets],
2551    docbook_path="$withval", docbook_path="auto")
2552 case "$docbook_path" in
2553 auto)
2554         AC_MSG_RESULT(auto)
2555         docbook_xsl_trees="/usr/pkg/share/xsl/docbook /usr/local/share/xsl/docbook /usr/share/xsl/docbook"
2556         ;;
2557 *)
2558         docbook_xsl_trees="$withval"
2559         AC_MSG_RESULT($docbook_xsl_trees)
2560         ;;
2561 esac
2562
2563 #
2564 # Look for stylesheets we need.
2565 #
2566
2567 NOM_PATH_FILE(XSLT_DOCBOOK_STYLE_HTML, html/docbook.xsl, $docbook_xsl_trees)
2568 NOM_PATH_FILE(XSLT_DOCBOOK_STYLE_XHTML, xhtml/docbook.xsl, $docbook_xsl_trees)
2569 NOM_PATH_FILE(XSLT_DOCBOOK_STYLE_MAN, manpages/docbook.xsl, $docbook_xsl_trees)
2570 NOM_PATH_FILE(XSLT_DOCBOOK_CHUNK_HTML, html/chunk.xsl, $docbook_xsl_trees)
2571 NOM_PATH_FILE(XSLT_DOCBOOK_CHUNK_XHTML, xhtml/chunk.xsl, $docbook_xsl_trees)
2572 NOM_PATH_FILE(XSLT_DOCBOOK_CHUNKTOC_HTML, html/chunktoc.xsl, $docbook_xsl_trees)
2573 NOM_PATH_FILE(XSLT_DOCBOOK_CHUNKTOC_XHTML, xhtml/chunktoc.xsl, $docbook_xsl_trees)
2574 NOM_PATH_FILE(XSLT_DOCBOOK_MAKETOC_HTML, html/maketoc.xsl, $docbook_xsl_trees)
2575 NOM_PATH_FILE(XSLT_DOCBOOK_MAKETOC_XHTML, xhtml/maketoc.xsl, $docbook_xsl_trees)
2576
2577 #
2578 # Same dance for db2latex
2579 #
2580 # No idea where this lives except on FreeBSD.
2581 #
2582
2583 db2latex_xsl_trees="/usr/local/share"
2584
2585 #
2586 # Look for stylesheets we need.
2587 #
2588
2589 NOM_PATH_FILE(XSLT_DB2LATEX_STYLE, db2latex/xsl/docbook.xsl, $db2latex_xsl_trees)
2590
2591 #
2592 # Look for "admonition" image directory.  Can't use NOM_PATH_FILE()
2593 # because it's a directory, so just do the same things, inline.
2594 #
2595
2596 AC_MSG_CHECKING(for db2latex/xsl/figures)
2597 for d in $db2latex_xsl_trees
2598 do
2599         dd=$d/db2latex/xsl/figures
2600         if test -d $dd
2601         then
2602                 XSLT_DB2LATEX_ADMONITIONS=$dd
2603                 AC_MSG_RESULT($dd)
2604                 break
2605         fi
2606 done
2607 if test "X$XSLT_DB2LATEX_ADMONITIONS" = "X"
2608 then
2609         AC_MSG_RESULT(not found)
2610         XSLT_DB2LATEX_ADMONITIONS=db2latex/xsl/figures
2611 fi
2612 AC_SUBST(XSLT_DB2LATEX_ADMONITIONS)
2613
2614 #
2615 # IDN support
2616 #
2617 AC_ARG_WITH(idn,
2618         [  --with-idn[=MPREFIX]      enable IDN support using idnkit [default PREFIX]],
2619         use_idn="$withval", use_idn="no")
2620 case "$use_idn" in
2621 yes)
2622         if test X$prefix = XNONE ; then
2623                 idn_path=/usr/local
2624         else
2625                 idn_path=$prefix
2626         fi
2627         ;;
2628 no)
2629         ;;
2630 *)
2631         idn_path="$use_idn"
2632         ;;
2633 esac
2634
2635 iconvinc=
2636 iconvlib=
2637 AC_ARG_WITH(libiconv,
2638         [  --with-libiconv[=IPREFIX] GNU libiconv are in IPREFIX [default PREFIX]],
2639         use_libiconv="$withval", use_libiconv="no")
2640 case "$use_libiconv" in
2641 yes)
2642         if test X$prefix = XNONE ; then
2643                 iconvlib="-L/usr/local/lib -R/usr/local/lib -liconv"
2644         else
2645                 iconvlib="-L$prefix/lib -R$prefix/lib -liconv"
2646         fi
2647         ;;
2648 no)
2649         iconvlib=
2650         ;;
2651 *)
2652         iconvlib="-L$use_libiconv/lib -R$use_libiconv/lib -liconv"
2653         ;;
2654 esac
2655
2656 AC_ARG_WITH(iconv,
2657         [  --with-iconv[=LIBSPEC]    specify iconv library [default -liconv]],
2658         iconvlib="$withval")
2659 case "$iconvlib" in
2660 no)
2661         iconvlib=
2662         ;;
2663 yes)
2664         iconvlib=-liconv
2665         ;;
2666 esac
2667
2668 AC_ARG_WITH(idnlib,
2669         [  --with-idnlib=ARG       specify libidnkit],
2670         idnlib="$withval", idnlib="no")
2671 if test "$idnlib" = yes; then
2672         AC_MSG_ERROR([You must specify ARG for --with-idnlib.])
2673 fi
2674
2675 IDNLIBS=
2676 if test "$use_idn" != no; then
2677         AC_DEFINE(WITH_IDN, 1, [define if idnkit support is to be included.])
2678         STD_CINCLUDES="$STD_CINCLUDES -I$idn_path/include"
2679         if test "$idnlib" != no; then
2680                 IDNLIBS="$idnlib $iconvlib"
2681         else
2682                 IDNLIBS="-L$idn_path/lib -lidnkit $iconvlib"
2683         fi
2684 fi
2685 AC_SUBST(IDNLIBS)
2686
2687 AC_CHECK_HEADERS(locale.h)
2688 AC_CHECK_FUNCS(setlocale)
2689
2690 #
2691 # Substitutions
2692 #
2693 AC_SUBST(BIND9_TOP_BUILDDIR)
2694 BIND9_TOP_BUILDDIR=`pwd`
2695
2696 AC_SUBST(BIND9_ISC_BUILDINCLUDE)
2697 AC_SUBST(BIND9_ISCCC_BUILDINCLUDE)
2698 AC_SUBST(BIND9_ISCCFG_BUILDINCLUDE)
2699 AC_SUBST(BIND9_DNS_BUILDINCLUDE)
2700 AC_SUBST(BIND9_LWRES_BUILDINCLUDE)
2701 AC_SUBST(BIND9_BIND9_BUILDINCLUDE)
2702 if test "X$srcdir" != "X"; then
2703         BIND9_ISC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isc/include"
2704         BIND9_ISCCC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isccc/include"
2705         BIND9_ISCCFG_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isccfg/include"
2706         BIND9_DNS_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/dns/include"
2707         BIND9_LWRES_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/lwres/include"
2708         BIND9_BIND9_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/bind9/include"
2709 else
2710         BIND9_ISC_BUILDINCLUDE=""
2711         BIND9_ISCCC_BUILDINCLUDE=""
2712         BIND9_ISCCFG_BUILDINCLUDE=""
2713         BIND9_DNS_BUILDINCLUDE=""
2714         BIND9_LWRES_BUILDINCLUDE=""
2715         BIND9_BIND9_BUILDINCLUDE=""
2716 fi
2717
2718 AC_SUBST_FILE(BIND9_MAKE_INCLUDES)
2719 BIND9_MAKE_INCLUDES=$BIND9_TOP_BUILDDIR/make/includes
2720
2721 AC_SUBST_FILE(BIND9_MAKE_RULES)
2722 BIND9_MAKE_RULES=$BIND9_TOP_BUILDDIR/make/rules
2723
2724 . $srcdir/version
2725 BIND9_VERSION="VERSION=${MAJORVER}.${MINORVER}${PATCHVER:+.}${PATCHVER}${RELEASETYPE}${RELEASEVER}"
2726 AC_SUBST(BIND9_VERSION)
2727
2728 if test -z "$ac_configure_args"; then
2729         BIND9_CONFIGARGS="defaults"
2730 else
2731         for a in $ac_configure_args
2732         do
2733                 BIND9_CONFIGARGS="$BIND9_CONFIGARGS $a"
2734         done
2735 fi
2736 BIND9_CONFIGARGS="`echo $BIND9_CONFIGARGS | sed 's/^ //'`"
2737 BIND9_CONFIGARGS="CONFIGARGS=${BIND9_CONFIGARGS}"
2738 AC_SUBST(BIND9_CONFIGARGS)
2739
2740 AC_SUBST_FILE(LIBISC_API)
2741 LIBISC_API=$srcdir/lib/isc/api
2742
2743 AC_SUBST_FILE(LIBISCCC_API)
2744 LIBISCCC_API=$srcdir/lib/isccc/api
2745
2746 AC_SUBST_FILE(LIBISCCFG_API)
2747 LIBISCCFG_API=$srcdir/lib/isccfg/api
2748
2749 AC_SUBST_FILE(LIBDNS_API)
2750 LIBDNS_API=$srcdir/lib/dns/api
2751
2752 AC_SUBST_FILE(LIBBIND9_API)
2753 LIBBIND9_API=$srcdir/lib/bind9/api
2754
2755 AC_SUBST_FILE(LIBLWRES_API)
2756 LIBLWRES_API=$srcdir/lib/lwres/api
2757
2758 #
2759 # Configure any DLZ drivers.
2760 #
2761 # If config.dlz.in selects one or more DLZ drivers, it will set
2762 # USE_DLZ to a non-empty value, which will be our clue to
2763 # enable the DLZ core functions.
2764 #
2765 # This section has to come after the libtool stuff because it needs to
2766 # know how to name the driver object files.
2767 #
2768
2769 USE_DLZ=""
2770 DLZ_DRIVER_INCLUDES=""
2771 DLZ_DRIVER_LIBS=""
2772 DLZ_DRIVER_SRCS=""
2773 DLZ_DRIVER_OBJS=""
2774
2775 sinclude(contrib/dlz/config.dlz.in)
2776
2777 AC_MSG_CHECKING(for DLZ)
2778
2779 if test -n "$USE_DLZ"
2780 then
2781         AC_MSG_RESULT(yes)
2782         USE_DLZ="-DDLZ $USE_DLZ"
2783         DLZ_DRIVER_RULES=contrib/dlz/drivers/rules
2784         AC_CONFIG_FILES([$DLZ_DRIVER_RULES])
2785 else
2786         AC_MSG_RESULT(no)
2787         DLZ_DRIVER_RULES=/dev/null
2788 fi
2789
2790 AC_SUBST(USE_DLZ)
2791 AC_SUBST(DLZ_DRIVER_INCLUDES)
2792 AC_SUBST(DLZ_DRIVER_LIBS)
2793 AC_SUBST(DLZ_DRIVER_SRCS)
2794 AC_SUBST(DLZ_DRIVER_OBJS)
2795 AC_SUBST_FILE(DLZ_DRIVER_RULES)
2796
2797 if test "$cross_compiling" = "yes"; then
2798         if test -z "$BUILD_CC"; then
2799                 AC_ERROR([BUILD_CC not set])
2800         fi
2801         BUILD_CFLAGS="$BUILD_CFLAGS"
2802         BUILD_CPPFLAGS="$BUILD_CPPFLAGS"
2803         BUILD_LDFLAGS="$BUILD_LDFLAGS"
2804         BUILD_LIBS="$BUILD_LIBS"
2805 else
2806         BUILD_CC="$CC" 
2807         BUILD_CFLAGS="$CFLAGS" 
2808         BUILD_CPPFLAGS="$CPPFLAGS $GEN_NEED_OPTARG"
2809         BUILD_LDFLAGS="$LDFLAGS"
2810         BUILD_LIBS="$LIBS"
2811 fi
2812
2813 NEWFLAGS=""
2814 for e in $BUILD_LDFLAGS ; do
2815     case $e in
2816         -L*)
2817             case $host_os in
2818                 netbsd*)
2819                     ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
2820                     NEWFLAGS="$NEWFLAGS $e $ee"
2821                     ;;
2822                 freebsd*)
2823                     ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
2824                     NEWFLAGS="$NEWFLAGS $e $ee"
2825                     ;;
2826                 solaris*)
2827                     ee=`echo $e | sed -e 's%^-L%-R%'`
2828                     NEWFLAGS="$NEWFLAGS $e $ee"
2829                     ;;
2830                 *)
2831                     NEWFLAGS="$NEWFLAGS $e"
2832                     ;;
2833                 esac
2834             ;;
2835         *)
2836             NEWFLAGS="$NEWFLAGS $e"
2837             ;;
2838     esac
2839 done
2840 BUILD_LDFLAGS="$NEWFLAGS"
2841
2842 NEWFLAGS=""
2843 for e in $DNS_GSSAPI_LIBS ; do
2844     case $e in
2845         -L*)
2846             case $host_os in
2847                 netbsd*)
2848                     ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
2849                     NEWFLAGS="$NEWFLAGS $e $ee"
2850                     ;;
2851                 freebsd*)
2852                     ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
2853                     NEWFLAGS="$NEWFLAGS $e $ee"
2854                     ;;
2855                 solaris*)
2856                     ee=`echo $e | sed -e 's%^-L%-R%'`
2857                     NEWFLAGS="$NEWFLAGS $e $ee"
2858                     ;;
2859                 *)
2860                     NEWFLAGS="$NEWFLAGS $e"
2861                     ;;
2862                 esac
2863             ;;
2864         *)
2865             NEWFLAGS="$NEWFLAGS $e"
2866             ;;
2867     esac
2868 done
2869 DNS_GSSAPI_LIBS="$NEWFLAGS"
2870
2871 NEWFLAGS=""
2872 for e in $DNS_CRYPTO_LIBS ; do
2873     case $e in
2874         -L*)
2875             case $host_os in
2876                 netbsd*)
2877                     ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
2878                     NEWFLAGS="$NEWFLAGS $e $ee"
2879                     ;;
2880                 freebsd*)
2881                     ee=`echo $e | sed -e 's%^-L%-Wl,-rpath,%'`
2882                     NEWFLAGS="$NEWFLAGS $e $ee"
2883                     ;;
2884                 solaris*)
2885                     ee=`echo $e | sed -e 's%^-L%-R%'`
2886                     NEWFLAGS="$NEWFLAGS $e $ee"
2887                     ;;
2888                 *)
2889                     NEWFLAGS="$NEWFLAGS $e"
2890                     ;;
2891                 esac
2892             ;;
2893         *)
2894             NEWFLAGS="$NEWFLAGS $e"
2895             ;;
2896     esac
2897 done
2898 DNS_CRYPTO_LIBS="$NEWFLAGS"
2899
2900 AC_SUBST(BUILD_CC)
2901 AC_SUBST(BUILD_CFLAGS)
2902 AC_SUBST(BUILD_CPPFLAGS)
2903 AC_SUBST(BUILD_LDFLAGS)
2904 AC_SUBST(BUILD_LIBS)
2905
2906 #
2907 # Commands to run at the end of config.status.
2908 # Don't just put these into configure, it won't work right if somebody
2909 # runs config.status directly (which autoconf allows).
2910 #
2911
2912 AC_CONFIG_COMMANDS(
2913         [chmod],
2914         [chmod a+x isc-config.sh doc/doxygen/doxygen-input-filter])
2915
2916 #
2917 # Files to configure.  These are listed here because we used to
2918 # specify them as arguments to AC_OUTPUT.  It's (now) ok to move these
2919 # elsewhere if there's a good reason for doing so.
2920 #
2921
2922 AC_CONFIG_FILES([
2923         Makefile
2924         make/Makefile
2925         make/mkdep
2926         lib/Makefile
2927         lib/isc/Makefile
2928         lib/isc/include/Makefile
2929         lib/isc/include/isc/Makefile
2930         lib/isc/include/isc/platform.h
2931         lib/isc/unix/Makefile
2932         lib/isc/unix/include/Makefile
2933         lib/isc/unix/include/isc/Makefile
2934         lib/isc/nls/Makefile
2935         lib/isc/$thread_dir/Makefile
2936         lib/isc/$thread_dir/include/Makefile
2937         lib/isc/$thread_dir/include/isc/Makefile
2938         lib/isc/$arch/Makefile
2939         lib/isc/$arch/include/Makefile
2940         lib/isc/$arch/include/isc/Makefile
2941         lib/isccc/Makefile
2942         lib/isccc/include/Makefile
2943         lib/isccc/include/isccc/Makefile
2944         lib/isccfg/Makefile
2945         lib/isccfg/include/Makefile
2946         lib/isccfg/include/isccfg/Makefile
2947         lib/dns/Makefile
2948         lib/dns/include/Makefile
2949         lib/dns/include/dns/Makefile
2950         lib/dns/include/dst/Makefile
2951         lib/bind9/Makefile
2952         lib/bind9/include/Makefile
2953         lib/bind9/include/bind9/Makefile
2954         lib/lwres/Makefile
2955         lib/lwres/include/Makefile
2956         lib/lwres/include/lwres/Makefile
2957         lib/lwres/include/lwres/netdb.h
2958         lib/lwres/include/lwres/platform.h
2959         lib/lwres/man/Makefile
2960         lib/lwres/unix/Makefile
2961         lib/lwres/unix/include/Makefile
2962         lib/lwres/unix/include/lwres/Makefile
2963         lib/tests/Makefile
2964         lib/tests/include/Makefile
2965         lib/tests/include/tests/Makefile
2966         bin/Makefile
2967         bin/check/Makefile
2968         bin/named/Makefile
2969         bin/named/unix/Makefile
2970         bin/rndc/Makefile
2971         bin/rndc/unix/Makefile
2972         bin/dig/Makefile
2973         bin/nsupdate/Makefile
2974         bin/tests/Makefile
2975         bin/tests/names/Makefile
2976         bin/tests/master/Makefile
2977         bin/tests/rbt/Makefile
2978         bin/tests/db/Makefile
2979         bin/tests/tasks/Makefile
2980         bin/tests/timers/Makefile
2981         bin/tests/dst/Makefile
2982         bin/tests/mem/Makefile
2983         bin/tests/net/Makefile
2984         bin/tests/sockaddr/Makefile
2985         bin/tests/system/Makefile
2986         bin/tests/system/conf.sh
2987         bin/tests/system/lwresd/Makefile
2988         bin/tests/system/tkey/Makefile
2989         bin/tests/headerdep_test.sh
2990         bin/dnssec/Makefile
2991         doc/Makefile
2992         doc/arm/Makefile
2993         doc/misc/Makefile
2994         isc-config.sh
2995         doc/xsl/Makefile
2996         doc/xsl/isc-docbook-chunk.xsl
2997         doc/xsl/isc-docbook-html.xsl
2998         doc/xsl/isc-docbook-latex.xsl
2999         doc/xsl/isc-manpage.xsl
3000         doc/doxygen/Doxyfile
3001         doc/doxygen/Makefile
3002         doc/doxygen/doxygen-input-filter
3003 ])
3004
3005 #
3006 # Do it
3007 #
3008
3009 AC_OUTPUT
3010
3011 if test "X$USE_OPENSSL" = "X"; then
3012 cat << \EOF                                                             
3013 BIND is being built without OpenSSL. This means it will not have DNSSEC support.
3014 EOF
3015 fi
3016
3017 if test "X$OPENSSL_WARNING" != "X"; then
3018 cat << \EOF
3019 WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
3020 WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
3021 WARNING                                                                 WARNING
3022 WARNING         Your OpenSSL crypto library may be vulnerable to        WARNING
3023 WARNING         one or more of the the following known security         WARNING
3024 WARNING         flaws:                                                  WARNING
3025 WARNING                                                                 WARNING
3026 WARNING         CAN-2002-0659, CAN-2006-4339, CVE-2006-2937 and         WARNING
3027 WARNING         CVE-2006-2940.                                          WARNING
3028 WARNING                                                                 WARNING
3029 WARNING         It is recommended that you upgrade to OpenSSL           WARNING
3030 WARNING         version 0.9.8d/0.9.7l (or greater).                     WARNING
3031 WARNING                                                                 WARNING
3032 WARNING         You can disable this warning by specifying:             WARNING
3033 WARNING                                                                 WARNING
3034 WARNING               --disable-openssl-version-check                   WARNING
3035 WARNING                                                                 WARNING
3036 WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
3037 WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
3038 EOF
3039 fi
3040
3041 # Tell Emacs to edit this file in shell mode.
3042 # Local Variables:
3043 # mode: sh
3044 # End: