From f956e9c5e2a090d642effcc370b61e9a0a44b468 Mon Sep 17 00:00:00 2001 From: flykhan Date: Thu, 27 Jul 2023 15:34:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E7=BB=84=E7=B1=BB=E7=9A=84=E5=B0=81?= =?UTF-8?q?=E8=A3=85:=20=E6=B7=BB=E5=8A=A0=20makefile=20=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day4/ec1/Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/day4/ec1/Makefile b/day4/ec1/Makefile index 3bf55d8..a217e1c 100644 --- a/day4/ec1/Makefile +++ b/day4/ec1/Makefile @@ -5,6 +5,7 @@ BIN_DIR = ./ # 定义编译器 CC = g++ +STD = -std=c++11 # 定义目标文件 TARGET = $(BIN_DIR)/a.out # 定义源文件 @@ -14,11 +15,11 @@ OBJS = $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SRCS)) # 编译规则 $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp - $(CC) -c $< -o $@ -std=c++11 + $(CC) -c $< -o $@ $(STD) # 链接规则 $(TARGET): $(OBJS) - $(CC) $^ -o $@ -std=c++11 + $(CC) $^ -o $@ $(STD) # 默认构建目标 all: $(TARGET) @@ -26,6 +27,10 @@ all: $(TARGET) # 创建目录 $(shell mkdir -p $(OBJ_DIR) $(BIN_DIR)) +# 运行测试 +run: $(TARGET) + $(TARGET) + # 清理规则 clean: rm -rf $(OBJ_DIR)/*.o $(TARGET)