-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
69 lines (50 loc) · 1.32 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
## This is a custom makefile built with the help of an LLM because I don't know how makefiles work and have been using the same one for 10 years.
## Fingers crossed.
# Project Names
PROJECT = genchord
# Compiler
CC = g++
# Compiler and Linker Options
CXXFLAGS = -std=c++20 -pthread -O3 -w -Ilibs/JSL
LDFLAGS = -lpthread
# Dependency Flags
DEPFLAGS = -MMD -MP
# Source and Build Directories
SRC_DIR = src
BUILD_DIR = build
### DON'T EDIT BELOW HERE
# Find all source files
SOURCE_FILES := $(shell find $(SRC_DIR) -name "*.cpp")
# Generate object files
OBJECTS := $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_DIR)/main/%.o, $(SOURCE_FILES))
# Dependency Files
DEPS := $(OBJECTS:.o=.d)
# Default Target: Build both projects
.PHONY: all
all: $(PROJECT)
# Build Main Project
$(PROJECT): $(OBJECTS)
@echo "Linking $(PROJECT)..."
$(CC) -o $@ $^ $(LDFLAGS)
# Compile Main Source Files
$(BUILD_DIR)/main/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(dir $@)
@echo "Compiling $< for $(PROJECT)..."
$(CC) $(CXXFLAGS) $(DEPFLAGS) -c -o $@ $<
# Include Dependencies
-include $(DEPS)
# Run Main Project
.PHONY: run
run: $(PROJECT)
./$(PROJECT)
# Clean Targets
.PHONY: clean
clean:
@echo "Cleaning up..."
rm -rf $(PROJECT) $(BUILD_DIR)
.PHONY: depclean
depclean:
@echo "Removing dependency files..."
rm -f $(DEPS)
.PHONY: clean-all
clean-all: clean depclean