在调用目标之前打印变量的内容
Printing content of Variables before a target is called
我目前有一个看起来像这样的 makefile
ifndef __makefile_env_setup_included_1__
export __makefile_env_setup_included_1__ := true
export ENV_ROOT := $(abspath $(lastword $(MAKEFILE_LIST))/../..)
export ENV_TOOLS := $(ENV_ROOT)/tools
endif # __makefile_env_setup_included_1__
include $(ENV_TOOLS)/Makefile.utils.function
include $(ENV_TOOLS)/Makefile.utils.variable
include $(ENV_TOOLS)/Makefile.utils.action
include $(ENV_TOOLS)/Makefile.utils.rule
我想回显正在使用的变量的值,例如
$ENV_ROOT
根据我目前所读的内容,我只能在已处理目标的命令部分插入命令。我的问题是有没有办法让我在到达包含文件之前回显某些变量?
您可以使用 Functions That Control Make 来执行此操作。具体来说 $(info)
和 $(warning)
.
$(warning text…)
This function works similarly to the error function, above, except that make doesn’t exit. Instead, text is expanded and the resulting message is displayed, but processing of the makefile continues.
The result of the expansion of this function is the empty string.
$(info text…)
This function does nothing more than print its (expanded) argument(s) to standard output. No makefile name or line number is added. The result of the expansion of this function is the empty string.
我目前有一个看起来像这样的 makefile
ifndef __makefile_env_setup_included_1__
export __makefile_env_setup_included_1__ := true
export ENV_ROOT := $(abspath $(lastword $(MAKEFILE_LIST))/../..)
export ENV_TOOLS := $(ENV_ROOT)/tools
endif # __makefile_env_setup_included_1__
include $(ENV_TOOLS)/Makefile.utils.function
include $(ENV_TOOLS)/Makefile.utils.variable
include $(ENV_TOOLS)/Makefile.utils.action
include $(ENV_TOOLS)/Makefile.utils.rule
我想回显正在使用的变量的值,例如
$ENV_ROOT
根据我目前所读的内容,我只能在已处理目标的命令部分插入命令。我的问题是有没有办法让我在到达包含文件之前回显某些变量?
您可以使用 Functions That Control Make 来执行此操作。具体来说 $(info)
和 $(warning)
.
$(warning text…)
This function works similarly to the error function, above, except that make doesn’t exit. Instead, text is expanded and the resulting message is displayed, but processing of the makefile continues.
The result of the expansion of this function is the empty string.
$(info text…)
This function does nothing more than print its (expanded) argument(s) to standard output. No makefile name or line number is added. The result of the expansion of this function is the empty string.