制造:覆盖标志 [英] Make: Override a flag

查看:91
本文介绍了制造:覆盖标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对>覆盖-Werror标志的快速方法的回答有些困惑.

所以我在这里问我的具体问题.

So I ask my specific question here.

我有多个Makefile文件一起工作,并且在(-Werror -Wall ..和许多其他文件)的过程中设置了CFLAGS

I have multiple Makefiles working together and CFLAGS has been set along the way to (-Werror -Wall .. and many others)

但在其中一个Makefile文件中,我希望不要将错误视为警告,因此我想删除-Werror标志.

But in one of the Makefiles, I wish that the errors not be treated as warnings and so I would like to remove -Werror flag.

实现此目标的最佳方法是什么,以便仅对此Makefile删除-Werror标志,而对其他文件进行正常执行?

What would be the best way to achieve this, so that only for this Makefile, -Werror flag is removed and for the others normal execution takes place?

谢谢, 阳光明媚

推荐答案

更简单的方法

您似乎可以调用

Simpler way

It looks like you can invoke

gcc -c ... -Werror ... -Wno-error ...

无需GCC投诉(GCC 4.7.1).因此,可以将-Wno-error添加到需要的一个makefile中其他位置设置的CFLAGS上.如果您使用的是GNU make,则可以在一个makefile中添加:

without having GCC complain (GCC 4.7.1). So, you can add -Wno-error to the CFLAGS set up elsewhere in the one makefile where you need it. If you're using GNU make, in the one makefile, you can add:

CFLAGS += -Wno-error

可能仅针对需要它的单个目标.

possibly for just the single target that needs it.

否则,您需要一个用于从组件构建CFLAGS的系统.我用于测试SO问题答案的makefile中包含的内容是:

Otherwise, you need a system for building CFLAGS from components. What I have in the makefile I use for testing answers to questions on SO is:

WFLAG1 = -Wall 
WFLAG2 = -Wextra
WFLAG3 = -Wmissing-prototypes 
WFLAG4 = -Wstrict-prototypes 
WFLAG5 = -Wold-style-definition
WFLAG6 =
WFLAGS = ${WFLAG1} ${WFLAG2} ${WFLAG3} ${WFLAG4} ${WFLAG5} ${WFLAG6} 
SFLAGS = -std=c99
GFLAGS = -g
OFLAGS = -O3
UFLAGS =
IFLAG1 = -I${HOME}/inc
IFLAGS = # ${IFLAG1}

CFLAGS   = ${OFLAGS} ${GFLAGS} ${IFLAGS} ${SFLAGS} ${WFLAGS} ${UFLAGS}

要点是每个标志都是独立可调的;我可以通过将${WFLAG1}设置为${WFLAG6}或通过在命令行上设置${WFLAGS}批发,或(实际上)通过设置${CFLAGS}来控制警告标志.但是,由于每个参数都可以单独调整,并且可以相对轻松地调整警告(主要麻烦是确定哪个WFLAGn需要破坏).

The main point is that each flag is independently adjustable; I can control the warning flags by setting any of ${WFLAG1} to ${WFLAG6}, or by setting ${WFLAGS} wholesale on the command line, or (indeed) by setting ${CFLAGS}. But because each is individually adjustable, and can tune the warnings relatively easily (the main hassle being determining which WFLAGn needs clobbering).

UFLAGS是用户标志",仅在命令行上设置;我可以通过设置将更多标志添加到命令行中.

The UFLAGS is 'user flags' and is only set on the command line; I can add more flags to my command line by setting it.

这种方式比较困难",因为它要求您修改设置CFLAGS的makefile系统的中央部分.您的同事对它一见钟情的可能性也较小.

This way is 'harder' because it requires you to modify the central part of your makefile system where you set CFLAGS. It is also less likely to be understood by your colleagues at first sight.

这篇关于制造:覆盖标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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