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