Makefile 使用ifdef条件设置Make标志
我有一个简单的gnu生成文件:Makefile 使用ifdef条件设置Make标志,makefile,gnu-make,Makefile,Gnu Make,我有一个简单的gnu生成文件: ifdef $(DEBUGGING) CFLAGS = -g -O0 -Wall else CFLAGS = -O3 -Wall endif test: @echo DEBUGGING is $(DEBUGGING) @echo $(CFLAGS) 当我这样调用它时,我看到调试设置为true,但ifdef$debuging似乎为false: $ DEBUGGING=true make test DEBUGGING is true -O3
ifdef $(DEBUGGING)
CFLAGS = -g -O0 -Wall
else
CFLAGS = -O3 -Wall
endif
test:
@echo DEBUGGING is $(DEBUGGING)
@echo $(CFLAGS)
当我这样调用它时,我看到调试设置为true,但ifdef$debuging
似乎为false:
$ DEBUGGING=true make test
DEBUGGING is true
-O3 -Wall
我希望CFLAGS设置为“-g-O0-Wall”。我遗漏了什么?在ifdef
中使用变量的名称:
ifdef DEBUGGING
首先展开给定给ifdef
的值,并将结果视为变量名。在ifdef
中使用变量名:
ifdef DEBUGGING
首先展开给定给ifdef
的值,并将结果视为变量名