Pergunta

As the title suggests, how can I prevent race conditions in make?

My specific use case is where I want clean and then build the all target:

make -j 4 clean all

Should I give up and settle for make clean && make -j 4 all?

Foi útil?

Solução 2

I think the only way to make this work is to put this in the Makefile:

all : clean

which you don't want (obviously). My next idea would be:

clean_all: clean
    $(MAKE) all

That would allow you to write make -j clean_all but I'm not happy with it, either.

Outras dicas

You cannot really execute in parallel a recipe that builds a target and another one that destroys it.

What a use case do you have in mind that would not be satisfied with:

make clean && make -j4

?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top