一段简单通用的Makefile
CFLAGS = -Wall -g -o CC = gcc src=$(wildcard ./*.c) obj=$(patsubst %.c, %.o, $(src)) target=app $(target):$(obj) $(CC) $^ $(CFLAGS) $@ %.o:%.c $(CC) $< $(CFLAGS) $@ .PHONY:clean clean: $(RM) $(obj) $(target) -f @echo 清理完成
CFLAGS = -Wall -g -o CC = gcc src=$(wildcard ./*.c) obj=$(patsubst %.c, %.o, $(src)) target=app $(target):$(obj) $(CC) $^ $(CFLAGS) $@ %.o:%.c $(CC) $< $(CFLAGS) $@ .PHONY:clean clean: $(RM) $(obj) $(target) -f @echo 清理完成