@@ -16,9 +16,11 @@ check_toolchain()
: ${PKG_CONFIG:=pkg-config}
: ${AR=ar}
: ${CC=gcc}
+ : ${YACC=bison}
echo "PKG_CONFIG:=${PKG_CONFIG}" >>$CONFIG
echo "AR:=${AR}" >>$CONFIG
echo "CC:=${CC}" >>$CONFIG
+ echo "YACC:=${YACC}" >>$CONFIG
}
check_atm()
@@ -1,7 +1,7 @@
arpd
ifstat
ss
-ssfilter.c
+ssfilter.tab.c
nstat
lnstat
rtacct
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
-SSOBJ=ss.o ssfilter.o
+SSOBJ=ss.o ssfilter.tab.o
LNSTATOBJ=lnstat.o lnstat_util.o
TARGETS=ss nstat ifstat rtacct lnstat
@@ -27,8 +27,8 @@ rtacct: rtacct.c
arpd: arpd.c
$(QUIET_CC)$(CC) $(CFLAGS) -I$(DBM_INCLUDE) $(CPPFLAGS) $(LDFLAGS) -o arpd arpd.c $(LDLIBS) -ldb
-ssfilter.c: ssfilter.y
- $(QUIET_YACC)bison ssfilter.y -o ssfilter.c
+ssfilter.tab.c: ssfilter.y
+ $(QUIET_YACC)$(YACC) -b ssfilter ssfilter.y
lnstat: $(LNSTATOBJ)
$(QUIET_LINK)$(CC) $^ $(LDFLAGS) $(LDLIBS) -o $@
@@ -1,5 +1,5 @@
-*.yacc.c
+*.tab.c
*.lex.c
*.output
-*.yacc.h
+*.tab.h
tc
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
TCOBJ= tc.o tc_qdisc.o tc_class.o tc_filter.o tc_util.o tc_monitor.o \
tc_exec.o m_police.o m_estimator.o m_action.o m_ematch.o \
- emp_ematch.yacc.o emp_ematch.lex.o
+ emp_ematch.tab.o emp_ematch.lex.o
include ../config.mk
@@ -125,7 +125,6 @@ ifneq ($(IPT_LIB_DIR),)
CFLAGS += -DIPT_LIB_DIR=\"$(IPT_LIB_DIR)\"
endif
-YACC := bison
LEX := flex
CFLAGS += -DYY_NO_INPUT
@@ -158,8 +157,8 @@ install: all
fi
clean:
- rm -f $(TCOBJ) $(TCLIB) libtc.a tc *.so emp_ematch.yacc.h; \
- rm -f emp_ematch.yacc.*
+ rm -f $(TCOBJ) $(TCLIB) libtc.a tc *.so emp_ematch.tab.h; \
+ rm -f emp_ematch.tab.*
q_atm.so: q_atm.c
$(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fpic -o q_atm.so q_atm.c -latm
@@ -178,8 +177,8 @@ ifeq ($(TC_CONFIG_XT),y)
LDLIBS += $$($(PKG_CONFIG) xtables --libs)
endif
-%.yacc.c: %.y
- $(QUIET_YACC)$(YACC) $(YACCFLAGS) -o $@ $<
+%.tab.c: %.y
+ $(QUIET_YACC)$(YACC) $(YACCFLAGS) -p ematch_ -b $(basename $(basename $@)) $<
%.lex.c: %.l
$(QUIET_LEX)$(LEX) $(LEXFLAGS) -o$@ $<
@@ -187,7 +186,7 @@ endif
# our lexer includes the header from yacc, so make sure
# we don't attempt to compile it before the header has
# been generated as part of the yacc step.
-emp_ematch.lex.o: emp_ematch.yacc.c
+emp_ematch.lex.o: emp_ematch.tab.c
ifneq ($(SHARED_LIBS),y)
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0 */
%{
- #include "emp_ematch.yacc.h"
+ #include "emp_ematch.tab.h"
#include "m_ematch.h"
extern int ematch_argc;
@@ -6,11 +6,6 @@
#include "m_ematch.h"
%}
-%locations
-%token-table
-%define parse.error verbose
-%define api.prefix {ematch_}
-
%union {
unsigned int i;
struct bstr *b;
config: put YACC in config.mk and use environmental variable if present ss: use YACC variable instead of hardcoding bison place options before source file argument use -b to specify file prefix instead of output file, as -o isn't POSIX compatible, this generates ssfilter.tab.c instead of ssfilter.c replace any references to ssfilter.c with references to ssfilter.tab.c tc: use -p flag to set name prefix instead of bison-specific api.prefix directive remove unneeded bison-specific directives use -b instead of -o, replace references to previously generated emp_ematch.yacc.[ch] with references to newly generated emp_ematch.tab.[ch] Signed-off-by: Ethan Sommer <e5ten.arch@gmail.com> --- configure | 2 ++ misc/.gitignore | 2 +- misc/Makefile | 6 +++--- tc/.gitignore | 4 ++-- tc/Makefile | 13 ++++++------- tc/emp_ematch.l | 2 +- tc/emp_ematch.y | 5 ----- 7 files changed, 15 insertions(+), 19 deletions(-)