]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bind9/configure.in
This commit was generated by cvs2svn to compensate for changes in r141098,
[FreeBSD/FreeBSD.git] / contrib / bind9 / configure.in
1 # Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
2 # Copyright (C) 1998-2003  Internet Software Consortium.
3 #
4 # Permission to use, copy, modify, and 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.294.2.23.2.30 $)
22
23 AC_INIT(lib/dns/name.c)
24 AC_PREREQ(2.13)
25
26 AC_CONFIG_HEADER(config.h)
27 AC_CONFIG_SUBDIRS(lib/bind)
28
29 AC_CANONICAL_HOST
30
31 AC_PROG_MAKE_SET
32 AC_PROG_RANLIB
33 AC_PROG_INSTALL
34
35 AC_SUBST(STD_CINCLUDES)
36 AC_SUBST(STD_CDEFINES)
37 AC_SUBST(STD_CWARNINGS)
38 AC_SUBST(CCOPT)
39
40 AC_PATH_PROG(AR, ar)
41 ARFLAGS="cruv"
42 AC_SUBST(AR)
43 AC_SUBST(ARFLAGS)
44
45 # The POSIX ln(1) program.  Non-POSIX systems may substitute
46 # "copy" or something.
47 LN=ln
48 AC_SUBST(LN)
49
50 case "$AR" in
51         "")
52                 AC_MSG_ERROR([
53 ar program not found.  Please fix your PATH to include the directory in
54 which ar resides, or set AR in the environment with the full path to ar.
55 ])
56
57                 ;;
58 esac
59
60 #
61 # Etags.
62 #
63 AC_PATH_PROGS(ETAGS, etags emacs-etags)
64
65 #
66 # Some systems, e.g. RH7, have the Exuberant Ctags etags instead of
67 # GNU emacs etags, and it requires the -L flag.
68 #
69 if test "X$ETAGS" != "X"; then
70         AC_MSG_CHECKING(for Exuberant Ctags etags)
71         if $ETAGS --version 2>&1 | grep 'Exuberant Ctags' >/dev/null 2>&1; then
72                 AC_MSG_RESULT(yes)
73                 ETAGS="$ETAGS -L"
74         else
75                 AC_MSG_RESULT(no)
76         fi
77 fi
78 AC_SUBST(ETAGS)
79
80 #
81 # Perl is optional; it is used only by some of the system test scripts.
82 #
83 AC_PATH_PROGS(PERL, perl5 perl)
84 AC_SUBST(PERL)
85
86 #
87 # Special processing of paths depending on whether --prefix,
88 # --sysconfdir or --localstatedir arguments were given.  What's
89 # desired is some compatibility with the way previous versions
90 # of BIND built; they defaulted to /usr/local for most parts of
91 # the installation, but named.boot/named.conf was in /etc
92 # and named.pid was in /var/run.
93 #
94 # So ... if none of --prefix, --sysconfdir or --localstatedir are
95 # specified, set things up that way.  If --prefix is given, use
96 # it for sysconfdir and localstatedir the way configure normally
97 # would.  To change the prefix for everything but leave named.conf
98 # in /etc or named.pid in /var/run, then do this the usual configure way:
99 # ./configure --prefix=/somewhere --sysconfdir=/etc
100 # ./configure --prefix=/somewhere --localstatedir=/var
101 #
102 # To put named.conf and named.pid in /usr/local with everything else,
103 # set the prefix explicitly to /usr/local even though that's the default:
104 # ./configure --prefix=/usr/local
105 #
106 case "$prefix" in
107         NONE)
108                 case "$sysconfdir" in
109                         '${prefix}/etc')
110                                 sysconfdir=/etc
111                                 ;;
112                 esac
113                 case "$localstatedir" in
114                         '${prefix}/var')
115                                 localstatedir=/var
116                                 ;;
117                 esac
118                 ;;
119 esac
120
121 #
122 # Make sure INSTALL uses an absolute path, else it will be wrong in all
123 # Makefiles, since they use make/rules.in and INSTALL will be adjusted by
124 # configure based on the location of the file where it is substituted.
125 # Since in BIND9 INSTALL is only substituted into make/rules.in, an immediate
126 # subdirectory of install-sh, This relative path will be wrong for all
127 # directories more than one level down from install-sh.
128 #
129 case "$INSTALL" in
130         /*)
131                 ;;
132         *)
133                 #
134                 # Not all systems have dirname.
135                 #
136                 changequote({, })
137                 ac_dir="`echo $INSTALL | sed 's%/[^/]*$%%'`"
138                 changequote([, ])
139
140                 ac_prog="`echo $INSTALL | sed 's%.*/%%'`"
141                 test "$ac_dir" = "$ac_prog" && ac_dir=.
142                 test -d "$ac_dir" && ac_dir="`(cd \"$ac_dir\" && pwd)`"
143                 INSTALL="$ac_dir/$ac_prog"
144                 ;;
145 esac
146
147 #
148 # On these hosts, we really want to use cc, not gcc, even if it is
149 # found.  The gcc that these systems have will not correctly handle
150 # pthreads.
151 #
152 # However, if the user sets $CC to be something, let that override
153 # our change.
154 #
155 if test "X$CC" = "X" ; then
156         case "$host" in
157                 *-dec-osf*)
158                         CC="cc"
159                         ;;
160                 *-solaris*)
161                         # Use Sun's cc if it is available, but watch
162                         # out for /usr/ucb/cc; it will never be the right
163                         # compiler to use.
164                         #
165                         # If setting CC here fails, the AC_PROG_CC done
166                         # below might still find gcc.
167                         IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS=":"
168                         for ac_dir in $PATH; do
169                                 test -z "$ac_dir" && ac_dir=.
170                                 case "$ac_dir" in
171                                 /usr/ucb)
172                                         # exclude
173                                         ;;
174                                 *)
175                                         if test -f "$ac_dir/cc"; then
176                                                 CC="$ac_dir/cc"
177                                                 break
178                                         fi
179                                         ;;
180                                 esac
181                         done
182                         IFS="$ac_save_ifs"
183                         ;;
184                 *-hp-hpux*)
185                         CC="cc"
186                         ;;
187                 mips-sgi-irix*)
188                         CC="cc"
189                         ;;
190         esac
191 fi
192
193 AC_PROG_CC
194
195 #
196 # gcc's optimiser is broken at -02 for ultrasparc
197 #
198 if test "$ac_env_CFLAGS_set" != set -a "X$GCC" = "Xyes"; then
199         case "$host" in
200         sparc-*)
201                 CCFLAGS="-g -O1"
202                 ;;
203         esac
204 fi
205
206 #
207 # OS dependent CC flags
208 #
209 case "$host" in
210         # OSF 5.0: recv/send are only avaliable with -D_POSIX_PII_SOCKET or
211         # -D_XOPEN_SOURCE_EXTENDED.
212         *-dec-osf*)
213                 STD_CDEFINES="$STD_CDEFINES -D_POSIX_PII_SOCKET"
214                 CPPFLAGS="$CPPFLAGS -D_POSIX_PII_SOCKET"
215                 ;;
216         #HP-UX: need -D_XOPEN_SOURCE_EXTENDED and -lxnet for CMSG macros
217         *-hp-hpux*)
218                 STD_CDEFINES="$STD_CDEFINES -D_XOPEN_SOURCE_EXTENDED"
219                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
220                 LIBS="-lxnet $LIBS"
221                 ;;
222         # Solaris: need -D_XPG4_2 and -D__EXTENSIONS__ for CMSG macros
223         *-solaris*)
224                 STD_CDEFINES="$STD_CDEFINES -D_XPG4_2 -D__EXTENSIONS__"
225                 CPPFLAGS="$CPPFLAGS -D_XPG4_2 -D__EXTENSIONS__"
226                 ;;
227 esac
228
229 AC_HEADER_STDC
230
231 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,,,
232 [$ac_includes_default
233 #ifdef HAVE_SYS_PARAM_H
234 # include <sys/param.h>
235 #endif
236 ])
237
238 AC_C_CONST
239 AC_C_INLINE
240 AC_CHECK_FUNC(sysctlbyname, AC_DEFINE(HAVE_SYSCTLBYNAME))
241
242 #
243 # UnixWare 7.1.1 with the feature supplement to the UDK compiler
244 # is reported to not support "static inline" (RT #1212).
245 #
246 AC_MSG_CHECKING(for static inline breakage)
247 AC_TRY_COMPILE(, [
248                 foo1();
249         }
250
251         static inline int foo1() {
252                 return 0;
253         }
254
255         static inline int foo2() {
256                 return foo1();
257         ],
258         [AC_MSG_RESULT(no)],
259         [AC_MSG_RESULT(yes)
260          AC_DEFINE(inline, )])
261
262 AC_TYPE_SIZE_T
263 AC_CHECK_TYPE(ssize_t, int)
264 AC_HEADER_TIME
265 AC_MSG_CHECKING(for long long)
266 AC_TRY_COMPILE([],[long long i = 0; return (0);],
267         [AC_MSG_RESULT(yes)
268                 ISC_PLATFORM_HAVELONGLONG="#define ISC_PLATFORM_HAVELONGLONG 1"],
269         [AC_MSG_RESULT(no)
270                 ISC_PLATFORM_HAVELONGLONG="#undef ISC_PLATFORM_HAVELONGLONG"])
271 AC_SUBST(ISC_PLATFORM_HAVELONGLONG)
272
273 #
274 # check if we have lifconf
275 #
276 AC_MSG_CHECKING(for struct lifconf)
277 AC_TRY_COMPILE([
278 #include <sys/types.h>
279 #include <sys/socket.h>
280 #include <net/if.h>
281 ],
282 [
283 struct lifconf lifconf;
284 lifconf.lifc_len = 0;
285 ]
286 ,
287         [AC_MSG_RESULT(yes)
288                 ISC_PLATFORM_HAVELIFCONF="#define ISC_PLATFORM_HAVELIFCONF 1"],
289         [AC_MSG_RESULT(no)
290                 ISC_PLATFORM_HAVELIFCONF="#undef ISC_PLATFORM_HAVELIFCONF"])
291 AC_SUBST(ISC_PLATFORM_HAVELIFCONF)
292
293
294 #
295 # check if we need to #include sys/select.h explicitly
296 #
297 case $ac_cv_header_unistd_h in
298 yes)
299 AC_MSG_CHECKING(if unistd.h or sys/types.h defines fd_set)
300 AC_TRY_COMPILE([
301 #include <sys/types.h> /* Ultrix */
302 #include <unistd.h>],
303 [fd_set read_set; return (0);],
304         [AC_MSG_RESULT(yes)
305          ISC_PLATFORM_NEEDSYSSELECTH="#undef ISC_PLATFORM_NEEDSYSSELECTH"
306          LWRES_PLATFORM_NEEDSYSSELECTH="#undef LWRES_PLATFORM_NEEDSYSSELECTH"],
307         [AC_MSG_RESULT(no)
308         case $ac_cv_header_sys_select_h in
309         yes)
310          ISC_PLATFORM_NEEDSYSSELECTH="#define ISC_PLATFORM_NEEDSYSSELECTH 1"
311          LWRES_PLATFORM_NEEDSYSSELECTH="#define LWRES_PLATFORM_NEEDSYSSELECTH 1"
312                 ;;
313         no)
314                 AC_MSG_ERROR([need either working unistd.h or sys/select.h])
315                 ;;
316         esac
317         ])
318         ;;
319 no)
320         case $ac_cv_header_sys_select_h in
321         yes)
322              ISC_PLATFORM_NEEDSYSSELECTH="#define ISC_PLATFORM_NEEDSYSSELECTH 1"
323              LWRES_PLATFORM_NEEDSYSSELECTH="#define LWRES_PLATFORM_NEEDSYSSELECTH 1"
324                 ;;
325         no)
326                 AC_MSG_ERROR([need either unistd.h or sys/select.h])
327                 ;;
328         esac
329         ;;
330 esac
331 AC_SUBST(ISC_PLATFORM_NEEDSYSSELECTH)
332 AC_SUBST(LWRES_PLATFORM_NEEDSYSSELECTH)
333
334 #
335 # Find the machine's endian flavor.
336 #
337 AC_C_BIGENDIAN
338
339 #
340 # was --with-openssl specified?
341 #
342 AC_MSG_CHECKING(for OpenSSL library)
343 AC_ARG_WITH(openssl,
344 [  --with-openssl[=PATH]   Build with OpenSSL [yes|no|path].
345                           (Required for DNSSEC)],
346     use_openssl="$withval", use_openssl="auto")
347
348 case "$use_openssl" in
349         no)
350                 AC_MSG_RESULT(no)
351                 DST_OPENSSL_INC=""
352                 USE_OPENSSL=""
353                 ;;
354         *)
355                 if test "$use_openssl" = "yes" -o "$use_openssl" = "auto"
356                 then
357                         # User did not specify a path - guess it
358                         openssldirs="/usr /usr/local /usr/local/ssl /usr/pkg"
359                         for d in $openssldirs
360                         do
361                                 if test -f $d/include/openssl/opensslv.h
362                                 then
363                                         use_openssl=$d
364                                         break
365                                 fi
366                         done
367                         if test "$use_openssl" = "yes"
368                         then
369                                 AC_MSG_RESULT(not found)
370                                 AC_MSG_ERROR(
371 [OpenSSL was not found in any of $openssldirs; use --with-openssl=/path])
372                         elif test "$use_openssl" = "auto"
373                         then
374                                 DST_OPENSSL_INC=""
375                                 USE_OPENSSL=""
376                                 AC_MSG_RESULT(not found)
377                                 break
378                         fi
379                 fi
380                 USE_OPENSSL='-DOPENSSL'
381                 if test "$use_openssl" = "/usr"
382                 then
383                         DST_OPENSSL_INC=""
384                         DNS_OPENSSL_LIBS="-lcrypto"
385                 else
386                         DST_OPENSSL_INC="-I$use_openssl/include"
387                         case $host in
388                         *-solaris*)
389                                 DNS_OPENSSL_LIBS="-L$use_openssl/lib -R$use_openssl/lib -lcrypto"
390                                 ;;
391                         *)
392                                 DNS_OPENSSL_LIBS="-L$use_openssl/lib -lcrypto"
393                                 ;;
394                         esac
395                 fi
396                 AC_MSG_RESULT(using openssl from $use_openssl/lib and $use_openssl/include)
397
398                 saved_cflags="$CFLAGS"
399                 saved_libs="$LIBS"
400                 CFLAGS="$CFLAGS $DST_OPENSSL_INC"
401                 LIBS="$LIBS $DNS_OPENSSL_LIBS"
402                 AC_MSG_CHECKING(whether linking with OpenSSL works)
403                 AC_TRY_RUN([
404 #include <openssl/err.h>
405 int main() {
406         ERR_clear_error();
407         return (0);
408 }
409 ],
410                 [AC_MSG_RESULT(yes)],
411                 [AC_MSG_RESULT(no)
412                  AC_MSG_ERROR(Could not run test program using OpenSSL from
413 $use_openssl/lib and $use_openssl/include.
414 Please check the argument to --with-openssl and your
415 shared library configuration (e.g., LD_LIBRARY_PATH).)],
416                 [AC_MSG_RESULT(assuming it does work on target platform)])
417
418                 AC_MSG_CHECKING(whether linking with OpenSSL requires -ldl)
419                 AC_TRY_LINK([
420 #include <openssl/err.h>],
421 [ DSO_METHOD_dlfcn(); ],
422                 [AC_MSG_RESULT(no)],
423                 [LIBS="$LIBS -ldl"
424                 AC_TRY_LINK([
425 #include <openssl/err.h>
426 ],[ DSO_METHOD_dlfcn(); ],
427                 [AC_MSG_RESULT(yes)
428                 DNS_OPENSSL_LIBS="$DNS_OPENSSL_LIBS -ldl"
429                 ],
430                  [AC_MSG_RESULT(unknown)
431                  AC_MSG_ERROR(OpenSSL has unsupported dynamic loading)],
432                 [AC_MSG_RESULT(assuming it does work on target platform)])
433                 ],
434                 [AC_MSG_RESULT(assuming it does work on target platform)]
435                 )
436                  
437 #
438 #       OpenSSLDie is new with CERT CS-2002-23.  If we see it we have may
439 #       have a patched library otherwise check that we are greater than
440 #       the fixed versions
441 #
442                 AC_CHECK_FUNC(OpenSSLDie,
443                 AC_MSG_CHECKING(OpenSSL library version)
444                 AC_TRY_RUN([
445 #include <stdio.h>
446 #include <openssl/opensslv.h>
447 int main() {
448         if (OPENSSL_VERSION_NUMBER >= 0x0090581fL)
449                 return (0);
450         printf("\n\nFound   OPENSSL_VERSION_NUMBER %#010x\n",
451                 OPENSSL_VERSION_NUMBER);
452         printf("Require OPENSSL_VERSION_NUMBER 0x0090581f or greater\n\n");
453         return (1);
454 }
455 ],
456                 [AC_MSG_RESULT(ok)],
457                 [AC_MSG_RESULT(not compatible)
458                  AC_MSG_ERROR(you need OpenSSL 0.9.5a or newer)],
459                 [AC_MSG_RESULT(assuming target platform has compatible version)])
460                 ,
461                 AC_MSG_RESULT(did not find fixes for CERT CA-2002-23)
462                 AC_MSG_CHECKING(OpenSSL library version)
463                 AC_TRY_RUN([
464 #include <stdio.h>
465 #include <openssl/opensslv.h>
466 int main() {
467         if ((OPENSSL_VERSION_NUMBER >= 0x0090605fL &&
468              OPENSSL_VERSION_NUMBER < 0x009070000L) ||
469              OPENSSL_VERSION_NUMBER >= 0x00907003L)
470                 return (0);
471         printf("\n\nFound   OPENSSL_VERSION_NUMBER %#010x\n",
472                 OPENSSL_VERSION_NUMBER);
473         printf("Require OPENSSL_VERSION_NUMBER 0x0090605f or greater (0.9.6e)\n"
474                "Require OPENSSL_VERSION_NUMBER 0x00907003 or greater (0.9.7-beta2)\n\n");
475         return (1);
476 }
477 ],
478                 [AC_MSG_RESULT(ok)],
479                 [AC_MSG_RESULT(not compatible)
480                  AC_MSG_ERROR(you need OpenSSL 0.9.6e/0.9.7-beta2 (or newer): CERT CA-2002-23)],
481                 [AC_MSG_RESULT(assuming target platform has compatible version)]))
482                 AC_MSG_CHECKING(for OpenSSL DSA support)
483                 if test -f $use_openssl/include/openssl/dsa.h
484                 then
485                         AC_DEFINE(HAVE_OPENSSL_DSA)
486                         AC_MSG_RESULT(yes)
487                 else
488                         AC_MSG_RESULT(no)
489                 fi
490                 CFLAGS="$saved_cflags"
491                 LIBS="$saved_libs"
492                 ;;
493 esac
494
495 #
496 # This would include the system openssl path (and linker options to use
497 # it as needed) if it is found.
498 #
499
500 AC_SUBST(USE_OPENSSL)
501 AC_SUBST(DST_OPENSSL_INC)
502 DNS_CRYPTO_LIBS="$DNS_CRYPTO_LIBS $DNS_OPENSSL_LIBS"
503
504 #
505 # was --with-gssapi specified?
506 #
507 #AC_MSG_CHECKING(for GSSAPI library)
508 #AC_ARG_WITH(gssapi,
509 #[  --with-gssapi=PATH   Specify path for system-supplied GSSAPI],
510 #    use_gssapi="$withval", use_gssapi="no")
511 #
512 #case "$use_gssapi" in
513 #       no)
514 #               USE_GSSAPI=''
515 #               DST_GSSAPI_INC=''
516 #               DNS_GSSAPI_LIBS=''
517 #               AC_MSG_RESULT(not specified)
518 #               ;;
519 #       yes)
520 #               AC_MSG_ERROR([--with-gssapi must specify a path])
521 #               ;;
522 #       *)
523 #               USE_GSSAPI='-DGSSAPI'
524 #               DST_GSSAPI_INC="-I$use_gssapi/include"
525 #               DNS_GSSAPI_LIBS="-L$use_gssapi/lib -lgssapi_krb5"
526 #               AC_MSG_RESULT(using gssapi from $use_gssapi/lib and $use_gssapi/include)
527 #               ;;
528 #esac
529
530 USE_GSSAPI=''
531 DST_GSSAPI_INC=''
532 DNS_GSSAPI_LIBS=''
533
534 AC_SUBST(USE_GSSAPI)
535 AC_SUBST(DST_GSSAPI_INC)
536 DNS_CRYPTO_LIBS="$DNS_CRYPTO_LIBS $DNS_GSSAPI_LIBS"
537
538 #
539 # Applications linking with libdns also need to link with these libraries.
540 #
541
542 AC_SUBST(DNS_CRYPTO_LIBS)
543
544 #
545 # was --with-randomdev specified?
546 #
547 AC_MSG_CHECKING(for random device)
548 AC_ARG_WITH(randomdev,
549 [  --with-randomdev=PATH Specify path for random device],
550     use_randomdev="$withval", use_randomdev="unspec")
551
552 case "$use_randomdev" in
553         unspec)
554                 case "$host" in
555                         *-openbsd*)
556                                 devrandom=/dev/arandom
557                                 ;;
558                         *)
559                                 devrandom=/dev/random
560                                 ;;
561                 esac
562                 AC_MSG_RESULT($devrandom)
563                 AC_CHECK_FILE($devrandom,
564                               AC_DEFINE_UNQUOTED(PATH_RANDOMDEV,
565                                                  "$devrandom"),)
566                 ;;
567         yes)
568                 AC_MSG_ERROR([--with-randomdev must specify a path])
569                 ;;
570         no)
571                 AC_MSG_RESULT(disabled)
572                 ;;
573         *)
574                 AC_DEFINE_UNQUOTED(PATH_RANDOMDEV, "$use_randomdev")
575                 AC_MSG_RESULT(using "$use_randomdev")
576                 ;;
577 esac
578
579 #
580 # Do we have arc4random() ?
581 #
582 AC_CHECK_FUNC(arc4random, AC_DEFINE(HAVE_ARC4RANDOM))
583
584 #
585 # Begin pthreads checking.
586 #
587 # First, decide whether to use multithreading or not.
588 #
589 # Enable multithreading by default on systems where it is known
590 # to work well, and where debugging of multithreaded programs
591 # is supported.
592 #
593
594 AC_MSG_CHECKING(whether to build with thread support)
595
596 case $host in
597 *-dec-osf*)
598         use_threads=true ;;
599 [*-solaris2.[0-6]])
600         # Thread signals are broken on Solaris 2.6; they are sometimes
601         # delivered to the wrong thread.
602         use_threads=false ;;
603 *-solaris*)
604         use_threads=true ;;
605 *-ibm-aix*)
606         use_threads=true ;;
607 *-hp-hpux10*)
608         use_threads=false ;;
609 *-hp-hpux11*)
610         use_threads=true ;;
611 *-sgi-irix*)
612         use_threads=true ;;
613 *-sco-sysv*uw*|*-*-sysv*UnixWare*)
614         # UnixWare
615         use_threads=false ;;
616 *-*-sysv*OpenUNIX*)
617         # UnixWare
618         use_threads=true ;;
619 *-netbsd*)
620         if test -r /usr/lib/libpthread.so ; then
621             use_threads=true
622         else
623             # Socket I/O optimizations introduced in 9.2 expose a
624             # bug in unproven-pthreads; see PR #12650
625             use_threads=false
626         fi
627         ;;
628 *-openbsd*)
629         # OpenBSD users have reported that named dumps core on
630         # startup when built with threads.
631         use_threads=false ;;
632 *-freebsd*)
633         use_threads=false ;;
634 *-bsdi[234]*)
635         # Thread signals do not work reliably on some versions of BSD/OS.
636         use_threads=false ;;
637 *-bsdi5*)
638         use_threads=true ;;
639 *-linux*)
640         # Threads are disabled on Linux by default because most
641         # Linux kernels produce unusable core dumps from multithreaded
642         # programs, and because of limitations in setuid().
643         use_threads=false ;;    
644 *)
645         use_threads=false ;;
646 esac
647
648 AC_ARG_ENABLE(threads,
649         [  --enable-threads     enable multithreading])
650 case "$enable_threads" in
651         yes)
652                 use_threads=true
653                 ;;
654         no)
655                 use_threads=false
656                 ;;
657         '')
658                 # Use system-dependent default
659                 ;;
660         *)
661                 AC_MSG_ERROR([--enable-threads takes yes or no])
662                 ;;
663 esac
664
665 if $use_threads
666 then
667         AC_MSG_RESULT(yes)
668 else
669         AC_MSG_RESULT(no)       
670 fi
671
672 if $use_threads
673 then
674         #
675         # Search for / configure pthreads in a system-dependent fashion.
676         #
677         case "$host" in
678           *-netbsd*)
679                 # NetBSD has multiple pthreads implementations.  The
680                 # recommended one to use is "unproven-pthreads".  The
681                 # older "mit-pthreads" may also work on some NetBSD
682                 # versions.  The PTL2 thread library does not
683                 # currently work with bind9, but can be chosen with
684                 # the --with-ptl2 option for those who wish to
685                 # experiment with it.
686                 CC="gcc"
687                 AC_MSG_CHECKING(which NetBSD thread library to use)
688
689                 AC_ARG_WITH(ptl2,
690 [  --with-ptl2          on NetBSD, use the ptl2 thread library (experimental)],
691                     use_ptl2="$withval", use_ptl2="no")
692
693                 : ${LOCALBASE:=/usr/pkg}
694
695                 if test "X$use_ptl2" = "Xyes"
696                 then
697                         AC_MSG_RESULT(PTL2)
698                         AC_MSG_WARN(
699 [linking with PTL2 is highly experimental and not expected to work])
700                         CC=ptlgcc
701                 else
702                         if test -r /usr/lib/libpthread.so
703                         then
704                                 AC_MSG_RESULT(native)
705                                 LIBS="-lpthread $LIBS"
706                         else
707                                 if test ! -d $LOCALBASE/pthreads
708                                 then
709                                         AC_MSG_RESULT(none)
710                                         AC_MSG_ERROR("could not find thread libraries")
711                                 fi
712
713                                 if $use_threads
714                                 then
715                                         AC_MSG_RESULT(mit-pthreads/unproven-pthreads)
716                                         pkg="$LOCALBASE/pthreads"
717                                         lib1="-L$pkg/lib -Wl,-R$pkg/lib"
718                                         lib2="-lpthread -lm -lgcc -lpthread"
719                                         LIBS="$lib1 $lib2 $LIBS"
720                                         CPPFLAGS="$CPPFLAGS -I$pkg/include"
721                                         STD_CINCLUDES="$STD_CINCLUDES -I$pkg/include"
722                                 fi
723                         fi
724                 fi
725                 ;;
726                 *)
727                         AC_CHECK_LIB(pthread, pthread_create,,
728                                 AC_CHECK_LIB(pthread, __pthread_create,,
729                                 AC_CHECK_LIB(pthread, __pthread_create_system,,
730                                 AC_CHECK_LIB(c_r, pthread_create,,
731                                 AC_CHECK_LIB(c, pthread_create,,
732                                 AC_MSG_ERROR("could not find thread libraries"))))))
733                 ;;
734         esac
735 fi
736
737 if $use_threads
738 then
739         #
740         # We'd like to use sigwait() too
741         #
742         AC_CHECK_LIB(c, sigwait,
743                      AC_DEFINE(HAVE_SIGWAIT),
744                      AC_CHECK_LIB(pthread, sigwait,
745                                   AC_DEFINE(HAVE_SIGWAIT),
746                                   AC_CHECK_LIB(pthread, _Psigwait,
747                                                AC_DEFINE(HAVE_SIGWAIT),))
748         )
749
750         AC_CHECK_FUNC(pthread_attr_getstacksize,
751                       AC_DEFINE(HAVE_PTHREAD_ATTR_GETSTACKSIZE),)
752
753         AC_CHECK_FUNC(pthread_attr_setstacksize,
754                       AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACKSIZE),)
755
756         #
757         # Additional OS-specific issues related to pthreads and sigwait.
758         #
759         case "$host" in
760                 #
761                 # One more place to look for sigwait.
762                 #
763                 *-freebsd*)
764                         AC_CHECK_LIB(c_r, sigwait, AC_DEFINE(HAVE_SIGWAIT),)
765                         ;;
766                 #
767                 # BSDI 3.0 through 4.0.1 needs pthread_init() to be
768                 # called before certain pthreads calls.  This is deprecated
769                 # in BSD/OS 4.1.
770                 #
771                 *-bsdi3.*|*-bsdi4.0*)
772                         AC_DEFINE(NEED_PTHREAD_INIT)
773                         ;;
774                 #
775                 # LinuxThreads requires some changes to the way we
776                 # deal with signals.
777                 #
778                 *-linux*)
779                         AC_DEFINE(HAVE_LINUXTHREADS)
780                         ;;
781                 #
782                 # Ensure the right sigwait() semantics on Solaris and make
783                 # sure we call pthread_setconcurrency.
784                 #
785                 *-solaris*)
786                         AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
787                         AC_CHECK_FUNC(pthread_setconcurrency,
788                                       AC_DEFINE(CALL_PTHREAD_SETCONCURRENCY))
789                         ;;
790                 #
791                 # UnixWare does things its own way.
792                 #
793                 *-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
794                         AC_DEFINE(HAVE_UNIXWARE_SIGWAIT)
795                         ;;
796         esac
797
798         #
799         # Look for sysconf to allow detection of the number of processors.
800         #
801         AC_CHECK_FUNC(sysconf, AC_DEFINE(HAVE_SYSCONF),)
802
803         if test "X$GCC" = "Xyes"; then
804                 case "$host" in
805                 *-freebsd*)
806                         CC="$CC -pthread"
807                         CCOPT="$CCOPT -pthread"
808                         STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
809                         ;;
810                 *-openbsd*)
811                         CC="$CC -pthread"
812                         CCOPT="$CCOPT -pthread"
813                         ;;
814                 *-solaris*)
815                         LIBS="$LIBS -lthread"
816                         ;;
817                 *-ibm-aix*)
818                         STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
819                         ;;
820                 esac
821         else
822                 case $host in
823                 *-dec-osf*)
824                         CC="$CC -pthread"
825                         CCOPT="$CCOPT -pthread"
826                         ;;
827                 *-solaris*)
828                         CC="$CC -mt"
829                         CCOPT="$CCOPT -mt"
830                         ;;
831                 *-ibm-aix*)
832                         STD_CDEFINES="$STD_CDEFINES -D_THREAD_SAFE"
833                         ;;
834                 *-sco-sysv*uw*|*-*-sysv*UnixWare*)
835                         CC="$CC -Kthread"
836                         CCOPT="$CCOPT -Kthread"
837                         ;;
838                 *-*-sysv*OpenUNIX*)
839                         CC="$CC -Kpthread"
840                         CCOPT="$CCOPT -Kpthread"
841                         ;;
842                 esac
843         fi
844         ALWAYS_DEFINES="-D_REENTRANT"
845         ISC_PLATFORM_USETHREADS="#define ISC_PLATFORM_USETHREADS 1"
846         thread_dir=pthreads
847 else
848         ISC_PLATFORM_USETHREADS="#undef ISC_PLATFORM_USETHREADS"
849         thread_dir=nothreads
850         ALWAYS_DEFINES=""
851 fi
852
853 AC_SUBST(ALWAYS_DEFINES)
854 AC_SUBST(ISC_PLATFORM_USETHREADS)
855
856 ISC_THREAD_DIR=$thread_dir
857 AC_SUBST(ISC_THREAD_DIR)
858
859 #
860 # In solaris 10, SMF can manage named service
861 #
862 AC_CHECK_LIB(scf, smf_enable_instance)
863
864 #
865 # flockfile is usually provided by pthreads, but we may want to use it
866 # even if compiled with --disable-threads.  getc_unlocked might also not
867 # be defined.
868 #
869 AC_CHECK_FUNC(flockfile, AC_DEFINE(HAVE_FLOCKFILE),)
870 AC_CHECK_FUNC(getc_unlocked, AC_DEFINE(HAVE_GETCUNLOCKED),)
871
872
873 # Indicate what the final decision was regarding threads.
874 #
875 AC_MSG_CHECKING(whether to build with threads)
876 if $use_threads; then
877         AC_MSG_RESULT(yes)
878 else
879         AC_MSG_RESULT(no)
880 fi
881
882
883 # End of pthreads stuff.
884 #
885
886 #
887 # Large File
888 #
889 AC_ARG_ENABLE(largefile, [  --enable-largefile    64-bit file support],
890               want_largefile="yes", want_largefile="no")
891 case $want_largefile in
892         yes)
893                 ALWAYS_DEFINES="$ALWAYS_DEFINES -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
894                 ;;
895         *)
896                 ;;
897 esac
898
899 #
900 # Additional compiler settings.
901 #
902 MKDEPCC="$CC"
903 MKDEPCFLAGS="-M"
904 IRIX_DNSSEC_WARNINGS_HACK=""
905
906 if test "X$GCC" = "Xyes"; then
907         STD_CWARNINGS="$STD_CWARNINGS -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat"
908 else
909         case $host in
910         *-dec-osf*)
911                 CC="$CC -std"
912                 CCOPT="$CCOPT -std"
913                 MKDEPCC="$CC"
914                 ;;
915         *-hp-hpux*)
916                 CC="$CC -Ae -z"
917                 # The version of the C compiler that constantly warns about
918                 # 'const' as well as alignment issues is unfortunately not
919                 # able to be discerned via the version of the operating
920                 # system, nor does cc have a version flag.
921                 case "`$CC +W 123 2>&1`" in
922                 *Unknown?option*)
923                         STD_CWARNINGS="+w1"
924                         ;;
925                 *)
926                         # Turn off the pointlessly noisy warnings.
927                         STD_CWARNINGS="+w1 +W 474,530"
928                         ;;
929                 esac
930                 CCOPT="$CCOPT -Ae -z"
931                 LIBS="-Wl,+vnocompatwarnings $LIBS"
932                 MKDEPPROG='cc -Ae -E -Wp,-M >/dev/null 2>>$TMP'
933                 ;;
934         *-sgi-irix*)
935                 STD_CWARNINGS="-fullwarn -woff 1209"
936                 #
937                 # Silence more than 250 instances of
938                 #   "prototyped function redeclared without prototype"
939                 # and 11 instances of
940                 #   "variable ... was set but never used"
941                 # from lib/dns/sec/openssl.
942                 #
943                 IRIX_DNSSEC_WARNINGS_HACK="-woff 1692,1552"
944                 ;;
945         *-solaris*)
946                 MKDEPCFLAGS="-xM"
947                 ;;
948         *-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
949                 # UnixWare
950                 CC="$CC -w"
951                 ;;
952         esac
953 fi
954
955 AC_SUBST(MKDEPCC)
956 AC_SUBST(MKDEPCFLAGS)
957 AC_SUBST(MKDEPPROG)
958 AC_SUBST(IRIX_DNSSEC_WARNINGS_HACK)
959
960 #
961 # NLS
962 #
963 AC_CHECK_FUNC(catgets, AC_DEFINE(HAVE_CATGETS),)
964
965 #
966 # -lxnet buys us one big porting headache...  standards, gotta love 'em.
967 #
968 # AC_CHECK_LIB(xnet, socket, ,
969 #    AC_CHECK_LIB(socket, socket)
970 #    AC_CHECK_LIB(nsl, inet_ntoa)
971 # )
972 #
973 # Use this for now, instead:
974 #
975 case "$host" in
976         mips-sgi-irix*)
977                 ;;
978         *)
979                 AC_CHECK_LIB(socket, socket)
980                 AC_CHECK_LIB(nsl, inet_ntoa)
981                 ;;
982 esac
983
984 #
985 # Purify support
986 #
987 AC_MSG_CHECKING(whether to use purify)
988 AC_ARG_WITH(purify,
989         [  --with-purify[=PATH] use Rational purify],
990         use_purify="$withval", use_purify="no")
991
992 case "$use_purify" in
993         no)
994                 ;;
995         yes)
996                 AC_PATH_PROG(purify_path, purify, purify)
997                 ;;
998         *)
999                 purify_path="$use_purify"
1000                 ;;
1001 esac
1002
1003 case "$use_purify" in
1004         no)
1005                 AC_MSG_RESULT(no)
1006                 PURIFY=""
1007                 ;;
1008         *)
1009                 if test -f $purify_path || test $purify_path = purify; then
1010                         AC_MSG_RESULT($purify_path)
1011                         PURIFYFLAGS="`echo $PURIFYOPTIONS`"
1012                         PURIFY="$purify_path $PURIFYFLAGS"
1013                 else
1014                         AC_MSG_ERROR([$purify_path not found.
1015
1016 Please choose the proper path with the following command:
1017
1018     configure --with-purify=PATH
1019 ])
1020                 fi
1021                 ;;
1022 esac
1023
1024 AC_SUBST(PURIFY)
1025
1026 #
1027 # GNU libtool support
1028 #
1029 AC_ARG_WITH(libtool,
1030             [  --with-libtool   use GNU libtool (following indented options supported)],
1031             use_libtool="$withval", use_libtool="no")
1032
1033 case $use_libtool in
1034         yes)
1035                 AM_PROG_LIBTOOL
1036                 O=lo
1037                 A=la
1038                 LIBTOOL_MKDEP_SED='s;\.o;\.lo;'
1039                 LIBTOOL_MODE_COMPILE='--mode=compile'
1040                 LIBTOOL_MODE_INSTALL='--mode=install'
1041                 LIBTOOL_MODE_LINK='--mode=link'
1042                 ;;
1043         *)
1044                 O=o
1045                 A=a
1046                 LIBTOOL=
1047                 AC_SUBST(LIBTOOL)
1048                 LIBTOOL_MKDEP_SED=
1049                 LIBTOOL_MODE_COMPILE=
1050                 LIBTOOL_MODE_INSTALL=
1051                 LIBTOOL_MODE_LINK=
1052                 ;;
1053 esac
1054
1055 #
1056 # File name extension for static archive files, for those few places
1057 # where they are treated differently from dynamic ones.
1058 #
1059 SA=a
1060
1061 AC_SUBST(O)
1062 AC_SUBST(A)
1063 AC_SUBST(SA)
1064 AC_SUBST(LIBTOOL_MKDEP_SED)
1065 AC_SUBST(LIBTOOL_MODE_COMPILE)
1066 AC_SUBST(LIBTOOL_MODE_INSTALL)
1067 AC_SUBST(LIBTOOL_MODE_LINK)
1068
1069 #
1070 # build libbind?
1071 #
1072 AC_ARG_ENABLE(libbind,
1073         [  --enable-libbind             build libbind [default=no]])
1074
1075 case "$enable_libbind" in
1076         yes)
1077                 LIBBIND=lib/bind
1078                 AC_SUBST(LIBBIND)
1079                 ;;
1080         no|'')
1081                 ;;
1082 esac
1083
1084 #
1085 # Here begins a very long section to determine the system's networking
1086 # capabilities.  The order of the tests is signficant.
1087 #
1088
1089 #
1090 # IPv6
1091 #
1092 AC_ARG_ENABLE(ipv6,
1093         [  --enable-ipv6                use IPv6 [default=autodetect]])
1094
1095 case "$enable_ipv6" in
1096         yes|''|autodetect)
1097                 AC_DEFINE(WANT_IPV6)
1098                 ;;
1099         no)
1100                 ;;
1101 esac
1102
1103 #
1104 # We do the IPv6 compilation checking after libtool so that we can put
1105 # the right suffix on the files.
1106 #
1107 AC_MSG_CHECKING(for IPv6 structures)
1108 AC_TRY_COMPILE([
1109 #include <sys/types.h>
1110 #include <sys/socket.h>
1111 #include <netinet/in.h>],
1112 [struct sockaddr_in6 sin6; return (0);],
1113         [AC_MSG_RESULT(yes)
1114          found_ipv6=yes],
1115         [AC_MSG_RESULT(no)
1116          found_ipv6=no])
1117
1118 #
1119 # See whether IPv6 support is provided via a Kame add-on.
1120 # This is done before other IPv6 linking tests to LIBS is properly set.
1121 #
1122 AC_MSG_CHECKING(for Kame IPv6 support)
1123 AC_ARG_WITH(kame,
1124         [  --with-kame[=PATH]   use Kame IPv6 [default path /usr/local/v6]],
1125         use_kame="$withval", use_kame="no")
1126
1127 case "$use_kame" in
1128         no)
1129                 ;;
1130         yes)
1131                 kame_path=/usr/local/v6
1132                 ;;
1133         *)
1134                 kame_path="$use_kame"
1135                 ;;
1136 esac
1137
1138 case "$use_kame" in
1139         no)
1140                 AC_MSG_RESULT(no)
1141                 ;;
1142         *)
1143                 if test -f $kame_path/lib/libinet6.a; then
1144                         AC_MSG_RESULT($kame_path/lib/libinet6.a)
1145                         LIBS="-L$kame_path/lib -linet6 $LIBS"
1146                 else
1147                         AC_MSG_ERROR([$kame_path/lib/libinet6.a not found.
1148
1149 Please choose the proper path with the following command:
1150
1151     configure --with-kame=PATH
1152 ])
1153                 fi
1154                 ;;
1155 esac
1156
1157 #
1158 # Whether netinet6/in6.h is needed has to be defined in isc/platform.h.
1159 # Including it on Kame-using platforms is very bad, though, because
1160 # Kame uses #error against direct inclusion.   So include it on only
1161 # the platform that is otherwise broken without it -- BSD/OS 4.0 through 4.1.
1162 # This is done before the in6_pktinfo check because that's what
1163 # netinet6/in6.h is needed for.
1164 #
1165 changequote({, })
1166 case "$host" in
1167 *-bsdi4.[01]*)
1168         ISC_PLATFORM_NEEDNETINET6IN6H="#define ISC_PLATFORM_NEEDNETINET6IN6H 1"
1169         LWRES_PLATFORM_NEEDNETINET6IN6H="#define LWRES_PLATFORM_NEEDNETINET6IN6H 1"
1170         isc_netinet6in6_hack="#include <netinet6/in6.h>"
1171         ;;
1172 *)
1173         ISC_PLATFORM_NEEDNETINET6IN6H="#undef ISC_PLATFORM_NEEDNETINET6IN6H"
1174         LWRES_PLATFORM_NEEDNETINET6IN6H="#undef LWRES_PLATFORM_NEEDNETINET6IN6H"
1175         isc_netinet6in6_hack=""
1176         ;;
1177 esac
1178 changequote([, ])
1179
1180 #
1181 # This is similar to the netinet6/in6.h issue.
1182 #
1183 case "$host" in
1184 *-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
1185         # UnixWare
1186         ISC_PLATFORM_NEEDNETINETIN6H="#define ISC_PLATFORM_NEEDNETINETIN6H 1"
1187         LWRES_PLATFORM_NEEDNETINETIN6H="#define LWRES_PLATFORM_NEEDNETINETIN6H 1"
1188         ISC_PLATFORM_FIXIN6ISADDR="#define ISC_PLATFORM_FIXIN6ISADDR 1"
1189         isc_netinetin6_hack="#include <netinet/in6.h>"
1190         ;;
1191 *)
1192         ISC_PLATFORM_NEEDNETINETIN6H="#undef ISC_PLATFORM_NEEDNETINETIN6H"
1193         LWRES_PLATFORM_NEEDNETINETIN6H="#undef LWRES_PLATFORM_NEEDNETINETIN6H"
1194         ISC_PLATFORM_FIXIN6ISADDR="#undef ISC_PLATFORM_FIXIN6ISADDR"
1195         isc_netinetin6_hack=""
1196         ;;
1197 esac
1198
1199 #
1200 # Now delve deeper into the suitability of the IPv6 support.
1201 #
1202 case "$found_ipv6" in
1203         yes)
1204                 ISC_PLATFORM_HAVEIPV6="#define ISC_PLATFORM_HAVEIPV6 1"
1205                 LWRES_PLATFORM_HAVEIPV6="#define LWRES_PLATFORM_HAVEIPV6 1"
1206
1207                 AC_MSG_CHECKING(for in6_addr)
1208                 AC_TRY_COMPILE([
1209 #include <sys/types.h>
1210 #include <sys/socket.h>
1211 #include <netinet/in.h>
1212 $isc_netinetin6_hack
1213 $isc_netinet6in6_hack
1214 ],
1215 [struct in6_addr in6; return (0);],
1216                 [AC_MSG_RESULT(yes)
1217                  ISC_PLATFORM_HAVEINADDR6="#undef ISC_PLATFORM_HAVEINADDR6"
1218                  LWRES_PLATFORM_HAVEINADDR6="#undef LWRES_PLATFORM_HAVEINADDR6"
1219                  isc_in_addr6_hack=""],
1220                 [AC_MSG_RESULT(no)
1221                  ISC_PLATFORM_HAVEINADDR6="#define ISC_PLATFORM_HAVEINADDR6 1"
1222                  LWRES_PLATFORM_HAVEINADDR6="#define LWRES_PLATFORM_HAVEINADDR6 1"
1223                  isc_in_addr6_hack="#define in6_addr in_addr6"])
1224
1225                 AC_MSG_CHECKING(for in6addr_any)
1226                 AC_TRY_LINK([
1227 #include <sys/types.h>
1228 #include <sys/socket.h>
1229 #include <netinet/in.h>
1230 $isc_netinetin6_hack
1231 $isc_netinet6in6_hack
1232 $isc_in_addr6_hack
1233 ],
1234                 [struct in6_addr in6; in6 = in6addr_any; return (in6.s6_addr[0]);],
1235                         [AC_MSG_RESULT(yes)
1236                          ISC_PLATFORM_NEEDIN6ADDRANY="#undef ISC_PLATFORM_NEEDIN6ADDRANY"
1237                          LWRES_PLATFORM_NEEDIN6ADDRANY="#undef LWRES_PLATFORM_NEEDIN6ADDRANY"],
1238                         [AC_MSG_RESULT(no)
1239                          ISC_PLATFORM_NEEDIN6ADDRANY="#define ISC_PLATFORM_NEEDIN6ADDRANY 1"
1240                          LWRES_PLATFORM_NEEDIN6ADDRANY="#define LWRES_PLATFORM_NEEDIN6ADDRANY 1"])
1241
1242                 AC_MSG_CHECKING(for in6addr_loopback)
1243                 AC_TRY_LINK([
1244 #include <sys/types.h>
1245 #include <sys/socket.h>
1246 #include <netinet/in.h>
1247 $isc_netinetin6_hack
1248 $isc_netinet6in6_hack
1249 $isc_in_addr6_hack
1250 ],
1251                 [struct in6_addr in6; in6 = in6addr_loopback; return (in6.s6_addr[0]);],
1252                         [AC_MSG_RESULT(yes)
1253                          ISC_PLATFORM_NEEDIN6ADDRLOOPBACK="#undef ISC_PLATFORM_NEEDIN6ADDRLOOPBACK"
1254                          LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK="#undef LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK"],
1255                         [AC_MSG_RESULT(no)
1256                          ISC_PLATFORM_NEEDIN6ADDRLOOPBACK="#define ISC_PLATFORM_NEEDIN6ADDRLOOPBACK 1"
1257                          LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK="#define LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK 1"])
1258
1259                 AC_MSG_CHECKING(for sin6_scope_id in struct sockaddr_in6)
1260                 AC_TRY_COMPILE([
1261 #include <sys/types.h>
1262 #include <sys/socket.h>
1263 #include <netinet/in.h>
1264 $isc_netinetin6_hack
1265 $isc_netinet6in6_hack
1266 ],
1267                 [struct sockaddr_in6 xyzzy; xyzzy.sin6_scope_id = 0; return (0);],
1268                         [AC_MSG_RESULT(yes)
1269                          ISC_PLATFORM_HAVESCOPEID="#define ISC_PLATFORM_HAVESCOPEID 1"
1270                          result="#define LWRES_HAVE_SIN6_SCOPE_ID 1"],
1271                         [AC_MSG_RESULT(no)
1272                          ISC_PLATFORM_HAVESCOPEID="#undef ISC_PLATFORM_HAVESCOPEID"
1273                          result="#undef LWRES_HAVE_SIN6_SCOPE_ID"])
1274                 LWRES_HAVE_SIN6_SCOPE_ID="$result"
1275
1276                 AC_MSG_CHECKING(for in6_pktinfo)
1277                 AC_TRY_COMPILE([
1278 #include <sys/types.h>
1279 #include <sys/socket.h>
1280 #include <netinet/in.h>
1281 $isc_netinetin6_hack
1282 $isc_netinet6in6_hack
1283 ],
1284                 [struct in6_pktinfo xyzzy; return (0);],
1285                         [AC_MSG_RESULT(yes)
1286                          ISC_PLATFORM_HAVEIN6PKTINFO="#define ISC_PLATFORM_HAVEIN6PKTINFO 1"],
1287                         [AC_MSG_RESULT(no -- disabling runtime ipv6 support)
1288                          ISC_PLATFORM_HAVEIN6PKTINFO="#undef ISC_PLATFORM_HAVEIN6PKTINFO"])
1289                 ;;
1290         no)
1291                 ISC_PLATFORM_HAVEIPV6="#undef ISC_PLATFORM_HAVEIPV6"
1292                 LWRES_PLATFORM_HAVEIPV6="#undef LWRES_PLATFORM_HAVEIPV6"
1293                 ISC_PLATFORM_NEEDIN6ADDRANY="#undef ISC_PLATFORM_NEEDIN6ADDRANY"
1294                 LWRES_PLATFORM_NEEDIN6ADDRANY="#undef LWRES_PLATFORM_NEEDIN6ADDRANY"
1295                 ISC_PLATFORM_HAVEIN6PKTINFO="#undef ISC_PLATFORM_HAVEIN6PKTINFO"
1296                 LWRES_HAVE_SIN6_SCOPE_ID="#define LWRES_HAVE_SIN6_SCOPE_ID 1"
1297                 ISC_PLATFORM_HAVESCOPEID="#define ISC_PLATFORM_HAVESCOPEID 1"
1298                 ISC_IPV6_H="ipv6.h"
1299                 ISC_IPV6_O="ipv6.$O"
1300                 ISC_ISCIPV6_O="unix/ipv6.$O"
1301                 ISC_IPV6_C="ipv6.c"
1302                 ;;
1303 esac
1304
1305 AC_SUBST(ISC_PLATFORM_HAVEIPV6)
1306 AC_SUBST(LWRES_PLATFORM_HAVEIPV6)
1307 AC_SUBST(ISC_PLATFORM_NEEDNETINETIN6H)
1308 AC_SUBST(LWRES_PLATFORM_NEEDNETINETIN6H)
1309 AC_SUBST(ISC_PLATFORM_NEEDNETINET6IN6H)
1310 AC_SUBST(LWRES_PLATFORM_NEEDNETINET6IN6H)
1311 AC_SUBST(ISC_PLATFORM_HAVEINADDR6)
1312 AC_SUBST(LWRES_PLATFORM_HAVEINADDR6)
1313 AC_SUBST(ISC_PLATFORM_NEEDIN6ADDRANY)
1314 AC_SUBST(LWRES_PLATFORM_NEEDIN6ADDRANY)
1315 AC_SUBST(ISC_PLATFORM_NEEDIN6ADDRLOOPBACK)
1316 AC_SUBST(LWRES_PLATFORM_NEEDIN6ADDRLOOPBACK)
1317 AC_SUBST(ISC_PLATFORM_HAVEIN6PKTINFO)
1318 AC_SUBST(ISC_PLATFORM_FIXIN6ISADDR)
1319 AC_SUBST(ISC_IPV6_H)
1320 AC_SUBST(ISC_IPV6_O)
1321 AC_SUBST(ISC_ISCIPV6_O)
1322 AC_SUBST(ISC_IPV6_C)
1323 AC_SUBST(LWRES_HAVE_SIN6_SCOPE_ID)
1324 AC_SUBST(ISC_PLATFORM_HAVESCOPEID)
1325
1326 AC_MSG_CHECKING([for struct if_laddrreq])
1327 AC_TRY_LINK([
1328 #include <sys/types.h>
1329 #include <net/if6.h>
1330 ],[ struct if_laddrreq a; ],
1331         [AC_MSG_RESULT(yes)
1332         ISC_PLATFORM_HAVEIF_LADDRREQ="#define ISC_PLATFORM_HAVEIF_LADDRREQ 1"],
1333         [AC_MSG_RESULT(no)
1334         ISC_PLATFORM_HAVEIF_LADDRREQ="#undef ISC_PLATFORM_HAVEIF_LADDRREQ"])
1335 AC_SUBST(ISC_PLATFORM_HAVEIF_LADDRREQ)
1336
1337 AC_MSG_CHECKING([for struct if_laddrconf])
1338 AC_TRY_LINK([
1339 #include <sys/types.h>
1340 #include <net/if6.h>
1341 ],[ struct if_laddrconf a; ],
1342         [AC_MSG_RESULT(yes)
1343         ISC_PLATFORM_HAVEIF_LADDRCONF="#define ISC_PLATFORM_HAVEIF_LADDRCONF 1"],
1344         [AC_MSG_RESULT(no)
1345         ISC_PLATFORM_HAVEIF_LADDRCONF="#undef ISC_PLATFORM_HAVEIF_LADDRCONF"])
1346 AC_SUBST(ISC_PLATFORM_HAVEIF_LADDRCONF)
1347
1348 #
1349 # Check for network functions that are often missing.  We do this
1350 # after the libtool checking, so we can put the right suffix on
1351 # the files.  It also needs to come after checking for a Kame add-on,
1352 # which provides some (all?) of the desired functions.
1353 #
1354
1355 AC_MSG_CHECKING([for inet_ntop with IPv6 support])
1356 AC_TRY_RUN([
1357 #include <sys/types.h>
1358 #include <sys/socket.h>
1359 #include <netinet/in.h>
1360 #include <arpa/inet.h>
1361 main() {
1362 char a[16],b[64]; return(inet_ntop(AF_INET6, a, b, sizeof(b)) == (char*)0);}],
1363         [AC_MSG_RESULT(yes)
1364         ISC_PLATFORM_NEEDNTOP="#undef ISC_PLATFORM_NEEDNTOP"],
1365
1366         [AC_MSG_RESULT(no)
1367         ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_ntop.$O"
1368         ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_ntop.c"
1369         ISC_PLATFORM_NEEDNTOP="#define ISC_PLATFORM_NEEDNTOP 1"])
1370
1371
1372 # On NetBSD 1.4.2 and maybe others, inet_pton() incorrectly accepts
1373 # addresses with less than four octets, like "1.2.3".  Also leading
1374 # zeros should also be rejected.
1375
1376 AC_MSG_CHECKING([for working inet_pton with IPv6 support])
1377 AC_TRY_RUN([
1378 #include <sys/types.h>
1379 #include <sys/socket.h>
1380 #include <netinet/in.h>
1381 #include <arpa/inet.h>
1382 main() { char a[16]; return (inet_pton(AF_INET, "1.2.3", a) == 1 ? 1 :
1383                              inet_pton(AF_INET, "1.2.3.04", a) == 1 ? 1 : 
1384                              (inet_pton(AF_INET6, "::1.2.3.4", a) != 1)); }],
1385         [AC_MSG_RESULT(yes)
1386         ISC_PLATFORM_NEEDPTON="#undef ISC_PLATFORM_NEEDPTON"],
1387         [AC_MSG_RESULT(no)
1388         ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_pton.$O"
1389         ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_pton.c"
1390         ISC_PLATFORM_NEEDPTON="#define ISC_PLATFORM_NEEDPTON 1"],
1391         [AC_MSG_RESULT(assuming target platform has working inet_pton)
1392         ISC_PLATFORM_NEEDPTON="#undef ISC_PLATFORM_NEEDPTON"])
1393
1394 AC_MSG_CHECKING([for inet_aton])
1395 AC_TRY_LINK([
1396 #include <sys/types.h>
1397 #include <netinet/in.h>
1398 #include <arpa/inet.h>],
1399         [struct in_addr in; inet_aton(0, &in); return (0);],
1400         [AC_MSG_RESULT(yes)
1401         ISC_PLATFORM_NEEDATON="#undef ISC_PLATFORM_NEEDATON"],
1402
1403         [AC_MSG_RESULT(no)
1404         ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS inet_aton.$O"
1405         ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS inet_aton.c"
1406         ISC_PLATFORM_NEEDATON="#define ISC_PLATFORM_NEEDATON 1"])
1407
1408 AC_SUBST(ISC_PLATFORM_NEEDNTOP)
1409 AC_SUBST(ISC_PLATFORM_NEEDPTON)
1410 AC_SUBST(ISC_PLATFORM_NEEDATON)
1411
1412 #
1413 # Look for a 4.4BSD-style sa_len member in struct sockaddr.
1414 #
1415 case "$host" in
1416         *-dec-osf*)
1417                 # Turn on 4.4BSD style sa_len support.
1418                 AC_DEFINE(_SOCKADDR_LEN)
1419                 ;;
1420 esac
1421
1422 AC_MSG_CHECKING(for sa_len in struct sockaddr)
1423 AC_TRY_COMPILE([
1424 #include <sys/types.h>
1425 #include <sys/socket.h>],
1426 [struct sockaddr sa; sa.sa_len = 0; return (0);],
1427         [AC_MSG_RESULT(yes)
1428         ISC_PLATFORM_HAVESALEN="#define ISC_PLATFORM_HAVESALEN 1"
1429         LWRES_PLATFORM_HAVESALEN="#define LWRES_PLATFORM_HAVESALEN 1"],
1430         [AC_MSG_RESULT(no)
1431         ISC_PLATFORM_HAVESALEN="#undef ISC_PLATFORM_HAVESALEN"
1432         LWRES_PLATFORM_HAVESALEN="#undef LWRES_PLATFORM_HAVESALEN"])
1433 AC_SUBST(ISC_PLATFORM_HAVESALEN)
1434 AC_SUBST(LWRES_PLATFORM_HAVESALEN)
1435
1436 #
1437 # Look for a 4.4BSD or 4.3BSD struct msghdr
1438 #
1439 AC_MSG_CHECKING(for struct msghdr flavor)
1440 AC_TRY_COMPILE([
1441 #include <sys/types.h>
1442 #include <sys/socket.h>],
1443 [struct msghdr msg; msg.msg_flags = 0; return (0);],
1444         [AC_MSG_RESULT(4.4BSD)
1445         ISC_PLATFORM_MSGHDRFLAVOR="#define ISC_NET_BSD44MSGHDR 1"],
1446         [AC_MSG_RESULT(4.3BSD)
1447         ISC_PLATFORM_MSGHDRFLAVOR="#define ISC_NET_BSD43MSGHDR 1"])
1448 AC_SUBST(ISC_PLATFORM_MSGHDRFLAVOR)
1449
1450 #
1451 # Look for in_port_t.
1452 #
1453 AC_MSG_CHECKING(for type in_port_t)
1454 AC_TRY_COMPILE([
1455 #include <sys/types.h>
1456 #include <netinet/in.h>],
1457 [in_port_t port = 25; return (0);],
1458         [AC_MSG_RESULT(yes)
1459         ISC_PLATFORM_NEEDPORTT="#undef ISC_PLATFORM_NEEDPORTT"],
1460         [AC_MSG_RESULT(no)
1461         ISC_PLATFORM_NEEDPORTT="#define ISC_PLATFORM_NEEDPORTT 1"])
1462 AC_SUBST(ISC_PLATFORM_NEEDPORTT)
1463
1464 #
1465 # Check for addrinfo
1466 #
1467 AC_MSG_CHECKING(for struct addrinfo)
1468 AC_TRY_COMPILE([
1469 #include <netdb.h>],
1470 [struct addrinfo a; return (0);],
1471         [AC_MSG_RESULT(yes)
1472         ISC_LWRES_NEEDADDRINFO="#undef ISC_LWRES_NEEDADDRINFO"
1473         AC_DEFINE(HAVE_ADDRINFO)],
1474         [AC_MSG_RESULT(no)
1475         ISC_LWRES_NEEDADDRINFO="#define ISC_LWRES_NEEDADDRINFO 1"])
1476 AC_SUBST(ISC_LWRES_NEEDADDRINFO)
1477
1478 #
1479 # Check for rrsetinfo
1480 #
1481 AC_MSG_CHECKING(for struct rrsetinfo)
1482 AC_TRY_COMPILE([
1483 #include <netdb.h>],
1484 [struct rrsetinfo r; return (0);],
1485         [AC_MSG_RESULT(yes)
1486         ISC_LWRES_NEEDRRSETINFO="#undef ISC_LWRES_NEEDRRSETINFO"],
1487         [AC_MSG_RESULT(no)
1488         ISC_LWRES_NEEDRRSETINFO="#define ISC_LWRES_NEEDRRSETINFO 1"])
1489 AC_SUBST(ISC_LWRES_NEEDRRSETINFO)
1490
1491 AC_MSG_CHECKING(for int sethostent)
1492 AC_TRY_COMPILE([
1493 #include <netdb.h>],
1494 [int i = sethostent(0); return(0);],
1495         [AC_MSG_RESULT(yes)
1496         ISC_LWRES_SETHOSTENTINT="#define ISC_LWRES_SETHOSTENTINT 1"],
1497         [AC_MSG_RESULT(no)
1498         ISC_LWRES_SETHOSTENTINT="#undef ISC_LWRES_SETHOSTENTINT"])
1499 AC_SUBST(ISC_LWRES_SETHOSTENTINT)
1500
1501 AC_MSG_CHECKING(for int endhostent)
1502 AC_TRY_COMPILE([
1503 #include <netdb.h>],
1504 [int i = endhostent(); return(0);],
1505         [AC_MSG_RESULT(yes)
1506         ISC_LWRES_ENDHOSTENTINT="#define ISC_LWRES_ENDHOSTENTINT 1"],
1507         [AC_MSG_RESULT(no)
1508         ISC_LWRES_ENDHOSTENTINT="#undef ISC_LWRES_ENDHOSTENTINT"])
1509 AC_SUBST(ISC_LWRES_ENDHOSTENTINT)
1510
1511 AC_MSG_CHECKING(for getnetbyaddr(in_addr_t, ...))
1512 AC_TRY_COMPILE([
1513 #include <netdb.h>
1514 struct netent *getnetbyaddr(in_addr_t, int);],
1515 [],
1516         [AC_MSG_RESULT(yes)
1517         ISC_LWRES_GETNETBYADDRINADDR="#define ISC_LWRES_GETNETBYADDRINADDR 1"],
1518         [AC_MSG_RESULT(no)
1519         ISC_LWRES_GETNETBYADDRINADDR="#undef ISC_LWRES_GETNETBYADDRINADDR"])
1520 AC_SUBST(ISC_LWRES_GETNETBYADDRINADDR)
1521
1522 AC_MSG_CHECKING(for int setnetent)
1523 AC_TRY_COMPILE([
1524 #include <netdb.h>],
1525 [int i = setnetent(0); return(0);],
1526         [AC_MSG_RESULT(yes)
1527         ISC_LWRES_SETNETENTINT="#define ISC_LWRES_SETNETENTINT 1"],
1528         [AC_MSG_RESULT(no)
1529         ISC_LWRES_SETNETENTINT="#undef ISC_LWRES_SETNETENTINT"])
1530 AC_SUBST(ISC_LWRES_SETNETENTINT)
1531
1532 AC_MSG_CHECKING(for int endnetent)
1533 AC_TRY_COMPILE([
1534 #include <netdb.h>],
1535 [int i = endnetent(); return(0);],
1536         [AC_MSG_RESULT(yes)
1537         ISC_LWRES_ENDNETENTINT="#define ISC_LWRES_ENDNETENTINT 1"],
1538         [AC_MSG_RESULT(no)
1539         ISC_LWRES_ENDNETENTINT="#undef ISC_LWRES_ENDNETENTINT"])
1540 AC_SUBST(ISC_LWRES_ENDNETENTINT)
1541
1542 AC_MSG_CHECKING(for gethostbyaddr(const void *, size_t, ...))
1543 AC_TRY_COMPILE([
1544 #include <netdb.h>
1545 struct hostent *gethostbyaddr(const void *, size_t, int);],
1546 [return(0);],
1547         [AC_MSG_RESULT(yes)
1548         ISC_LWRES_GETHOSTBYADDRVOID="#define ISC_LWRES_GETHOSTBYADDRVOID 1"],
1549         [AC_MSG_RESULT(no)
1550         ISC_LWRES_GETHOSTBYADDRVOID="#undef ISC_LWRES_GETHOSTBYADDRVOID"])
1551 AC_SUBST(ISC_LWRES_GETHOSTBYADDRVOID)
1552
1553 AC_MSG_CHECKING(for h_errno in netdb.h)
1554 AC_TRY_COMPILE([
1555 #include <netdb.h>],
1556 [h_errno = 1; return(0);],
1557         [AC_MSG_RESULT(yes)
1558         ISC_LWRES_NEEDHERRNO="#undef ISC_LWRES_NEEDHERRNO"],
1559         [AC_MSG_RESULT(no)
1560         ISC_LWRES_NEEDHERRNO="#define ISC_LWRES_NEEDHERRNO 1"])
1561 AC_SUBST(ISC_LWRES_NEEDHERRNO)
1562
1563 AC_CHECK_FUNC(getipnodebyname,
1564         [ISC_LWRES_GETIPNODEPROTO="#undef ISC_LWRES_GETIPNODEPROTO"],
1565         [ISC_LWRES_GETIPNODEPROTO="#define ISC_LWRES_GETIPNODEPROTO 1"])
1566 AC_CHECK_FUNC(getnameinfo,
1567         [ISC_LWRES_GETNAMEINFOPROTO="#undef ISC_LWRES_GETNAMEINFOPROTO"],
1568         [ISC_LWRES_GETNAMEINFOPROTO="#define ISC_LWRES_GETNAMEINFOPROTO 1"])
1569 AC_CHECK_FUNC(getaddrinfo,
1570         [ISC_LWRES_GETADDRINFOPROTO="#undef ISC_LWRES_GETADDRINFOPROTO"
1571         AC_DEFINE(HAVE_GETADDRINFO)],
1572         [ISC_LWRES_GETADDRINFOPROTO="#define ISC_LWRES_GETADDRINFOPROTO 1"])
1573 AC_CHECK_FUNC(gai_strerror, AC_DEFINE(HAVE_GAISTRERROR))
1574 AC_SUBST(ISC_LWRES_GETIPNODEPROTO)
1575 AC_SUBST(ISC_LWRES_GETADDRINFOPROTO)
1576 AC_SUBST(ISC_LWRES_GETNAMEINFOPROTO)
1577
1578 AC_ARG_ENABLE(getifaddrs,
1579 [  --enable-getifaddrs    Enable the use of getifaddrs() [[yes|no|glibc]].
1580              glibc: Use getifaddrs() in glibc if you know it supports IPv6.],
1581     want_getifaddrs="$enableval",  want_getifaddrs="yes")
1582
1583 case $want_getifaddrs in
1584 yes|glibc)
1585 #
1586 # Do we have getifaddrs() ?
1587 #
1588 case $host in
1589 *-linux*)
1590         # Some recent versions of glibc support getifaddrs() which does not
1591         # provide AF_INET6 addresses while the function provided by the USAGI
1592         # project handles the AF_INET6 case correctly.  We need to avoid
1593         # using the former but prefer the latter unless overridden by
1594         # --enable-getifaddrs=glibc.
1595         if test $use_getifaddrs = glibc
1596         then
1597                 AC_CHECK_FUNC(getifaddrs, AC_DEFINE(HAVE_GETIFADDRS))
1598         else
1599                 save_LIBS="$LIBS"
1600                 LIBS="-L/usr/local/v6/lib $LIBS"
1601                 AC_CHECK_LIB(inet6, getifaddrs,
1602                         LIBS="$LIBS -linet6"
1603                         AC_DEFINE(HAVE_GETIFADDRS),
1604                         LIBS=${save_LIBS})
1605         fi
1606         ;;
1607 *)
1608         AC_CHECK_FUNC(getifaddrs, AC_DEFINE(HAVE_GETIFADDRS))
1609         ;;
1610 esac
1611 ;;
1612 no)
1613 ;;
1614 esac
1615
1616 #
1617 # Look for a sysctl call to get the list of network interfaces.
1618 #
1619 case $ac_cv_header_sys_sysctl_h in
1620 yes)
1621 AC_MSG_CHECKING(for interface list sysctl)
1622 AC_EGREP_CPP(found_rt_iflist, [
1623 #include <sys/param.h>
1624 #include <sys/sysctl.h>
1625 #include <sys/socket.h>
1626 #ifdef NET_RT_IFLIST
1627 found_rt_iflist
1628 #endif
1629 ],
1630         [AC_MSG_RESULT(yes)
1631          AC_DEFINE(HAVE_IFLIST_SYSCTL)],
1632         [AC_MSG_RESULT(no)])
1633 ;;
1634 esac
1635
1636 #
1637 # Check for some other useful functions that are not ever-present.
1638 #
1639
1640 # We test for strsep() using AC_TRY_LINK instead of AC_CHECK_FUNC
1641 # because AIX 4.3.3 with patches for bos.adt.include to version 4.3.3.77
1642 # reportedly defines strsep() without declaring it in <string.h> when
1643 # -D_LINUX_SOURCE_COMPAT is not defined [RT #2190], and
1644 # AC_CHECK_FUNC() incorrectly succeeds because it declares
1645 # the function itself.
1646 AC_MSG_CHECKING(for correctly declared strsep())
1647 AC_TRY_LINK([#include <string.h>], [char *sp; char *foo = strsep(&sp, ".");],
1648         [AC_MSG_RESULT(yes); ISC_PLATFORM_NEEDSTRSEP="#undef ISC_PLATFORM_NEEDSTRSEP"],
1649         [AC_MSG_RESULT(no); ISC_PLATFORM_NEEDSTRSEP="#define ISC_PLATFORM_NEEDSTRSEP 1"])
1650 AC_SUBST(ISC_PLATFORM_NEEDSTRSEP)
1651
1652 AC_CHECK_FUNC(memmove,
1653         [ISC_PLATFORM_NEEDMEMMOVE="#undef ISC_PLATFORM_NEEDMEMMOVE"],
1654         [ISC_PLATFORM_NEEDMEMMOVE="#define ISC_PLATFORM_NEEDMEMMOVE 1"])
1655 AC_SUBST(ISC_PLATFORM_NEEDMEMMOVE)
1656
1657 AC_CHECK_FUNC(strtoul,
1658         [ISC_PLATFORM_NEEDSTRTOUL="#undef ISC_PLATFORM_NEEDSTRTOUL"],
1659         [ISC_PLATFORM_NEEDSTRTOUL="#define ISC_PLATFORM_NEEDSTRTOUL 1"])
1660 AC_SUBST(ISC_PLATFORM_NEEDSTRTOUL)
1661
1662 AC_CHECK_FUNC(strlcpy,
1663         [ISC_PLATFORM_NEEDSTRLCPY="#undef ISC_PLATFORM_NEEDSTRLCPY"],
1664         [ISC_PLATFORM_NEEDSTRLCPY="#define ISC_PLATFORM_NEEDSTRLCPY 1"])
1665 AC_SUBST(ISC_PLATFORM_NEEDSTRLCPY)
1666
1667 AC_CHECK_FUNC(strlcat,
1668         [ISC_PLATFORM_NEEDSTRLCAT="#undef ISC_PLATFORM_NEEDSTRLCAT"],
1669         [ISC_PLATFORM_NEEDSTRLCAT="#define ISC_PLATFORM_NEEDSTRLCAT 1"])
1670 AC_SUBST(ISC_PLATFORM_NEEDSTRLCAT)
1671
1672 ISC_PRINT_OBJS=
1673 ISC_PRINT_SRCS=
1674 AC_MSG_CHECKING(sprintf)
1675 AC_TRY_COMPILE([
1676 #include <stdio.h>
1677 ],
1678 [ char buf[2]; return(*sprintf(buf,"x"));],
1679 [
1680 ISC_PRINT_OBJS="print.$O"
1681 ISC_PRINT_SRCS="print.c"
1682 ISC_PLATFORM_NEEDSPRINTF="#define ISC_PLATFORM_NEEDSPRINTF"
1683 LWRES_PLATFORM_NEEDSPRINTF="#define LWRES_PLATFORM_NEEDSPRINTF"
1684 ],
1685 [ISC_PLATFORM_NEEDSPRINTF="#undef ISC_PLATFORM_NEEDSPRINTF"
1686  LWRES_PLATFORM_NEEDSPRINTF="#undef LWRES_PLATFORM_NEEDSPRINTF"]
1687 )
1688 AC_SUBST(ISC_PLATFORM_NEEDSPRINTF)
1689 AC_SUBST(LWRES_PLATFORM_NEEDSPRINTF)
1690
1691 AC_CHECK_FUNC(vsnprintf,
1692         [ISC_PLATFORM_NEEDVSNPRINTF="#undef ISC_PLATFORM_NEEDVSNPRINTF"
1693          LWRES_PLATFORM_NEEDVSNPRINTF="#undef LWRES_PLATFORM_NEEDVSNPRINTF"],
1694         [ISC_PRINT_OBJS="print.$O"
1695          ISC_PRINT_SRCS="print.c"
1696          ISC_PLATFORM_NEEDVSNPRINTF="#define ISC_PLATFORM_NEEDVSNPRINTF 1"
1697          LWRES_PLATFORM_NEEDVSNPRINTF="#define LWRES_PLATFORM_NEEDVSNPRINTF 1"])
1698 AC_SUBST(ISC_PLATFORM_NEEDVSNPRINTF)
1699 AC_SUBST(LWRES_PLATFORM_NEEDVSNPRINTF)
1700 ISC_EXTRA_OBJS="$ISC_EXTRA_OBJS $ISC_PRINT_OBJS"
1701 ISC_EXTRA_SRCS="$ISC_EXTRA_SRCS $ISC_PRINT_SRCS"
1702
1703 AC_CHECK_FUNC(strerror, AC_DEFINE(HAVE_STRERROR))
1704
1705 AC_SUBST(ISC_EXTRA_OBJS)
1706 AC_SUBST(ISC_EXTRA_SRCS)
1707
1708 # Determine the printf format characters to use when printing
1709 # values of type isc_int64_t. This will normally be "ll", but where
1710 # the compiler treats "long long" as a alias for "long" and printf
1711 # doesn't know about "long long" use "l".  Hopefully the sprintf
1712 # will produce a inconsistant result in the later case.  If the compiler
1713 # fails due to seeing "%lld" we fall back to "l".
1714 #
1715 # Win32 uses "%I64d", but that's defined elsewhere since we don't use
1716 # configure on Win32.
1717 #
1718 AC_MSG_CHECKING(printf format modifier for 64-bit integers)
1719 AC_TRY_RUN([
1720 #include <stdio.h>
1721 main() {
1722         long long int j = 0;
1723         char buf[100];
1724         buf[0] = 0;
1725         sprintf(buf, "%lld", j);
1726         exit((sizeof(long long int) != sizeof(long int))? 0 :
1727              (strcmp(buf, "0") != 0));
1728
1729 ],
1730         [AC_MSG_RESULT(ll)
1731         ISC_PLATFORM_QUADFORMAT='#define ISC_PLATFORM_QUADFORMAT "ll"'],
1732         [AC_MSG_RESULT(l)
1733         ISC_PLATFORM_QUADFORMAT='#define ISC_PLATFORM_QUADFORMAT "l"'],
1734         [AC_MSG_RESULT(assuming target platform uses ll)
1735         ISC_PLATFORM_QUADFORMAT='#define ISC_PLATFORM_QUADFORMAT "ll"'])
1736 AC_SUBST(ISC_PLATFORM_QUADFORMAT)
1737
1738 #
1739 # Security Stuff
1740 #
1741 AC_CHECK_FUNC(chroot, AC_DEFINE(HAVE_CHROOT))
1742 AC_ARG_ENABLE(linux-caps,
1743         [  --disable-linux-caps disable linux capabilities])
1744 case "$enable_linux_caps" in
1745         yes|'')
1746                 AC_CHECK_HEADERS(linux/capability.h)
1747                 ;;
1748         no)
1749                 ;;
1750 esac
1751 AC_CHECK_HEADERS(sys/prctl.h)
1752
1753 #
1754 # Time Zone Stuff
1755 #
1756 AC_CHECK_FUNC(tzset, AC_DEFINE(HAVE_TZSET))
1757
1758 #
1759 # BSD/OS, and perhaps some others, don't define rlim_t.
1760 #
1761 AC_MSG_CHECKING(for type rlim_t)
1762 AC_TRY_COMPILE([
1763 #include <sys/types.h>
1764 #include <sys/time.h>
1765 #include <sys/resource.h>],
1766 [rlim_t rl = 19671212; return (0);],
1767 [AC_MSG_RESULT(yes)
1768  ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE rlim_t"],
1769 [AC_MSG_RESULT(no)
1770
1771 AC_MSG_CHECKING(type of rlim_cur)
1772 AC_TRY_RUN([
1773 #include <sys/types.h>
1774 #include <sys/time.h>
1775 #include <sys/resource.h>
1776 main() { struct rlimit r; exit(!(sizeof(r.rlim_cur) == sizeof(int)));}],
1777 [AC_MSG_RESULT(int)
1778 ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE int"],
1779 [
1780 AC_TRY_RUN([
1781 #include <sys/types.h>
1782 #include <sys/time.h>
1783 #include <sys/resource.h>
1784 main() { struct rlimit r; exit(!(sizeof(r.rlim_cur) == sizeof(long int)));}],
1785 [AC_MSG_RESULT(long int)
1786 ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE long int"],
1787 [
1788 AC_TRY_RUN([
1789 #include <sys/types.h>
1790 #include <sys/time.h>
1791 #include <sys/resource.h>
1792 main() { struct rlimit r; exit((!sizeof(r.rlim_cur) == sizeof(long long int)));}],
1793 [AC_MSG_RESULT(long long int)
1794 ISC_PLATFORM_RLIMITTYPE="#define ISC_PLATFORM_RLIMITTYPE long long int"],
1795 [AC_MSG_ERROR([unable to determine sizeof rlim_cur])
1796 ],[AC_MSG_ERROR(this cannot happen)])
1797 ],[AC_MSG_ERROR(this cannot happen)])
1798 ],[AC_MSG_ERROR(cannot determine type of rlim_cur when cross compiling - define rlim_t)])
1799 ])
1800 AC_SUBST(ISC_PLATFORM_RLIMITTYPE)
1801
1802 #
1803 # Compaq TruCluster requires more code for handling cluster IP aliases
1804 #
1805 case "$host" in
1806         *-dec-osf*)
1807                 AC_CHECK_LIB(clua, clua_getaliasaddress, LIBS="-lclua $LIBS")
1808                 AC_CHECK_FUNC(clua_getaliasaddress,
1809                                 AC_DEFINE(HAVE_TRUCLUSTER, 1,
1810                                         [Define if running under Compaq TruCluster]))
1811                 ;;
1812         *)
1813                 ;;
1814 esac
1815
1816 #
1817 # Microsoft has their own way of handling shared libraries that requires
1818 # additional qualifiers on extern variables.  Unix systems don't need it.
1819 #
1820 AC_SUBST(ISC_PLATFORM_USEDECLSPEC)
1821 ISC_PLATFORM_USEDECLSPEC="#undef ISC_PLATFORM_USEDECLSPEC"
1822 AC_SUBST(LWRES_PLATFORM_USEDECLSPEC)
1823 LWRES_PLATFORM_USEDECLSPEC="#undef LWRES_PLATFORM_USEDECLSPEC"
1824
1825 #
1826 # Random remaining OS-specific issues involving compiler warnings.
1827 # XXXDCL print messages to indicate some compensation is being done?
1828 #
1829 AC_SUBST(ISC_PLATFORM_BRACEPTHREADONCEINIT)
1830 ISC_PLATFORM_BRACEPTHREADONCEINIT="#undef ISC_PLATFORM_BRACEPTHREADONCEINIT"
1831
1832 case "$host" in
1833         *-bsdi3.1*)
1834                 hack_shutup_sputaux=yes
1835                 ;;
1836         *-bsdi4.0*)
1837                 hack_shutup_sigwait=yes
1838                 hack_shutup_sputaux=yes
1839                 ;;
1840         [*-bsdi4.[12]*])
1841                 hack_shutup_stdargcast=yes
1842                 ;;
1843         [*-solaris2.[89]])
1844                 hack_shutup_pthreadonceinit=yes
1845                 ;;
1846 esac
1847
1848 case "$hack_shutup_pthreadonceinit" in
1849         yes)
1850                 #
1851                 # Shut up PTHREAD_ONCE_INIT unbraced initializer warnings.
1852                 #
1853                 ISC_PLATFORM_BRACEPTHREADONCEINIT="#define ISC_PLATFORM_BRACEPTHREADONCEINIT 1"
1854                 ;;
1855 esac
1856
1857 case "$hack_shutup_sigwait" in
1858         yes)
1859                 #
1860                 # Shut up a -Wmissing-prototypes warning for sigwait().
1861                 #
1862                 AC_DEFINE(SHUTUP_SIGWAIT)
1863                 ;;
1864 esac
1865
1866 case "$hack_shutup_sputaux" in
1867         yes)
1868                 #
1869                 # Shut up a -Wmissing-prototypes warning from <stdio.h>.
1870                 #
1871                 AC_DEFINE(SHUTUP_SPUTAUX)
1872                 ;;
1873 esac
1874
1875 case "$hack_shutup_stdargcast" in
1876         yes)
1877                 #
1878                 # Shut up a -Wcast-qual warning from va_start().
1879                 #
1880                 AC_DEFINE(SHUTUP_STDARG_CAST)
1881                 ;;
1882 esac
1883
1884 #
1885 # Check for if_nametoindex() for IPv6 scoped addresses support
1886 #
1887 AC_CHECK_FUNC(if_nametoindex, ac_cv_have_if_nametoindex=yes,
1888                 ac_cv_have_if_nametoindex=no)
1889 case $ac_cv_have_if_nametoindex in
1890 no)
1891         case "$host" in
1892         *-hp-hpux*)
1893                 AC_CHECK_LIB(ipv6, if_nametoindex,
1894                                 ac_cv_have_if_nametoindex=yes
1895                                 LIBS="-lipv6 $LIBS",)
1896         ;;
1897         esac
1898 esac
1899 case $ac_cv_have_if_nametoindex in
1900 yes)
1901         ISC_PLATFORM_HAVEIFNAMETOINDEX="#define ISC_PLATFORM_HAVEIFNAMETOINDEX 1"
1902         ;;
1903 *)
1904         ISC_PLATFORM_HAVEIFNAMETOINDEX="#undef ISC_PLATFORM_HAVEIFNAMETOINDEX"
1905         ;;
1906 esac
1907 AC_SUBST(ISC_PLATFORM_HAVEIFNAMETOINDEX)
1908
1909 #
1910 # The following sections deal with tools used for formatting
1911 # the documentation.  They are all optional, unless you are
1912 # a developer editing the documentation source.
1913 #
1914
1915 # Directory trees where SGML files are commonly found.
1916 sgmltrees="/usr/pkg/share/sgml /usr/local/share/sgml /usr/share/sgml"
1917
1918 #
1919 # Look for openjade.  Plain jade is no longer supported.
1920 #
1921
1922 AC_PATH_PROGS(OPENJADE, openjade, openjade)
1923 AC_SUBST(OPENJADE)
1924
1925 #
1926 # Look for TeX.
1927 #
1928
1929 AC_PATH_PROGS(JADETEX, jadetex, jadetex)
1930 AC_SUBST(JADETEX)
1931
1932 AC_PATH_PROGS(PDFJADETEX, pdfjadetex, pdfjadetex)
1933 AC_SUBST(PDFJADETEX)
1934
1935 #
1936 # Subroutine for searching for an ordinary file (e.g., a stylesheet)
1937 # in a number of directories:
1938 #
1939 #   NOM_PATH_FILE(VARIABLE, FILENAME, DIRECTORIES)
1940 #
1941 # If the file FILENAME is found in one of the DIRECTORIES, the shell
1942 # variable VARIABLE is defined to its absolute pathname.  Otherwise, 
1943 # it is set to FILENAME, with no directory prefix (that's not terribly
1944 # useful, but looks less confusing in substitutions than leaving it
1945 # empty).  The variable VARIABLE will be substituted into output files.
1946
1947
1948 AC_DEFUN(NOM_PATH_FILE, [
1949 $1=""
1950 AC_MSG_CHECKING(for $2)
1951 for d in $3
1952 do
1953         f=$d/$2
1954         if test -f $f
1955         then
1956                 $1=$f
1957                 AC_MSG_RESULT($f)
1958                 break
1959         fi
1960 done
1961 if test "X[$]$1" = "X"
1962 then
1963         AC_MSG_RESULT("not found");
1964         $1=$2
1965 fi
1966 AC_SUBST($1)
1967 ])
1968
1969 #
1970 # Look for the SGML catalog.
1971 # Its location varies, so far we have seen:
1972 #
1973 #       NetBSD  /usr/pkg/share/sgml/docbook/catalog
1974 #       FreeBSD /usr/local/share/sgml/docbook/catalog
1975 #       Linux   /usr/local/share/dsssl/docbook/catalog
1976 #               /usr/share/sgml/docbook/dsssl-stylesheets/catalog
1977 #
1978 catalogpath=""
1979 for d in $sgmltrees 
1980 do
1981         catalogpath="$catalogpath $d"
1982         for s in docbook/dsssl-stylesheets
1983         do
1984                 catalogpath="$catalogpath $d/$s"
1985         done
1986 done
1987 NOM_PATH_FILE(SGMLCATALOG, catalog, $catalogpath)
1988
1989 #
1990 # Look for the HTML stylesheet html/docbook.dsl, used for
1991 # formatting man pages in HTML.  Its location varies,
1992 # so far we have seen:
1993 #
1994 #       NetBSD  /usr/pkg/share/sgml/docbook/dsssl/modular/
1995 #       FreeBSD /usr/local/share/sgml/docbook/dsssl/modular/
1996 #       Linux   /usr/local/share/dsssl/docbook/
1997 #               /usr/share/sgml/docbook/dsssl-stylesheets/
1998 #
1999 # Ditto for the print stylesheet print/docbook.dsl.
2000 #
2001
2002 stylepath=""
2003 for d in $sgmltrees 
2004 do
2005         for s in docbook/dsssl/modular dsssl/docbook docbook/dsssl-stylesheets
2006         do
2007                 stylepath="$stylepath $d/$s"
2008         done
2009 done
2010 NOM_PATH_FILE(HTMLSTYLE, html/docbook.dsl, $stylepath)
2011 NOM_PATH_FILE(PRINTSTYLE, print/docbook.dsl, $stylepath)
2012
2013 #
2014 # Look for XML declarations.
2015 # Its location varies, so far we have seen:
2016 #
2017 #       NetBSD  /usr/pkg/share/sgml/docbook/dsssl/modular/dtds/decls/
2018 #       FreeBSD /usr/local/share/sgml/docbook/dsssl/modular/dtds/decls/
2019 #       Linux   /usr/local/share/dsssl/docbook/dtds/decls/
2020 #               /usr/share/sgml/docbook/dsssl-stylesheets/dtds/decls/
2021 #
2022
2023 xmlpath=""
2024 for d in $sgmltrees 
2025 do
2026         for s in docbook/dsssl/modular dsssl/docbook docbook/dsssl-stylesheets
2027         do
2028                 xmlpath="$xmlpath $d/$s"
2029         done
2030 done
2031 NOM_PATH_FILE(XMLDCL, dtds/decls/xml.dcl, $xmlpath)
2032
2033 #
2034 # Look for docbook2man-spec.pl
2035 #
2036
2037 NOM_PATH_FILE(DOCBOOK2MANSPEC, docbook2X/docbook2man-spec.pl, $sgmltrees)
2038
2039 #
2040 # Substitutions
2041 #
2042 AC_SUBST(BIND9_TOP_BUILDDIR)
2043 BIND9_TOP_BUILDDIR=`pwd`
2044
2045 AC_SUBST(BIND9_ISC_BUILDINCLUDE)
2046 AC_SUBST(BIND9_ISCCC_BUILDINCLUDE)
2047 AC_SUBST(BIND9_ISCCFG_BUILDINCLUDE)
2048 AC_SUBST(BIND9_DNS_BUILDINCLUDE)
2049 AC_SUBST(BIND9_LWRES_BUILDINCLUDE)
2050 AC_SUBST(BIND9_BIND9_BUILDINCLUDE)
2051 if test "X$srcdir" != "X"; then
2052         BIND9_ISC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isc/include"
2053         BIND9_ISCCC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isccc/include"
2054         BIND9_ISCCFG_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isccfg/include"
2055         BIND9_DNS_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/dns/include"
2056         BIND9_LWRES_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/lwres/include"
2057         BIND9_BIND9_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/bind9/include"
2058 else
2059         BIND9_ISC_BUILDINCLUDE=""
2060         BIND9_ISCCC_BUILDINCLUDE=""
2061         BIND9_ISCCFG_BUILDINCLUDE=""
2062         BIND9_DNS_BUILDINCLUDE=""
2063         BIND9_LWRES_BUILDINCLUDE=""
2064         BIND9_BIND9_BUILDINCLUDE=""
2065 fi
2066
2067 AC_SUBST_FILE(BIND9_MAKE_INCLUDES)
2068 BIND9_MAKE_INCLUDES=$BIND9_TOP_BUILDDIR/make/includes
2069
2070 AC_SUBST_FILE(BIND9_MAKE_RULES)
2071 BIND9_MAKE_RULES=$BIND9_TOP_BUILDDIR/make/rules
2072
2073 . $srcdir/version
2074 BIND9_VERSION="VERSION=${MAJORVER}.${MINORVER}.${PATCHVER}${RELEASETYPE}${RELEASEVER}"
2075 AC_SUBST(BIND9_VERSION)
2076
2077 AC_SUBST_FILE(LIBISC_API)
2078 LIBISC_API=$srcdir/lib/isc/api
2079
2080 AC_SUBST_FILE(LIBISCCC_API)
2081 LIBISCCC_API=$srcdir/lib/isccc/api
2082
2083 AC_SUBST_FILE(LIBISCCFG_API)
2084 LIBISCCFG_API=$srcdir/lib/isccfg/api
2085
2086 AC_SUBST_FILE(LIBDNS_API)
2087 LIBDNS_API=$srcdir/lib/dns/api
2088
2089 AC_SUBST_FILE(LIBBIND9_API)
2090 LIBBIND9_API=$srcdir/lib/bind9/api
2091
2092 AC_SUBST_FILE(LIBLWRES_API)
2093 LIBLWRES_API=$srcdir/lib/lwres/api
2094
2095 AC_OUTPUT(
2096         make/rules
2097         make/includes
2098         Makefile
2099         make/Makefile
2100         make/mkdep
2101         lib/Makefile
2102         lib/isc/Makefile
2103         lib/isc/include/Makefile
2104         lib/isc/include/isc/Makefile
2105         lib/isc/include/isc/platform.h
2106         lib/isc/unix/Makefile
2107         lib/isc/unix/include/Makefile
2108         lib/isc/unix/include/isc/Makefile
2109         lib/isc/nls/Makefile
2110         lib/isc/$thread_dir/Makefile
2111         lib/isc/$thread_dir/include/Makefile
2112         lib/isc/$thread_dir/include/isc/Makefile
2113         lib/isccc/Makefile
2114         lib/isccc/include/Makefile
2115         lib/isccc/include/isccc/Makefile
2116         lib/isccfg/Makefile
2117         lib/isccfg/include/Makefile
2118         lib/isccfg/include/isccfg/Makefile
2119         lib/dns/Makefile
2120         lib/dns/include/Makefile
2121         lib/dns/include/dns/Makefile
2122         lib/dns/sec/Makefile
2123         lib/dns/sec/dst/Makefile
2124         lib/dns/sec/dst/include/Makefile
2125         lib/dns/sec/dst/include/dst/Makefile
2126         lib/bind9/Makefile
2127         lib/bind9/include/Makefile
2128         lib/bind9/include/bind9/Makefile
2129         lib/lwres/Makefile
2130         lib/lwres/include/Makefile
2131         lib/lwres/include/lwres/Makefile
2132         lib/lwres/include/lwres/netdb.h
2133         lib/lwres/include/lwres/platform.h
2134         lib/lwres/man/Makefile
2135         lib/lwres/unix/Makefile
2136         lib/lwres/unix/include/Makefile
2137         lib/lwres/unix/include/lwres/Makefile
2138         lib/tests/Makefile
2139         lib/tests/include/Makefile
2140         lib/tests/include/tests/Makefile
2141         bin/Makefile
2142         bin/check/Makefile
2143         bin/named/Makefile
2144         bin/named/unix/Makefile
2145         bin/rndc/Makefile
2146         bin/rndc/unix/Makefile
2147         bin/dig/Makefile
2148         bin/nsupdate/Makefile
2149         bin/tests/Makefile
2150         bin/tests/names/Makefile
2151         bin/tests/master/Makefile
2152         bin/tests/rbt/Makefile
2153         bin/tests/db/Makefile
2154         bin/tests/tasks/Makefile
2155         bin/tests/timers/Makefile
2156         bin/tests/dst/Makefile
2157         bin/tests/mem/Makefile
2158         bin/tests/net/Makefile
2159         bin/tests/sockaddr/Makefile
2160         bin/tests/system/Makefile
2161         bin/tests/system/conf.sh
2162         bin/tests/system/lwresd/Makefile
2163         bin/tests/system/tkey/Makefile
2164         bin/tests/headerdep_test.sh
2165         bin/dnssec/Makefile
2166         doc/Makefile
2167         doc/arm/Makefile
2168         doc/arm/nominum-docbook-html.dsl
2169         doc/arm/nominum-docbook-print.dsl
2170         doc/arm/validate.sh
2171         doc/misc/Makefile
2172         docutil/docbook2man-wrapper.sh
2173         isc-config.sh
2174 )
2175 chmod a+x isc-config.sh
2176
2177 # Tell Emacs to edit this file in shell mode.
2178 # Local Variables:
2179 # mode: sh
2180 # End: