1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Pregenerate lex and yacc files and remove the build dependency on those

programs.
This commit is contained in:
david
2009-10-27 22:43:09 +00:00
parent 3889091495
commit 0b1816c0ff
8 changed files with 8946 additions and 220 deletions

View File

@@ -62,14 +62,6 @@ 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@
# 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
# problem if you don't own the file but can write to the directory.
@@ -122,7 +114,7 @@ TAGHDR = \
TAGFILES = \
$(SRC) $(HDR) $(TAGHDR)
CLEANFILES = $(OBJ) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c
CLEANFILES = $(OBJ) libpcap.a lex.yy.c
MAN1 = pcap-config.1
@@ -344,22 +336,11 @@ libpcap.dylib: $(OBJ)
-compatibility_version 1 \
-current_version `sed 's/[^0-9.].*$$//' $(srcdir)/VERSION`
scanner.c: $(srcdir)/scanner.l
@rm -f $@
./runlex.sh $(LEX) -o$@ $<
scanner.o: scanner.c tokdefs.h
$(CC) $(CFLAGS) -c scanner.c
pcap.o: version.h
tokdefs.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
grammar.o: grammar.c
@rm -f $@
$(CC) $(CFLAGS) -Dyylval=pcap_lval -c grammar.c

View File

@@ -23,6 +23,100 @@ o Added @CFLAGS@ to the CFLAGS definition in Makefile.in to pick up -g
# INSTALL = @INSTALL@
# INSTALL_PROGRAM = @INSTALL_PROGRAM@
o Eliminated Lex/Yacc requirement and added the generated files:
grammar.c
scanner.c
scanner.h
tokdefs.h
--- Makefile.in.orig 2009-10-27 16:17:34.000000000 -0600
+++ Makefile.in 2009-10-27 16:19:50.000000000 -0600
@@ -62,14 +62,6 @@
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@
-
# 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
# problem if you don't own the file but can write to the directory.
@@ -122,7 +114,7 @@
TAGFILES = \
$(SRC) $(HDR) $(TAGHDR)
-CLEANFILES = $(OBJ) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c
+CLEANFILES = $(OBJ) libpcap.a lex.yy.c
MAN1 = pcap-config.1
@@ -344,22 +336,11 @@
-compatibility_version 1 \
-current_version `sed 's/[^0-9.].*$$//' $(srcdir)/VERSION`
-scanner.c: $(srcdir)/scanner.l
- @rm -f $@
- ./runlex.sh $(LEX) -o$@ $<
-
scanner.o: scanner.c tokdefs.h
$(CC) $(CFLAGS) -c scanner.c
pcap.o: version.h
-tokdefs.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
-
grammar.o: grammar.c
@rm -f $@
$(CC) $(CFLAGS) -Dyylval=pcap_lval -c grammar.c
--- configure.in.orig 2009-10-27 16:20:34.000000000 -0600
+++ configure.in 2009-10-27 16:14:32.000000000 -0600
@@ -848,24 +848,6 @@
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
-fi
-
#
# Assume a.out/ELF convention for shared library names (".so"), and
# V7/BSD convention for man pages (file formats in section 5,
@@ -1004,10 +986,8 @@
AC_SUBST(V_DEFS)
AC_SUBST(V_INCLS)
AC_SUBST(V_LIBS)
-AC_SUBST(V_LEX)
AC_SUBST(V_PCAP)
AC_SUBST(V_FINDALLDEVS)
-AC_SUBST(V_YACC)
AC_SUBST(SSRC)
AC_SUBST(DYEXT)
AC_SUBST(DAGLIBS)
o The following patch removes some code that apparently causes libpcap
on Solaris to wait for 64K chunks before returning in some cases,
regardless of the timeout values. Problem report and original patch
@@ -45,3 +139,5 @@ o The following patch removes some code that apparently causes libpcap
return (retv);
}
#endif /* HAVE_SYS_BUFMOD_H */
o Regenerated configure.

181
libpcap/configure vendored
View File

@@ -675,8 +675,6 @@ CPP
GREP
EGREP
LIBOBJS
V_LEX
V_YACC
RANLIB
V_CCOPT
V_DEFS
@@ -1297,8 +1295,6 @@ Optional Packages:
--with-dag-includes=DIR Endace DAG include directory
--with-dag-libraries=DIR Endace DAG library directory
--with-septel[=DIR] include Septel support (located in directory DIR, if supplied). default=yes, on Linux, if present
--without-flex don't use flex
--without-bison don't use bison
Some influential environment variables:
CC C compiler command
@@ -8405,177 +8401,6 @@ echo "$as_me: error: Specifying the capture type as 'septel' requires the Septel
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
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
if test "${ac_cv_prog_V_LEX+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$V_LEX"; then
ac_cv_prog_V_LEX="$V_LEX" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_V_LEX="$ac_prog"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
V_LEX=$ac_cv_prog_V_LEX
if test -n "$V_LEX"; then
{ echo "$as_me:$LINENO: result: $V_LEX" >&5
echo "${ECHO_T}$V_LEX" >&6; }
else
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
test -n "$V_LEX" && break
done
test -n "$V_LEX" || V_LEX="lex"
fi
if test "$V_LEX" = flex ; then
# The -V flag was added in 2.4
{ echo "$as_me:$LINENO: checking for flex 2.4 or higher" >&5
echo $ECHO_N "checking for flex 2.4 or higher... $ECHO_C" >&6; }
if test "${ac_cv_lbl_flex_v24+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if flex -V >/dev/null 2>&1; then
ac_cv_lbl_flex_v24=yes
else
ac_cv_lbl_flex_v24=no
fi
fi
{ echo "$as_me:$LINENO: result: $ac_cv_lbl_flex_v24" >&5
echo "${ECHO_T}$ac_cv_lbl_flex_v24" >&6; }
if test $ac_cv_lbl_flex_v24 = no ; then
s="2.4 or higher required"
{ echo "$as_me:$LINENO: WARNING: ignoring obsolete flex executable ($s)" >&5
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
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
if test "${ac_cv_prog_V_YACC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$V_YACC"; then
ac_cv_prog_V_YACC="$V_YACC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_V_YACC="$ac_prog"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
V_YACC=$ac_cv_prog_V_YACC
if test -n "$V_YACC"; then
{ echo "$as_me:$LINENO: result: $V_YACC" >&5
echo "${ECHO_T}$V_YACC" >&6; }
else
{ echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6; }
fi
test -n "$V_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
{ echo "$as_me:$LINENO: WARNING: don't have both flex and bison; reverting to lex/yacc" >&5
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_"
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.
{ echo "$as_me:$LINENO: checking for capable lex" >&5
echo $ECHO_N "checking for capable lex... $ECHO_C" >&6; }
if test "${tcpdump_cv_capable_lex+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&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
{ echo "$as_me:$LINENO: result: $tcpdump_cv_capable_lex" >&5
echo "${ECHO_T}$tcpdump_cv_capable_lex" >&6; }
if test $tcpdump_cv_capable_lex = insufficient ; then
{ { echo "$as_me:$LINENO: 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 ." >&5
echo "$as_me: 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 ." >&2;}
{ (exit 1); exit 1; }; }
fi
fi
#
# Assume a.out/ELF convention for shared library names (".so"), and
# V7/BSD convention for man pages (file formats in section 5,
@@ -9186,8 +9011,6 @@ ln -s ${srcdir}/bpf/net net
{ echo "$as_me:$LINENO: checking for USB sniffing support" >&5
echo $ECHO_N "checking for USB sniffing support... $ECHO_C" >&6; }
case "$host_os" in
@@ -10147,8 +9970,6 @@ CPP!$CPP$ac_delim
GREP!$GREP$ac_delim
EGREP!$EGREP$ac_delim
LIBOBJS!$LIBOBJS$ac_delim
V_LEX!$V_LEX$ac_delim
V_YACC!$V_YACC$ac_delim
RANLIB!$RANLIB$ac_delim
V_CCOPT!$V_CCOPT$ac_delim
V_DEFS!$V_DEFS$ac_delim
@@ -10172,7 +9993,7 @@ INSTALL_DATA!$INSTALL_DATA$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 84; then
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 82; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

View File

@@ -848,24 +848,6 @@ if test "$V_PCAP" = septel -a "$ac_cv_lbl_septel_api" = no; then
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
fi
#
# Assume a.out/ELF convention for shared library names (".so"), and
# V7/BSD convention for man pages (file formats in section 5,
@@ -1004,10 +986,8 @@ AC_SUBST(V_CCOPT)
AC_SUBST(V_DEFS)
AC_SUBST(V_INCLS)
AC_SUBST(V_LIBS)
AC_SUBST(V_LEX)
AC_SUBST(V_PCAP)
AC_SUBST(V_FINDALLDEVS)
AC_SUBST(V_YACC)
AC_SUBST(SSRC)
AC_SUBST(DYEXT)
AC_SUBST(DAGLIBS)

3803
libpcap/grammar.c Normal file

File diff suppressed because it is too large Load Diff

4741
libpcap/scanner.c Normal file

File diff suppressed because it is too large Load Diff

6
libpcap/scanner.h Normal file
View File

@@ -0,0 +1,6 @@
/* This is generated by runlex.sh. Do not edit it. */
#ifndef YY_DECL
#define YY_DECL int yylex(void)
#endif
YY_DECL;

298
libpcap/tokdefs.h Normal file
View File

@@ -0,0 +1,298 @@
/* A Bison parser, made by GNU Bison 2.4.1. */
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
DST = 258,
SRC = 259,
HOST = 260,
GATEWAY = 261,
NET = 262,
NETMASK = 263,
PORT = 264,
PORTRANGE = 265,
LESS = 266,
GREATER = 267,
PROTO = 268,
PROTOCHAIN = 269,
CBYTE = 270,
ARP = 271,
RARP = 272,
IP = 273,
SCTP = 274,
TCP = 275,
UDP = 276,
ICMP = 277,
IGMP = 278,
IGRP = 279,
PIM = 280,
VRRP = 281,
ATALK = 282,
AARP = 283,
DECNET = 284,
LAT = 285,
SCA = 286,
MOPRC = 287,
MOPDL = 288,
TK_BROADCAST = 289,
TK_MULTICAST = 290,
NUM = 291,
INBOUND = 292,
OUTBOUND = 293,
PF_IFNAME = 294,
PF_RSET = 295,
PF_RNR = 296,
PF_SRNR = 297,
PF_REASON = 298,
PF_ACTION = 299,
TYPE = 300,
SUBTYPE = 301,
DIR = 302,
ADDR1 = 303,
ADDR2 = 304,
ADDR3 = 305,
ADDR4 = 306,
LINK = 307,
GEQ = 308,
LEQ = 309,
NEQ = 310,
ID = 311,
EID = 312,
HID = 313,
HID6 = 314,
AID = 315,
LSH = 316,
RSH = 317,
LEN = 318,
IPV6 = 319,
ICMPV6 = 320,
AH = 321,
ESP = 322,
VLAN = 323,
MPLS = 324,
PPPOED = 325,
PPPOES = 326,
ISO = 327,
ESIS = 328,
CLNP = 329,
ISIS = 330,
L1 = 331,
L2 = 332,
IIH = 333,
LSP = 334,
SNP = 335,
CSNP = 336,
PSNP = 337,
STP = 338,
IPX = 339,
NETBEUI = 340,
LANE = 341,
LLC = 342,
METAC = 343,
BCC = 344,
SC = 345,
ILMIC = 346,
OAMF4EC = 347,
OAMF4SC = 348,
OAM = 349,
OAMF4 = 350,
CONNECTMSG = 351,
METACONNECT = 352,
VPI = 353,
VCI = 354,
RADIO = 355,
FISU = 356,
LSSU = 357,
MSU = 358,
SIO = 359,
OPC = 360,
DPC = 361,
SLS = 362,
AND = 363,
OR = 364,
UMINUS = 365
};
#endif
/* Tokens. */
#define DST 258
#define SRC 259
#define HOST 260
#define GATEWAY 261
#define NET 262
#define NETMASK 263
#define PORT 264
#define PORTRANGE 265
#define LESS 266
#define GREATER 267
#define PROTO 268
#define PROTOCHAIN 269
#define CBYTE 270
#define ARP 271
#define RARP 272
#define IP 273
#define SCTP 274
#define TCP 275
#define UDP 276
#define ICMP 277
#define IGMP 278
#define IGRP 279
#define PIM 280
#define VRRP 281
#define ATALK 282
#define AARP 283
#define DECNET 284
#define LAT 285
#define SCA 286
#define MOPRC 287
#define MOPDL 288
#define TK_BROADCAST 289
#define TK_MULTICAST 290
#define NUM 291
#define INBOUND 292
#define OUTBOUND 293
#define PF_IFNAME 294
#define PF_RSET 295
#define PF_RNR 296
#define PF_SRNR 297
#define PF_REASON 298
#define PF_ACTION 299
#define TYPE 300
#define SUBTYPE 301
#define DIR 302
#define ADDR1 303
#define ADDR2 304
#define ADDR3 305
#define ADDR4 306
#define LINK 307
#define GEQ 308
#define LEQ 309
#define NEQ 310
#define ID 311
#define EID 312
#define HID 313
#define HID6 314
#define AID 315
#define LSH 316
#define RSH 317
#define LEN 318
#define IPV6 319
#define ICMPV6 320
#define AH 321
#define ESP 322
#define VLAN 323
#define MPLS 324
#define PPPOED 325
#define PPPOES 326
#define ISO 327
#define ESIS 328
#define CLNP 329
#define ISIS 330
#define L1 331
#define L2 332
#define IIH 333
#define LSP 334
#define SNP 335
#define CSNP 336
#define PSNP 337
#define STP 338
#define IPX 339
#define NETBEUI 340
#define LANE 341
#define LLC 342
#define METAC 343
#define BCC 344
#define SC 345
#define ILMIC 346
#define OAMF4EC 347
#define OAMF4SC 348
#define OAM 349
#define OAMF4 350
#define CONNECTMSG 351
#define METACONNECT 352
#define VPI 353
#define VCI 354
#define RADIO 355
#define FISU 356
#define LSSU 357
#define MSU 358
#define SIO 359
#define OPC 360
#define DPC 361
#define SLS 362
#define AND 363
#define OR 364
#define UMINUS 365
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 1676 of yacc.c */
#line 241 "grammar.y"
int i;
bpf_u_int32 h;
u_char *e;
char *s;
struct stmt *stmt;
struct arth *a;
struct {
struct qual q;
int atmfieldtype;
int mtp3fieldtype;
struct block *b;
} blk;
struct block *rblk;
/* Line 1676 of yacc.c */
#line 290 "y.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE pcap_lval;