简单的makefile,完成输出对象文件到指定的文件夹来自csdn论坛

面这个是一个完整的makefile,功能简单,就是将obj放到 output下,你好好研究研究

SRCS := $(wildcard *.c)
OBJS  := $(patsubst %.c,output/%.o,$(SRCS)) 

TARGET := hello

all: $(TARGET)

clean:
rm -f $(TARGET) $(OBJS)

$(TARGET):$(OBJS)
gcc -o $(TARGET) $(OBJS)

$(OBJS):output/%.o:%.c
gcc -c $<  -o $@

原文地址:https://www.cnblogs.com/canphp/p/2940128.html