从Makefile中的C ++ FLAGS删除标志? [英] Remove a flag from C++FLAGS in Makefile?

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

问题描述

我有一个Makefile,其中包含另一个设置很多默认值的makefile.我无法编辑包含的生成文件,即使在包含的生成文件中设置了C ++ FLAGS的值,我也想更改其值.具体来说,每当debug = 1时,我都希望从C ++ FLAGS中删除优化标志.

I've got a Makefile that includes another makefile that sets a lot of defaults. I can't edit the included makefile and I'd like to change the value of C++FLAGS in my makefile even though it is set in the included makefile. Specifically, I'd like to remove the optimization flag from C++FLAGS whenever debug=1.

我尝试了以下操作:

C++FLAGS=$(filter-out -O3,$(C++FLAGS))

哪个失败并出现以下错误:

Which fails with the following error:

Recursive variable `C++FLAGS' references itself (eventually).  Stop.

似乎可以做这样的事情,有人知道秘密吗?

It seems like doing something like this should be possible, anybody know the secret?

推荐答案

C++FLAGS:=$(filter-out -O3,$(C++FLAGS))

:=赋值立即评估右值,因此应该可以正常工作.另一方面,=具有延迟的扩展语义(即,只要使用左值,C++FLAGS就会扩展,从而导致递归).

The := assignment immediately evaluates the rvalue and this should therefore work. = on the other hand has delayed expansion semantics (i.e. the C++FLAGS will expand whenever the lvalue gets used, which leads to recursion).

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

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