DEPDIR = build_dep TARGET_NAME = helloworld CFLAGS = -Wall SRCS = main.c SRCS += foo.c OBJS = $(SRCS:%.c=%.o) all: $(OBJS) $(CC) $(CFLAGS) $^ -o $(TARGET_NAME) debug: @echo "CC = $(CC)" @echo "MAKE = $(MAKE)" @echo "SRCS = $(SRCS)" @echo "OBJS = $(OBJS)" @echo "CFLAGS = $(CFLAGS)" $(DEPDIR)/%.d: %.c $(SHELL) -ec ‘mkdir -p $(DEPDIR); \ $(CC) -MM $(CFLAGS) $< | sed ‘\‘‘[email protected]\($*\)\.o[ :]*@\1.o [email protected] : @g‘\‘‘ > [email protected]$$$$; cp [email protected]$$$$ [email protected]; rm [email protected]$$$$‘ include $(SRCS:%.c=$(DEPDIR)/%.d) clean: @rm -f $(TARGET_NAME) @rm -f *.o
时间: 2024-10-03 13:45:58