添加编译器选项而不编辑Makefile文件 [英] Add compiler option without editing Makefile

查看:84
本文介绍了添加编译器选项而不编辑Makefile文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该通过编译一个Makefile用C语言编写的程序。我应该插入的Makefile,一些选项,比如: -O2,-march = i686的。我怎样才能插入没有写Makefile中的该选项成吗?

i should compile a program written in C through a Makefile. I should insert into the Makefile, some option, for instance: -O2, -march=i686. How can I insert this option in the Makefile without write into it?

推荐答案

您应该使用像 CFLAGS 宏。看看GNU GCC 文档

You should use a macro like CFLAGS. Check out GNU GCC documentation.

这样的事情应该工作:

CFLAGS := $(CFLAGS) -O2 -march=i686

或者,如果你preFER不修改Makefile使用:

Or, if you prefer not to modify the makefile use:

make CFLAGS='-O2 -march=i686' 

其他选项会虽然自动拾取。请参见覆盖变量的。

这篇关于添加编译器选项而不编辑Makefile文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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