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