From: Ethan Sommer Date: Wed, 8 Jan 2020 19:57:05 +0000 (-0500) Subject: make yacc usage POSIX compatible X-Git-Url: https://git.proxmox.com/?p=mirror_iproute2.git;a=commitdiff_plain;h=5f78bc3e1da9a371582f2609e9a674ee294d7bcf make yacc usage POSIX compatible 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 Signed-off-by: Stephen Hemminger --- diff --git a/configure b/configure index 45fcffb6..f415bf49 100755 --- a/configure +++ b/configure @@ -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() diff --git a/misc/.gitignore b/misc/.gitignore index f73f7f21..d7df0b02 100644 --- a/misc/.gitignore +++ b/misc/.gitignore @@ -1,7 +1,7 @@ arpd ifstat ss -ssfilter.c +ssfilter.tab.c nstat lnstat rtacct diff --git a/misc/Makefile b/misc/Makefile index 6a849af4..1debfb15 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -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 $@ diff --git a/tc/.gitignore b/tc/.gitignore index e8e86c97..0dbe9195 100644 --- a/tc/.gitignore +++ b/tc/.gitignore @@ -1,5 +1,5 @@ -*.yacc.c +*.tab.c *.lex.c *.output -*.yacc.h +*.tab.h tc diff --git a/tc/Makefile b/tc/Makefile index 14171a28..a378c403 100644 --- a/tc/Makefile +++ b/tc/Makefile @@ -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) diff --git a/tc/emp_ematch.l b/tc/emp_ematch.l index d7a99304..2f4926d4 100644 --- a/tc/emp_ematch.l +++ b/tc/emp_ematch.l @@ -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; diff --git a/tc/emp_ematch.y b/tc/emp_ematch.y index a02e831a..4da3daed 100644 --- a/tc/emp_ematch.y +++ b/tc/emp_ematch.y @@ -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;