If you want to really test what is going on, you have to provide commands that actually create your target files. #bison -d calc.y
is a comment, so it is run first for "creating" y.tab.h
because of the dependency of lex.yy.o
and since no y.tab.c
was created from that, it is run again to create y.tab.c
because of the dependency of y.tab.o
. A more realistic simulation could use touch
to create the files:
all: y.tab.o lex.yy.o
lex.yy.c: calc.l
#flex calc.l
@touch $@
y.tab.c y.tab.h: calc.y
#bison -d calc.y
@touch y.tab.c y.tab.h
lex.yy.o: lex.yy.c y.tab.h
#gcc -c lex.yy.c
@touch $@
y.tab.o: y.tab.c
#gcc -c y.tab.c
@touch $@
create:
touch calc.l calc.y
clean:
rm y.tab.o lex.yy.o lex.yy.c y.tab.c y.tab.h lex.yy.o y.tab.o calc.l calc.y
With this setting, make
"launches" bison
only once, as expected.
#bison -d calc.y
#gcc -c y.tab.c
#flex calc.l
#gcc -c lex.yy.c
Note that this might not solve your issue with make -j
, as in this case the creation of both y.tab.h
and y.tab.c
may be scheduled independently. A solution is to make only y.tab.c
depend on calc.y
, y.tab.h
depending on y.tab.c
with a recipe that does nothing, as in:
y.tab.c: calc.y
#bison -d calc.y
@touch y.tab.c y.tab.h
y.tab.h: y.tab.c
: