-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
40 lines (30 loc) · 928 Bytes
/
Makefile
File metadata and controls
40 lines (30 loc) · 928 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
35
36
37
38
39
40
# Compiler und Flags
CXX = g++
CXXFLAGS = -Wall -Wextra -std=c++11 -g
# Verzeichnisse
SRC_DIR = src
BUILD_DIR = build
# Automatisches Finden aller .cpp Dateien im src/ Ordner
SOURCES = $(wildcard $(SRC_DIR)/*.cpp)
OBJECTS = $(SOURCES:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o)
# Name der ausführbaren Datei
TARGET = $(BUILD_DIR)/program
# Standard-Target: Kompiliert das Programm
all: $(TARGET)
# Linken der Object-Dateien zur ausführbaren Datei
$(TARGET): $(OBJECTS)
$(CXX) $(CXXFLAGS) -o $@ $^
# Kompilieren der .cpp Dateien zu .o Dateien
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp | $(BUILD_DIR)
$(CXX) $(CXXFLAGS) -c $< -o $@
# Erstellt das build/ Verzeichnis falls es nicht existiert
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
# Löscht alle kompilierten Dateien
clean:
rm -rf $(BUILD_DIR)
# Kompiliert und führt das Programm aus
run: $(TARGET)
./$(TARGET)
# Verhindert Konflikte mit gleichnamigen Dateien
.PHONY: all clean run