如何从makefile中的变量中去除参数 [英] How to strip parameters from a variable in a makefile
本文介绍了如何从makefile中的变量中去除参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
copt = -mcpu = cortex-m3 -mthumb -g -c
我想删除-mthumb并将其替换为其他选项。
是否有任何方法可以剥离选项并添加其他选项。
我知道如何添加:示例 - copt + = -O3但不知道如何删除已有的选项。
谢谢!
解决方案
$(subst from,to,text)
对文本文本执行文本替换:from的每次出现都被替换为。
您的情况:
newopts = $(subst -mthumb,new_opt,$(copt))
Below is a variable I am using in a makefile.
copt = -mcpu=cortex-m3 -mthumb -g -c
I want to remove -mthumb and replace it with some other option. Is there any way I can strip the option and add few other options. I know how to add : Example - copt += -O3 but don't know how to remove the already existing options.
Thanks!
解决方案
$(subst from,to,text)
Performs a textual replacement on the text text: each occurrence of from is replaced by to. The result is substituted for the function call.
In your case:
newopts = $(subst -mthumb, new_opt, $(copt))
这篇关于如何从makefile中的变量中去除参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文