Makefile 先决条件中的变量分配

Variable assignment in Makefile Prerequisites

我正在查看 Linux 内核代码以尝试了解图像的构建方式。 在 scripts/makefile.build Makefile 中,有些行如下所示:

$(real-objs-m)    :   part-of-module :=y
$(real-objs-m)    :   quiet_modtag := [M]
$(multi-objs-m)   : modname=$(modname-multi)

它们看起来不像目标和先决条件行,也不像静态模式规则。 我已经被谷歌搜索了很多,但似乎没有答案。 这些语法是什么意思?

这是特定于目标的变量值

来自文档https://www.gnu.org/software/make/manual/html_node/Target_002dspecific.html

This feature allows you to define different values for the same variable, based on the target that make is currently building. As with automatic variables, these values are only available within the context of a target’s recipe (and in other target-specific assignments).

There is one more special feature of target-specific variables: when you define a target-specific variable that variable value is also in effect for all prerequisites of this target, and all their prerequisites, etc. (unless those prerequisites override that variable with their own target-specific variable value).