当我运行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/