DIR = .
DIR_INC = $(DIR)/inc
DIR_SRC = $(DIR)/src
#DIR_SRC1 = ./src1
#DIR_SRC2 = ./src2
DIR_OBJ = $(DIR)/obj
DIR_BIN = $(DIR)/bin
SRC = $(wildcard $(DIR_SRC)/*.c)
#SRC += $(wildcard $(DIR_SRC1)/*.c)
#SRC += $(wildcard $(DIR_SRC2)/*.c)
OBJ = $(patsubst %.c,$(DIR_OBJ)/%.o,$(notdir $(SRC)))
#OBJ = $(patsubst %.c,%.o, $(SRC))
TARGET = test
BIN_TARGET = $(DIR_BIN)/$(TARGET)
CC = gcc
CFLAGS = -g -I$(DIR_INC)
$(TARGET):$(0BJ)
$(CC) $(OBJ) -o $@
$(DIR_OBJ)/%.o:$(DIR_SRC)/%.c
$(CC) $(CFLAGS) -c $< -o $@
.PHONY:clean
clean:
rm -rf ./bin/* ./obj/*
Makefile:多目录文件编写
最新推荐文章于 2024-09-14 16:45:08 发布