Home | History | Annotate | Download | only in libpcap
      1 dnl @(#) $Header: /tcpdump/master/libpcap/aclocal.m4,v 1.93 2008-11-18 07:29:48 guy Exp $ (LBL)
      2 dnl
      3 dnl Copyright (c) 1995, 1996, 1997, 1998
      4 dnl	The Regents of the University of California.  All rights reserved.
      5 dnl
      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.
     21 dnl
     22 dnl LBL autoconf macros
     23 dnl
     24 
     25 dnl
     26 dnl Do whatever AC_LBL_C_INIT work is necessary before using AC_PROG_CC.
     27 dnl
     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.
     33 dnl
     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.
     39 dnl
     40 AC_DEFUN(AC_LBL_C_INIT_BEFORE_CC,
     41 [
     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])
     47     $1=""
     48     if test "${srcdir}" != "." ; then
     49 	    $1="-I\$(srcdir)"
     50     fi
     51     if test "${CFLAGS+set}" = set; then
     52 	    LBL_CFLAGS="$CFLAGS"
     53     fi
     54     if test -z "$CC" ; then
     55 	    case "$host_os" in
     56 
     57 	    bsdi*)
     58 		    AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
     59 		    if test $SHLICC2 = yes ; then
     60 			    CC=shlicc2
     61 			    export CC
     62 		    fi
     63 		    ;;
     64 	    esac
     65     fi
     66     if test -z "$CC" -a "$with_gcc" = no ; then
     67 	    CC=cc
     68 	    export CC
     69     fi
     70 ])
     71 
     72 dnl
     73 dnl Determine which compiler we're using (cc or gcc)
     74 dnl If using gcc, determine the version number
     75 dnl If using cc:
     76 dnl     require that it support ansi prototypes
     77 dnl     use -O (AC_PROG_CC will use -g -O2 on gcc, so we don't need to
     78 dnl     do that ourselves for gcc)
     79 dnl     add -g flags, as appropriate
     80 dnl     explicitly specify /usr/local/include
     81 dnl
     82 dnl NOTE WELL: with newer versions of autoconf, "gcc" means any compiler
     83 dnl that defines __GNUC__, which means clang, for example, counts as "gcc".
     84 dnl
     85 dnl usage:
     86 dnl
     87 dnl	AC_LBL_C_INIT(copt, incls)
     88 dnl
     89 dnl results:
     90 dnl
     91 dnl	$1 (copt set)
     92 dnl	$2 (incls set)
     93 dnl	CC
     94 dnl	LDFLAGS
     95 dnl	LBL_CFLAGS
     96 dnl
     97 AC_DEFUN(AC_LBL_C_INIT,
     98 [
     99     AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
    100     AC_BEFORE([$0], [AC_LBL_DEVEL])
    101     AC_BEFORE([$0], [AC_LBL_SHLIBS_INIT])
    102     if test "$GCC" = yes ; then
    103 	    #
    104 	    # -Werror forces warnings to be errors.
    105 	    #
    106 	    ac_lbl_cc_force_warning_errors=-Werror
    107     else
    108 	    $2="$$2 -I/usr/local/include"
    109 	    LDFLAGS="$LDFLAGS -L/usr/local/lib"
    110 
    111 	    case "$host_os" in
    112 
    113 	    darwin*)
    114 		    #
    115 		    # This is assumed either to be GCC or clang, both
    116 		    # of which use -Werror to force warnings to be errors.
    117 		    #
    118 		    ac_lbl_cc_force_warning_errors=-Werror
    119 		    ;;
    120 
    121 	    hpux*)
    122 		    #
    123 		    # HP C, which is what we presume we're using, doesn't
    124 		    # exit with a non-zero exit status if we hand it an
    125 		    # invalid -W flag, can't be forced to do so even with
    126 		    # +We, and doesn't handle GCC-style -W flags, so we
    127 		    # don't want to try using GCC-style -W flags.
    128 		    #
    129 		    ac_lbl_cc_dont_try_gcc_dashW=yes
    130 		    ;;
    131 
    132 	    irix*)
    133 		    #
    134 		    # MIPS C, which is what we presume we're using, doesn't
    135 		    # necessarily exit with a non-zero exit status if we
    136 		    # hand it an invalid -W flag, can't be forced to do
    137 		    # so, and doesn't handle GCC-style -W flags, so we
    138 		    # don't want to try using GCC-style -W flags.
    139 		    #
    140 		    ac_lbl_cc_dont_try_gcc_dashW=yes
    141 		    #
    142 		    # It also, apparently, defaults to "char" being
    143 		    # unsigned, unlike most other C implementations;
    144 		    # I suppose we could say "signed char" whenever
    145 		    # we want to guarantee a signed "char", but let's
    146 		    # just force signed chars.
    147 		    #
    148 		    # -xansi is normally the default, but the
    149 		    # configure script was setting it; perhaps -cckr
    150 		    # was the default in the Old Days.  (Then again,
    151 		    # that would probably be for backwards compatibility
    152 		    # in the days when ANSI C was Shiny and New, i.e.
    153 		    # 1989 and the early '90's, so maybe we can just
    154 		    # drop support for those compilers.)
    155 		    #
    156 		    # -g is equivalent to -g2, which turns off
    157 		    # optimization; we choose -g3, which generates
    158 		    # debugging information but doesn't turn off
    159 		    # optimization (even if the optimization would
    160 		    # cause inaccuracies in debugging).
    161 		    #
    162 		    $1="$$1 -xansi -signed -g3"
    163 		    ;;
    164 
    165 	    osf*)
    166 		    #
    167 		    # Presumed to be DEC OSF/1, Digital UNIX, or
    168 		    # Tru64 UNIX.
    169 		    #
    170 		    # The DEC C compiler, which is what we presume we're
    171 		    # using, doesn't exit with a non-zero exit status if we
    172 		    # hand it an invalid -W flag, can't be forced to do
    173 		    # so, and doesn't handle GCC-style -W flags, so we
    174 		    # don't want to try using GCC-style -W flags.
    175 		    #
    176 		    ac_lbl_cc_dont_try_gcc_dashW=yes
    177 		    #
    178 		    # -g is equivalent to -g2, which turns off
    179 		    # optimization; we choose -g3, which generates
    180 		    # debugging information but doesn't turn off
    181 		    # optimization (even if the optimization would
    182 		    # cause inaccuracies in debugging).
    183 		    #
    184 		    $1="$$1 -g3"
    185 		    ;;
    186 
    187 	    solaris*)
    188 		    #
    189 		    # Assumed to be Sun C, which requires -errwarn to force
    190 		    # warnings to be treated as errors.
    191 		    #
    192 		    ac_lbl_cc_force_warning_errors=-errwarn
    193 		    ;;
    194 
    195 	    ultrix*)
    196 		    AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
    197 		    AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
    198 			AC_TRY_COMPILE(
    199 			    [#include <sys/types.h>],
    200 			    [struct a { int b; };
    201 			    void c(const struct a *)],
    202 			    ac_cv_lbl_cc_const_proto=yes,
    203 			    ac_cv_lbl_cc_const_proto=no))
    204 		    AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
    205 		    if test $ac_cv_lbl_cc_const_proto = no ; then
    206 			    AC_DEFINE(const,[],
    207 			        [to handle Ultrix compilers that don't support const in prototypes])
    208 		    fi
    209 		    ;;
    210 	    esac
    211 	    $1="$$1 -O"
    212     fi
    213 ])
    214 
    215 dnl
    216 dnl Check whether, if you pass an unknown warning option to the
    217 dnl compiler, it fails or just prints a warning message and succeeds.
    218 dnl Set ac_lbl_unknown_warning_option_error to the appropriate flag
    219 dnl to force an error if it would otherwise just print a warning message
    220 dnl and succeed.
    221 dnl
    222 AC_DEFUN(AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR,
    223     [
    224 	AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option])
    225 	save_CFLAGS="$CFLAGS"
    226 	CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
    227 	AC_TRY_COMPILE(
    228 	    [],
    229 	    [return 0],
    230 	    [
    231 		AC_MSG_RESULT([no])
    232 		#
    233 		# We're assuming this is clang, where
    234 		# -Werror=unknown-warning-option is the appropriate
    235 		# option to force the compiler to fail.
    236 		# 
    237 		ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
    238 	    ],
    239 	    [
    240 		AC_MSG_RESULT([yes])
    241 	    ])
    242 	CFLAGS="$save_CFLAGS"
    243     ])
    244 
    245 dnl
    246 dnl Check whether the compiler option specified as the second argument
    247 dnl is supported by the compiler and, if so, add it to the macro
    248 dnl specified as the first argument
    249 dnl
    250 AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
    251     [
    252 	AC_MSG_CHECKING([whether the compiler supports the $2 option])
    253 	save_CFLAGS="$CFLAGS"
    254 	CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2"
    255 	AC_TRY_COMPILE(
    256 	    [],
    257 	    [return 0],
    258 	    [
    259 		AC_MSG_RESULT([yes])
    260 		CFLAGS="$save_CFLAGS"
    261 		$1="$$1 $2"
    262 	    ],
    263 	    [
    264 		AC_MSG_RESULT([no])
    265 		CFLAGS="$save_CFLAGS"
    266 	    ])
    267     ])
    268 
    269 dnl
    270 dnl Check whether the compiler supports an option to generate
    271 dnl Makefile-style dependency lines
    272 dnl
    273 dnl GCC uses -M for this.  Non-GCC compilers that support this
    274 dnl use a variety of flags, including but not limited to -M.
    275 dnl
    276 dnl We test whether the flag in question is supported, as older
    277 dnl versions of compilers might not support it.
    278 dnl
    279 dnl We don't try all the possible flags, just in case some flag means
    280 dnl "generate dependencies" on one compiler but means something else
    281 dnl on another compiler.
    282 dnl
    283 dnl Most compilers that support this send the output to the standard
    284 dnl output by default.  IBM's XLC, however, supports -M but sends
    285 dnl the output to {sourcefile-basename}.u, and AIX has no /dev/stdout
    286 dnl to work around that, so we don't bother with XLC.
    287 dnl
    288 AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT,
    289     [
    290 	AC_MSG_CHECKING([whether the compiler supports generating dependencies])
    291 	if test "$GCC" = yes ; then
    292 		#
    293 		# GCC, or a compiler deemed to be GCC by AC_PROG_CC (even
    294 		# though it's not); we assume that, in this case, the flag
    295 		# would be -M.
    296 		#
    297 		ac_lbl_dependency_flag="-M"
    298 	else
    299 		#
    300 		# Not GCC or a compiler deemed to be GCC; what platform is
    301 		# this?  (We're assuming that if the compiler isn't GCC
    302 		# it's the compiler from the vendor of the OS; that won't
    303 		# necessarily be true for x86 platforms, where it might be
    304 		# the Intel C compiler.)
    305 		#
    306 		case "$host_os" in
    307 
    308 		irix*|osf*|darwin*)
    309 			#
    310 			# MIPS C for IRIX, DEC C, and clang all use -M.
    311 			#
    312 			ac_lbl_dependency_flag="-M"
    313 			;;
    314 
    315 		solaris*)
    316 			#
    317 			# Sun C uses -xM.
    318 			#
    319 			ac_lbl_dependency_flag="-xM"
    320 			;;
    321 
    322 		hpux*)
    323 			#
    324 			# HP's older C compilers don't support this.
    325 			# HP's newer C compilers support this with
    326 			# either +M or +Make; the older compilers
    327 			# interpret +M as something completely
    328 			# different, so we use +Make so we don't
    329 			# think it works with the older compilers.
    330 			#
    331 			ac_lbl_dependency_flag="+Make"
    332 			;;
    333 
    334 		*)
    335 			#
    336 			# Not one of the above; assume no support for
    337 			# generating dependencies.
    338 			#
    339 			ac_lbl_dependency_flag=""
    340 			;;
    341 		esac
    342 	fi
    343 
    344 	#
    345 	# Is ac_lbl_dependency_flag defined and, if so, does the compiler
    346 	# complain about it?
    347 	#
    348 	# Note: clang doesn't seem to exit with an error status when handed
    349 	# an unknown non-warning error, even if you pass it
    350 	# -Werror=unknown-warning-option.  However, it always supports
    351 	# -M, so the fact that this test always succeeds with clang
    352 	# isn't an issue.
    353 	#
    354 	if test ! -z "$ac_lbl_dependency_flag"; then
    355 		AC_LANG_CONFTEST(
    356 		    [AC_LANG_SOURCE([[int main(void) { return 0; }]])])
    357 		echo "$CC" $ac_lbl_dependency_flag conftest.c >&5
    358 		if "$CC" $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1; then
    359 			AC_MSG_RESULT([yes, with $ac_lbl_dependency_flag])
    360 			DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
    361 			MKDEP='${srcdir}/mkdep'
    362 		else
    363 			AC_MSG_RESULT([no])
    364 			#
    365 			# We can't run mkdep, so have "make depend" do
    366 			# nothing.
    367 			#
    368 			MKDEP=:
    369 		fi
    370 		rm -rf conftest*
    371 	else
    372 		AC_MSG_RESULT([no])
    373 		#
    374 		# We can't run mkdep, so have "make depend" do
    375 		# nothing.
    376 		#
    377 		MKDEP=:
    378 	fi
    379 	AC_SUBST(DEPENDENCY_CFLAG)
    380 	AC_SUBST(MKDEP)
    381     ])
    382 
    383 dnl
    384 dnl Determine what options are needed to build a shared library
    385 dnl
    386 dnl usage:
    387 dnl
    388 dnl	AC_LBL_SHLIBS_INIT
    389 dnl
    390 dnl results:
    391 dnl
    392 dnl	V_CCOPT (modified to build position-independent code)
    393 dnl	V_SHLIB_CMD
    394 dnl	V_SHLIB_OPT
    395 dnl	V_SONAME_OPT
    396 dnl	V_RPATH_OPT
    397 dnl
    398 AC_DEFUN(AC_LBL_SHLIBS_INIT,
    399     [AC_PREREQ(2.50)
    400     if test "$GCC" = yes ; then
    401 	    #
    402 	    # On platforms where we build a shared library:
    403 	    #
    404 	    #	add options to generate position-independent code,
    405 	    #	if necessary (it's the default in AIX and Darwin/OS X);
    406 	    #
    407 	    #	define option to set the soname of the shared library,
    408 	    #	if the OS supports that;
    409 	    #
    410 	    #	add options to specify, at link time, a directory to
    411 	    #	add to the run-time search path, if that's necessary.
    412 	    #
    413 	    V_SHLIB_CMD="\$(CC)"
    414 	    V_SHLIB_OPT="-shared"
    415 	    case "$host_os" in
    416 
    417 	    aix*)
    418 		    ;;
    419 
    420 	    freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*)
    421 	    	    #
    422 		    # Platforms where the linker is the GNU linker
    423 		    # or accepts command-line arguments like
    424 		    # those the GNU linker accepts.
    425 		    #
    426 		    # Some instruction sets require -fPIC on some
    427 		    # operating systems.  Check for them.  If you
    428 		    # have a combination that requires it, add it
    429 		    # here.
    430 		    #
    431 		    PIC_OPT=-fpic
    432 		    case "$host_cpu" in
    433 
    434 		    sparc64*)
    435 			case "$host_os" in
    436 
    437 			freebsd*|openbsd*)
    438 			    PIC_OPT=-fPIC
    439 			    ;;
    440 			esac
    441 			;;
    442 		    esac
    443 		    V_CCOPT="$V_CCOPT $PIC_OPT"
    444 		    V_SONAME_OPT="-Wl,-soname,"
    445 		    V_RPATH_OPT="-Wl,-rpath,"
    446 		    ;;
    447 
    448 	    hpux*)
    449 		    V_CCOPT="$V_CCOPT -fpic"
    450 	    	    #
    451 		    # XXX - this assumes GCC is using the HP linker,
    452 		    # rather than the GNU linker, and that the "+h"
    453 		    # option is used on all HP-UX platforms, both .sl
    454 		    # and .so.
    455 		    #
    456 		    V_SONAME_OPT="-Wl,+h,"
    457 		    #
    458 		    # By default, directories specifed with -L
    459 		    # are added to the run-time search path, so
    460 		    # we don't add them in pcap-config.
    461 		    #
    462 		    ;;
    463 
    464 	    solaris*)
    465 		    V_CCOPT="$V_CCOPT -fpic"
    466 		    #
    467 		    # XXX - this assumes GCC is using the Sun linker,
    468 		    # rather than the GNU linker.
    469 		    #
    470 		    V_SONAME_OPT="-Wl,-h,"
    471 		    V_RPATH_OPT="-Wl,-R,"
    472 		    ;;
    473 	    esac
    474     else
    475 	    #
    476 	    # Set the appropriate compiler flags and, on platforms
    477 	    # where we build a shared library:
    478 	    #
    479 	    #	add options to generate position-independent code,
    480 	    #	if necessary (it's the default in Darwin/OS X);
    481 	    #
    482 	    #	if we generate ".so" shared libraries, define the
    483 	    #	appropriate options for building the shared library;
    484 	    #
    485 	    #	add options to specify, at link time, a directory to
    486 	    #	add to the run-time search path, if that's necessary.
    487 	    #
    488 	    # Note: spaces after V_SONAME_OPT are significant; on
    489 	    # some platforms the soname is passed with a GCC-like
    490 	    # "-Wl,-soname,{soname}" option, with the soname part
    491 	    # of the option, while on other platforms the C compiler
    492 	    # driver takes it as a regular option with the soname
    493 	    # following the option.  The same applies to V_RPATH_OPT.
    494 	    #
    495 	    case "$host_os" in
    496 
    497 	    aix*)
    498 		    V_SHLIB_CMD="\$(CC)"
    499 		    V_SHLIB_OPT="-G -bnoentry -bexpall"
    500 		    ;;
    501 
    502 	    freebsd*|netbsd*|openbsd*|dragonfly*|linux*)
    503 		    #
    504 		    # "cc" is GCC.
    505 		    #
    506 		    V_CCOPT="$V_CCOPT -fpic"
    507 		    V_SHLIB_CMD="\$(CC)"
    508 		    V_SHLIB_OPT="-shared"
    509 		    V_SONAME_OPT="-Wl,-soname,"
    510 		    V_RPATH_OPT="-Wl,-rpath,"
    511 		    ;;
    512 
    513 	    hpux*)
    514 		    V_CCOPT="$V_CCOPT +z"
    515 		    V_SHLIB_CMD="\$(LD)"
    516 		    V_SHLIB_OPT="-b"
    517 		    V_SONAME_OPT="+h "
    518 		    #
    519 		    # By default, directories specifed with -L
    520 		    # are added to the run-time search path, so
    521 		    # we don't add them in pcap-config.
    522 		    #
    523 		    ;;
    524 
    525 	    osf*)
    526 	    	    #
    527 		    # Presumed to be DEC OSF/1, Digital UNIX, or
    528 		    # Tru64 UNIX.
    529 		    #
    530 		    V_SHLIB_CMD="\$(CC)"
    531 		    V_SHLIB_OPT="-shared"
    532 		    V_SONAME_OPT="-soname "
    533 		    V_RPATH_OPT="-rpath "
    534 		    ;;
    535 
    536 	    solaris*)
    537 		    V_CCOPT="$V_CCOPT -Kpic"
    538 		    V_SHLIB_CMD="\$(CC)"
    539 		    V_SHLIB_OPT="-G"
    540 		    V_SONAME_OPT="-h "
    541 		    V_RPATH_OPT="-R"
    542 		    ;;
    543 	    esac
    544     fi
    545 ])
    546 
    547 #
    548 # Try compiling a sample of the type of code that appears in
    549 # gencode.c with "inline", "__inline__", and "__inline".
    550 #
    551 # Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough,
    552 # as it just tests whether a function returning "int" can be inlined;
    553 # at least some versions of HP's C compiler can inline that, but can't
    554 # inline a function that returns a struct pointer.
    555 #
    556 # Make sure we use the V_CCOPT flags, because some of those might
    557 # disable inlining.
    558 #
    559 AC_DEFUN(AC_LBL_C_INLINE,
    560     [AC_MSG_CHECKING(for inline)
    561     save_CFLAGS="$CFLAGS"
    562     CFLAGS="$V_CCOPT"
    563     AC_CACHE_VAL(ac_cv_lbl_inline, [
    564 	ac_cv_lbl_inline=""
    565 	ac_lbl_cc_inline=no
    566 	for ac_lbl_inline in inline __inline__ __inline
    567 	do
    568 	    AC_TRY_COMPILE(
    569 		[#define inline $ac_lbl_inline
    570 		static inline struct iltest *foo(void);
    571 		struct iltest {
    572 		    int iltest1;
    573 		    int iltest2;
    574 		};
    575 
    576 		static inline struct iltest *
    577 		foo()
    578 		{
    579 		    static struct iltest xxx;
    580 
    581 		    return &xxx;
    582 		}],,ac_lbl_cc_inline=yes,)
    583 	    if test "$ac_lbl_cc_inline" = yes ; then
    584 		break;
    585 	    fi
    586 	done
    587 	if test "$ac_lbl_cc_inline" = yes ; then
    588 	    ac_cv_lbl_inline=$ac_lbl_inline
    589 	fi])
    590     CFLAGS="$save_CFLAGS"
    591     if test ! -z "$ac_cv_lbl_inline" ; then
    592 	AC_MSG_RESULT($ac_cv_lbl_inline)
    593     else
    594 	AC_MSG_RESULT(no)
    595     fi
    596     AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
    597 
    598 dnl
    599 dnl If using gcc, make sure we have ANSI ioctl definitions
    600 dnl
    601 dnl usage:
    602 dnl
    603 dnl	AC_LBL_FIXINCLUDES
    604 dnl
    605 AC_DEFUN(AC_LBL_FIXINCLUDES,
    606     [if test "$GCC" = yes ; then
    607 	    AC_MSG_CHECKING(for ANSI ioctl definitions)
    608 	    AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes,
    609 		AC_TRY_COMPILE(
    610 		    [/*
    611 		     * This generates a "duplicate case value" when fixincludes
    612 		     * has not be run.
    613 		     */
    614 #		include <sys/types.h>
    615 #		include <sys/time.h>
    616 #		include <sys/ioctl.h>
    617 #		ifdef HAVE_SYS_IOCCOM_H
    618 #		include <sys/ioccom.h>
    619 #		endif],
    620 		    [switch (0) {
    621 		    case _IO('A', 1):;
    622 		    case _IO('B', 1):;
    623 		    }],
    624 		    ac_cv_lbl_gcc_fixincludes=yes,
    625 		    ac_cv_lbl_gcc_fixincludes=no))
    626 	    AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes)
    627 	    if test $ac_cv_lbl_gcc_fixincludes = no ; then
    628 		    # Don't cache failure
    629 		    unset ac_cv_lbl_gcc_fixincludes
    630 		    AC_MSG_ERROR(see the INSTALL for more info)
    631 	    fi
    632     fi])
    633 
    634 dnl
    635 dnl Check for flex, default to lex
    636 dnl Require flex 2.4 or higher
    637 dnl Check for bison, default to yacc
    638 dnl Default to lex/yacc if both flex and bison are not available
    639 dnl
    640 dnl If we're using flex and bison, pass -P to flex and -p to bison
    641 dnl to define a prefix string for the lexer and parser
    642 dnl
    643 dnl If we're not using flex and bison, don't pass those options
    644 dnl (as they might not work - although if "lex" is a wrapper for
    645 dnl Flex and "yacc" is a wrapper for Bison, they will work), and
    646 dnl define NEED_YYPARSE_WRAPPER (we *CANNOT* use YYBISON to check
    647 dnl whether the wrapper is needed, as some people apparently, for
    648 dnl some unknown reason, choose to use --without-flex and
    649 dnl --without-bison on systems that have Flex and Bison, which
    650 dnl means that the "yacc" they end up using is a wrapper that
    651 dnl runs "bison -y", and at least some versions of Bison define
    652 dnl YYBISON even if run with "-y", so we end up not compiling
    653 dnl the yyparse wrapper and end up with a libpcap that doesn't
    654 dnl define pcap_parse())
    655 dnl
    656 dnl usage:
    657 dnl
    658 dnl	AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix)
    659 dnl
    660 dnl results:
    661 dnl
    662 dnl	$1 (lex set)
    663 dnl	$2 (yacc appended)
    664 dnl	$3 (optional flex and bison -P prefix)
    665 dnl
    666 AC_DEFUN(AC_LBL_LEX_AND_YACC,
    667     [AC_ARG_WITH(flex, [  --without-flex          don't use flex])
    668     AC_ARG_WITH(bison, [  --without-bison         don't use bison])
    669     if test "$with_flex" = no ; then
    670 	    $1=lex
    671     else
    672 	    AC_CHECK_PROGS($1, flex, lex)
    673     fi
    674     if test "$$1" = flex ; then
    675 	    # The -V flag was added in 2.4
    676 	    AC_MSG_CHECKING(for flex 2.4 or higher)
    677 	    AC_CACHE_VAL(ac_cv_lbl_flex_v24,
    678 		if flex -V >/dev/null 2>&1; then
    679 			ac_cv_lbl_flex_v24=yes
    680 		else
    681 			ac_cv_lbl_flex_v24=no
    682 		fi)
    683 	    AC_MSG_RESULT($ac_cv_lbl_flex_v24)
    684 	    if test $ac_cv_lbl_flex_v24 = no ; then
    685 		    s="2.4 or higher required"
    686 		    AC_MSG_WARN(ignoring obsolete flex executable ($s))
    687 		    $1=lex
    688 	    fi
    689     fi
    690     if test "$with_bison" = no ; then
    691 	    $2=yacc
    692     else
    693 	    AC_CHECK_PROGS($2, bison, yacc)
    694     fi
    695     if test "$$2" = bison ; then
    696 	    $2="$$2 -y"
    697     fi
    698     if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then
    699 	    AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc)
    700 	    $1=lex
    701 	    $2=yacc
    702     fi
    703     if test "$$1" = flex -a -n "$3" ; then
    704 	    $1="$$1 -P$3"
    705 	    $2="$$2 -p $3"
    706     else
    707 	    AC_DEFINE(NEED_YYPARSE_WRAPPER,1,[if we need a pcap_parse wrapper around yyparse])
    708     fi])
    709 
    710 dnl
    711 dnl Checks to see if union wait is used with WEXITSTATUS()
    712 dnl
    713 dnl usage:
    714 dnl
    715 dnl	AC_LBL_UNION_WAIT
    716 dnl
    717 dnl results:
    718 dnl
    719 dnl	DECLWAITSTATUS (defined)
    720 dnl
    721 AC_DEFUN(AC_LBL_UNION_WAIT,
    722     [AC_MSG_CHECKING(if union wait is used)
    723     AC_CACHE_VAL(ac_cv_lbl_union_wait,
    724 	AC_TRY_COMPILE([
    725 #	include <sys/types.h>
    726 #	include <sys/wait.h>],
    727 	    [int status;
    728 	    u_int i = WEXITSTATUS(status);
    729 	    u_int j = waitpid(0, &status, 0);],
    730 	    ac_cv_lbl_union_wait=no,
    731 	    ac_cv_lbl_union_wait=yes))
    732     AC_MSG_RESULT($ac_cv_lbl_union_wait)
    733     if test $ac_cv_lbl_union_wait = yes ; then
    734 	    AC_DEFINE(DECLWAITSTATUS,union wait,[type for wait])
    735     else
    736 	    AC_DEFINE(DECLWAITSTATUS,int,[type for wait])
    737     fi])
    738 
    739 dnl
    740 dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
    741 dnl
    742 dnl usage:
    743 dnl
    744 dnl	AC_LBL_SOCKADDR_SA_LEN
    745 dnl
    746 dnl results:
    747 dnl
    748 dnl	HAVE_SOCKADDR_SA_LEN (defined)
    749 dnl
    750 AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
    751     [AC_MSG_CHECKING(if sockaddr struct has the sa_len member)
    752     AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len,
    753 	AC_TRY_COMPILE([
    754 #	include <sys/types.h>
    755 #	include <sys/socket.h>],
    756 	[u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
    757 	ac_cv_lbl_sockaddr_has_sa_len=yes,
    758 	ac_cv_lbl_sockaddr_has_sa_len=no))
    759     AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len)
    760     if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then
    761 	    AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[if struct sockaddr has the sa_len member])
    762     fi])
    763 
    764 dnl
    765 dnl Checks to see if there's a sockaddr_storage structure
    766 dnl
    767 dnl usage:
    768 dnl
    769 dnl	AC_LBL_SOCKADDR_STORAGE
    770 dnl
    771 dnl results:
    772 dnl
    773 dnl	HAVE_SOCKADDR_STORAGE (defined)
    774 dnl
    775 AC_DEFUN(AC_LBL_SOCKADDR_STORAGE,
    776     [AC_MSG_CHECKING(if sockaddr_storage struct exists)
    777     AC_CACHE_VAL(ac_cv_lbl_has_sockaddr_storage,
    778 	AC_TRY_COMPILE([
    779 #	include <sys/types.h>
    780 #	include <sys/socket.h>],
    781 	[u_int i = sizeof (struct sockaddr_storage)],
    782 	ac_cv_lbl_has_sockaddr_storage=yes,
    783 	ac_cv_lbl_has_sockaddr_storage=no))
    784     AC_MSG_RESULT($ac_cv_lbl_has_sockaddr_storage)
    785     if test $ac_cv_lbl_has_sockaddr_storage = yes ; then
    786 	    AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[if struct sockaddr_storage exists])
    787     fi])
    788 
    789 dnl
    790 dnl Checks to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
    791 dnl dl_module_id_1 member
    792 dnl
    793 dnl usage:
    794 dnl
    795 dnl	AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1
    796 dnl
    797 dnl results:
    798 dnl
    799 dnl	HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 (defined)
    800 dnl
    801 dnl NOTE: any compile failure means we conclude that it doesn't have
    802 dnl that member, so if we don't have DLPI, don't have a <sys/dlpi_ext.h>
    803 dnl header, or have one that doesn't declare a dl_hp_ppa_info_t type,
    804 dnl we conclude it doesn't have that member (which is OK, as either we
    805 dnl won't be using code that would use that member, or we wouldn't
    806 dnl compile in any case).
    807 dnl
    808 AC_DEFUN(AC_LBL_HP_PPA_INFO_T_DL_MODULE_ID_1,
    809     [AC_MSG_CHECKING(if dl_hp_ppa_info_t struct has dl_module_id_1 member)
    810     AC_CACHE_VAL(ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1,
    811 	AC_TRY_COMPILE([
    812 #	include <sys/types.h>
    813 #	include <sys/dlpi.h>
    814 #	include <sys/dlpi_ext.h>],
    815 	[u_int i = sizeof(((dl_hp_ppa_info_t *)0)->dl_module_id_1)],
    816 	ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=yes,
    817 	ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1=no))
    818     AC_MSG_RESULT($ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1)
    819     if test $ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1 = yes ; then
    820 	    AC_DEFINE(HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1,1,[if ppa_info_t_dl_module_id exists])
    821     fi])
    822 
    823 dnl
    824 dnl Checks to see if -R is used
    825 dnl
    826 dnl usage:
    827 dnl
    828 dnl	AC_LBL_HAVE_RUN_PATH
    829 dnl
    830 dnl results:
    831 dnl
    832 dnl	ac_cv_lbl_have_run_path (yes or no)
    833 dnl
    834 AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
    835     [AC_MSG_CHECKING(for ${CC-cc} -R)
    836     AC_CACHE_VAL(ac_cv_lbl_have_run_path,
    837 	[echo 'main(){}' > conftest.c
    838 	${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
    839 	if test ! -s conftest.out ; then
    840 		ac_cv_lbl_have_run_path=yes
    841 	else
    842 		ac_cv_lbl_have_run_path=no
    843 	fi
    844 	rm -f -r conftest*])
    845     AC_MSG_RESULT($ac_cv_lbl_have_run_path)
    846     ])
    847 
    848 dnl
    849 dnl Checks to see if unaligned memory accesses fail
    850 dnl
    851 dnl usage:
    852 dnl
    853 dnl	AC_LBL_UNALIGNED_ACCESS
    854 dnl
    855 dnl results:
    856 dnl
    857 dnl	LBL_ALIGN (DEFINED)
    858 dnl
    859 AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
    860     [AC_MSG_CHECKING(if unaligned accesses fail)
    861     AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
    862 	[case "$host_cpu" in
    863 
    864 	#
    865 	# These are CPU types where:
    866 	#
    867 	#	the CPU faults on an unaligned access, but at least some
    868 	#	OSes that support that CPU catch the fault and simulate
    869 	#	the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) -
    870 	#	the simulation is slow, so we don't want to use it;
    871 	#
    872 	#	the CPU, I infer (from the old
    873 	#
    874 	# XXX: should also check that they don't do weird things (like on arm)
    875 	#
    876 	#	comment) doesn't fault on unaligned accesses, but doesn't
    877 	#	do a normal unaligned fetch, either (e.g., presumably, ARM);
    878 	#
    879 	#	for whatever reason, the test program doesn't work
    880 	#	(this has been claimed to be the case for several of those
    881 	#	CPUs - I don't know what the problem is; the problem
    882 	#	was reported as "the test program dumps core" for SuperH,
    883 	#	but that's what the test program is *supposed* to do -
    884 	#	it dumps core before it writes anything, so the test
    885 	#	for an empty output file should find an empty output
    886 	#	file and conclude that unaligned accesses don't work).
    887 	#
    888 	# This run-time test won't work if you're cross-compiling, so
    889 	# in order to support cross-compiling for a particular CPU,
    890 	# we have to wire in the list of CPU types anyway, as far as
    891 	# I know, so perhaps we should just have a set of CPUs on
    892 	# which we know it doesn't work, a set of CPUs on which we
    893 	# know it does work, and have the script just fail on other
    894 	# cpu types and update it when such a failure occurs.
    895 	#
    896 	alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1)
    897 		ac_cv_lbl_unaligned_fail=yes
    898 		;;
    899 
    900 	*)
    901 		cat >conftest.c <<EOF
    902 #		include <sys/types.h>
    903 #		include <sys/wait.h>
    904 #		include <stdio.h>
    905 		unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
    906 		main() {
    907 		unsigned int i;
    908 		pid_t pid;
    909 		int status;
    910 		/* avoid "core dumped" message */
    911 		pid = fork();
    912 		if (pid <  0)
    913 			exit(2);
    914 		if (pid > 0) {
    915 			/* parent */
    916 			pid = waitpid(pid, &status, 0);
    917 			if (pid < 0)
    918 				exit(3);
    919 			exit(!WIFEXITED(status));
    920 		}
    921 		/* child */
    922 		i = *(unsigned int *)&a[[1]];
    923 		printf("%d\n", i);
    924 		exit(0);
    925 		}
    926 EOF
    927 		${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
    928 		    conftest.c $LIBS >/dev/null 2>&1
    929 		if test ! -x conftest ; then
    930 			dnl failed to compile for some reason
    931 			ac_cv_lbl_unaligned_fail=yes
    932 		else
    933 			./conftest >conftest.out
    934 			if test ! -s conftest.out ; then
    935 				ac_cv_lbl_unaligned_fail=yes
    936 			else
    937 				ac_cv_lbl_unaligned_fail=no
    938 			fi
    939 		fi
    940 		rm -f -r conftest* core core.conftest
    941 		;;
    942 	esac])
    943     AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
    944     if test $ac_cv_lbl_unaligned_fail = yes ; then
    945 	    AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails])
    946     fi])
    947 
    948 dnl
    949 dnl If the file .devel exists:
    950 dnl	Add some warning flags if the compiler supports them
    951 dnl	If an os prototype include exists, symlink os-proto.h to it
    952 dnl
    953 dnl usage:
    954 dnl
    955 dnl	AC_LBL_DEVEL(copt)
    956 dnl
    957 dnl results:
    958 dnl
    959 dnl	$1 (copt appended)
    960 dnl	HAVE_OS_PROTO_H (defined)
    961 dnl	os-proto.h (symlinked)
    962 dnl
    963 AC_DEFUN(AC_LBL_DEVEL,
    964     [rm -f os-proto.h
    965     if test "${LBL_CFLAGS+set}" = set; then
    966 	    $1="$$1 ${LBL_CFLAGS}"
    967     fi
    968     if test -f .devel ; then
    969 	    #
    970 	    # Skip all the warning option stuff on some compilers.
    971 	    #
    972 	    if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
    973 		    AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR()
    974 		    AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
    975 		    AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
    976 		    AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
    977 	    fi
    978 	    AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
    979 	    #
    980 	    # We used to set -n32 for IRIX 6 when not using GCC (presumed
    981 	    # to mean that we're using MIPS C or MIPSpro C); it specified
    982 	    # the "new" faster 32-bit ABI, introduced in IRIX 6.2.  I'm
    983 	    # not sure why that would be something to do *only* with a
    984 	    # .devel file; why should the ABI for which we produce code
    985 	    # depend on .devel?
    986 	    #
    987 	    os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
    988 	    name="lbl/os-$os.h"
    989 	    if test -f $name ; then
    990 		    ln -s $name os-proto.h
    991 		    AC_DEFINE(HAVE_OS_PROTO_H, 1,
    992 			[if there's an os_proto.h for this platform, to use additional prototypes])
    993 	    else
    994 		    AC_MSG_WARN(can't find $name)
    995 	    fi
    996     fi])
    997 
    998 dnl
    999 dnl Improved version of AC_CHECK_LIB
   1000 dnl
   1001 dnl Thanks to John Hawkinson (jhawk (a] mit.edu)
   1002 dnl
   1003 dnl usage:
   1004 dnl
   1005 dnl	AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
   1006 dnl	    ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
   1007 dnl
   1008 dnl results:
   1009 dnl
   1010 dnl	LIBS
   1011 dnl
   1012 dnl XXX - "AC_LBL_LIBRARY_NET" was redone to use "AC_SEARCH_LIBS"
   1013 dnl rather than "AC_LBL_CHECK_LIB", so this isn't used any more.
   1014 dnl We keep it around for reference purposes in case it's ever
   1015 dnl useful in the future.
   1016 dnl
   1017 
   1018 define(AC_LBL_CHECK_LIB,
   1019 [AC_MSG_CHECKING([for $2 in -l$1])
   1020 dnl Use a cache variable name containing the library, function
   1021 dnl name, and extra libraries to link with, because the test really is
   1022 dnl for library $1 defining function $2, when linked with potinal
   1023 dnl library $5, not just for library $1.  Separate tests with the same
   1024 dnl $1 and different $2's or $5's may have different results.
   1025 ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
   1026 AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
   1027 [ac_save_LIBS="$LIBS"
   1028 LIBS="-l$1 $5 $LIBS"
   1029 AC_TRY_LINK(dnl
   1030 ifelse([$2], [main], , dnl Avoid conflicting decl of main.
   1031 [/* Override any gcc2 internal prototype to avoid an error.  */
   1032 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
   1033 extern "C"
   1034 #endif
   1035 ])dnl
   1036 [/* We use char because int might match the return type of a gcc2
   1037     builtin and then its argument prototype would still apply.  */
   1038 char $2();
   1039 ]),
   1040 	    [$2()],
   1041 	    eval "ac_cv_lbl_lib_$ac_lib_var=yes",
   1042 	    eval "ac_cv_lbl_lib_$ac_lib_var=no")
   1043 LIBS="$ac_save_LIBS"
   1044 ])dnl
   1045 if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
   1046   AC_MSG_RESULT(yes)
   1047   ifelse([$3], ,
   1048 [changequote(, )dnl
   1049   ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
   1050     -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
   1051 changequote([, ])dnl
   1052   AC_DEFINE_UNQUOTED($ac_tr_lib)
   1053   LIBS="-l$1 $LIBS"
   1054 ], [$3])
   1055 else
   1056   AC_MSG_RESULT(no)
   1057 ifelse([$4], , , [$4
   1058 ])dnl
   1059 fi
   1060 ])
   1061 
   1062 dnl
   1063 dnl AC_LBL_LIBRARY_NET
   1064 dnl
   1065 dnl This test is for network applications that need socket() and
   1066 dnl gethostbyname() -ish functions.  Under Solaris, those applications
   1067 dnl need to link with "-lsocket -lnsl".  Under IRIX, they need to link
   1068 dnl with "-lnsl" but should *not* link with "-lsocket" because
   1069 dnl libsocket.a breaks a number of things (for instance:
   1070 dnl gethostbyname() under IRIX 5.2, and snoop sockets under most
   1071 dnl versions of IRIX).
   1072 dnl
   1073 dnl Unfortunately, many application developers are not aware of this,
   1074 dnl and mistakenly write tests that cause -lsocket to be used under
   1075 dnl IRIX.  It is also easy to write tests that cause -lnsl to be used
   1076 dnl under operating systems where neither are necessary (or useful),
   1077 dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
   1078 dnl
   1079 dnl This test exists so that every application developer does not test
   1080 dnl this in a different, and subtly broken fashion.
   1081 
   1082 dnl It has been argued that this test should be broken up into two
   1083 dnl seperate tests, one for the resolver libraries, and one for the
   1084 dnl libraries necessary for using Sockets API. Unfortunately, the two
   1085 dnl are carefully intertwined and allowing the autoconf user to use
   1086 dnl them independantly potentially results in unfortunate ordering
   1087 dnl dependancies -- as such, such component macros would have to
   1088 dnl carefully use indirection and be aware if the other components were
   1089 dnl executed. Since other autoconf macros do not go to this trouble,
   1090 dnl and almost no applications use sockets without the resolver, this
   1091 dnl complexity has not been implemented.
   1092 dnl
   1093 dnl The check for libresolv is in case you are attempting to link
   1094 dnl statically and happen to have a libresolv.a lying around (and no
   1095 dnl libnsl.a).
   1096 dnl
   1097 AC_DEFUN(AC_LBL_LIBRARY_NET, [
   1098     # Most operating systems have gethostbyname() in the default searched
   1099     # libraries (i.e. libc):
   1100     # Some OSes (eg. Solaris) place it in libnsl
   1101     # Some strange OSes (SINIX) have it in libsocket:
   1102     AC_SEARCH_LIBS(gethostbyname, nsl socket resolv)
   1103     # Unfortunately libsocket sometimes depends on libnsl and
   1104     # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this.
   1105     if test "$ac_cv_search_gethostbyname" = "no"
   1106     then
   1107 	AC_CHECK_LIB(socket, gethostbyname,
   1108                      LIBS="-lsocket -lnsl $LIBS", , -lnsl)
   1109     fi
   1110     AC_SEARCH_LIBS(socket, socket, ,
   1111 	AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl))
   1112     # DLPI needs putmsg under HPUX so test for -lstr while we're at it
   1113     AC_SEARCH_LIBS(putmsg, str)
   1114     ])
   1115 
   1116 dnl
   1117 dnl Test for __attribute__
   1118 dnl
   1119 
   1120 AC_DEFUN(AC_C___ATTRIBUTE__, [
   1121 AC_MSG_CHECKING(for __attribute__)
   1122 AC_CACHE_VAL(ac_cv___attribute__, [
   1123 AC_COMPILE_IFELSE([
   1124   AC_LANG_SOURCE([[
   1125 #include <stdlib.h>
   1126 
   1127 static void foo(void) __attribute__ ((noreturn));
   1128 
   1129 static void
   1130 foo(void)
   1131 {
   1132   exit(1);
   1133 }
   1134 
   1135 int
   1136 main(int argc, char **argv)
   1137 {
   1138   foo();
   1139 }
   1140   ]])],
   1141 ac_cv___attribute__=yes,
   1142 ac_cv___attribute__=no)])
   1143 if test "$ac_cv___attribute__" = "yes"; then
   1144   AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
   1145 else
   1146   #
   1147   # We can't use __attribute__, so we can't use __attribute__((unused)),
   1148   # so we define _U_ to an empty string.
   1149   #
   1150   V_DEFS="$V_DEFS -D_U_=\"\""
   1151 fi
   1152 AC_MSG_RESULT($ac_cv___attribute__)
   1153 ])
   1154 
   1155 dnl
   1156 dnl Test whether __attribute__((unused)) can be used without warnings
   1157 dnl
   1158 
   1159 AC_DEFUN(AC_C___ATTRIBUTE___UNUSED, [
   1160 AC_MSG_CHECKING([whether __attribute__((unused)) can be used without warnings])
   1161 AC_CACHE_VAL(ac_cv___attribute___unused, [
   1162 save_CFLAGS="$CFLAGS"
   1163 CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
   1164 AC_COMPILE_IFELSE([
   1165   AC_LANG_SOURCE([[
   1166 #include <stdlib.h>
   1167 #include <stdio.h>
   1168 
   1169 int
   1170 main(int argc  __attribute((unused)), char **argv __attribute((unused)))
   1171 {
   1172   printf("Hello, world!\n");
   1173   return 0;
   1174 }
   1175   ]])],
   1176 ac_cv___attribute___unused=yes,
   1177 ac_cv___attribute___unused=no)])
   1178 CFLAGS="$save_CFLAGS"
   1179 if test "$ac_cv___attribute___unused" = "yes"; then
   1180   V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
   1181 else
   1182   V_DEFS="$V_DEFS -D_U_=\"\""
   1183 fi
   1184 AC_MSG_RESULT($ac_cv___attribute___unused)
   1185 ])
   1186 
   1187 dnl
   1188 dnl Test whether __attribute__((format)) can be used without warnings
   1189 dnl
   1190 
   1191 AC_DEFUN(AC_C___ATTRIBUTE___FORMAT, [
   1192 AC_MSG_CHECKING([whether __attribute__((format)) can be used without warnings])
   1193 AC_CACHE_VAL(ac_cv___attribute___format, [
   1194 save_CFLAGS="$CFLAGS"
   1195 CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
   1196 AC_COMPILE_IFELSE([
   1197   AC_LANG_SOURCE([[
   1198 #include <stdlib.h>
   1199 
   1200 extern int foo(const char *fmt, ...)
   1201 		  __attribute__ ((format (printf, 1, 2)));
   1202 
   1203 int
   1204 main(int argc, char **argv)
   1205 {
   1206   foo("%s", "test");
   1207 }
   1208   ]])],
   1209 ac_cv___attribute___format=yes,
   1210 ac_cv___attribute___format=no)])
   1211 CFLAGS="$save_CFLAGS"
   1212 if test "$ac_cv___attribute___format" = "yes"; then
   1213   AC_DEFINE(__ATTRIBUTE___FORMAT_OK, 1,
   1214     [define if your compiler allows __attribute__((format)) without a warning])
   1215 fi
   1216 AC_MSG_RESULT($ac_cv___attribute___format)
   1217 ])
   1218 
   1219 dnl
   1220 dnl Checks to see if tpacket_stats is defined in linux/if_packet.h
   1221 dnl If so then pcap-linux.c can use this to report proper statistics.
   1222 dnl
   1223 dnl -Scott Barron
   1224 dnl
   1225 AC_DEFUN(AC_LBL_TPACKET_STATS,
   1226    [AC_MSG_CHECKING(if if_packet.h has tpacket_stats defined)
   1227    AC_CACHE_VAL(ac_cv_lbl_tpacket_stats,
   1228    AC_TRY_COMPILE([
   1229 #  include <linux/if_packet.h>],
   1230    [struct tpacket_stats stats],
   1231    ac_cv_lbl_tpacket_stats=yes,
   1232    ac_cv_lbl_tpacket_stats=no))
   1233    AC_MSG_RESULT($ac_cv_lbl_tpacket_stats)
   1234    if test $ac_cv_lbl_tpacket_stats = yes; then
   1235        AC_DEFINE(HAVE_TPACKET_STATS,1,[if if_packet.h has tpacket_stats defined])
   1236    fi])
   1237 
   1238 dnl
   1239 dnl Checks to see if the tpacket_auxdata struct has a tp_vlan_tci member.
   1240 dnl
   1241 dnl usage:
   1242 dnl
   1243 dnl	AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
   1244 dnl
   1245 dnl results:
   1246 dnl
   1247 dnl	HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI (defined)
   1248 dnl
   1249 dnl NOTE: any compile failure means we conclude that it doesn't have
   1250 dnl that member, so if we don't have tpacket_auxdata, we conclude it
   1251 dnl doesn't have that member (which is OK, as either we won't be using
   1252 dnl code that would use that member, or we wouldn't compile in any case).
   1253 dnl
   1254 AC_DEFUN(AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,
   1255     [AC_MSG_CHECKING(if tpacket_auxdata struct has tp_vlan_tci member)
   1256     AC_CACHE_VAL(ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci,
   1257 	AC_TRY_COMPILE([
   1258 #	include <sys/types.h>
   1259 #	include <linux/if_packet.h>],
   1260 	[u_int i = sizeof(((struct tpacket_auxdata *)0)->tp_vlan_tci)],
   1261 	ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=yes,
   1262 	ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=no))
   1263     AC_MSG_RESULT($ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci)
   1264     if test $ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci = yes ; then
   1265 	    HAVE_LINUX_TPACKET_AUXDATA=tp_vlan_tci
   1266 	    AC_SUBST(HAVE_LINUX_TPACKET_AUXDATA)
   1267 	    AC_DEFINE(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,1,[if tp_vlan_tci exists])
   1268     fi])
   1269 
   1270 dnl
   1271 dnl Checks to see if Solaris has the dl_passive_req_t struct defined
   1272 dnl in <sys/dlpi.h>.
   1273 dnl
   1274 dnl usage:
   1275 dnl
   1276 dnl	AC_LBL_DL_PASSIVE_REQ_T
   1277 dnl
   1278 dnl results:
   1279 dnl 
   1280 dnl 	HAVE_DLPI_PASSIVE (defined)
   1281 dnl
   1282 AC_DEFUN(AC_LBL_DL_PASSIVE_REQ_T,
   1283         [AC_MSG_CHECKING(if dl_passive_req_t struct exists)
   1284        AC_CACHE_VAL(ac_cv_lbl_has_dl_passive_req_t,
   1285                 AC_TRY_COMPILE([
   1286 #       include <sys/types.h>
   1287 #       include <sys/dlpi.h>],
   1288         [u_int i = sizeof(dl_passive_req_t)],
   1289         ac_cv_lbl_has_dl_passive_req_t=yes,
   1290         ac_cv_lbl_has_dl_passive_req_t=no))
   1291     AC_MSG_RESULT($ac_cv_lbl_has_dl_passive_req_t)
   1292     if test $ac_cv_lbl_has_dl_passive_req_t = yes ; then
   1293             AC_DEFINE(HAVE_DLPI_PASSIVE,1,[if passive_req_t primitive
   1294 		exists])
   1295     fi])
   1296