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?

有帮助吗?

解决方案 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.

其他提示

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

?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top