]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
make yacc usage POSIX compatible
authorEthan Sommer <e5ten.arch@gmail.com>
Wed, 8 Jan 2020 19:57:05 +0000 (14:57 -0500)
committerStephen Hemminger <stephen@networkplumber.org>
Mon, 20 Jan 2020 17:43:22 +0000 (09:43 -0800)
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>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
configure
misc/.gitignore
misc/Makefile
tc/.gitignore
tc/Makefile
tc/emp_ematch.l
tc/emp_ematch.y

index 45fcffb69bb532a876cd9462090f97cb42ff54eb..f415bf4975e710bd1386b68f46a93adc2ff273f2 100755 (executable)
--- 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()
index f73f7f211e6c88b95e780c4ec5473a160e74e264..d7df0b025c8db006cac96caadbdd247ca28a6595 100644 (file)
@@ -1,7 +1,7 @@
 arpd
 ifstat
 ss
-ssfilter.c
+ssfilter.tab.c
 nstat
 lnstat
 rtacct
index 6a849af4be221a3657994dd84c3916e028134e48..1debfb15986f5ec3b704297ffaeeeb24cb219bd2 100644 (file)
@@ -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 $@
index e8e86c97a0fbcbf5f29eeb0240294b751e0bf03c..0dbe91956a38fa2c7bbc3dad16ff29b605c4b59a 100644 (file)
@@ -1,5 +1,5 @@
-*.yacc.c
+*.tab.c
 *.lex.c
 *.output
-*.yacc.h
+*.tab.h
 tc
index 14171a28cba5d2bfeb5b1af4b713279c668859d2..a378c403a6a576a18edec9cd9f4a73ac9f92c904 100644 (file)
@@ -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)
 
index d7a99304ba14c7a7ee59795f4344b960a39780ae..2f4926d43d5b2a9eb55253ac2eb26d2e4c86c1aa 100644 (file)
@@ -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;
index a02e831aa7ea6f3e2af76cef685956b3498e744c..4da3daed095c54a7a98a9c2d540f601c265eba6e 100644 (file)
@@ -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;