TARGET = a.exe SRCEXT = c OBJDIR = o CC = gcc CFLAGS = -DHAVE_CONFIG_H -DGAWK -DNDEBUG -I. -g # -Os SRCS = $(wildcard *.$(SRCEXT)) OBJS = $(patsubst %.$(SRCEXT), $(OBJDIR)/%.o, $(SRCS)) # $(patsubst pattern, replacement, text) pattern substitute $(TARGET) : $(OBJS) # $^ 所有 $(CC) -o $@ $^ $(OBJDIR)/%.o : ./%.$(SRCEXT) # $< 第一个 $(CC) $(CFLAGS) -c -o $@ $< clean: # 用@打头则不echo要执行的命令,-忽略命令的exit值 @-rm -f $(OBJS) dep: $(CC) $(CFLAGS) -MM $(SRCS) >.dep wtf: # What the fuck (什么鬼) @echo SRCS = $(SRCS) @echo OBJS = $(OBJS) @echo $(wildcard *.sh) -include .dep # -使得当.dep不存在时不报错 # https://www.cnblogs.com/haoxing990/p/4629454.html # https://www.cnblogs.com/guolongnv/articles/8728353.html # https://www.cnblogs.com/geeker/p/4455538.html # https://blog.csdn.net/qinglongqishi1/article/details/80419332标签:SRCEXT,OBJS,%.,Makefile,www,目录,SRCS,https,放入 From: https://www.cnblogs.com/funwithwords/p/17005966.html