Makefile 的 prequisite 執行順序 single multi thread

Makefile 代碼如下:
B 需要 A 的 產出,

all: A B

A B 是 target,

case 1:
single-thread
make -j1
則執行的順序為 A -> B
A 先產出,B 再消化。

case 2:
multi-thread
make -j16
則執行的順序為平行 A->
B->
A 尚未產出 B 所需要的東西,
B 就向去拿,會發生 error,

解法:
Makefile

all: A

A:
    $(MAKE) B

https://stackoverflow.com/questions/8496135/parallel-makefile-requires-dependency-ordering

原文地址:https://www.cnblogs.com/youchihwang/p/10599139.html