Makefile:存储 'make' 之后的参数(即第二个命令行参数)不起作用

Makefile: Storing the Argument that comes after 'make' (i.e the 2nd command line argument) isn't Working

我正在尝试将命令行中传递的第二个参数(即 make 之后的参数)存储在一个名为 NAME 的变量中,然后用它来做一些事情。如果没有第二个参数,则 NAME = a

为什么不起作用?

这是我的 Makefile 的片段:

NAME := $(shell )

ifeq ($(strip $(NAME)),)
    $(NAME) = a
endif


# ... and do other things with NAME

它给我这个错误:

*** empty variable name. Stop

您不能在 make 中使用 </code>(和类似的)。</p> <p><code>make的参数是目标或选项,不能用</code>访问。</p> <p>命令 <code>make foo 指示 make 创建 foo 目标。如果你想传递参数,你可以使用 make param=foo 并且可以在 Makefile 中访问 ${param} 变量(值为 foo)。