如何在 Makefile 中抑制所有默认变量和默认隐式规则?

How to suppress all default variables and default implicit rules in Makefile?

我想从一个干净的 Makefile 开始,所以每个隐式规则都应该明确声明,不要有任何意外。

我还想抑制所有默认变量和后缀规则。

谢谢

您可以拨打make -rR

或添加到 Makefile:


MAKEFLAGS += -rR

注意: 似乎在旧版本的 Gnu-Make(4.0 版之前)上,您还应该添加:

.SUFFIXES :

GNU-Make Maintainer:

"That's why in the makefile you need BOTH the .SUFFIXES: special target AND the MAKEFLAGS+=-r. Having the .SUFFIXES: special target set to empty ensures that no suffix rules are searched but it does NOT remove all the suffix rules from the database. So they still show up with -p, but they don't have any impact on the algorithms make uses to build targets".