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