Last active
April 10, 2021 21:49
-
-
Save Jamlee/51d2b90045f34d138452785355cecde5 to your computer and use it in GitHub Desktop.
Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default: all | |
OUTDIR=out | |
CFLAGS=-g -Wall | |
INCLUDES=-I../src | |
# 测试依赖内容 | |
OBJECTS=main.o adlist.o zmalloc.o | |
$(foreach i,$(OBJECTS),$(eval "$(OUTDIR)/$(subst .o,,$(i)).o:$(subst .o,,$(i)).c")) | |
# 在其他目录寻找文件 | |
vpath % ../src | |
all: app | |
app: $(addprefix $(OUTDIR)/, $(OBJECTS)) | |
$(CC) $^ -o $(OUTDIR)/$@ | |
$(OUTDIR)/%.o: %.c | |
$(CC) $(CFLAGS) $^ $(INCLUDES) -c -o $@ | |
clean: | |
rm -fr out/* | |
.PHONY: clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment