V0.9: Update lex/yacc builds to be consistent and to support parallel builds

Not all the lex/yacc (flex/bison) targets were using a consistent syntax.
This patch fixes that and explicitly serializes the *.c/*.cc and *.h build.
Not doing this was causing problem when using make -j. The issue appears to
be that if two targets are specified for a rule (e.g. file.cc file.h: file.y)
make does not realize they are both built by the same call so the rule is
executed twice. Once for the .cc target and once for the .h target. This is
not a problem for a serial build. To work around this only use the .c/.cc
file in the main target and then make the .h file depend on the .c/.cc file
as a sub-target.
This commit is contained in:
Cary R 2012-01-04 18:39:27 -08:00
parent e1789e7fb9
commit b47fad7d19
5 changed files with 22 additions and 17 deletions

View File

@ -118,8 +118,8 @@ endif
clean:
$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@ && ) true
rm -f *.o parse.cc parse.h lexor.cc
rm -f ivl.exp iverilog-vpi.man iverilog-vpi.pdf iverilog-vpi.ps parse.output
rm -f syn-rules.output dosify.exe ivl@EXEEXT@ check.vvp
rm -f ivl.exp iverilog-vpi.man iverilog-vpi.pdf iverilog-vpi.ps
rm -f parse.output syn-rules.output dosify.exe ivl@EXEEXT@ check.vvp
rm -f lexor_keyword.cc libivl.a libvpi.a iverilog-vpi syn-rules.cc
rm -rf dep
rm -f version.exe
@ -223,15 +223,17 @@ lexor.o: lexor.cc parse.h
parse.o: parse.cc
parse.cc parse.h: $(srcdir)/parse.y
$(YACC) --verbose -t -p VL -d -o parse.cc $(srcdir)/parse.y
# 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 parse.h 2>/dev/null || mv parse.hh parse.h
syn-rules.cc: $(srcdir)/syn-rules.y
$(YACC) --verbose -p syn_ -o syn-rules.cc $(srcdir)/syn-rules.y
$(YACC) --verbose -t -p syn_ -o $@ $<
lexor.cc: $(srcdir)/lexor.lex
$(LEX) -PVL -s -olexor.cc $(srcdir)/lexor.lex
$(LEX) -PVL -s -t $< > $@
lexor_keyword.o: lexor_keyword.cc parse.h

View File

@ -68,10 +68,12 @@ iverilog@EXEEXT@: $O
$(CC) $(LDFLAGS) $O -o iverilog@EXEEXT@ @EXTRALIBS@
cflexor.c: cflexor.lex
$(LEX) -s -Pcf -ocflexor.c $(srcdir)/cflexor.lex
$(LEX) -Pcf -s -t $< > $@
cfparse.h cfparse.c: cfparse.y
$(YACC) --verbose -t -d -o cfparse.c --name-prefix=cf $(srcdir)/cfparse.y
# Build this in two steps to avoid parallel build issues (see pr3462585)
cfparse.c: cfparse.y
$(YACC) --verbose -t -p cf -d -o $@ $<
cfparse.h: cfparse.c
dep:
mkdir dep

View File

@ -61,7 +61,7 @@ ivlpp@EXEEXT@: $O
$(CC) $(LDFLAGS) $O -o ivlpp@EXEEXT@ @EXTRALIBS@
lexor.c: lexor.lex
$(LEX) -olexor.c $(srcdir)/lexor.lex
$(LEX) -s -t $< > $@
install: all installdirs $(libdir)/ivl$(suffix)/ivlpp@EXEEXT@

View File

@ -87,15 +87,17 @@ system.vpi: $O ../vvp/libvpi.a
$(CC) @shared@ -o $@ $O -L../vvp $(LDFLAGS) -lvpi $(SYSTEM_VPI_LDFLAGS)
sys_readmem_lex.c: sys_readmem_lex.lex
$(LEX) -t -Preadmem $(srcdir)/sys_readmem_lex.lex > sys_readmem_lex.c
$(LEX) -Preadmem -s -t $< > $@
sdf_lexor.o: sdf_lexor.c sdf_parse.h
sdf_lexor.c: sdf_lexor.lex
$(LEX) -t -Psdf $(srcdir)/sdf_lexor.lex > sdf_lexor.c
$(LEX) -Psdf -s -t $< > $@
sdf_parse.c sdf_parse.h: $(srcdir)/sdf_parse.y
$(YACC) --verbose -d -p sdf -o sdf_parse.c $(srcdir)/sdf_parse.y
# 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
v2005_math.vpi: $M ../vvp/libvpi.a
$(CC) @shared@ -o $@ $M -L../vvp $(LDFLAGS) -lvpi $(VA_MATH_VPI_LDFLAGS)

View File

@ -140,10 +140,9 @@ parse.o: parse.cc
tables.o: tables.cc
parse.cc: $(srcdir)/parse.y
$(YACC) --verbose -t -d -o parse.cc $(srcdir)/parse.y
$(YACC) --verbose -t -d -o $@ $<
parse.h: parse.cc
mv parse.cc.h parse.h 2>/dev/null || mv parse.hh parse.h
mv parse.cc.h $@ 2>/dev/null || mv parse.hh $@
lexor.cc: $(srcdir)/lexor.lex
$(LEX) -s -olexor.cc $(srcdir)/lexor.lex