Reputation: 3046
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
?
Upvotes: 1
Views: 559
Reputation: 136286
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
?
Upvotes: 2
Reputation: 328614
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.
Upvotes: 1