我有一个简单的gnu makefile:
ifdef $(DEBUGGING)
CFLAGS = -g -O0 -Wall
else
CFLAGS = -O3 -Wall
endif
test:
@echo DEBUGGING is $(DEBUGGING)
@echo $(CFLAGS)
当我这样调用它时,我看到DEBUGGING设置为true,但ifdef $DEBUGGING
似乎是假的:
$ DEBUGGING=true make test
DEBUGGING is true
-O3 -Wall
我希望CFLAGS设置为" -g -O0 -Wall"。我错过了什么?
答案 0 :(得分:4)
您使用ifdef
中变量的 NAME :
ifdef DEBUGGING
首先展开给ifdef
的值,结果被视为变量名。