-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
34 lines (26 loc) · 678 Bytes
/
Copy pathMakefile
File metadata and controls
34 lines (26 loc) · 678 Bytes
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
# === Directories ===
SRC_DIR := src
INC_DIR := include
OBJ_DIR := build
# === Compiler & Flags ===
CXX := g++
CXXFLAGS := -std=c++17 -Wall -Wextra -I$(INC_DIR)
# === Source and Object Files ===
CPP_FILES := $(shell find $(SRC_DIR) -name '*.cpp')
OBJ_FILES := $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(CPP_FILES))
# === Output Executable ===
TARGET := $(OBJ_DIR)/optio
# === Default Rule ===
all: $(TARGET)
# === Linking ===
$(TARGET): $(OBJ_FILES)
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $^ -o $@
# === Compiling ===
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) -c $< -o $@
# === Clean ===
clean:
rm -rf $(OBJ_DIR)
.PHONY: all clean