SRCS = $(wildcard *.c)
SRC= $(SRCS)
TARGET =app
BUILD_DIR=build
OBJS := $(patsubst %.c,$(BUILD_DIR)/%.o,$(SRC))
PPS :=$(OBJS:%.o=%.i)
CFLAGS +=-g
CFLAGS += -I./
.PHONY: all echo prease
all:clean prease $(OBJS) $(PPS)
@echo ""
@echo "buil target"
gcc $(OBJS) $(CFLAGS) -o $(TARGET)
$(OBJS):$(BUILD_DIR)/%.o:%.c
gcc -c $< -o $@
$(PPS):$(BUILD_DIR)/%.i:%.c
@gcc -E $< -o $@
@echo "gcc -E $< -o $@"
clean:
echo "cread build dir"
rm -rf $(BUILD_DIR)
-rm -rf $(TARGET) *.o
prease:
-@mkdir -p $(BUILD_DIR)
echo:
@echo "target=$(TARGET)"
@echo "OBJS = $(OBJS)"
@echo "SRC = $(SRC)"
Makefile编写
最新推荐文章于 2024-05-24 17:31:31 发布