makefile - 如何在运行 make 时添加额外的标志?

标签 makefile

当我运行make时,如何添加一些额外的标志?

看起来像:

make CXXFLAGS="-pg" # will substitute original flags

和:

make CXXFLAGS+="-pg" # does not work either

最佳答案

你是对的,在基本的Makefile中,当你使用环境命令行变量时,它们将替换原始变量。

要仅添加一些额外的标志,您可以使用 override directive 。在您的 Makefile 中:

CFLAGS ?= -Wall -Wextra -Werror

override CFLAGS += -I include/

这样,您就可以使用其他标志运行 make:

make CFLAGS=-MyOtherFlag

你将拥有:

CFLAGS = -MyOtherFlag -I include/

关于makefile - 如何在运行 make 时添加额外的标志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43407374/

相关文章:

gcc - 编译 OpenSSL 时 undefined reference

makefile - EXTRA_CFLAGS的目的是什么?

linux - CUnit - 尝试使用 makefile 或 gcc 构建时出错

c++ - 包含 NSS 头文件的问题

c++ - 编译器标志更改时自动重新编译

c++ - 如何将文件与 C++ 应用程序的二进制文件打包在一起?

postgresql - Makefile:运行命令“go test./…”后终止

c - 如何在 makefile 中使用 POSIX 消息队列名称

linux - 如何将我自己的软件添加到 Buildroot Linux 软件包中?

file - WinAVR 和 native Windows 控制台应用程序