Frage

I have a makefile with this line:

parser_yacc.h parser_yacc.c :   parser_yacc.y
    bison -y -d parser_yacc.y && mv y.tab.h parser_yacc.h && \
            mv y.tab.c parser_yacc.c

now I have several other lines that depend on parser_yacc.h. When I perform make everything runs fine. However when I run make -j4 I always get this warning:

mv: cannot stat `y.tab.c': No such file or directory

As I understand make tries to build both parser_yacc.c and another file that needs parser_yacc.hat the same time; thus spawning twice the commands

bison -y -d parser_yacc.y && mv y.tab.h parser_yacc.h && \
    mv y.tab.c parser_yacc.c

causing the second to crash... How could I circumvent this problem?

War es hilfreich?

Lösung

You might rewrite the rule for either of the targets alone (e.g. the .c), and add another rule for completing the other one.

parser_yacc.c :   parser_yacc.y
    bison -y -d parser_yacc.y && mv y.tab.c parser_yacc.c

parser_yacc.h : parser_yacc.c
    mv y.tab.h parser_yacc.h
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top