-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
35 lines (26 loc) · 800 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
CXX = g++-12
CXXFLAGS = -std=c++20 -Wall -g -MMD
SRC_DIR = src
BUILD_DIR = bin
EXEC = buckshot-roulette
# Find all source files in the source directory
SOURCES = $(wildcard $(SRC_DIR)/*.cc)
# Generate a list of corresponding object files in the build directory
OBJECTS = $(patsubst $(SRC_DIR)/%.cc,$(BUILD_DIR)/%.o,$(SOURCES))
# Dependency files
DEPENDS = $(OBJECTS:.o=.d)
# Default target
all: $(EXEC)
# Linking object files to create the executable
$(EXEC): $(OBJECTS)
$(CXX) $(CXXFLAGS) $^ -o $@
# Compiling each source file into object files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cc
$(CXX) $(CXXFLAGS) -c $< -o $@
# Include dependency files
-include $(DEPENDS)
.PHONY: clean
clean:
rm -rf $(BUILD_DIR) $(EXEC)
# Create the build directory if it does not exist
$(shell mkdir -p $(BUILD_DIR))