Gnu make "clean" 仅删除 OBJ/ASM 变量中的 .c 文件
Gnu make "clean" only removes .c files in OBJ/ASM variables
我正在尝试删除所有 .o 、 .i 、 .asm 、 .d 文件以这种形式存储在变量中:
OBJS := $(SRCS:.c=.o)
PP := $(SRCS:.c=.i)
ASM := $(SRCS:.c=.asm)
DEP := $(SRCS:.c=.d)
使用此代码:
SRCS = text1.c\
text2.c
OBJS :=$(SRCS:.c=.o)
PP := $(SRCS:.c =.i)
ASM := $(SRCS:.c =.asm)
DEP := $(SRCS:.c =.d)
.PHONY : clean
clean :
rm -f $(OBJS) $(PP) $(ASM) $(DEP)
但它只将 .o 应用于 $(OBJS),如下所示:
rm -f text1.o text2.o text1.c text2.c text1.c text2.c text1.c text2.c
我不明白为什么它没有用 *.i 或 *.asm 等替换 *.c 文件。
我用这个来解决它:
.PHONY: clean
clean:
rm -f *.o *.i *.asm *.d
但我仍在学习“制作”,所以我想知道为什么第一个不起作用..提前谢谢你。
等号后面不能有空格,否则它会尝试匹配名称中的空格。
这里是固定版本:
SRCS = text1.c text2.c
OBJS := $(SRCS:.c=.o)
PP := $(SRCS:.c=.i)
ASM := $(SRCS:.c=.asm)
DEP := $(SRCS:.c=.d)
# Note this does not match due to the extra space
PP2 := $(SRCS:.c =.i)
.PHONY : clean
clean :
rm -f $(OBJS) $(PP) $(ASM) $(DEP)
我正在尝试删除所有 .o 、 .i 、 .asm 、 .d 文件以这种形式存储在变量中:
OBJS := $(SRCS:.c=.o)
PP := $(SRCS:.c=.i)
ASM := $(SRCS:.c=.asm)
DEP := $(SRCS:.c=.d)
使用此代码:
SRCS = text1.c\
text2.c
OBJS :=$(SRCS:.c=.o)
PP := $(SRCS:.c =.i)
ASM := $(SRCS:.c =.asm)
DEP := $(SRCS:.c =.d)
.PHONY : clean
clean :
rm -f $(OBJS) $(PP) $(ASM) $(DEP)
但它只将 .o 应用于 $(OBJS),如下所示:
rm -f text1.o text2.o text1.c text2.c text1.c text2.c text1.c text2.c
我不明白为什么它没有用 *.i 或 *.asm 等替换 *.c 文件。
我用这个来解决它:
.PHONY: clean
clean:
rm -f *.o *.i *.asm *.d
但我仍在学习“制作”,所以我想知道为什么第一个不起作用..提前谢谢你。
等号后面不能有空格,否则它会尝试匹配名称中的空格。
这里是固定版本:
SRCS = text1.c text2.c
OBJS := $(SRCS:.c=.o)
PP := $(SRCS:.c=.i)
ASM := $(SRCS:.c=.asm)
DEP := $(SRCS:.c=.d)
# Note this does not match due to the extra space
PP2 := $(SRCS:.c =.i)
.PHONY : clean
clean :
rm -f $(OBJS) $(PP) $(ASM) $(DEP)