All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ethan Sommer <e5ten.arch@gmail.com>
To: netdev@vger.kernel.org
Cc: Ethan Sommer <e5ten.arch@gmail.com>
Subject: [PATCH iproute2] make yacc usage POSIX compatible
Date: Wed,  8 Jan 2020 14:57:05 -0500	[thread overview]
Message-ID: <20200108195705.15348-1-e5ten.arch@gmail.com> (raw)

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(-)

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;
-- 
2.24.1


             reply	other threads:[~2020-01-08 19:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-08 19:57 Ethan Sommer [this message]
2020-01-20 17:45 ` [PATCH iproute2] make yacc usage POSIX compatible Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200108195705.15348-1-e5ten.arch@gmail.com \
    --to=e5ten.arch@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.