-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
94 lines (77 loc) · 2.16 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Nombre del ejecutable
TARGET = survivalProject
USE_VALGRIND = 0
# Compilador
CC = g++
# Opciones de compilación para el modo "release"
CFLAGS_RELEASE = -std=c++17 -I/usr/local/include -O2 -s
# Opciones de compilación para el modo "debug"
CFLAGS_DEBUG = -std=c++17 -I/usr/local/include -O0 -g
# Rutas a las bibliotecas
LDFLAGS = -L/usr/local/lib
LIBS = -lSDL3 -ltinyxml
OBJ_DIR = ./obj
# Fuentes y cabeceras
SOURCES = \
src/Graphics/TextureManager.cpp \
src/main.cpp \
src/Core/Engine.cpp \
src/Object/GameObject.cpp \
src/Characters/Character.cpp \
src/Characters/Player.cpp \
src/Characters/CurrentPlayer.cpp \
src/Graphics/Animation.cpp \
src/Inputs/Input.cpp \
src/Map/GameMap.cpp \
src/Map/MapParser.cpp \
src/Map/Chunk.cpp \
src/Camera/Camera.cpp \
src/Physics/CollisionHandler.cpp \
src/Assets/AssetsManager.cpp \
HEADERS = \
src/Graphics/TextureManager.h \
src/Physics/Vector2D.h \
src/Core/Engine.h \
src/Object/IObject.h \
src/Object/GameObject.h \
src/Characters/Character.h \
src/Characters/Player.h \
src/Characters/CurrentPlayer.h \
src/Graphics/Animation.h \
src/Physics/RigidBody.h \
src/Inputs/Input.h \
src/Timer/Timer.h \
src/Map/GameMap.h \
src/Map/Chunk.h \
src/Physics/Point.h \
src/Camera/Camera.h \
src/Physics/Collider.h \
src/Physics/CollisionHandler.h \
src/Assets/AssetsManager.h \
# Objetos generados
OBJECTS = $(addprefix $(OBJ_DIR)/,$(SOURCES:.cpp=.o))
CFLAGS = $(CFLAGS_DEBUG)
# Definición de la variable de opciones de compilación
#release:
#$(eval override CFLAGS := $(CFLAGS_RELEASE))
# Regla de construcción del ejecutable
$(TARGET): $(OBJECTS)
mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) -o $(TARGET) $(LIBS)
ifeq ($(USE_VALGRIND), 1)
valgrind --show-leak-kinds=definite $(OBJ_DIR)/$(TARGET) 2> valgind.txt
endif
$(OBJ_DIR)/%.o: %.cpp $(HEADERS)
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
# Regla para generar las dependencias automáticamente
depend: .depend
.depend: $(SOURCES) $(HEADERS)
$(CC) $(CFLAGS) -MM $(SOURCES) > .depend
include .depend
# Regla para limpiar archivos generados
clean:
rm -f $(OBJECTS) $(TARGET) .depend
# Regla por defecto
all: $(TARGET)
.PHONY: all clean depend