Skip to content

Commit c783984

Browse files
committed
update the makefile
1 parent d14855c commit c783984

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

scanner/Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ CXXFLAGS := -std=c++17 -Iinclude -I/usr/include/gtest -Wall -Wextra -Werror
44
GTEST_DIR := /usr/include/gtest
55
GTEST_LIB_DIR := /usr/lib/x86_64-linux-gnu
66

7+
# Build type (debug or release)
8+
BUILD_TYPE ?= release
9+
10+
ifeq ($(BUILD_TYPE), debug)
11+
CXXFLAGS += -O0 -g
12+
else ifeq ($(BUILD_TYPE), release)
13+
CXXFLAGS += -O3
14+
else
15+
$(error Unknown BUILD_TYPE "$(BUILD_TYPE)")
16+
endif
17+
718
# Directories
819
SRC_DIR := src
920
INCLUDE_DIR := include
@@ -16,7 +27,7 @@ SRCS := $(wildcard $(SRC_DIR)/*.cpp)
1627
OBJS := $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(SRCS))
1728

1829
# Object files excluding the main program
19-
TEST_OBJS := $(filter-out $(BUILD_DIR)/mian.o, $(OBJS))
30+
TEST_OBJS := $(filter-out $(BUILD_DIR)/main.o, $(OBJS))
2031

2132
# Target executable
2233
TARGET := scanner
@@ -62,5 +73,4 @@ test: $(TEST_OBJS) | $(BUILD_DIR)
6273
-o $(BUILD_DIR)/$(TEST_FILE)_test && ./$(BUILD_DIR)/$(TEST_FILE)_test; \
6374
fi
6475

65-
6676
.PHONY: all clean run test

0 commit comments

Comments
 (0)