【发布时间】:2017-06-08 00:25:43
【问题描述】:
我想在运行 make 时将标志附加到编译器标志,而不用任何方式更改 Makefile,例如
make CXX_FLAGS+='-DDEBUG'
上面将“+=”视为“=”,所以它不是正确的符号。
【问题讨论】:
标签: c++ makefile compilation gnu-make compiler-flags
我想在运行 make 时将标志附加到编译器标志,而不用任何方式更改 Makefile,例如
make CXX_FLAGS+='-DDEBUG'
上面将“+=”视为“=”,所以它不是正确的符号。
【问题讨论】:
标签: c++ makefile compilation gnu-make compiler-flags
您只需在 Makefile 中将变量修改为 override 一次。然后你就可以做你想做的事了。
这是一个例子,
生成文件:
override CFLAGS+=-g
app: main.c
gcc $(CFLAGS) -o app main.c
运行make:
$ make
gcc -g -o app main.c
在命令中将“-Wall”附加到 $CFLAGS:
$ make CFLAGS=-Wall
gcc -Wall -g -o app main.c
在这里工作正常。这是manual,您可以参考。
【讨论】:
override CFLAGS := -g $(CFLAGS)。