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