本文介绍了如何在gnu makefile中仅删除一个文件的-D?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的CXXFLAGS中有"-Wredundant-decls",但是对于一个文件,我希望将其删除.

I have '-Wredundant-decls' in my CXXFLAGS but for one file, I want it removed.

在我的GNU makefile中,如何构造规则以仅删除CXXFLAGS的那部分.

In my GNU makefile, how can I structure a rule to remove just that part of the CXXFLAGS.

我知道如何仅为该文件添加内容,我将执行以下操作:

I know how to add only for that file, I would do something like this:

$O/just_one_file.o: CXXFLAGS += -Wredundant-decls

因此,理想情况下,我会执行以下操作(无效)将其删除:

So, ideally I'd do something like this (which doesn't work) to remove it:

$O/just_one_file.o: CXXFLAGS -= -Wredundant-decls

但是,也许可以用一些$魔术来构造某种sed或perl脚本以剥离-Wr​​edundant-decls并将CXXFLAGS设置为剥离的值:

However, maybe with some $ magic, I can construct some kind of sed or perl script to strip out the -Wredundant-decls and set CXXFLAGS to the stripped value:

$O/just_one_file.o: CXXFLAGS = $(shell strip magic here for $CXXFLAGS)

推荐答案

不需要shell:

$O/just_one_file.o: CXXFLAGS := $(subst -Wredundant-decls,,$(CXXFLAGS))

$O/just_one_file.o: CXXFLAGS := $(filter-out -Wredundant-decls,$(CXXFLAGS))

这篇关于如何在gnu makefile中仅删除一个文件的-D?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 05:43