From b988543096183650979e2aae9702de3750fee798 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Thu, 30 Jul 2020 16:27:01 +0100 Subject: [PATCH] Use GNU make pattern rules to handle multiple file output from bison. With a pattern rule, the recipe will only be executed once, even when the rule has multiple targets. Using this to handle the output from bison is included as an example in the GNU make manual. This fixes the makefiles so that bison-generated header files will be regenerated if they are deleted. --- Makefile.in | 9 +++------ driver/Makefile.in | 7 +++---- tgt-pcb/Makefile.in | 7 ++----- vhdlpp/Makefile.in | 9 +++------ vpi/Makefile.in | 14 ++++++-------- vvp/Makefile.in | 9 +++------ 6 files changed, 20 insertions(+), 35 deletions(-) diff --git a/Makefile.in b/Makefile.in index fbbc84847..0f336540e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -252,12 +252,9 @@ lexor.o: lexor.cc parse.h parse.o: parse.cc -# Build this in two steps to avoid parallel build issues (see pr3462585) -parse.cc: $(srcdir)/parse.y - $(YACC) --verbose -t -p VL -d -o $@ $< -parse.h: parse.cc - mv parse.cc.h $@ 2>/dev/null || mv parse.hh $@ - touch $@ +# Use pattern rules to avoid parallel build issues (see pr3462585) +parse%cc parse%h: $(srcdir)/parse%y + $(YACC) --verbose -t -p VL --defines=parse.h -o parse.cc $< syn-rules.cc: $(srcdir)/syn-rules.y $(YACC) --verbose -t -p syn_ -o $@ $< diff --git a/driver/Makefile.in b/driver/Makefile.in index b2ad7150c..7e7ad6236 100644 --- a/driver/Makefile.in +++ b/driver/Makefile.in @@ -85,10 +85,9 @@ iverilog@EXEEXT@: $O cflexor.c: $(srcdir)/cflexor.lex $(LEX) -s -t $< > $@ -# Build this in two steps to avoid parallel build issues (see pr3462585) -cfparse.c: $(srcdir)/cfparse.y - $(YACC) --verbose -t -p cf -d -o $@ $< -cfparse.h: cfparse.c +# Use pattern rules to avoid parallel build issues (see pr3462585) +cfparse%c cfparse%h: $(srcdir)/cfparse%y + $(YACC) --verbose -t -p cf -d -o cfparse.c $< %.o: %.c $(CC) $(CPPFLAGS) $(CFLAGS) @DEPENDENCY_FLAG@ -c $< -o $*.o diff --git a/tgt-pcb/Makefile.in b/tgt-pcb/Makefile.in index 228ede553..dd63370ed 100644 --- a/tgt-pcb/Makefile.in +++ b/tgt-pcb/Makefile.in @@ -87,11 +87,8 @@ fp_lex.o: fp_lex.cc fp.h fp_lex.cc: $(srcdir)/fp.lex $(LEX) -s -ofp_lex.cc $(srcdir)/fp.lex -fp.cc: $(srcdir)/fp.y - $(YACC) --verbose -t -p fp -d -o $@ $< -fp.h: fp.cc - mv fp.cc.h $@ 2>/dev/null || mv fp.hh $@ - touch $@ +fp%cc fp%h: $(srcdir)/fp%y + $(YACC) --verbose -t -p fp --defines=fp.h -o fp.cc $< ifeq (@WIN32@,yes) TGTLDFLAGS=-L.. -livl diff --git a/vhdlpp/Makefile.in b/vhdlpp/Makefile.in index 9bafaf100..301b07142 100644 --- a/vhdlpp/Makefile.in +++ b/vhdlpp/Makefile.in @@ -115,12 +115,9 @@ parse.o: parse.cc lexor.cc: $(srcdir)/lexor.lex $(LEX) -s -olexor.cc $(srcdir)/lexor.lex -# Build this in two steps to avoid parallel build issues (see pr3462585) -parse.cc: $(srcdir)/parse.y - $(YACC) --verbose -t -d -o $@ $< -parse.h: parse.cc - mv parse.cc.h $@ 2>/dev/null || mv parse.hh $@ - touch $@ +# Use pattern rules to avoid parallel build issues (see pr3462585) +parse%cc parse%h: $(srcdir)/parse%y + $(YACC) --verbose -t --defines=parse.h -o parse.cc $< lexor_keyword.o: lexor_keyword.cc parse.h diff --git a/vpi/Makefile.in b/vpi/Makefile.in index 1f8fbd0aa..60e49775a 100644 --- a/vpi/Makefile.in +++ b/vpi/Makefile.in @@ -136,20 +136,18 @@ sdf_lexor.o: sdf_lexor.c sdf_parse.h sdf_lexor.c: $(srcdir)/sdf_lexor.lex $(LEX) -t $< > $@ -# Build this in two steps to avoid parallel build issues (see pr3462585) -sdf_parse.c: $(srcdir)/sdf_parse.y - $(YACC) --verbose -t -p sdf -d -o $@ $< -sdf_parse.h: sdf_parse.c +# Use pattern rules to avoid parallel build issues (see pr3462585) +sdf_parse%c sdf_parse%h: $(srcdir)/sdf_parse%y + $(YACC) --verbose -t -p sdf -d -o sdf_parse.c $< table_mod_lexor.o: table_mod_lexor.c table_mod_parse.h table_mod_lexor.c: $(srcdir)/table_mod_lexor.lex $(LEX) -t $< > $@ -# Build this in two steps to avoid parallel build issues (see pr3462585) -table_mod_parse.c: $(srcdir)/table_mod_parse.y - $(YACC) --verbose -t -p tblmod -d -o $@ $< -table_mod_parse.h: table_mod_parse.c +# Use pattern rules to avoid parallel build issues (see pr3462585) +table_mod_parse%c table_mod_parse%h: $(srcdir)/table_mod_parse%y + $(YACC) --verbose -t -p tblmod -d -o table_mod_parse.c $< v2005_math.vpi: $M ../vvp/libvpi.a $(CC) @shared@ -o $@ $M -L../vvp $(LDFLAGS) -lvpi $(VA_MATH_VPI_LDFLAGS) diff --git a/vvp/Makefile.in b/vvp/Makefile.in index bbbece898..8e30c313e 100644 --- a/vvp/Makefile.in +++ b/vvp/Makefile.in @@ -163,12 +163,9 @@ parse.o: parse.cc tables.o: tables.cc -# Build this in two steps to avoid parallel build issues (see pr3462585) -parse.cc: $(srcdir)/parse.y - $(YACC) --verbose -t -d -o $@ $< -parse.h: parse.cc - mv parse.cc.h $@ 2>/dev/null || mv parse.hh $@ - touch $@ +# Use pattern rules to avoid parallel build issues (see pr3462585) +parse%cc parse%h: $(srcdir)/parse%y + $(YACC) --verbose -t --defines=parse.h -o parse.cc $< lexor.cc: $(srcdir)/lexor.lex $(LEX) -s -olexor.cc $(srcdir)/lexor.lex