diff options
-rw-r--r-- | Makefile.in | 25 | ||||
-rw-r--r-- | aclocal.m4 | 76 | ||||
-rw-r--r-- | config.h.in | 7 | ||||
-rwxr-xr-x | configure | 299 | ||||
-rw-r--r-- | configure.in | 54 | ||||
-rw-r--r-- | grammar.y | 10 | ||||
-rwxr-xr-x | runlex.sh | 233 | ||||
-rw-r--r-- | scanner.l | 9 |
8 files changed, 253 insertions, 460 deletions
diff --git a/Makefile.in b/Makefile.in index c6153964..902f2afc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -69,13 +69,8 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ RANLIB = @RANLIB@ -# -# Flex and bison allow you to specify the prefixes of the global symbols -# used by the generated parser. This allows programs to use lex/yacc -# and link against libpcap. If you don't have flex or bison, get them. -# -LEX = @V_LEX@ -YACC = @V_YACC@ +LEX = @LEX@ +YACC = @YACC@ # Explicitly define compilation rule since SunOS 4's make doesn't like gcc. # Also, gcc does not remove the .o before forking 'as', which can be a @@ -149,7 +144,7 @@ TESTS_SRC = \ tests/valgrindtest.c GENHDR = \ - scanner.h tokdefs.h version.h + scanner.h grammar.h version.h TAGFILES = \ $(SRC) $(HDR) @@ -337,7 +332,6 @@ EXTRA_DIST = \ pcap-usb-linux.c \ pcap-usb-linux.h \ pcap-win32.c \ - runlex.sh \ scanner.l \ Win32/Include/Gnuc.h \ Win32/Include/net/if.h \ @@ -429,21 +423,18 @@ libpcap.shareda: $(OBJ) # libpcap.none: +scanner.h: scanner.c scanner.c: $(srcdir)/scanner.l - @rm -f $@ - $(srcdir)/runlex.sh $(LEX) -o$@ $< + $(LEX) -P pcap_ --header-file=scanner.h --nounput -o scanner.c $< -scanner.o: scanner.c tokdefs.h +scanner.o: scanner.c grammar.h $(CC) $(FULL_CFLAGS) -c scanner.c pcap.o: version.h -tokdefs.h: grammar.c +grammar.h: grammar.c grammar.c: $(srcdir)/grammar.y - @rm -f grammar.c tokdefs.h - $(YACC) -d $< - mv y.tab.c grammar.c - mv y.tab.h tokdefs.h + $(YACC) -p pcap_ -o grammar.c -d $< grammar.o: grammar.c @rm -f $@ @@ -630,82 +630,6 @@ AC_DEFUN(AC_LBL_FIXINCLUDES, fi]) dnl -dnl Check for flex, default to lex -dnl Require flex 2.4 or higher -dnl Check for bison, default to yacc -dnl Default to lex/yacc if both flex and bison are not available -dnl -dnl If we're using flex and bison, pass -P to flex and -p to bison -dnl to define a prefix string for the lexer and parser -dnl -dnl If we're not using flex and bison, don't pass those options -dnl (as they might not work - although if "lex" is a wrapper for -dnl Flex and "yacc" is a wrapper for Bison, they will work), and -dnl define NEED_YYPARSE_WRAPPER (we *CANNOT* use YYBISON to check -dnl whether the wrapper is needed, as some people apparently, for -dnl some unknown reason, choose to use --without-flex and -dnl --without-bison on systems that have Flex and Bison, which -dnl means that the "yacc" they end up using is a wrapper that -dnl runs "bison -y", and at least some versions of Bison define -dnl YYBISON even if run with "-y", so we end up not compiling -dnl the yyparse wrapper and end up with a libpcap that doesn't -dnl define pcap_parse()) -dnl -dnl usage: -dnl -dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix) -dnl -dnl results: -dnl -dnl $1 (lex set) -dnl $2 (yacc appended) -dnl $3 (optional flex and bison -P prefix) -dnl -AC_DEFUN(AC_LBL_LEX_AND_YACC, - [AC_ARG_WITH(flex, [ --without-flex don't use flex]) - AC_ARG_WITH(bison, [ --without-bison don't use bison]) - if test "$with_flex" = no ; then - $1=lex - else - AC_CHECK_PROGS($1, flex, lex) - fi - if test "$$1" = flex ; then - # The -V flag was added in 2.4 - AC_MSG_CHECKING(for flex 2.4 or higher) - AC_CACHE_VAL(ac_cv_lbl_flex_v24, - if flex -V >/dev/null 2>&1; then - ac_cv_lbl_flex_v24=yes - else - ac_cv_lbl_flex_v24=no - fi) - AC_MSG_RESULT($ac_cv_lbl_flex_v24) - if test $ac_cv_lbl_flex_v24 = no ; then - s="2.4 or higher required" - AC_MSG_WARN(ignoring obsolete flex executable ($s)) - $1=lex - fi - fi - if test "$with_bison" = no ; then - $2=yacc - else - AC_CHECK_PROGS($2, bison, yacc) - fi - if test "$$2" = bison ; then - $2="$$2 -y" - fi - if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then - AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc) - $1=lex - $2=yacc - fi - if test "$$1" = flex -a -n "$3" ; then - $1="$$1 -P$3" - $2="$$2 -p $3" - else - AC_DEFINE(NEED_YYPARSE_WRAPPER,1,[if we need a pcap_parse wrapper around yyparse]) - fi]) - -dnl dnl Checks to see if union wait is used with WEXITSTATUS() dnl dnl usage: diff --git a/config.h.in b/config.h.in index 13b1a0c8..a0864854 100644 --- a/config.h.in +++ b/config.h.in @@ -226,9 +226,6 @@ /* path for device for USB sniffing */ #undef LINUX_USB_MON_DEV -/* if we need a pcap_parse wrapper around yyparse */ -#undef NEED_YYPARSE_WRAPPER - /* Define to 1 if netinet/ether.h declares `ether_hostton' */ #undef NETINET_ETHER_H_DECLARES_ETHER_HOSTTON @@ -295,6 +292,10 @@ /* Enable parser debugging */ #undef YYDEBUG +/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a + `char[]'. */ +#undef YYTEXT_POINTER + /* Enable large inode numbers on Mac OS X 10.5. */ #ifndef _DARWIN_USE_64_BIT_INODE # define _DARWIN_USE_64_BIT_INODE 1 @@ -644,11 +644,13 @@ DYEXT SSRC ADDLARCHIVEOBJS ADDLOBJS +V_YACC V_RPATH_OPT V_SONAME_OPT V_SHLIB_OPT V_SHLIB_CMD V_PCAP +V_LEX V_INCLS V_FINDALLDEVS V_DEFS @@ -658,8 +660,11 @@ DEPENDENCY_CFLAG LN_S AR RANLIB -V_YACC -V_LEX +YFLAGS +YACC +LEXLIB +LEX_OUTPUT_ROOT +LEX HAVE_LINUX_TPACKET_AUXDATA LIBOBJS EGREP @@ -743,8 +748,6 @@ with_snf with_snf_includes with_snf_libraries with_turbocap -with_flex -with_bison enable_universal enable_shared enable_usb @@ -762,7 +765,9 @@ CFLAGS LDFLAGS LIBS CPPFLAGS -CPP' +CPP +YACC +YFLAGS' # Initialize some variables set by options. @@ -1421,8 +1426,6 @@ Optional Packages: --with-turbocap[=DIR] include Riverbed TurboCap support (located in directory DIR, if supplied). [default=yes, if present] - --without-flex don't use flex - --without-bison don't use bison Some influential environment variables: CC C compiler command @@ -1433,6 +1436,12 @@ Some influential environment variables: CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir> CPP C preprocessor + YACC The `Yet Another Compiler Compiler' implementation to use. + Defaults to the first program found out of: `bison -y', `byacc', + `yacc'. + YFLAGS The list of arguments that will be passed by default to $YACC. + This script will default YFLAGS to the empty string to avoid a + default value of `-d' given by some make applications. Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -6755,32 +6764,20 @@ $as_echo "no" >&6; } fi fi - -# Check whether --with-flex was given. -if test "${with_flex+set}" = set; then : - withval=$with_flex; -fi - - -# Check whether --with-bison was given. -if test "${with_bison+set}" = set; then : - withval=$with_bison; -fi - - if test "$with_flex" = no ; then - V_LEX=lex - else - for ac_prog in flex +# +# Look for {f}lex. +# +for ac_prog in flex lex do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_V_LEX+:} false; then : +if ${ac_cv_prog_LEX+:} false; then : $as_echo_n "(cached) " >&6 else - if test -n "$V_LEX"; then - ac_cv_prog_V_LEX="$V_LEX" # Let the user override the test. + if test -n "$LEX"; then + ac_cv_prog_LEX="$LEX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -6789,7 +6786,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_V_LEX="$ac_prog" + ac_cv_prog_LEX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6799,58 +6796,173 @@ IFS=$as_save_IFS fi fi -V_LEX=$ac_cv_prog_V_LEX -if test -n "$V_LEX"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $V_LEX" >&5 -$as_echo "$V_LEX" >&6; } +LEX=$ac_cv_prog_LEX +if test -n "$LEX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LEX" >&5 +$as_echo "$LEX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - test -n "$V_LEX" && break + test -n "$LEX" && break done -test -n "$V_LEX" || V_LEX="lex" +test -n "$LEX" || LEX=":" + +if test "x$LEX" != "x:"; then + cat >conftest.l <<_ACEOF +%% +a { ECHO; } +b { REJECT; } +c { yymore (); } +d { yyless (1); } +e { /* IRIX 6.5 flex 2.5.4 underquotes its yyless argument. */ + yyless ((input () != 0)); } +f { unput (yytext[0]); } +. { BEGIN INITIAL; } +%% +#ifdef YYTEXT_POINTER +extern char *yytext; +#endif +int +main (void) +{ + return ! yylex () + ! yywrap (); +} +_ACEOF +{ { ac_try="$LEX conftest.l" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$LEX conftest.l") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking lex output file root" >&5 +$as_echo_n "checking lex output file root... " >&6; } +if ${ac_cv_prog_lex_root+:} false; then : + $as_echo_n "(cached) " >&6 +else - fi - if test "$V_LEX" = flex ; then - # The -V flag was added in 2.4 - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for flex 2.4 or higher" >&5 -$as_echo_n "checking for flex 2.4 or higher... " >&6; } - if ${ac_cv_lbl_flex_v24+:} false; then : +if test -f lex.yy.c; then + ac_cv_prog_lex_root=lex.yy +elif test -f lexyy.c; then + ac_cv_prog_lex_root=lexyy +else + as_fn_error $? "cannot find output from $LEX; giving up" "$LINENO" 5 +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_root" >&5 +$as_echo "$ac_cv_prog_lex_root" >&6; } +LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root + +if test -z "${LEXLIB+set}"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking lex library" >&5 +$as_echo_n "checking lex library... " >&6; } +if ${ac_cv_lib_lex+:} false; then : $as_echo_n "(cached) " >&6 else - if flex -V >/dev/null 2>&1; then - ac_cv_lbl_flex_v24=yes - else - ac_cv_lbl_flex_v24=no - fi + + ac_save_LIBS=$LIBS + ac_cv_lib_lex='none needed' + for ac_lib in '' -lfl -ll; do + LIBS="$ac_lib $ac_save_LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +`cat $LEX_OUTPUT_ROOT.c` +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_lex=$ac_lib +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + test "$ac_cv_lib_lex" != 'none needed' && break + done + LIBS=$ac_save_LIBS + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lex" >&5 +$as_echo "$ac_cv_lib_lex" >&6; } + test "$ac_cv_lib_lex" != 'none needed' && LEXLIB=$ac_cv_lib_lex fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_flex_v24" >&5 -$as_echo "$ac_cv_lbl_flex_v24" >&6; } - if test $ac_cv_lbl_flex_v24 = no ; then - s="2.4 or higher required" - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: ignoring obsolete flex executable ($s)" >&5 -$as_echo "$as_me: WARNING: ignoring obsolete flex executable ($s)" >&2;} - V_LEX=lex - fi - fi - if test "$with_bison" = no ; then - V_YACC=yacc - else - for ac_prog in bison + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yytext is a pointer" >&5 +$as_echo_n "checking whether yytext is a pointer... " >&6; } +if ${ac_cv_prog_lex_yytext_pointer+:} false; then : + $as_echo_n "(cached) " >&6 +else + # POSIX says lex can declare yytext either as a pointer or an array; the +# default is implementation-dependent. Figure out which it is, since +# not all implementations provide the %pointer and %array declarations. +ac_cv_prog_lex_yytext_pointer=no +ac_save_LIBS=$LIBS +LIBS="$LEXLIB $ac_save_LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define YYTEXT_POINTER 1 +`cat $LEX_OUTPUT_ROOT.c` +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_prog_lex_yytext_pointer=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_save_LIBS + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_yytext_pointer" >&5 +$as_echo "$ac_cv_prog_lex_yytext_pointer" >&6; } +if test $ac_cv_prog_lex_yytext_pointer = yes; then + +$as_echo "#define YYTEXT_POINTER 1" >>confdefs.h + +fi +rm -f conftest.l $LEX_OUTPUT_ROOT.c + +fi + +# +# Make sure {f}lex supports the -P, --header-file, and --nounput flags +# and supports processing our scanner.l. +# +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for capable lex" >&5 +$as_echo_n "checking for capable lex... " >&6; } +if ${tcpdump_cv_capable_lex+:} false; then : + $as_echo_n "(cached) " >&6 +else + if $LEX -P pcap_ --header-file=/dev/null --nounput -t scanner.l > /dev/null 2>&1; then + tcpdump_cv_capable_lex=yes + else + tcpdump_cv_capable_lex=insufficient + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcpdump_cv_capable_lex" >&5 +$as_echo "$tcpdump_cv_capable_lex" >&6; } +if test $tcpdump_cv_capable_lex = insufficient ; then + as_fn_error $? "$LEX is insufficient to compile libpcap. + libpcap requires Flex 2.5.31 or later, or a compatible version of lex." "$LINENO" 5 +fi + +# +# Look for yacc/bison/byacc. +# +for ac_prog in 'bison -y' byacc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_V_YACC+:} false; then : +if ${ac_cv_prog_YACC+:} false; then : $as_echo_n "(cached) " >&6 else - if test -n "$V_YACC"; then - ac_cv_prog_V_YACC="$V_YACC" # Let the user override the test. + if test -n "$YACC"; then + ac_cv_prog_YACC="$YACC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -6859,7 +6971,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_V_YACC="$ac_prog" + ac_cv_prog_YACC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -6869,61 +6981,42 @@ IFS=$as_save_IFS fi fi -V_YACC=$ac_cv_prog_V_YACC -if test -n "$V_YACC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $V_YACC" >&5 -$as_echo "$V_YACC" >&6; } +YACC=$ac_cv_prog_YACC +if test -n "$YACC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5 +$as_echo "$YACC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - test -n "$V_YACC" && break + test -n "$YACC" && break done -test -n "$V_YACC" || V_YACC="yacc" - - fi - if test "$V_YACC" = bison ; then - V_YACC="$V_YACC -y" - fi - if test "$V_LEX" != lex -a "$V_YACC" = yacc -o "$V_LEX" = lex -a "$V_YACC" != yacc ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: don't have both flex and bison; reverting to lex/yacc" >&5 -$as_echo "$as_me: WARNING: don't have both flex and bison; reverting to lex/yacc" >&2;} - V_LEX=lex - V_YACC=yacc - fi - if test "$V_LEX" = flex -a -n "pcap_" ; then - V_LEX="$V_LEX -Ppcap_" - V_YACC="$V_YACC -p pcap_" - else +test -n "$YACC" || YACC="yacc" -$as_echo "#define NEED_YYPARSE_WRAPPER 1" >>confdefs.h - fi -if test "$V_LEX" = lex ; then -# Some versions of lex can't handle the definitions section of scanner.l . -# Try lexing it and complain if it can't deal. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for capable lex" >&5 -$as_echo_n "checking for capable lex... " >&6; } -if ${tcpdump_cv_capable_lex+:} false; then : +# +# Make sure it supports the -p flag and supports processing our +# grammar.y. +# +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for capable yacc/bison" >&5 +$as_echo_n "checking for capable yacc/bison... " >&6; } +if ${tcpdump_cv_capable_yacc+:} false; then : $as_echo_n "(cached) " >&6 else - if lex -t scanner.l > /dev/null 2>&1; then - tcpdump_cv_capable_lex=yes - else - tcpdump_cv_capable_lex=insufficient - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcpdump_cv_capable_lex" >&5 -$as_echo "$tcpdump_cv_capable_lex" >&6; } - if test $tcpdump_cv_capable_lex = insufficient ; then - as_fn_error $? "Your operating system's lex is insufficient to compile - libpcap. flex is a lex replacement that has many advantages, including - being able to compile libpcap. For more information, see - http://www.gnu.org/software/flex/flex.html ." "$LINENO" 5 + if $YACC -p pcap_ grammar.y -o /dev/null >/dev/null 2>&1; then + tcpdump_cv_capable_yacc=yes + else + tcpdump_cv_capable_yacc=insufficient fi fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcpdump_cv_capable_yacc" >&5 +$as_echo "$tcpdump_cv_capable_yacc" >&6; } +if test $tcpdump_cv_capable_yacc = insufficient ; then + as_fn_error $? "$YACC is insufficient to compile libpcap. + libpcap requires Bison, Berkeley YACC, or another YACC compatible with them." "$LINENO" 5 +fi # # Assume, by default, no support for shared libraries and V7/BSD convention diff --git a/configure.in b/configure.in index 8a928821..d0b9f73a 100644 --- a/configure.in +++ b/configure.in @@ -1078,22 +1078,44 @@ if test "$want_turbocap" != no; then fi fi -AC_LBL_LEX_AND_YACC(V_LEX, V_YACC, pcap_) -if test "$V_LEX" = lex ; then -# Some versions of lex can't handle the definitions section of scanner.l . -# Try lexing it and complain if it can't deal. - AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex, - if lex -t scanner.l > /dev/null 2>&1; then - tcpdump_cv_capable_lex=yes - else - tcpdump_cv_capable_lex=insufficient - fi) - if test $tcpdump_cv_capable_lex = insufficient ; then - AC_MSG_ERROR([Your operating system's lex is insufficient to compile - libpcap. flex is a lex replacement that has many advantages, including - being able to compile libpcap. For more information, see - http://www.gnu.org/software/flex/flex.html .]) - fi +# +# Look for {f}lex. +# +AC_PROG_LEX + +# +# Make sure {f}lex supports the -P, --header-file, and --nounput flags +# and supports processing our scanner.l. +# +AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex, + if $LEX -P pcap_ --header-file=/dev/null --nounput -t scanner.l > /dev/null 2>&1; then + tcpdump_cv_capable_lex=yes + else + tcpdump_cv_capable_lex=insufficient + fi) +if test $tcpdump_cv_capable_lex = insufficient ; then + AC_MSG_ERROR([$LEX is insufficient to compile libpcap. + libpcap requires Flex 2.5.31 or later, or a compatible version of lex.]) +fi + +# +# Look for yacc/bison/byacc. +# +AC_PROG_YACC + +# +# Make sure it supports the -p flag and supports processing our +# grammar.y. +# +AC_CACHE_CHECK([for capable yacc/bison], tcpdump_cv_capable_yacc, + if $YACC -p pcap_ grammar.y -o /dev/null >/dev/null 2>&1; then + tcpdump_cv_capable_yacc=yes + else + tcpdump_cv_capable_yacc=insufficient + fi) +if test $tcpdump_cv_capable_yacc = insufficient ; then + AC_MSG_ERROR([$YACC is insufficient to compile libpcap. + libpcap requires Bison, Berkeley YACC, or another YACC compatible with them.]) fi # @@ -181,16 +181,6 @@ yyerror(const char *msg) /* NOTREACHED */ } -#ifdef NEED_YYPARSE_WRAPPER -int yyparse(void); - -int -pcap_parse() -{ - return (yyparse()); -} -#endif - #ifdef HAVE_NET_PFVAR_H static int pfreason_to_num(const char *reason) diff --git a/runlex.sh b/runlex.sh deleted file mode 100755 index 06b8bd45..00000000 --- a/runlex.sh +++ /dev/null @@ -1,233 +0,0 @@ -#! /bin/sh - -# -# runlex.sh -# Script to run Lex/Flex. -# First argument is the (quoted) name of the command; if it's null, that -# means that neither Flex nor Lex was found, so we report an error and -# quit. -# - -# -# Get the name of the command to run, and then shift to get the arguments. -# -if [ $# -eq 0 ] -then - echo "Usage: runlex <lex/flex command to run> [ arguments ]" 1>&2 - exit 1 -fi -LEX="$1" -shift - -# -# Check whether we have Lex or Flex. -# -if [ -z "${LEX}" ] -then - echo "Neither lex nor flex was found" 1>&2 - exit 1 -fi - -# -# Process the flags. We don't use getopt because we don't want to -# embed complete knowledge of what options are supported by Lex/Flex. -# -flags="" -outfile=lex.yy.c -while [ $# -ne 0 ] -do - case "$1" in - - -o*) - # - # Set the output file name. - # - outfile=`echo "$1" | sed 's/-o\(.*\)/\1/'` - ;; - - -*) - # - # Add this to the list of flags. - # - flags="$flags $1" - ;; - - --|*) - # - # End of flags. - # - break - ;; - esac - shift -done - -# -# Is it Lex, or is it Flex? -# -if [ "${LEX}" = flex ] -then - # - # It's Flex. - # - have_flex=yes - - # - # Does it support the --noFUNCTION options? If so, we pass - # --nounput, as at least some versions that support those - # options don't support disabling yyunput by defining - # YY_NO_UNPUT. - # - if flex --help | egrep noFUNCTION >/dev/null - then - flags="$flags --nounput" - - # - # Does it support -R, for generating reentrant scanners? - # If so, we're not currently using that feature, but - # it'll generate some unused functions anyway - and there - # won't be any header file declaring them, so there'll be - # defined-but-not-declared warnings. Therefore, we use - # --noFUNCTION options to suppress generating those - # functions. - # - if flex --help | egrep reentrant >/dev/null - then - flags="$flags --noyyget_lineno --noyyget_in --noyyget_out --noyyget_leng --noyyget_text --noyyset_lineno --noyyset_in --noyyset_out" - fi - fi -else - # - # It's Lex. - # - have_flex=no -fi - -# -# OK, run it. -# If it's lex, it doesn't support -o, so we just write to -# lex.yy.c and, if it succeeds, rename it to the right name, -# otherwise we remove lex.yy.c. -# If it's flex, it supports -o, so we use that - flex with -P doesn't -# write to lex.yy.c, it writes to a lex.{prefix from -P}.c. -# -if [ $have_flex = yes ] -then - ${LEX} $flags -o"$outfile" "$@" - - # - # Did it succeed? - # - status=$? - if [ $status -ne 0 ] - then - # - # No. Exit with the failing exit status. - # - exit $status - fi - - # - # Flex has the annoying habit of stripping all but the last - # component of the "-o" flag argument and using that as the - # place to put the output. This gets in the way of building - # in a directory different from the source directory. Try - # to work around this. - # - # Is the outfile where we think it is? - # - outfile_base=`basename "$outfile"` - if [ "$outfile_base" != "$outfile" -a \( ! -r "$outfile" \) -a -r "$outfile_base" ] - then - # - # No, it's not, but it is in the current directory. Put it - # where it's supposed to be. - # - mv "$outfile_base" "$outfile" - - # - # Did that succeed? - # - status=$? - if [ $status -ne 0 ] - then - # - # No. Exit with the failing exit status. - # - exit $status - fi - fi -else - ${LEX} $flags "$@" - - # - # Did it succeed? - # - status=$? - if [ $status -ne 0 ] - then - # - # No. Get rid of any lex.yy.c file we generated, and - # exit with the failing exit status. - # - rm -f lex.yy.c - exit $status - fi - - # - # OK, rename lex.yy.c to the right output file. - # - mv lex.yy.c "$outfile" - - # - # Did that succeed? - # - status=$? - if [ $status -ne 0 ] - then - # - # No. Get rid of any lex.yy.c file we generated, and - # exit with the failing exit status. - # - rm -f lex.yy.c - exit $status - fi -fi - -# -# OK, now let's generate a header file declaring the relevant functions -# defined by the .c file; if the .c file is .../foo.c, the header file -# will be .../foo.h. -# -# This works around some other Flex suckage, wherein it doesn't declare -# the lex routine before defining it, causing compiler warnings. -# XXX - newer versions of Flex support --header-file=, to generate the -# appropriate header file. With those versions, we should use that option. -# - -# -# Get the name of the prefix; scan the source files for a %option prefix -# line. We use the last one. -# -prefix=`sed -n 's/%option[ ][ ]*prefix="\(.*\)".*/\1/p' "$@" | tail -1` -if [ ! -z "$prefix" ] -then - prefixline="#define yylex ${prefix}lex" -fi - -# -# Construct the name of the header file. -# -header_file=`dirname "$outfile"`/`basename "$outfile" .c`.h - -# -# Spew out the declaration. -# -cat <<EOF >$header_file -/* This is generated by runlex.sh. Do not edit it. */ -$prefixline -#ifndef YY_DECL -#define YY_DECL int yylex(void) -#endif -YY_DECL; -EOF @@ -1,10 +1,15 @@ -%top{ +%top { /* Must come first for _LARGE_FILE_API on AIX. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif } +/* + * We don't read from the terminal. + */ +%option never-interactive + %{ /* * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 @@ -87,7 +92,7 @@ #endif /*INET6*/ #include <pcap/namedb.h> -#include "tokdefs.h" +#include "grammar.h" #ifdef HAVE_OS_PROTO_H #include "os-proto.h" |