2023-07-27 15:31:47 +08:00
|
|
|
# 定义路径变量
|
|
|
|
SRC_DIR = ./
|
|
|
|
OBJ_DIR = ./
|
|
|
|
BIN_DIR = ./
|
|
|
|
|
|
|
|
# 定义编译器
|
|
|
|
CC = g++
|
2023-07-27 15:34:51 +08:00
|
|
|
STD = -std=c++11
|
2023-07-27 15:31:47 +08:00
|
|
|
# 定义目标文件
|
|
|
|
TARGET = $(BIN_DIR)/a.out
|
|
|
|
# 定义源文件
|
|
|
|
SRCS = $(wildcard $(SRC_DIR)/*.cpp)
|
|
|
|
# OBJS = $(OBJ_DIR)/lrc.o $(OBJ_DIR)/console.o $(OBJ_DIR)/start_mplayer.o $(OBJ_DIR)/time_delay.o $(OBJ_DIR)/main.o
|
|
|
|
OBJS = $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SRCS))
|
|
|
|
|
|
|
|
# 编译规则
|
|
|
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
|
2023-07-27 15:34:51 +08:00
|
|
|
$(CC) -c $< -o $@ $(STD)
|
2023-07-27 15:31:47 +08:00
|
|
|
|
|
|
|
# 链接规则
|
|
|
|
$(TARGET): $(OBJS)
|
2023-07-27 15:34:51 +08:00
|
|
|
$(CC) $^ -o $@ $(STD)
|
2023-07-27 15:31:47 +08:00
|
|
|
|
|
|
|
# 默认构建目标
|
|
|
|
all: $(TARGET)
|
|
|
|
|
|
|
|
# 创建目录
|
|
|
|
$(shell mkdir -p $(OBJ_DIR) $(BIN_DIR))
|
|
|
|
|
2023-07-27 15:34:51 +08:00
|
|
|
# 运行测试
|
|
|
|
run: $(TARGET)
|
|
|
|
$(TARGET)
|
|
|
|
|
2023-07-27 15:31:47 +08:00
|
|
|
# 清理规则
|
|
|
|
clean:
|
|
|
|
rm -rf $(OBJ_DIR)/*.o $(TARGET)
|
|
|
|
|
|
|
|
# 伪目标
|
|
|
|
.PHONY: all clean
|