一段简单通用的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 清理完成

 

posted @ 2020-03-28 20:06  ziwuxian  阅读(91)  评论(0编辑  收藏  举报