Makefile
makefile同名目标处理方式¶
参考:
Makefile中短划线¶
all:
-/bin/rm -rf *.log
其中,"-/bin/rm
"的短划线"-
"是一个特殊前缀,表示忽略命令执行过程的错误。
为每个源文件生成一个可执行程序¶
SRCS = $(wildcard *.c)
all: $(SRCS:.c=)
# Unnecessary, as the default rules are adequate.
.c:
gcc $(CPFLAGS) $< -o $@
最后两行其实不需要,默认规则已经足够了。
其中,$(SRCS:.c=.o)
表示将变量SRCS
中的每个单词(以空格分割)中的.c
替换为.o
。以上代码则是将所有.c
都去掉。