1 dnl @(#) Header: /proj/cvs/prod/bind9/contrib/nslint-2.1a3/aclocal.m4,v 1.1 2001/12/21 04:12:03 marka Exp (LBL)
3 dnl Copyright (c) 1995, 1996, 1997, 1998, 1999
4 dnl The Regents of the University of California. All rights reserved.
6 dnl Redistribution and use in source and binary forms, with or without
7 dnl modification, are permitted provided that: (1) source code distributions
8 dnl retain the above copyright notice and this paragraph in its entirety, (2)
9 dnl distributions including binary code include the above copyright notice and
10 dnl this paragraph in its entirety in the documentation or other materials
11 dnl provided with the distribution, and (3) all advertising materials mentioning
12 dnl features or use of this software display the following acknowledgement:
13 dnl ``This product includes software developed by the University of California,
14 dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
15 dnl the University nor the names of its contributors may be used to endorse
16 dnl or promote products derived from this software without specific prior
17 dnl written permission.
18 dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19 dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20 dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 dnl LBL autoconf macros
26 dnl Determine which compiler we're using (cc or gcc)
27 dnl If using gcc, determine the version number
28 dnl If using cc, require that it support ansi prototypes
29 dnl If using gcc, use -O2 (otherwise use -O)
30 dnl If using cc, explicitly specify /usr/local/include
34 dnl AC_LBL_C_INIT(copt, incls)
44 AC_DEFUN(AC_LBL_C_INIT,
46 AC_BEFORE([$0], [AC_PROG_CC])
47 AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
48 AC_BEFORE([$0], [AC_LBL_DEVEL])
49 AC_ARG_WITH(gcc, [ --without-gcc don't use gcc])
52 if test "${srcdir}" != "." ; then
55 if test "${CFLAGS+set}" = set; then
58 if test -z "$CC" ; then
62 AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
63 if test $SHLICC2 = yes ; then
70 if test -z "$CC" -a "$with_gcc" = no ; then
75 if test "$GCC" != yes ; then
76 AC_MSG_CHECKING(that $CC handles ansi prototypes)
77 AC_CACHE_VAL(ac_cv_lbl_cc_ansi_prototypes,
79 [#include <sys/types.h>],
80 [int frob(int, char *)],
81 ac_cv_lbl_cc_ansi_prototypes=yes,
82 ac_cv_lbl_cc_ansi_prototypes=no))
83 AC_MSG_RESULT($ac_cv_lbl_cc_ansi_prototypes)
84 if test $ac_cv_lbl_cc_ansi_prototypes = no ; then
88 AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE))
90 CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
91 AC_CACHE_VAL(ac_cv_lbl_cc_hpux_cc_aa,
93 [#include <sys/types.h>],
94 [int frob(int, char *)],
95 ac_cv_lbl_cc_hpux_cc_aa=yes,
96 ac_cv_lbl_cc_hpux_cc_aa=no))
97 AC_MSG_RESULT($ac_cv_lbl_cc_hpux_cc_aa)
98 if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then
99 AC_MSG_ERROR(see the INSTALL doc for more info)
101 CFLAGS="$savedcflags"
103 AC_DEFINE(_HPUX_SOURCE)
107 AC_MSG_ERROR(see the INSTALL doc for more info)
111 $2="$$2 -I/usr/local/include"
112 LDFLAGS="$LDFLAGS -L/usr/local/lib"
117 $1="$$1 -xansi -signed -g3"
125 AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
126 AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
128 [#include <sys/types.h>],
129 [struct a { int b; };
130 void c(const struct a *)],
131 ac_cv_lbl_cc_const_proto=yes,
132 ac_cv_lbl_cc_const_proto=no))
133 AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
134 if test $ac_cv_lbl_cc_const_proto = no ; then
143 dnl Use pfopen.c if available and pfopen() not in standard libraries
145 dnl Look for libpcap in ..
146 dnl Use the installed libpcap if there is no local version
150 dnl AC_LBL_LIBPCAP(pcapdep, incls)
155 dnl $2 (incls appended)
160 AC_DEFUN(AC_LBL_LIBPCAP,
161 [AC_REQUIRE([AC_LBL_LIBRARY_NET])
163 dnl save a copy before locating libpcap.a
166 pfopen=/usr/examples/packetfilter/pfopen.c
167 if test -f $pfopen ; then
168 AC_CHECK_FUNCS(pfopen)
169 if test $ac_cv_func_pfopen = "no" ; then
170 AC_MSG_RESULT(Using $pfopen)
174 AC_MSG_CHECKING(for local pcap library)
177 places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \
178 egrep '/libpcap-[[0-9]]*\.[[0-9]]*(\.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
179 for dir in $places ../libpcap libpcap ; do
180 basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//'`
181 if test $lastdir = $basedir ; then
182 dnl skip alphas when an actual release is present
186 if test -r $dir/pcap.c ; then
187 libpcap=$dir/libpcap.a
189 dnl continue and select the last one that exists
192 if test "x$libpcap" = xFAIL ; then
193 AC_MSG_RESULT(not found)
194 unset ac_cv_lbl_lib_pcap_pcap_open_live_
195 AC_LBL_CHECK_LIB(pcap, pcap_open_live, libpcap="-lpcap")
196 if test "x$libpcap" = xFAIL ; then
197 unset ac_cv_lbl_lib_pcap_pcap_open_live_
198 CFLAGS="$CFLAGS -I/usr/local/include"
199 LIBS="$LIBS -L/usr/local/lib"
200 AC_LBL_CHECK_LIB(pcap, pcap_open_live, libpcap="-lpcap")
201 if test "x$libpcap" = xFAIL ; then
202 AC_MSG_ERROR(see the INSTALL doc for more info)
204 $2="$$2 -I/usr/local/include"
210 AC_MSG_RESULT($libpcap)
212 if test "x$libpcap" != "x-lpcap" ; then
213 LIBS="$libpcap $LIBS"
218 pseexe="/lib/pse.exp"
219 AC_MSG_CHECKING(for $pseexe)
220 if test -f $pseexe ; then
222 LIBS="$LIBS -I:$pseexe"
228 dnl Define RETSIGTYPE and RETSIGVAL
232 dnl AC_LBL_TYPE_SIGNAL
236 dnl RETSIGTYPE (defined)
237 dnl RETSIGVAL (defined)
239 AC_DEFUN(AC_LBL_TYPE_SIGNAL,
240 [AC_BEFORE([$0], [AC_LBL_LIBPCAP])
242 if test "$ac_cv_type_signal" = void ; then
243 AC_DEFINE(RETSIGVAL,)
245 AC_DEFINE(RETSIGVAL,(0))
250 AC_DEFINE(_BSD_SIGNALS)
254 dnl prefer sigset() to sigaction()
255 AC_CHECK_FUNCS(sigset)
256 if test $ac_cv_func_sigset = yes ; then
257 AC_DEFINE(signal,sigset)
259 AC_CHECK_FUNCS(sigaction)
265 dnl If using gcc, make sure we have ANSI ioctl definitions
269 dnl AC_LBL_FIXINCLUDES
271 AC_DEFUN(AC_LBL_FIXINCLUDES,
272 [if test "$GCC" = yes ; then
273 AC_MSG_CHECKING(for ANSI ioctl definitions)
274 AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes,
277 * This generates a "duplicate case value" when fixincludes
280 # include <sys/types.h>
281 # include <sys/time.h>
282 # include <sys/ioctl.h>
283 # ifdef HAVE_SYS_IOCCOM_H
284 # include <sys/ioccom.h>
290 ac_cv_lbl_gcc_fixincludes=yes,
291 ac_cv_lbl_gcc_fixincludes=no))
292 AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes)
293 if test $ac_cv_lbl_gcc_fixincludes = no ; then
294 # Don't cache failure
295 unset ac_cv_lbl_gcc_fixincludes
296 AC_MSG_ERROR(see the INSTALL for more info)
301 dnl Check for flex, default to lex
302 dnl Require flex 2.4 or higher
303 dnl Check for bison, default to yacc
304 dnl Default to lex/yacc if both flex and bison are not available
305 dnl Define the yy prefix string if using flex and bison
309 dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
314 dnl $2 (yacc appended)
315 dnl $3 (optional flex and bison -P prefix)
317 AC_DEFUN(AC_LBL_LEX_AND_YACC,
318 [AC_ARG_WITH(flex, [ --without-flex don't use flex])
319 AC_ARG_WITH(bison, [ --without-bison don't use bison])
320 if test "$with_flex" = no ; then
323 AC_CHECK_PROGS($1, flex, lex)
325 if test "$$1" = flex ; then
326 # The -V flag was added in 2.4
327 AC_MSG_CHECKING(for flex 2.4 or higher)
328 AC_CACHE_VAL(ac_cv_lbl_flex_v24,
329 if flex -V >/dev/null 2>&1; then
330 ac_cv_lbl_flex_v24=yes
332 ac_cv_lbl_flex_v24=no
334 AC_MSG_RESULT($ac_cv_lbl_flex_v24)
335 if test $ac_cv_lbl_flex_v24 = no ; then
336 s="2.4 or higher required"
337 AC_MSG_WARN(ignoring obsolete flex executable ($s))
341 if test "$with_bison" = no ; then
344 AC_CHECK_PROGS($2, bison, yacc)
346 if test "$$2" = bison ; then
349 if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
350 AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
354 if test "$$1" = flex -a -n "$3" ; then
360 dnl Checks to see if union wait is used with WEXITSTATUS()
364 dnl AC_LBL_UNION_WAIT
368 dnl DECLWAITSTATUS (defined)
370 AC_DEFUN(AC_LBL_UNION_WAIT,
371 [AC_MSG_CHECKING(if union wait is used)
372 AC_CACHE_VAL(ac_cv_lbl_union_wait,
374 # include <sys/types.h>
375 # include <sys/wait.h>],
377 u_int i = WEXITSTATUS(status);
378 u_int j = waitpid(0, &status, 0);],
379 ac_cv_lbl_union_wait=no,
380 ac_cv_lbl_union_wait=yes))
381 AC_MSG_RESULT($ac_cv_lbl_union_wait)
382 if test $ac_cv_lbl_union_wait = yes ; then
383 AC_DEFINE(DECLWAITSTATUS,union wait)
385 AC_DEFINE(DECLWAITSTATUS,int)
389 dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
393 dnl AC_LBL_SOCKADDR_SA_LEN
397 dnl HAVE_SOCKADDR_SA_LEN (defined)
399 AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
400 [AC_MSG_CHECKING(if sockaddr struct has sa_len member)
401 AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len,
403 # include <sys/types.h>
404 # include <sys/socket.h>],
405 [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
406 ac_cv_lbl_sockaddr_has_sa_len=yes,
407 ac_cv_lbl_sockaddr_has_sa_len=no))
408 AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len)
409 if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then
410 AC_DEFINE(HAVE_SOCKADDR_SA_LEN)
414 dnl Checks to see if the IFF_LOOPBACK exists as a define or enum
416 dnl (stupidly some versions of linux use an enum...)
420 dnl AC_LBL_IFF_LOOPBACK
424 dnl HAVE_IFF_LOOPBACK (defined)
426 AC_DEFUN(AC_LBL_IFF_LOOPBACK,
427 [AC_MSG_CHECKING(for IFF_LOOPBACK define/enum)
428 AC_CACHE_VAL(ac_cv_lbl_have_iff_loopback,
430 # include <sys/param.h>
431 # include <sys/file.h>
432 # include <sys/ioctl.h>
433 # include <sys/socket.h>
434 # ifdef HAVE_SYS_SOCKIO_H
435 # include <sys/sockio.h>
437 # include <sys/time.h>
439 # include <netinet/in.h>],
440 [int i = IFF_LOOPBACK],
441 ac_cv_lbl_have_iff_loopback=yes,
442 ac_cv_lbl_have_iff_loopback=no))
443 AC_MSG_RESULT($ac_cv_lbl_have_iff_loopback)
444 if test $ac_cv_lbl_have_iff_loopback = yes ; then
445 AC_DEFINE(HAVE_IFF_LOOPBACK)
449 dnl Checks to see if -R is used
453 dnl AC_LBL_HAVE_RUN_PATH
457 dnl ac_cv_lbl_have_run_path (yes or no)
459 AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
460 [AC_MSG_CHECKING(for ${CC-cc} -R)
461 AC_CACHE_VAL(ac_cv_lbl_have_run_path,
462 [echo 'main(){}' > conftest.c
463 ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
464 if test ! -s conftest.out ; then
465 ac_cv_lbl_have_run_path=yes
467 ac_cv_lbl_have_run_path=no
470 AC_MSG_RESULT($ac_cv_lbl_have_run_path)
474 dnl Due to the stupid way it's implemented, AC_CHECK_TYPE is nearly useless.
478 dnl AC_LBL_CHECK_TYPE
482 dnl int32_t (defined)
483 dnl u_int32_t (defined)
485 AC_DEFUN(AC_LBL_CHECK_TYPE,
486 [AC_MSG_CHECKING(for $1 using $CC)
487 AC_CACHE_VAL(ac_cv_lbl_have_$1,
489 # include "confdefs.h"
490 # include <sys/types.h>
496 ac_cv_lbl_have_$1=yes,
497 ac_cv_lbl_have_$1=no))
498 AC_MSG_RESULT($ac_cv_lbl_have_$1)
499 if test $ac_cv_lbl_have_$1 = no ; then
504 dnl Checks to see if unaligned memory accesses fail
508 dnl AC_LBL_UNALIGNED_ACCESS
512 dnl LBL_ALIGN (DEFINED)
514 AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
515 [AC_MSG_CHECKING(if unaligned accesses fail)
516 AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
517 [case "$target_cpu" in
519 alpha|hp*|mips|sparc)
520 ac_cv_lbl_unaligned_fail=yes
524 cat >conftest.c <<EOF
525 # include <sys/types.h>
526 # include <sys/wait.h>
528 unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
533 /* avoid "core dumped" message */
539 pid = waitpid(pid, &status, 0);
542 exit(!WIFEXITED(status));
545 i = *(unsigned int *)&a[[1]];
550 ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
551 conftest.c $LIBS >/dev/null 2>&1
552 if test ! -x conftest ; then
553 dnl failed to compile for some reason
554 ac_cv_lbl_unaligned_fail=yes
556 ./conftest >conftest.out
557 if test ! -s conftest.out ; then
558 ac_cv_lbl_unaligned_fail=yes
560 ac_cv_lbl_unaligned_fail=no
563 rm -f conftest* core core.conftest
566 AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
567 if test $ac_cv_lbl_unaligned_fail = yes ; then
572 dnl add all warning option to CFLAGS
576 dnl AC_LBL_CHECK_WALL(copt)
580 dnl $1 (copt appended)
581 dnl ac_cv_lbl_gcc_vers
583 AC_DEFUN(AC_LBL_CHECK_WALL,
584 [ if test "$GCC" = yes ; then
585 if test "$SHLICC2" = yes ; then
587 $1="`echo $$1 | sed -e 's/-O/-O2/'`"
589 AC_MSG_CHECKING(gcc version)
590 AC_CACHE_VAL(ac_cv_lbl_gcc_vers,
591 ac_cv_lbl_gcc_vers=`$CC --version 2>&1 | \
593 AC_MSG_RESULT($ac_cv_lbl_gcc_vers)
594 if test $ac_cv_lbl_gcc_vers -gt 1 ; then
595 $1="`echo $$1 | sed -e 's/-O/-O2/'`"
598 if test "${LBL_CFLAGS+set}" != set; then
599 if test "$ac_cv_prog_cc_g" = yes ; then
603 if test $ac_cv_lbl_gcc_vers -gt 1 ; then
604 $1="$$1 -Wmissing-prototypes -Wstrict-prototypes"
611 $1="$$1 -fullwarn -n32"
620 dnl If using gcc and the file .devel exists:
621 dnl Compile with -g (if supported) and -Wall
622 dnl If using gcc 2, do extra prototype checking
623 dnl If an os prototype include exists, symlink os-proto.h to it
627 dnl AC_LBL_DEVEL(copt)
631 dnl $1 (copt appended)
632 dnl HAVE_OS_PROTO_H (defined)
633 dnl os-proto.h (symlinked)
635 AC_DEFUN(AC_LBL_DEVEL,
637 if test "${LBL_CFLAGS+set}" = set; then
638 $1="$$1 ${LBL_CFLAGS}"
640 if test -f .devel ; then
641 AC_LBL_CHECK_WALL($1)
642 os=`echo $target_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
644 if test -f $name ; then
645 ln -s $name os-proto.h
646 AC_DEFINE(HAVE_OS_PROTO_H)
648 AC_MSG_WARN(can't find $name)
653 dnl Improved version of AC_CHECK_LIB
655 dnl Thanks to John Hawkinson (jhawk@mit.edu)
659 dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
660 dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
667 define(AC_LBL_CHECK_LIB,
668 [AC_MSG_CHECKING([for $2 in -l$1])
669 dnl Use a cache variable name containing both the library and function name,
670 dnl because the test really is for library $1 defining function $2, not
671 dnl just for library $1. Separate tests with the same $1 and different $2's
672 dnl may have different results.
673 ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
674 AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
675 [ac_save_LIBS="$LIBS"
678 ifelse([$2], [main], , dnl Avoid conflicting decl of main.
679 [/* Override any gcc2 internal prototype to avoid an error. */
680 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
684 [/* We use char because int might match the return type of a gcc2
685 builtin and then its argument prototype would still apply. */
689 eval "ac_cv_lbl_lib_$ac_lib_var=yes",
690 eval "ac_cv_lbl_lib_$ac_lib_var=no")
693 if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
697 ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
698 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
700 AC_DEFINE_UNQUOTED($ac_tr_lib)
711 dnl AC_LBL_LIBRARY_NET
713 dnl This test is for network applications that need socket() and
714 dnl gethostbyname() -ish functions. Under Solaris, those applications
715 dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link
716 dnl with "-lnsl" but should *not* link with "-lsocket" because
717 dnl libsocket.a breaks a number of things (for instance:
718 dnl gethostbyname() under IRIX 5.2, and snoop sockets under most
719 dnl versions of IRIX).
721 dnl Unfortunately, many application developers are not aware of this,
722 dnl and mistakenly write tests that cause -lsocket to be used under
723 dnl IRIX. It is also easy to write tests that cause -lnsl to be used
724 dnl under operating systems where neither are necessary (or useful),
725 dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
727 dnl This test exists so that every application developer does not test
728 dnl this in a different, and subtly broken fashion.
730 dnl It has been argued that this test should be broken up into two
731 dnl seperate tests, one for the resolver libraries, and one for the
732 dnl libraries necessary for using Sockets API. Unfortunately, the two
733 dnl are carefully intertwined and allowing the autoconf user to use
734 dnl them independantly potentially results in unfortunate ordering
735 dnl dependancies -- as such, such component macros would have to
736 dnl carefully use indirection and be aware if the other components were
737 dnl executed. Since other autoconf macros do not go to this trouble,
738 dnl and almost no applications use sockets without the resolver, this
739 dnl complexity has not been implemented.
741 dnl The check for libresolv is in case you are attempting to link
742 dnl statically and happen to have a libresolv.a lying around (and no
745 AC_DEFUN(AC_LBL_LIBRARY_NET, [
746 # Most operating systems have gethostbyname() in the default searched
747 # libraries (i.e. libc):
748 AC_CHECK_FUNC(gethostbyname, ,
749 # Some OSes (eg. Solaris) place it in libnsl:
750 AC_LBL_CHECK_LIB(nsl, gethostbyname, ,
751 # Some strange OSes (SINIX) have it in libsocket:
752 AC_LBL_CHECK_LIB(socket, gethostbyname, ,
753 # Unfortunately libsocket sometimes depends on libnsl.
754 # AC_CHECK_LIB's API is essentially broken so the
755 # following ugliness is necessary:
756 AC_LBL_CHECK_LIB(socket, gethostbyname,
757 LIBS="-lsocket -lnsl $LIBS",
758 AC_CHECK_LIB(resolv, gethostbyname),
760 AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, ,
761 AC_LBL_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", ,
763 # DLPI needs putmsg under HPUX so test for -lstr while we're at it
764 AC_CHECK_LIB(str, putmsg)