-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
49 lines (37 loc) · 1017 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
41
42
43
44
45
46
47
48
49
# Define the compiler
CXX = g++
# Define the directories
SRCDIR = src
INCDIR = include
BINDIR = bin
# Define the target executable
TARGET = $(BINDIR)/app
# Define the source files
SOURCES = $(wildcard $(SRCDIR)/*.cpp)
# Define the object files
OBJECTS = $(patsubst $(SRCDIR)/%.cpp, $(BINDIR)/%.o, $(SOURCES)) main.cpp
# Define the compiler flags
CXXFLAGS = -I$(INCDIR)
# Define the linker flags
LDFLAGS = -lSDL2 -lSDL2_image
# Default rule to build the target
all: $(TARGET)
# Rule to link the object files into the target executable
$(TARGET): $(OBJECTS)
@echo "Linking: $(OBJECTS)"
$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)
# Rule to compile source files into object files
$(BINDIR)/%.o: $(SRCDIR)/%.cpp
@echo "Compiling $<"
mkdir -p $(BINDIR)
$(CXX) $(CXXFLAGS) -c $< -o $@
# Clean up generated files
clean:
rm -rf $(BINDIR)/*.o $(TARGET)
# Print variables for debugging
debug:
@echo "Sources: $(SOURCES)"
@echo "Objects: $(OBJECTS)"
@echo "Target: $(TARGET)"
# Phony targets
.PHONY: all clean debug