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