-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
40 lines (31 loc) · 793 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Define the compiler
CXX := g++
# Define the directories
SRC_DIR := src
BIN_DIR := bin
TEMP_DIR := .temp
INCLUDE_DIR := include
# Define the output executable
TARGET := $(BIN_DIR)/mtsp
# Define the source files
SRC_FILES := $(wildcard $(SRC_DIR)/*.cpp)
# Define the object files
OBJ_FILES := $(SRC_FILES:$(SRC_DIR)/%.cpp=$(TEMP_DIR)/%.o)
# Define the compiler flags
CXXFLAGS := -Wall -std=c++17 -O3 -I$(INCLUDE_DIR)
# Rule to build the target
$(TARGET): $(OBJ_FILES)
@mkdir -p $(BIN_DIR)
$(CXX) $(CXXFLAGS) -o $(TARGET) $(OBJ_FILES)
# Rule to build object files
$(TEMP_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(TEMP_DIR)
$(CXX) $(CXXFLAGS) -c $< -o $@
# Clean rule
.PHONY: clean
clean:
rm -f $(TEMP_DIR)/*.o $(TARGET)
all:
mkdir -p $(BIN_DIR)
mkdir -p $(TEMP_DIR)
make $(TARGET)