1 dnl @(#) $Header: /tcpdump/master/libpcap/aclocal.m4,v 1.93 2008-11-18 07:29:48 guy Exp $ (LBL)
3 dnl Copyright (c) 1995, 1996, 1997, 1998
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)
42 dnl ac_cv_lbl_gcc_vers
45 AC_DEFUN(AC_LBL_C_INIT,
47 AC_BEFORE([$0], [AC_PROG_CC])
48 AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
49 AC_BEFORE([$0], [AC_LBL_DEVEL])
50 AC_ARG_WITH(gcc, [ --without-gcc don't use gcc])
53 if test "${srcdir}" != "." ; then
56 if test "${CFLAGS+set}" = set; then
59 if test -z "$CC" ; then
63 AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
64 if test $SHLICC2 = yes ; then
71 if test -z "$CC" -a "$with_gcc" = no ; then
76 if test "$GCC" = yes ; then
77 if test "$SHLICC2" = yes ; then
81 AC_MSG_CHECKING(gcc version)
82 AC_CACHE_VAL(ac_cv_lbl_gcc_vers,
83 ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \
84 sed -e '/^gcc version /!d' \
85 -e 's/^gcc version //' \
86 -e 's/ .*//' -e 's/^[[[^0-9]]]*//' \
88 AC_MSG_RESULT($ac_cv_lbl_gcc_vers)
89 if test $ac_cv_lbl_gcc_vers -gt 1 ; then
95 # On platforms where we build a shared library:
97 # add options to generate position-independent code,
98 # if necessary (it's the default in AIX and Darwin/OS X);
100 # define option to set the soname of the shared library,
101 # if the OS supports that;
103 # add options to specify, at link time, a directory to
104 # add to the run-time search path, if that's necessary.
107 V_SHLIB_OPT="-shared"
113 freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*)
115 # Platforms where the linker is the GNU linker
116 # or accepts command-line arguments like
117 # those the GNU linker accepts.
119 V_CCOPT="$V_CCOPT -fpic"
120 V_SONAME_OPT="-Wl,-soname,"
121 V_RPATH_OPT="-Wl,-rpath,"
125 V_CCOPT="$V_CCOPT -fpic"
127 # XXX - this assumes GCC is using the HP linker,
128 # rather than the GNU linker, and that the "+h"
129 # option is used on all HP-UX platforms, both .sl
132 V_SONAME_OPT="-Wl,+h,"
134 # By default, directories specifed with -L
135 # are added to the run-time search path, so
136 # we don't add them in pcap-config.
141 V_CCOPT="$V_CCOPT -fpic"
143 # XXX - this assumes GCC is using the Sun linker,
144 # rather than the GNU linker.
146 V_SONAME_OPT="-Wl,-h,"
147 V_RPATH_OPT="-Wl,-R,"
151 AC_MSG_CHECKING(that $CC handles ansi prototypes)
152 AC_CACHE_VAL(ac_cv_lbl_cc_ansi_prototypes,
154 [#include <sys/types.h>],
155 [int frob(int, char *)],
156 ac_cv_lbl_cc_ansi_prototypes=yes,
157 ac_cv_lbl_cc_ansi_prototypes=no))
158 AC_MSG_RESULT($ac_cv_lbl_cc_ansi_prototypes)
159 if test $ac_cv_lbl_cc_ansi_prototypes = no ; then
163 AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE))
164 savedcflags="$CFLAGS"
165 CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
166 AC_CACHE_VAL(ac_cv_lbl_cc_hpux_cc_aa,
168 [#include <sys/types.h>],
169 [int frob(int, char *)],
170 ac_cv_lbl_cc_hpux_cc_aa=yes,
171 ac_cv_lbl_cc_hpux_cc_aa=no))
172 AC_MSG_RESULT($ac_cv_lbl_cc_hpux_cc_aa)
173 if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then
174 AC_MSG_ERROR(see the INSTALL doc for more info)
176 CFLAGS="$savedcflags"
178 AC_DEFINE(_HPUX_SOURCE,1,[needed on HP-UX])
182 AC_MSG_CHECKING(for ansi mode in DEC compiler ($CC -std1))
183 savedcflags="$CFLAGS"
185 AC_CACHE_VAL(ac_cv_lbl_cc_osf1_cc_std1,
187 [#include <sys/types.h>],
188 [int frob(int, char *)],
189 ac_cv_lbl_cc_osf1_cc_std1=yes,
190 ac_cv_lbl_cc_osf1_cc_std1=no))
191 AC_MSG_RESULT($ac_cv_lbl_cc_osf1_cc_std1)
192 if test $ac_cv_lbl_cc_osf1_cc_std1 = no ; then
193 AC_MSG_ERROR(see the INSTALL doc for more info)
195 CFLAGS="$savedcflags"
200 AC_MSG_ERROR(see the INSTALL doc for more info)
204 $2="$$2 -I/usr/local/include"
205 LDFLAGS="$LDFLAGS -L/usr/local/lib"
208 # Set the appropriate compiler flags and, on platforms
209 # where we build a shared library:
211 # add options to generate position-independent code,
212 # if necessary (it's the default in Darwin/OS X);
214 # if we generate ".so" shared libraries, define the
215 # appropriate options for building the shared library;
217 # add options to specify, at link time, a directory to
218 # add to the run-time search path, if that's necessary.
220 # Note: spaces after V_SONAME_OPT are significant; on
221 # some platforms the soname is passed with a GCC-like
222 # "-Wl,-soname,{soname}" option, with the soname part
223 # of the option, while on other platforms the C compiler
224 # driver takes it as a regular option with the soname
225 # following the option. The same applies to V_RPATH_OPT.
231 V_SHLIB_OPT="-G -bnoentry -bexpall"
234 freebsd*|netbsd*|openbsd*|dragonfly*|linux*)
240 V_SHLIB_OPT="-shared"
241 V_SONAME_OPT="-Wl,-soname,"
242 V_RPATH_OPT="-Wl,-rpath,"
251 # By default, directories specifed with -L
252 # are added to the run-time search path, so
253 # we don't add them in pcap-config.
258 $1="$$1 -xansi -signed -g3"
263 # Presumed to be DEC OSF/1, Digital UNIX, or
268 V_SHLIB_OPT="-shared"
269 V_SONAME_OPT="-soname "
270 V_RPATH_OPT="-rpath "
274 V_CCOPT="$V_CCOPT -Kpic"
282 AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
283 AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
285 [#include <sys/types.h>],
286 [struct a { int b; };
287 void c(const struct a *)],
288 ac_cv_lbl_cc_const_proto=yes,
289 ac_cv_lbl_cc_const_proto=no))
290 AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
291 if test $ac_cv_lbl_cc_const_proto = no ; then
293 [to handle Ultrix compilers that don't support const in prototypes])
301 # Try compiling a sample of the type of code that appears in
302 # gencode.c with "inline", "__inline__", and "__inline".
304 # Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough,
305 # as it just tests whether a function returning "int" can be inlined;
306 # at least some versions of HP's C compiler can inline that, but can't
307 # inline a function that returns a struct pointer.
309 # Make sure we use the V_CCOPT flags, because some of those might
312 AC_DEFUN(AC_LBL_C_INLINE,
313 [AC_MSG_CHECKING(for inline)
314 save_CFLAGS="$CFLAGS"
316 AC_CACHE_VAL(ac_cv_lbl_inline, [
319 for ac_lbl_inline in inline __inline__ __inline
322 [#define inline $ac_lbl_inline
323 static inline struct iltest *foo(void);
329 static inline struct iltest *
332 static struct iltest xxx;
335 }],,ac_lbl_cc_inline=yes,)
336 if test "$ac_lbl_cc_inline" = yes ; then
340 if test "$ac_lbl_cc_inline" = yes ; then
341 ac_cv_lbl_inline=$ac_lbl_inline
343 CFLAGS="$save_CFLAGS"
344 if test ! -z "$ac_cv_lbl_inline" ; then
345 AC_MSG_RESULT($ac_cv_lbl_inline)
349 AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
352 dnl If using gcc, make sure we have ANSI ioctl definitions
356 dnl AC_LBL_FIXINCLUDES
358 AC_DEFUN(AC_LBL_FIXINCLUDES,
359 [if test "$GCC" = yes ; then
360 AC_MSG_CHECKING(for ANSI ioctl definitions)
361 AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes,
364 * This generates a "duplicate case value" when fixincludes
367 # include <sys/types.h>
368 # include <sys/time.h>
369 # include <sys/ioctl.h>
370 # ifdef HAVE_SYS_IOCCOM_H
371 # include <sys/ioccom.h>
377 ac_cv_lbl_gcc_fixincludes=yes,
378 ac_cv_lbl_gcc_fixincludes=no))
379 AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes)
380 if test $ac_cv_lbl_gcc_fixincludes = no ; then
381 # Don't cache failure
382 unset ac_cv_lbl_gcc_fixincludes
383 AC_MSG_ERROR(see the INSTALL for more info)
388 dnl Check for flex, default to lex
389 dnl Require flex 2.4 or higher
390 dnl Check for bison, default to yacc
391 dnl Default to lex/yacc if both flex and bison are not available
392 dnl Define the yy prefix string if using flex and bison
396 dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
401 dnl $2 (yacc appended)
402 dnl $3 (optional flex and bison -P prefix)
404 AC_DEFUN(AC_LBL_LEX_AND_YACC,
405 [AC_ARG_WITH(flex, [ --without-flex don't use flex])
406 AC_ARG_WITH(bison, [ --without-bison don't use bison])
407 if test "$with_flex" = no ; then
410 AC_CHECK_PROGS($1, flex, lex)
412 if test "$$1" = flex ; then
413 # The -V flag was added in 2.4
414 AC_MSG_CHECKING(for flex 2.4 or higher)
415 AC_CACHE_VAL(ac_cv_lbl_flex_v24,
416 if flex -V >/dev/null 2>&1; then
417 ac_cv_lbl_flex_v24=yes
419 ac_cv_lbl_flex_v24=no
421 AC_MSG_RESULT($ac_cv_lbl_flex_v24)
422 if test $ac_cv_lbl_flex_v24 = no ; then
423 s="2.4 or higher required"
424 AC_MSG_WARN(ignoring obsolete flex executable ($s))
428 if test "$with_bison" = no ; then
431 AC_CHECK_PROGS($2, bison, yacc)
433 if test "$$2" = bison ; then
436 if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
437 AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
441 if test "$$1" = flex -a -n "$3" ; then
447 dnl Checks to see if union wait is used with WEXITSTATUS()
451 dnl AC_LBL_UNION_WAIT
455 dnl DECLWAITSTATUS (defined)
457 AC_DEFUN(AC_LBL_UNION_WAIT,
458 [AC_MSG_CHECKING(if union wait is used)
459 AC_CACHE_VAL(ac_cv_lbl_union_wait,
461 # include <sys/types.h>
462 # include <sys/wait.h>],
464 u_int i = WEXITSTATUS(status);
465 u_int j = waitpid(0, &status, 0);],
466 ac_cv_lbl_union_wait=no,
467 ac_cv_lbl_union_wait=yes))
468 AC_MSG_RESULT($ac_cv_lbl_union_wait)
469 if test $ac_cv_lbl_union_wait = yes ; then
470 AC_DEFINE(DECLWAITSTATUS,union wait,[type for wait])
472 AC_DEFINE(DECLWAITSTATUS,int,[type for wait])
476 dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
480 dnl AC_LBL_SOCKADDR_SA_LEN
484 dnl HAVE_SOCKADDR_SA_LEN (defined)
486 AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
487 [AC_MSG_CHECKING(if sockaddr struct has the sa_len member)
488 AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len,
490 # include <sys/types.h>
491 # include <sys/socket.h>],
492 [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
493 ac_cv_lbl_sockaddr_has_sa_len=yes,
494 ac_cv_lbl_sockaddr_has_sa_len=no))
495 AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len)
496 if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then
497 AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[if struct sockaddr has the sa_len member])
501 dnl Checks to see if there's a sockaddr_storage structure
505 dnl AC_LBL_SOCKADDR_STORAGE
509 dnl HAVE_SOCKADDR_STORAGE (defined)
511 AC_DEFUN(AC_LBL_SOCKADDR_STORAGE,
512 [AC_MSG_CHECKING(if sockaddr_storage struct exists)
513 AC_CACHE_VAL(ac_cv_lbl_has_sockaddr_storage,
515 # include <sys/types.h>
516 # include <sys/socket.h>],
517 [u_int i = sizeof (struct sockaddr_storage)],
518 ac_cv_lbl_has_sockaddr_storage=yes,
519 ac_cv_lbl_has_sockaddr_storage=no))
520 AC_MSG_RESULT($ac_cv_lbl_has_sockaddr_storage)
521 if test $ac_cv_lbl_has_sockaddr_storage = yes ; then
522 AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[if struct sockaddr_storage exists])
526 dnl Checks to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
527 dnl dl_module_id_1 member
531 dnl AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
535 dnl HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 (defined)
537 dnl NOTE: any compile failure means we conclude that it doesn't have
538 dnl that member, so if we don't have DLPI, don't have a <sys/dlpi_ext.h>
539 dnl header, or have one that doesn't declare a dl_hp_ppa_info_t type,
540 dnl we conclude it doesn't have that member (which is OK, as either we
541 dnl won't be using code that would use that member, or we wouldn't
542 dnl compile in any case).
544 AC_DEFUN(AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1,
545 [AC_MSG_CHECKING(if dl_hp_ppa_info_t struct has dl_module_id_1 member)
546 AC_CACHE_VAL(ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1,
548 # include <sys/types.h>
549 # include <sys/dlpi.h>
550 # include <sys/dlpi_ext.h>],
551 [u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)],
552 ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes,
553 ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no))
554 AC_MSG_RESULT($ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1)
555 if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then
556 AC_DEFINE(HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1,1,[if ppa_info_t_dl_module_id exists])
560 dnl Checks to see if -R is used
564 dnl AC_LBL_HAVE_RUN_PATH
568 dnl ac_cv_lbl_have_run_path (yes or no)
570 AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
571 [AC_MSG_CHECKING(for ${CC-cc} -R)
572 AC_CACHE_VAL(ac_cv_lbl_have_run_path,
573 [echo 'main(){}' > conftest.c
574 ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
575 if test ! -s conftest.out ; then
576 ac_cv_lbl_have_run_path=yes
578 ac_cv_lbl_have_run_path=no
581 AC_MSG_RESULT($ac_cv_lbl_have_run_path)
585 dnl Checks to see if unaligned memory accesses fail
589 dnl AC_LBL_UNALIGNED_ACCESS
593 dnl LBL_ALIGN (DEFINED)
595 AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
596 [AC_MSG_CHECKING(if unaligned accesses fail)
597 AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
601 # These are CPU types where:
603 # the CPU faults on an unaligned access, but at least some
604 # OSes that support that CPU catch the fault and simulate
605 # the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) -
606 # the simulation is slow, so we don't want to use it;
608 # the CPU, I infer (from the old
610 # XXX: should also check that they don't do weird things (like on arm)
612 # comment) doesn't fault on unaligned accesses, but doesn't
613 # do a normal unaligned fetch, either (e.g., presumably, ARM);
615 # for whatever reason, the test program doesn't work
616 # (this has been claimed to be the case for several of those
617 # CPUs - I don't know what the problem is; the problem
618 # was reported as "the test program dumps core" for SuperH,
619 # but that's what the test program is *supposed* to do -
620 # it dumps core before it writes anything, so the test
621 # for an empty output file should find an empty output
622 # file and conclude that unaligned accesses don't work).
624 # This run-time test won't work if you're cross-compiling, so
625 # in order to support cross-compiling for a particular CPU,
626 # we have to wire in the list of CPU types anyway, as far as
627 # I know, so perhaps we should just have a set of CPUs on
628 # which we know it doesn't work, a set of CPUs on which we
629 # know it does work, and have the script just fail on other
630 # cpu types and update it when such a failure occurs.
632 alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1)
633 ac_cv_lbl_unaligned_fail=yes
637 cat >conftest.c <<EOF
638 # include <sys/types.h>
639 # include <sys/wait.h>
641 unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
646 /* avoid "core dumped" message */
652 pid = waitpid(pid, &status, 0);
655 exit(!WIFEXITED(status));
658 i = *(unsigned int *)&a[[1]];
663 ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
664 conftest.c $LIBS >/dev/null 2>&1
665 if test ! -x conftest ; then
666 dnl failed to compile for some reason
667 ac_cv_lbl_unaligned_fail=yes
669 ./conftest >conftest.out
670 if test ! -s conftest.out ; then
671 ac_cv_lbl_unaligned_fail=yes
673 ac_cv_lbl_unaligned_fail=no
676 rm -f conftest* core core.conftest
679 AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
680 if test $ac_cv_lbl_unaligned_fail = yes ; then
681 AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails])
685 dnl If using gcc and the file .devel exists:
686 dnl Compile with -g (if supported) and -Wall
687 dnl If using gcc 2 or later, do extra prototype checking
688 dnl If an os prototype include exists, symlink os-proto.h to it
692 dnl AC_LBL_DEVEL(copt)
696 dnl $1 (copt appended)
697 dnl HAVE_OS_PROTO_H (defined)
698 dnl os-proto.h (symlinked)
700 AC_DEFUN(AC_LBL_DEVEL,
702 if test "${LBL_CFLAGS+set}" = set; then
703 $1="$$1 ${LBL_CFLAGS}"
705 if test -f .devel ; then
706 if test "$GCC" = yes ; then
707 if test "${LBL_CFLAGS+set}" != set; then
708 if test "$ac_cv_prog_cc_g" = yes ; then
712 if test $ac_cv_lbl_gcc_vers -gt 1 ; then
713 $1="$$1 -Wmissing-prototypes -Wstrict-prototypes"
720 V_CCOPT="$V_CCOPT -n32"
727 os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
729 if test -f $name ; then
730 ln -s $name os-proto.h
731 AC_DEFINE(HAVE_OS_PROTO_H, 1,
732 [if there's an os_proto.h for this platform, to use additional prototypes])
734 AC_MSG_WARN(can't find $name)
739 dnl Improved version of AC_CHECK_LIB
741 dnl Thanks to John Hawkinson (jhawk@mit.edu)
745 dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
746 dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
752 dnl XXX - "AC_LBL_LIBRARY_NET" was redone to use "AC_SEARCH_LIBS"
753 dnl rather than "AC_LBL_CHECK_LIB", so this isn't used any more.
754 dnl We keep it around for reference purposes in case it's ever
755 dnl useful in the future.
758 define(AC_LBL_CHECK_LIB,
759 [AC_MSG_CHECKING([for $2 in -l$1])
760 dnl Use a cache variable name containing the library, function
761 dnl name, and extra libraries to link with, because the test really is
762 dnl for library $1 defining function $2, when linked with potinal
763 dnl library $5, not just for library $1. Separate tests with the same
764 dnl $1 and different $2's or $5's may have different results.
765 ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
766 AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
767 [ac_save_LIBS="$LIBS"
770 ifelse([$2], [main], , dnl Avoid conflicting decl of main.
771 [/* Override any gcc2 internal prototype to avoid an error. */
772 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
776 [/* We use char because int might match the return type of a gcc2
777 builtin and then its argument prototype would still apply. */
781 eval "ac_cv_lbl_lib_$ac_lib_var=yes",
782 eval "ac_cv_lbl_lib_$ac_lib_var=no")
785 if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
789 ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
790 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
792 AC_DEFINE_UNQUOTED($ac_tr_lib)
803 dnl AC_LBL_LIBRARY_NET
805 dnl This test is for network applications that need socket() and
806 dnl gethostbyname() -ish functions. Under Solaris, those applications
807 dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link
808 dnl with "-lnsl" but should *not* link with "-lsocket" because
809 dnl libsocket.a breaks a number of things (for instance:
810 dnl gethostbyname() under IRIX 5.2, and snoop sockets under most
811 dnl versions of IRIX).
813 dnl Unfortunately, many application developers are not aware of this,
814 dnl and mistakenly write tests that cause -lsocket to be used under
815 dnl IRIX. It is also easy to write tests that cause -lnsl to be used
816 dnl under operating systems where neither are necessary (or useful),
817 dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
819 dnl This test exists so that every application developer does not test
820 dnl this in a different, and subtly broken fashion.
822 dnl It has been argued that this test should be broken up into two
823 dnl seperate tests, one for the resolver libraries, and one for the
824 dnl libraries necessary for using Sockets API. Unfortunately, the two
825 dnl are carefully intertwined and allowing the autoconf user to use
826 dnl them independantly potentially results in unfortunate ordering
827 dnl dependancies -- as such, such component macros would have to
828 dnl carefully use indirection and be aware if the other components were
829 dnl executed. Since other autoconf macros do not go to this trouble,
830 dnl and almost no applications use sockets without the resolver, this
831 dnl complexity has not been implemented.
833 dnl The check for libresolv is in case you are attempting to link
834 dnl statically and happen to have a libresolv.a lying around (and no
837 AC_DEFUN(AC_LBL_LIBRARY_NET, [
838 # Most operating systems have gethostbyname() in the default searched
839 # libraries (i.e. libc):
840 # Some OSes (eg. Solaris) place it in libnsl
841 # Some strange OSes (SINIX) have it in libsocket:
842 AC_SEARCH_LIBS(gethostbyname, nsl socket resolv)
843 # Unfortunately libsocket sometimes depends on libnsl and
844 # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this.
845 if test "$ac_cv_search_gethostbyname" = "no"
847 AC_CHECK_LIB(socket, gethostbyname,
848 LIBS="-lsocket -lnsl $LIBS", , -lnsl)
850 AC_SEARCH_LIBS(socket, socket, ,
851 AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl))
852 # DLPI needs putmsg under HPUX so test for -lstr while we're at it
853 AC_SEARCH_LIBS(putmsg, str)
857 dnl Test for __attribute__
860 AC_DEFUN(AC_C___ATTRIBUTE__, [
861 AC_MSG_CHECKING(for __attribute__)
862 AC_CACHE_VAL(ac_cv___attribute__, [
867 static void foo(void) __attribute__ ((noreturn));
876 main(int argc, char **argv)
881 ac_cv___attribute__=yes,
882 ac_cv___attribute__=no)])
883 if test "$ac_cv___attribute__" = "yes"; then
884 AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
885 V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
887 V_DEFS="$V_DEFS -D_U_=\"\""
889 AC_MSG_RESULT($ac_cv___attribute__)
893 dnl Checks to see if tpacket_stats is defined in linux/if_packet.h
894 dnl If so then pcap-linux.c can use this to report proper statistics.
898 AC_DEFUN(AC_LBL_TPACKET_STATS,
899 [AC_MSG_CHECKING(if if_packet.h has tpacket_stats defined)
900 AC_CACHE_VAL(ac_cv_lbl_tpacket_stats,
902 # include <linux/if_packet.h>],
903 [struct tpacket_stats stats],
904 ac_cv_lbl_tpacket_stats=yes,
905 ac_cv_lbl_tpacket_stats=no))
906 AC_MSG_RESULT($ac_cv_lbl_tpacket_stats)
907 if test $ac_cv_lbl_tpacket_stats = yes; then
908 AC_DEFINE(HAVE_TPACKET_STATS,1,[if if_packet.h has tpacket_stats defined])
912 dnl Checks to see if the tpacket_auxdata struct has a tp_vlan_tci member.
916 dnl AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
920 dnl HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI (defined)
922 dnl NOTE: any compile failure means we conclude that it doesn't have
923 dnl that member, so if we don't have tpacket_auxdata, we conclude it
924 dnl doesn't have that member (which is OK, as either we won't be using
925 dnl code that would use that member, or we wouldn't compile in any case).
927 AC_DEFUN(AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,
928 [AC_MSG_CHECKING(if tpacket_auxdata struct has tp_vlan_tci member)
929 AC_CACHE_VAL(ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1,
931 # include <linux/if_packet.h>],
932 [u_int i = sizeof(((struct tpacket_auxdata *)0)->tp_vlan_tci)],
933 ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=yes,
934 ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=no))
935 AC_MSG_RESULT($ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci)
936 if test $ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci = yes ; then
937 HAVE_LINUX_TPACKET_AUXDATA=tp_vlan_tci
938 AC_SUBST(HAVE_LINUX_TPACKET_AUXDATA)
939 AC_DEFINE(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,1,[if tp_vlan_tci exists])
943 dnl Checks to see if Solaris has the dl_passive_req_t struct defined
948 dnl AC_LBL_DL_PASSIVE_REQ_T
952 dnl HAVE_DLPI_PASSIVE (defined)
954 AC_DEFUN(AC_LBL_DL_PASSIVE_REQ_T,
955 [AC_MSG_CHECKING(if dl_passive_req_t struct exists)
956 AC_CACHE_VAL(ac_cv_lbl_has_dl_passive_req_t,
958 # include <sys/types.h>
959 # include <sys/dlpi.h>],
960 [u_int i = sizeof(dl_passive_req_t)],
961 ac_cv_lbl_has_dl_passive_req_t=yes,
962 ac_cv_lbl_has_dl_passive_req_t=no))
963 AC_MSG_RESULT($ac_cv_lbl_has_dl_passive_req_t)
964 if test $ac_cv_lbl_has_dl_passive_req_t = yes ; then
965 AC_DEFINE(HAVE_DLPI_PASSIVE,1,[if passive_req_t primitive