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 Do whatever AC_LBL_C_INIT work is necessary before using AC_PROG_CC.
28 dnl It appears that newer versions of autoconf (2.64 and later) will,
29 dnl if you use AC_TRY_COMPILE in a macro, stick AC_PROG_CC at the
30 dnl beginning of the macro, even if the macro itself calls AC_PROG_CC.
31 dnl See the "Prerequisite Macros" and "Expanded Before Required" sections
32 dnl in the Autoconf documentation.
34 dnl This causes a steaming heap of fail in our case, as we were, in
35 dnl AC_LBL_C_INIT, doing the tests we now do in AC_LBL_C_INIT_BEFORE_CC,
36 dnl calling AC_PROG_CC, and then doing the tests we now do in
37 dnl AC_LBL_C_INIT. Now, we run AC_LBL_C_INIT_BEFORE_CC, AC_PROG_CC,
38 dnl and AC_LBL_C_INIT at the top level.
40 AC_DEFUN(AC_LBL_C_INIT_BEFORE_CC,
42 AC_BEFORE([$0], [AC_LBL_C_INIT])
43 AC_BEFORE([$0], [AC_PROG_CC])
44 AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
45 AC_BEFORE([$0], [AC_LBL_DEVEL])
46 AC_ARG_WITH(gcc, [ --without-gcc don't use gcc])
49 if test "${srcdir}" != "." ; then
52 if test "${CFLAGS+set}" = set; then
55 if test -z "$CC" ; then
59 AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
60 if test $SHLICC2 = yes ; then
67 if test -z "$CC" -a "$with_gcc" = no ; then
74 dnl Determine which compiler we're using (cc or gcc)
75 dnl If using gcc, determine the version number
76 dnl If using cc, require that it support ansi prototypes
77 dnl If using gcc, use -O2 (otherwise use -O)
78 dnl If using cc, explicitly specify /usr/local/include
82 dnl AC_LBL_C_INIT(copt, incls)
90 dnl ac_cv_lbl_gcc_vers
93 AC_DEFUN(AC_LBL_C_INIT,
95 AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
96 AC_BEFORE([$0], [AC_LBL_DEVEL])
97 AC_BEFORE([$0], [AC_LBL_SHLIBS_INIT])
98 if test "$GCC" = yes ; then
99 if test "$SHLICC2" = yes ; then
103 AC_MSG_CHECKING(gcc version)
104 AC_CACHE_VAL(ac_cv_lbl_gcc_vers,
105 ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \
106 sed -e '/^gcc version /!d' \
107 -e 's/^gcc version //' \
108 -e 's/ .*//' -e 's/^[[[^0-9]]]*//' \
110 AC_MSG_RESULT($ac_cv_lbl_gcc_vers)
111 if test $ac_cv_lbl_gcc_vers -gt 1 ; then
116 AC_MSG_CHECKING(that $CC handles ansi prototypes)
117 AC_CACHE_VAL(ac_cv_lbl_cc_ansi_prototypes,
119 [#include <sys/types.h>],
120 [int frob(int, char *)],
121 ac_cv_lbl_cc_ansi_prototypes=yes,
122 ac_cv_lbl_cc_ansi_prototypes=no))
123 AC_MSG_RESULT($ac_cv_lbl_cc_ansi_prototypes)
124 if test $ac_cv_lbl_cc_ansi_prototypes = no ; then
128 AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE))
129 savedcflags="$CFLAGS"
130 CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
131 AC_CACHE_VAL(ac_cv_lbl_cc_hpux_cc_aa,
133 [#include <sys/types.h>],
134 [int frob(int, char *)],
135 ac_cv_lbl_cc_hpux_cc_aa=yes,
136 ac_cv_lbl_cc_hpux_cc_aa=no))
137 AC_MSG_RESULT($ac_cv_lbl_cc_hpux_cc_aa)
138 if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then
139 AC_MSG_ERROR(see the INSTALL doc for more info)
141 CFLAGS="$savedcflags"
143 AC_DEFINE(_HPUX_SOURCE,1,[needed on HP-UX])
147 AC_MSG_CHECKING(for ansi mode in DEC compiler ($CC -std1))
148 savedcflags="$CFLAGS"
150 AC_CACHE_VAL(ac_cv_lbl_cc_osf1_cc_std1,
152 [#include <sys/types.h>],
153 [int frob(int, char *)],
154 ac_cv_lbl_cc_osf1_cc_std1=yes,
155 ac_cv_lbl_cc_osf1_cc_std1=no))
156 AC_MSG_RESULT($ac_cv_lbl_cc_osf1_cc_std1)
157 if test $ac_cv_lbl_cc_osf1_cc_std1 = no ; then
158 AC_MSG_ERROR(see the INSTALL doc for more info)
160 CFLAGS="$savedcflags"
165 AC_MSG_ERROR(see the INSTALL doc for more info)
169 $2="$$2 -I/usr/local/include"
170 LDFLAGS="$LDFLAGS -L/usr/local/lib"
175 $1="$$1 -xansi -signed -g3"
180 # Presumed to be DEC OSF/1, Digital UNIX, or
187 AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
188 AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
190 [#include <sys/types.h>],
191 [struct a { int b; };
192 void c(const struct a *)],
193 ac_cv_lbl_cc_const_proto=yes,
194 ac_cv_lbl_cc_const_proto=no))
195 AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
196 if test $ac_cv_lbl_cc_const_proto = no ; then
198 [to handle Ultrix compilers that don't support const in prototypes])
206 dnl Determine what options are needed to build a shared library
210 dnl AC_LBL_SHLIBS_INIT
214 dnl V_CCOPT (modified to build position-independent code)
220 AC_DEFUN(AC_LBL_SHLIBS_INIT,
222 if test "$GCC" = yes ; then
224 # On platforms where we build a shared library:
226 # add options to generate position-independent code,
227 # if necessary (it's the default in AIX and Darwin/OS X);
229 # define option to set the soname of the shared library,
230 # if the OS supports that;
232 # add options to specify, at link time, a directory to
233 # add to the run-time search path, if that's necessary.
236 V_SHLIB_OPT="-shared"
242 freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*)
244 # Platforms where the linker is the GNU linker
245 # or accepts command-line arguments like
246 # those the GNU linker accepts.
248 # Some instruction sets require -fPIC on some
249 # operating systems. Check for them. If you
250 # have a combination that requires it, add it
265 V_CCOPT="$V_CCOPT $PIC_OPT"
266 V_SONAME_OPT="-Wl,-soname,"
267 V_RPATH_OPT="-Wl,-rpath,"
271 V_CCOPT="$V_CCOPT -fpic"
273 # XXX - this assumes GCC is using the HP linker,
274 # rather than the GNU linker, and that the "+h"
275 # option is used on all HP-UX platforms, both .sl
278 V_SONAME_OPT="-Wl,+h,"
280 # By default, directories specifed with -L
281 # are added to the run-time search path, so
282 # we don't add them in pcap-config.
287 V_CCOPT="$V_CCOPT -fpic"
289 # XXX - this assumes GCC is using the Sun linker,
290 # rather than the GNU linker.
292 V_SONAME_OPT="-Wl,-h,"
293 V_RPATH_OPT="-Wl,-R,"
298 # Set the appropriate compiler flags and, on platforms
299 # where we build a shared library:
301 # add options to generate position-independent code,
302 # if necessary (it's the default in Darwin/OS X);
304 # if we generate ".so" shared libraries, define the
305 # appropriate options for building the shared library;
307 # add options to specify, at link time, a directory to
308 # add to the run-time search path, if that's necessary.
310 # Note: spaces after V_SONAME_OPT are significant; on
311 # some platforms the soname is passed with a GCC-like
312 # "-Wl,-soname,{soname}" option, with the soname part
313 # of the option, while on other platforms the C compiler
314 # driver takes it as a regular option with the soname
315 # following the option. The same applies to V_RPATH_OPT.
321 V_SHLIB_OPT="-G -bnoentry -bexpall"
324 freebsd*|netbsd*|openbsd*|dragonfly*|linux*)
328 V_CCOPT="$V_CCOPT -fpic"
330 V_SHLIB_OPT="-shared"
331 V_SONAME_OPT="-Wl,-soname,"
332 V_RPATH_OPT="-Wl,-rpath,"
336 V_CCOPT="$V_CCOPT +z"
341 # By default, directories specifed with -L
342 # are added to the run-time search path, so
343 # we don't add them in pcap-config.
349 # Presumed to be DEC OSF/1, Digital UNIX, or
353 V_SHLIB_OPT="-shared"
354 V_SONAME_OPT="-soname "
355 V_RPATH_OPT="-rpath "
359 V_CCOPT="$V_CCOPT -Kpic"
370 # Try compiling a sample of the type of code that appears in
371 # gencode.c with "inline", "__inline__", and "__inline".
373 # Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough,
374 # as it just tests whether a function returning "int" can be inlined;
375 # at least some versions of HP's C compiler can inline that, but can't
376 # inline a function that returns a struct pointer.
378 # Make sure we use the V_CCOPT flags, because some of those might
381 AC_DEFUN(AC_LBL_C_INLINE,
382 [AC_MSG_CHECKING(for inline)
383 save_CFLAGS="$CFLAGS"
385 AC_CACHE_VAL(ac_cv_lbl_inline, [
388 for ac_lbl_inline in inline __inline__ __inline
391 [#define inline $ac_lbl_inline
392 static inline struct iltest *foo(void);
398 static inline struct iltest *
401 static struct iltest xxx;
404 }],,ac_lbl_cc_inline=yes,)
405 if test "$ac_lbl_cc_inline" = yes ; then
409 if test "$ac_lbl_cc_inline" = yes ; then
410 ac_cv_lbl_inline=$ac_lbl_inline
412 CFLAGS="$save_CFLAGS"
413 if test ! -z "$ac_cv_lbl_inline" ; then
414 AC_MSG_RESULT($ac_cv_lbl_inline)
418 AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
421 dnl If using gcc, make sure we have ANSI ioctl definitions
425 dnl AC_LBL_FIXINCLUDES
427 AC_DEFUN(AC_LBL_FIXINCLUDES,
428 [if test "$GCC" = yes ; then
429 AC_MSG_CHECKING(for ANSI ioctl definitions)
430 AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes,
433 * This generates a "duplicate case value" when fixincludes
436 # include <sys/types.h>
437 # include <sys/time.h>
438 # include <sys/ioctl.h>
439 # ifdef HAVE_SYS_IOCCOM_H
440 # include <sys/ioccom.h>
446 ac_cv_lbl_gcc_fixincludes=yes,
447 ac_cv_lbl_gcc_fixincludes=no))
448 AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes)
449 if test $ac_cv_lbl_gcc_fixincludes = no ; then
450 # Don't cache failure
451 unset ac_cv_lbl_gcc_fixincludes
452 AC_MSG_ERROR(see the INSTALL for more info)
457 dnl Check for flex, default to lex
458 dnl Require flex 2.4 or higher
459 dnl Check for bison, default to yacc
460 dnl Default to lex/yacc if both flex and bison are not available
461 dnl Define the yy prefix string if using flex and bison
465 dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
470 dnl $2 (yacc appended)
471 dnl $3 (optional flex and bison -P prefix)
473 AC_DEFUN(AC_LBL_LEX_AND_YACC,
474 [AC_ARG_WITH(flex, [ --without-flex don't use flex])
475 AC_ARG_WITH(bison, [ --without-bison don't use bison])
476 if test "$with_flex" = no ; then
479 AC_CHECK_PROGS($1, flex, lex)
481 if test "$$1" = flex ; then
482 # The -V flag was added in 2.4
483 AC_MSG_CHECKING(for flex 2.4 or higher)
484 AC_CACHE_VAL(ac_cv_lbl_flex_v24,
485 if flex -V >/dev/null 2>&1; then
486 ac_cv_lbl_flex_v24=yes
488 ac_cv_lbl_flex_v24=no
490 AC_MSG_RESULT($ac_cv_lbl_flex_v24)
491 if test $ac_cv_lbl_flex_v24 = no ; then
492 s="2.4 or higher required"
493 AC_MSG_WARN(ignoring obsolete flex executable ($s))
497 if test "$with_bison" = no ; then
500 AC_CHECK_PROGS($2, bison, yacc)
502 if test "$$2" = bison ; then
505 if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
506 AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
510 if test "$$1" = flex -a -n "$3" ; then
516 dnl Checks to see if union wait is used with WEXITSTATUS()
520 dnl AC_LBL_UNION_WAIT
524 dnl DECLWAITSTATUS (defined)
526 AC_DEFUN(AC_LBL_UNION_WAIT,
527 [AC_MSG_CHECKING(if union wait is used)
528 AC_CACHE_VAL(ac_cv_lbl_union_wait,
530 # include <sys/types.h>
531 # include <sys/wait.h>],
533 u_int i = WEXITSTATUS(status);
534 u_int j = waitpid(0, &status, 0);],
535 ac_cv_lbl_union_wait=no,
536 ac_cv_lbl_union_wait=yes))
537 AC_MSG_RESULT($ac_cv_lbl_union_wait)
538 if test $ac_cv_lbl_union_wait = yes ; then
539 AC_DEFINE(DECLWAITSTATUS,union wait,[type for wait])
541 AC_DEFINE(DECLWAITSTATUS,int,[type for wait])
545 dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
549 dnl AC_LBL_SOCKADDR_SA_LEN
553 dnl HAVE_SOCKADDR_SA_LEN (defined)
555 AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
556 [AC_MSG_CHECKING(if sockaddr struct has the sa_len member)
557 AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len,
559 # include <sys/types.h>
560 # include <sys/socket.h>],
561 [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
562 ac_cv_lbl_sockaddr_has_sa_len=yes,
563 ac_cv_lbl_sockaddr_has_sa_len=no))
564 AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len)
565 if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then
566 AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[if struct sockaddr has the sa_len member])
570 dnl Checks to see if there's a sockaddr_storage structure
574 dnl AC_LBL_SOCKADDR_STORAGE
578 dnl HAVE_SOCKADDR_STORAGE (defined)
580 AC_DEFUN(AC_LBL_SOCKADDR_STORAGE,
581 [AC_MSG_CHECKING(if sockaddr_storage struct exists)
582 AC_CACHE_VAL(ac_cv_lbl_has_sockaddr_storage,
584 # include <sys/types.h>
585 # include <sys/socket.h>],
586 [u_int i = sizeof (struct sockaddr_storage)],
587 ac_cv_lbl_has_sockaddr_storage=yes,
588 ac_cv_lbl_has_sockaddr_storage=no))
589 AC_MSG_RESULT($ac_cv_lbl_has_sockaddr_storage)
590 if test $ac_cv_lbl_has_sockaddr_storage = yes ; then
591 AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[if struct sockaddr_storage exists])
595 dnl Checks to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
596 dnl dl_module_id_1 member
600 dnl AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
604 dnl HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 (defined)
606 dnl NOTE: any compile failure means we conclude that it doesn't have
607 dnl that member, so if we don't have DLPI, don't have a <sys/dlpi_ext.h>
608 dnl header, or have one that doesn't declare a dl_hp_ppa_info_t type,
609 dnl we conclude it doesn't have that member (which is OK, as either we
610 dnl won't be using code that would use that member, or we wouldn't
611 dnl compile in any case).
613 AC_DEFUN(AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1,
614 [AC_MSG_CHECKING(if dl_hp_ppa_info_t struct has dl_module_id_1 member)
615 AC_CACHE_VAL(ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1,
617 # include <sys/types.h>
618 # include <sys/dlpi.h>
619 # include <sys/dlpi_ext.h>],
620 [u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)],
621 ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes,
622 ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no))
623 AC_MSG_RESULT($ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1)
624 if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then
625 AC_DEFINE(HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1,1,[if ppa_info_t_dl_module_id exists])
629 dnl Checks to see if -R is used
633 dnl AC_LBL_HAVE_RUN_PATH
637 dnl ac_cv_lbl_have_run_path (yes or no)
639 AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
640 [AC_MSG_CHECKING(for ${CC-cc} -R)
641 AC_CACHE_VAL(ac_cv_lbl_have_run_path,
642 [echo 'main(){}' > conftest.c
643 ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
644 if test ! -s conftest.out ; then
645 ac_cv_lbl_have_run_path=yes
647 ac_cv_lbl_have_run_path=no
650 AC_MSG_RESULT($ac_cv_lbl_have_run_path)
654 dnl Checks to see if unaligned memory accesses fail
658 dnl AC_LBL_UNALIGNED_ACCESS
662 dnl LBL_ALIGN (DEFINED)
664 AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
665 [AC_MSG_CHECKING(if unaligned accesses fail)
666 AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
670 # These are CPU types where:
672 # the CPU faults on an unaligned access, but at least some
673 # OSes that support that CPU catch the fault and simulate
674 # the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) -
675 # the simulation is slow, so we don't want to use it;
677 # the CPU, I infer (from the old
679 # XXX: should also check that they don't do weird things (like on arm)
681 # comment) doesn't fault on unaligned accesses, but doesn't
682 # do a normal unaligned fetch, either (e.g., presumably, ARM);
684 # for whatever reason, the test program doesn't work
685 # (this has been claimed to be the case for several of those
686 # CPUs - I don't know what the problem is; the problem
687 # was reported as "the test program dumps core" for SuperH,
688 # but that's what the test program is *supposed* to do -
689 # it dumps core before it writes anything, so the test
690 # for an empty output file should find an empty output
691 # file and conclude that unaligned accesses don't work).
693 # This run-time test won't work if you're cross-compiling, so
694 # in order to support cross-compiling for a particular CPU,
695 # we have to wire in the list of CPU types anyway, as far as
696 # I know, so perhaps we should just have a set of CPUs on
697 # which we know it doesn't work, a set of CPUs on which we
698 # know it does work, and have the script just fail on other
699 # cpu types and update it when such a failure occurs.
701 alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1)
702 ac_cv_lbl_unaligned_fail=yes
706 cat >conftest.c <<EOF
707 # include <sys/types.h>
708 # include <sys/wait.h>
710 unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
715 /* avoid "core dumped" message */
721 pid = waitpid(pid, &status, 0);
724 exit(!WIFEXITED(status));
727 i = *(unsigned int *)&a[[1]];
732 ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
733 conftest.c $LIBS >/dev/null 2>&1
734 if test ! -x conftest ; then
735 dnl failed to compile for some reason
736 ac_cv_lbl_unaligned_fail=yes
738 ./conftest >conftest.out
739 if test ! -s conftest.out ; then
740 ac_cv_lbl_unaligned_fail=yes
742 ac_cv_lbl_unaligned_fail=no
745 rm -f -r conftest* core core.conftest
748 AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
749 if test $ac_cv_lbl_unaligned_fail = yes ; then
750 AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails])
754 dnl If using gcc and the file .devel exists:
755 dnl Compile with -g (if supported) and -Wall
756 dnl If using gcc 2 or later, do extra prototype checking
757 dnl If an os prototype include exists, symlink os-proto.h to it
761 dnl AC_LBL_DEVEL(copt)
765 dnl $1 (copt appended)
766 dnl HAVE_OS_PROTO_H (defined)
767 dnl os-proto.h (symlinked)
769 AC_DEFUN(AC_LBL_DEVEL,
771 if test "${LBL_CFLAGS+set}" = set; then
772 $1="$$1 ${LBL_CFLAGS}"
774 if test -f .devel ; then
775 if test "$GCC" = yes ; then
776 if test "${LBL_CFLAGS+set}" != set; then
777 if test "$ac_cv_prog_cc_g" = yes ; then
781 if test $ac_cv_lbl_gcc_vers -gt 1 ; then
782 $1="$$1 -Wmissing-prototypes -Wstrict-prototypes"
789 V_CCOPT="$V_CCOPT -n32"
796 os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
798 if test -f $name ; then
799 ln -s $name os-proto.h
800 AC_DEFINE(HAVE_OS_PROTO_H, 1,
801 [if there's an os_proto.h for this platform, to use additional prototypes])
803 AC_MSG_WARN(can't find $name)
808 dnl Improved version of AC_CHECK_LIB
810 dnl Thanks to John Hawkinson (jhawk@mit.edu)
814 dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
815 dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
821 dnl XXX - "AC_LBL_LIBRARY_NET" was redone to use "AC_SEARCH_LIBS"
822 dnl rather than "AC_LBL_CHECK_LIB", so this isn't used any more.
823 dnl We keep it around for reference purposes in case it's ever
824 dnl useful in the future.
827 define(AC_LBL_CHECK_LIB,
828 [AC_MSG_CHECKING([for $2 in -l$1])
829 dnl Use a cache variable name containing the library, function
830 dnl name, and extra libraries to link with, because the test really is
831 dnl for library $1 defining function $2, when linked with potinal
832 dnl library $5, not just for library $1. Separate tests with the same
833 dnl $1 and different $2's or $5's may have different results.
834 ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
835 AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
836 [ac_save_LIBS="$LIBS"
839 ifelse([$2], [main], , dnl Avoid conflicting decl of main.
840 [/* Override any gcc2 internal prototype to avoid an error. */
841 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
845 [/* We use char because int might match the return type of a gcc2
846 builtin and then its argument prototype would still apply. */
850 eval "ac_cv_lbl_lib_$ac_lib_var=yes",
851 eval "ac_cv_lbl_lib_$ac_lib_var=no")
854 if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
858 ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
859 -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
861 AC_DEFINE_UNQUOTED($ac_tr_lib)
872 dnl AC_LBL_LIBRARY_NET
874 dnl This test is for network applications that need socket() and
875 dnl gethostbyname() -ish functions. Under Solaris, those applications
876 dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link
877 dnl with "-lnsl" but should *not* link with "-lsocket" because
878 dnl libsocket.a breaks a number of things (for instance:
879 dnl gethostbyname() under IRIX 5.2, and snoop sockets under most
880 dnl versions of IRIX).
882 dnl Unfortunately, many application developers are not aware of this,
883 dnl and mistakenly write tests that cause -lsocket to be used under
884 dnl IRIX. It is also easy to write tests that cause -lnsl to be used
885 dnl under operating systems where neither are necessary (or useful),
886 dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
888 dnl This test exists so that every application developer does not test
889 dnl this in a different, and subtly broken fashion.
891 dnl It has been argued that this test should be broken up into two
892 dnl seperate tests, one for the resolver libraries, and one for the
893 dnl libraries necessary for using Sockets API. Unfortunately, the two
894 dnl are carefully intertwined and allowing the autoconf user to use
895 dnl them independantly potentially results in unfortunate ordering
896 dnl dependancies -- as such, such component macros would have to
897 dnl carefully use indirection and be aware if the other components were
898 dnl executed. Since other autoconf macros do not go to this trouble,
899 dnl and almost no applications use sockets without the resolver, this
900 dnl complexity has not been implemented.
902 dnl The check for libresolv is in case you are attempting to link
903 dnl statically and happen to have a libresolv.a lying around (and no
906 AC_DEFUN(AC_LBL_LIBRARY_NET, [
907 # Most operating systems have gethostbyname() in the default searched
908 # libraries (i.e. libc):
909 # Some OSes (eg. Solaris) place it in libnsl
910 # Some strange OSes (SINIX) have it in libsocket:
911 AC_SEARCH_LIBS(gethostbyname, nsl socket resolv)
912 # Unfortunately libsocket sometimes depends on libnsl and
913 # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this.
914 if test "$ac_cv_search_gethostbyname" = "no"
916 AC_CHECK_LIB(socket, gethostbyname,
917 LIBS="-lsocket -lnsl $LIBS", , -lnsl)
919 AC_SEARCH_LIBS(socket, socket, ,
920 AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl))
921 # DLPI needs putmsg under HPUX so test for -lstr while we're at it
922 AC_SEARCH_LIBS(putmsg, str)
926 dnl Test for __attribute__
929 AC_DEFUN(AC_C___ATTRIBUTE__, [
930 AC_MSG_CHECKING(for __attribute__)
931 AC_CACHE_VAL(ac_cv___attribute__, [
936 static void foo(void) __attribute__ ((noreturn));
945 main(int argc, char **argv)
950 ac_cv___attribute__=yes,
951 ac_cv___attribute__=no)])
952 if test "$ac_cv___attribute__" = "yes"; then
953 AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
954 V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
956 V_DEFS="$V_DEFS -D_U_=\"\""
958 AC_MSG_RESULT($ac_cv___attribute__)
962 dnl Checks to see if tpacket_stats is defined in linux/if_packet.h
963 dnl If so then pcap-linux.c can use this to report proper statistics.
967 AC_DEFUN(AC_LBL_TPACKET_STATS,
968 [AC_MSG_CHECKING(if if_packet.h has tpacket_stats defined)
969 AC_CACHE_VAL(ac_cv_lbl_tpacket_stats,
971 # include <linux/if_packet.h>],
972 [struct tpacket_stats stats],
973 ac_cv_lbl_tpacket_stats=yes,
974 ac_cv_lbl_tpacket_stats=no))
975 AC_MSG_RESULT($ac_cv_lbl_tpacket_stats)
976 if test $ac_cv_lbl_tpacket_stats = yes; then
977 AC_DEFINE(HAVE_TPACKET_STATS,1,[if if_packet.h has tpacket_stats defined])
981 dnl Checks to see if the tpacket_auxdata struct has a tp_vlan_tci member.
985 dnl AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
989 dnl HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI (defined)
991 dnl NOTE: any compile failure means we conclude that it doesn't have
992 dnl that member, so if we don't have tpacket_auxdata, we conclude it
993 dnl doesn't have that member (which is OK, as either we won't be using
994 dnl code that would use that member, or we wouldn't compile in any case).
996 AC_DEFUN(AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,
997 [AC_MSG_CHECKING(if tpacket_auxdata struct has tp_vlan_tci member)
998 AC_CACHE_VAL(ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci,
1000 # include <sys/types.h>
1001 # include <linux/if_packet.h>],
1002 [u_int i = sizeof(((struct tpacket_auxdata *)0)->tp_vlan_tci)],
1003 ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=yes,
1004 ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=no))
1005 AC_MSG_RESULT($ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci)
1006 if test $ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci = yes ; then
1007 HAVE_LINUX_TPACKET_AUXDATA=tp_vlan_tci
1008 AC_SUBST(HAVE_LINUX_TPACKET_AUXDATA)
1009 AC_DEFINE(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,1,[if tp_vlan_tci exists])
1013 dnl Checks to see if Solaris has the dl_passive_req_t struct defined
1014 dnl in <sys/dlpi.h>.
1018 dnl AC_LBL_DL_PASSIVE_REQ_T
1022 dnl HAVE_DLPI_PASSIVE (defined)
1024 AC_DEFUN(AC_LBL_DL_PASSIVE_REQ_T,
1025 [AC_MSG_CHECKING(if dl_passive_req_t struct exists)
1026 AC_CACHE_VAL(ac_cv_lbl_has_dl_passive_req_t,
1028 # include <sys/types.h>
1029 # include <sys/dlpi.h>],
1030 [u_int i = sizeof(dl_passive_req_t)],
1031 ac_cv_lbl_has_dl_passive_req_t=yes,
1032 ac_cv_lbl_has_dl_passive_req_t=no))
1033 AC_MSG_RESULT($ac_cv_lbl_has_dl_passive_req_t)
1034 if test $ac_cv_lbl_has_dl_passive_req_t = yes ; then
1035 AC_DEFINE(HAVE_DLPI_PASSIVE,1,[if passive_req_t primitive