aclocal.m4

来自「TCPDUMP的C语言源代码,是在数据链路层的应用」· M4 代码 · 共 1,288 行 · 第 1/3 页

M4
1,288
字号
dnl @(#) $Header: /tcpdump/master/tcpdump/aclocal.m4,v 1.113.2.3 2008-09-25 21:50:04 guy Exp $ (LBL)dnldnl Copyright (c) 1995, 1996, 1997, 1998dnl	The Regents of the University of California.  All rights reserved.dnldnl Redistribution and use in source and binary forms, with or withoutdnl modification, are permitted provided that: (1) source code distributionsdnl retain the above copyright notice and this paragraph in its entirety, (2)dnl distributions including binary code include the above copyright notice anddnl this paragraph in its entirety in the documentation or other materialsdnl provided with the distribution, and (3) all advertising materials mentioningdnl features or use of this software display the following acknowledgement:dnl ``This product includes software developed by the University of California,dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name ofdnl the University nor the names of its contributors may be used to endorsednl or promote products derived from this software without specific priordnl written permission.dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIEDdnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OFdnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.dnldnl LBL autoconf macrosdnldnldnl Determine which compiler we're using (cc or gcc)dnl If using gcc, determine the version numberdnl If using cc, require that it support ansi prototypesdnl If using gcc, use -O2 (otherwise use -O)dnl If using cc, explicitly specify /usr/local/includednldnl usage:dnldnl	AC_LBL_C_INIT(copt, incls)dnldnl results:dnldnl	$1 (copt set)dnl	$2 (incls set)dnl	CCdnl	LDFLAGSdnl	ac_cv_lbl_gcc_versdnl	LBL_CFLAGSdnlAC_DEFUN(AC_LBL_C_INIT,    [AC_PREREQ(2.12)    AC_BEFORE([$0], [AC_PROG_CC])    AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])    AC_BEFORE([$0], [AC_LBL_DEVEL])    AC_ARG_WITH(gcc, [  --without-gcc           don't use gcc])    $1="-O"    $2=""    if test "${srcdir}" != "." ; then	    $2="-I\$(srcdir)"    fi    if test "${CFLAGS+set}" = set; then	    LBL_CFLAGS="$CFLAGS"    fi    if test -z "$CC" ; then	    case "$host_os" in	    bsdi*)		    AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)		    if test $SHLICC2 = yes ; then			    CC=shlicc2			    export CC		    fi		    ;;	    esac    fi    if test -z "$CC" -a "$with_gcc" = no ; then	    CC=cc	    export CC    fi    AC_PROG_CC    if test "$GCC" = yes ; then	    if test "$SHLICC2" = yes ; then		    ac_cv_lbl_gcc_vers=2		    $1="-O2"	    else		    AC_MSG_CHECKING(gcc version)		    AC_CACHE_VAL(ac_cv_lbl_gcc_vers,			ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \			    sed -e '/^gcc version /!d' \				-e 's/^gcc version //' \				-e 's/ .*//' -e 's/^[[[^0-9]]]*//' \				-e 's/\..*//'`)		    AC_MSG_RESULT($ac_cv_lbl_gcc_vers)		    if test $ac_cv_lbl_gcc_vers -gt 1 ; then			    $1="-O2"		    fi	    fi    else	    AC_MSG_CHECKING(that $CC handles ansi prototypes)	    AC_CACHE_VAL(ac_cv_lbl_cc_ansi_prototypes,		AC_TRY_COMPILE(		    [#include <sys/types.h>],		    [int frob(int, char *)],		    ac_cv_lbl_cc_ansi_prototypes=yes,		    ac_cv_lbl_cc_ansi_prototypes=no))	    AC_MSG_RESULT($ac_cv_lbl_cc_ansi_prototypes)	    if test $ac_cv_lbl_cc_ansi_prototypes = no ; then		    case "$host_os" in		    hpux*)			    AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE))			    savedcflags="$CFLAGS"			    CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"			    AC_CACHE_VAL(ac_cv_lbl_cc_hpux_cc_aa,				AC_TRY_COMPILE(				    [#include <sys/types.h>],				    [int frob(int, char *)],				    ac_cv_lbl_cc_hpux_cc_aa=yes,				    ac_cv_lbl_cc_hpux_cc_aa=no))			    AC_MSG_RESULT($ac_cv_lbl_cc_hpux_cc_aa)			    if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then				    AC_MSG_ERROR(see the INSTALL doc for more info)			    fi			    CFLAGS="$savedcflags"			    V_CCOPT="-Aa $V_CCOPT"			    AC_DEFINE(_HPUX_SOURCE)			    ;;		    *)			    AC_MSG_ERROR(see the INSTALL doc for more info)			    ;;		    esac	    fi	    $2="$$2 -I/usr/local/include"	    LDFLAGS="$LDFLAGS -L/usr/local/lib"	    case "$host_os" in	    irix*)		    V_CCOPT="$V_CCOPT -xansi -signed -O"		    ;;	    osf*)		    V_CCOPT="$V_CCOPT -std1 -O"		    ;;	    ultrix*)		    AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)		    AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,			AC_TRY_COMPILE(			    [#include <sys/types.h>],			    [struct a { int b; };			    void c(const struct a *)],			    ac_cv_lbl_cc_const_proto=yes,			    ac_cv_lbl_cc_const_proto=no))		    AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)		    if test $ac_cv_lbl_cc_const_proto = no ; then			    AC_DEFINE(const,)		    fi		    ;;	    esac    fi])## Try compiling a sample of the type of code that appears in# gencode.c with "inline", "__inline__", and "__inline".## Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough,# as it just tests whether a function returning "int" can be inlined;# at least some versions of HP's C compiler can inline that, but can't# inline a function that returns a struct pointer.#AC_DEFUN(AC_LBL_C_INLINE,    [AC_MSG_CHECKING(for inline)    AC_CACHE_VAL(ac_cv_lbl_inline, [	ac_cv_lbl_inline=""	ac_lbl_cc_inline=no	for ac_lbl_inline in inline __inline__ __inline	do	    AC_TRY_COMPILE(		[#define inline $ac_lbl_inline		static inline struct iltest *foo(void);		struct iltest {		    int iltest1;		    int iltest2;		};		static inline struct iltest *		foo()		{		    static struct iltest xxx;		    return &xxx;		}],,ac_lbl_cc_inline=yes,)	    if test "$ac_lbl_cc_inline" = yes ; then		break;	    fi	done	if test "$ac_lbl_cc_inline" = yes ; then	    ac_cv_lbl_inline=$ac_lbl_inline	fi])    if test ! -z "$ac_cv_lbl_inline" ; then	AC_MSG_RESULT($ac_cv_lbl_inline)    else	AC_MSG_RESULT(no)    fi    AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])dnldnl Use pfopen.c if available and pfopen() not in standard librariesdnl Require libpcapdnl Look for libpcap in ..dnl Use the installed libpcap if there is no local versiondnldnl usage:dnldnl	AC_LBL_LIBPCAP(pcapdep, incls)dnldnl results:dnldnl	$1 (pcapdep set)dnl	$2 (incls appended)dnl	LIBSdnl	LBL_LIBSdnlAC_DEFUN(AC_LBL_LIBPCAP,    [AC_REQUIRE([AC_LBL_LIBRARY_NET])    dnl    dnl save a copy before locating libpcap.a    dnl    LBL_LIBS="$LIBS"    pfopen=/usr/examples/packetfilter/pfopen.c    if test -f $pfopen ; then	    AC_CHECK_FUNCS(pfopen)	    if test $ac_cv_func_pfopen = "no" ; then		    AC_MSG_RESULT(Using $pfopen)		    LIBS="$LIBS $pfopen"	    fi    fi    AC_MSG_CHECKING(for local pcap library)    libpcap=FAIL    lastdir=FAIL    places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \	egrep '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'`    for dir in $places $srcdir/../libpcap $srcdir/libpcap ; do	    basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//'`	    if test $lastdir = $basedir ; then		    dnl skip alphas when an actual release is present		    continue;	    fi	    lastdir=$dir	    if test -r $dir/libpcap.a ; then		    libpcap=$dir/libpcap.a		    d=$dir		    dnl continue and select the last one that exists	    fi    done    if test $libpcap = FAIL ; then	    AC_MSG_RESULT(not found)	    AC_CHECK_LIB(pcap, main, libpcap="-lpcap")	    if test $libpcap = FAIL ; then		    AC_MSG_ERROR(see the INSTALL doc for more info)	    fi	    dnl	    dnl Some versions of Red Hat Linux put "pcap.h" in	    dnl "/usr/include/pcap"; had the LBL folks done so,	    dnl that would have been a good idea, but for	    dnl the Red Hat folks to do so just breaks source	    dnl compatibility with other systems.	    dnl	    dnl We work around this by assuming that, as we didn't	    dnl find a local libpcap, libpcap is in /usr/lib or	    dnl /usr/local/lib and that the corresponding header	    dnl file is under one of those directories; if we don't	    dnl find it in either of those directories, we check to	    dnl see if it's in a "pcap" subdirectory of them and,	    dnl if so, add that subdirectory to the "-I" list.	    dnl	    dnl (We now also put pcap.h in /usr/include/pcap, but we	    dnl leave behind a /usr/include/pcap.h that includes it,	    dnl so you can still just include <pcap.h>.)	    dnl	    AC_MSG_CHECKING(for extraneous pcap header directories)	    if test \( ! -r /usr/local/include/pcap.h \) -a \			\( ! -r /usr/include/pcap.h \); then		if test -r /usr/local/include/pcap/pcap.h; then		    d="/usr/local/include/pcap"		elif test -r /usr/include/pcap/pcap.h; then		    d="/usr/include/pcap"		fi	    fi	    if test -z "$d" ; then		AC_MSG_RESULT(not found)	    else		$2="-I$d $$2"		AC_MSG_RESULT(found -- -I$d added)	    fi    else	    $1=$libpcap	    places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \    	 		egrep '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'`	    if test -r $d/pcap.h; then		    $2="-I$d $$2"	    elif test -r $places/pcap.h; then		    $2="-I$places $$2"	    else                    AC_MSG_ERROR(cannot find pcap.h, see INSTALL) 	    fi	    AC_MSG_RESULT($libpcap)    fi    LIBS="$libpcap $LIBS"    case "$host_os" in    aix*)	    pseexe="/lib/pse.exp"	    AC_MSG_CHECKING(for $pseexe)	    if test -f $pseexe ; then		    AC_MSG_RESULT(yes)		    LIBS="$LIBS -I:$pseexe"	    fi	    #	    # We need "-lodm" and "-lcfg", as libpcap requires them on	    # AIX, and we just build a static libpcap.a and thus can't	    # arrange that when you link with libpcap you automatically	    # link with those libraries.	    #	    LIBS="$LIBS -lodm -lcfg"	    ;;    esac    dnl    dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()",    dnl and "pcap_datalink_name_to_val()", and use substitute versions    dnl if they're not present.    dnl    AC_CHECK_FUNC(pcap_list_datalinks,	AC_DEFINE(HAVE_PCAP_LIST_DATALINKS),	[	    AC_LIBOBJ(datalinks)	])    AC_CHECK_FUNC(pcap_set_datalink,	AC_DEFINE(HAVE_PCAP_SET_DATALINK))    AC_CHECK_FUNC(pcap_datalink_name_to_val,	[	    AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL)	    AC_CHECK_FUNC(pcap_datalink_val_to_description,		AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION),		[		    AC_LIBOBJ(dlnames)		])	],	[	    AC_LIBOBJ(dlnames)	])    dnl    dnl Check for "pcap_breakloop()"; you can't substitute for it if    dnl it's absent (it has hooks into the live capture routines),    dnl so just define the HAVE_ value if it's there.    dnl    AC_CHECK_FUNCS(pcap_breakloop)    dnl    dnl Check for "pcap_dump_ftell()" and use a substitute version    dnl if it's not present.    AC_CHECK_FUNC(pcap_dump_ftell,	AC_DEFINE(HAVE_PCAP_DUMP_FTELL),	[	    AC_LIBOBJ(pcap_dump_ftell)	])])dnldnl Define RETSIGTYPE and RETSIGVALdnldnl usage:dnldnl	AC_LBL_TYPE_SIGNALdnldnl results:dnldnl	RETSIGTYPE (defined)dnl	RETSIGVAL (defined)dnlAC_DEFUN(AC_LBL_TYPE_SIGNAL,    [AC_BEFORE([$0], [AC_LBL_LIBPCAP])    AC_TYPE_SIGNAL    if test "$ac_cv_type_signal" = void ; then	    AC_DEFINE(RETSIGVAL,)    else	    AC_DEFINE(RETSIGVAL,(0))    fi    case "$host_os" in    irix*)	    AC_DEFINE(_BSD_SIGNALS)	    ;;    *)	    dnl prefer sigaction() to sigset()	    AC_CHECK_FUNCS(sigaction)	    if test $ac_cv_func_sigaction = no ; then		    AC_CHECK_FUNCS(sigset)	    fi	    ;;    esac])dnldnl If using gcc, make sure we have ANSI ioctl definitionsdnldnl usage:dnldnl	AC_LBL_FIXINCLUDESdnlAC_DEFUN(AC_LBL_FIXINCLUDES,    [if test "$GCC" = yes ; then	    AC_MSG_CHECKING(for ANSI ioctl definitions)	    AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes,		AC_TRY_COMPILE(		    [/*		     * This generates a "duplicate case value" when fixincludes		     * has not be run.		     */#		include <sys/types.h>#		include <sys/time.h>#		include <sys/ioctl.h>#		ifdef HAVE_SYS_IOCCOM_H#		include <sys/ioccom.h>#		endif],		    [switch (0) {		    case _IO('A', 1):;		    case _IO('B', 1):;		    }],

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?