从MAKECMDGOALS中删除目标? [英] Remove target from MAKECMDGOALS?

查看:71
本文介绍了从MAKECMDGOALS中删除目标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的makefile文件中包含以下内容.它是GNUmakefile,因此支持其他品牌功能:

I have the following in my makefile. Its a GNUmakefile, so the additional make features are supported:

# Undefined Behavior Sanitzier (Clang and G++)
ifeq ($(findstring ubsan,$(MAKECMDGOALS)),ubsan)
CXXFLAGS += -fsanitize=undefined
MAKECMDGOALS := $(subst ubsan,,$(MAKECMDGOALS))
endif # UBsan    

运行它会导致:

make ubsan
make: *** No rule to make target 'ubsan'. Stop.

我知道代码路径正在执行中(通过在块中引入错误).如何从命令目标中删除目标?

I know the code path is being executed (by introducing an error in the block). How do I remove the target from the command goals?

推荐答案

据我所知,您不能在这里做您想做的事.

You cannot do what you want here as far as I know.

您可以修改变量值,如果您自己检查值,则会看到更改,但是修改MAKECMDGOALS的值不会以任何方式影响make.

You can modify the variable value and you will see the changes if you check the value yourself but modifying the value of MAKECMDGOALS will not affect make in any way.

如果您查看附录A快速参考在GNU Make手册中,您会看到它说:

If you look at Appendix A Quick Reference in the GNU Make Manual you will see that it says:

MAKECMDGOALS

MAKECMDGOALS

在命令行上指定要执行的目标.设置此变量对make的操作没有影响.

The targets given to make on the command line. Setting this variable has no effect on the operation of make.

请参见指定目标的参数.

我认为,最接近您要在此处执行的操作的方法是手动重新执行Makefile(或任何其他方式)上的make.

The closest you could get to what you are trying to do here, I think, would be to re-execute make on the Makefile (or whatever) manually.

话虽这么说,这种事情可能最好用变量而不是目标来完成.

That being said this sort of thing is probably better done as variables instead of targets.

$ cat Makefile
$(info $(origin UBSAN))
$ make
undefined
$ make UBSAN=
command line

类似这样的东西.

# Undefined Behavior Sanitzier (Clang and G++)
ifneq (undefined,$(origin UBSAN))
CXXFLAGS += -fsanitize=undefined
endif # UBsan

这篇关于从MAKECMDGOALS中删除目标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆