Makefile 项目 - 通过“-j”参数使用多个作业时防止构建失败

Makefile project - Preventing build failure when using multiple jobs via "-j" argument

我有许多简单的 C++ Makefile 项目,它们使用我手动编写的 GNU Make 风格的 makefile,而不是使用 Automake 或 CMake。其中最复杂的机制是使用 pkginfo 获取编译时标志并包含少数第三方库的路径。

我可以通过 运行ning make 大大加快我在当前硬件(Intel i7 四核)上的构建速度,所以,假设机器上有 4 个内核:

make -j5 -l4

但是,一些项目在 运行 串行时构建良好(即:j1),当我允许多个作业时失败。这些失败的项目本质上是一组从 "master" makefile 中按顺序构建的项目,并且某些依赖项是乱序构建的。

假设我有一个这样的项目列表:

library1 (all other projects depend on this)
library2 (all other projects depend on this)
library3 (some other projects depend on this)
example1
...
example20

是否有 simple/de-facto "standard" 方法来放置 marker/rule 以便主 makefile 首先连续构建库,然后允许剩余的示例项目构建在任何哪个顺序?

谢谢。

可能没看懂,为什么不在master makefile中人为声明库2依赖库1,库3依赖1和2等等,那应该只有可能吧供他们连续构建。

我不知道是否有专门的 makefile 语言或选项,很想学习。