使用ifdef条件来设置Make标志

时间:2014-06-09 20:10:04

标签: makefile gnu-make

我有一个简单的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"。我错过了什么?

1 个答案:

答案 0 :(得分:4)

您使用ifdef中变量的 NAME

ifdef DEBUGGING

首先展开给ifdef的值,结果被视为变量名。