从 makefile 设置标志的问题

problems setting flags from makefile

#include <stdlib.h>
#include <stdio.h>

int main(int argc, char** argv) {

#ifdef DEBUG
  printf("Debug!\n");
#endif

  printf("hello world\n");

}

生成文件:

CC=gcc-5

CFLAGS=-I

DEPS=foo.c

main: $(DEPS)
    $(CC) -o foo $(DEPS) $(CFLAGS).

debug: CFLAGS += -DDEBUG
debug: main

当我运行make debug

gcc-5 -o foo foo.c -I -DDEBUG.
> ./foo 
hello world

为什么我没有看到 "Debug!"?

-I 选项需要一个参数,现在是 -DDEBUG.。删除 -I 选项,或为其提供参数。我建议删除它,因为我看不到任何值得将目录添加到包含搜索路径的内容。