-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
74 lines (60 loc) · 1.73 KB
/
Copy pathMakefile
File metadata and controls
74 lines (60 loc) · 1.73 KB
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
# =========================================================
# Makefile — Game Engine Template
# =========================================================
# Dependencies:
# • GLFW3 (brew install glfw / apt install libglfw3-dev)
# • OpenGL (system)
# • stb_image.h (place in vendor/stb_image.h)
#
# Build:
# make — debug build
# make release — optimised build
# make clean
# =========================================================
CC := gcc
TARGET := game_engine
SRCDIR := .
# Source files
SRCS := \
core/logging.c \
core/window.c \
core/input.c \
core/time.c \
ecs/ecs.c \
scene/transform.c \
scene/component.c \
scene/entity.c \
scene/scene_manager.c \
rendering/shader.c \
rendering/mesh.c \
rendering/texture.c \
rendering/camera.c \
rendering/renderer.c \
engine.c \
main.c
OBJS := $(SRCS:.c=.o)
# Flags
CFLAGS_COMMON := -std=c11 -Wall -Wextra -Wpedantic -fsanitize=address\
-I. -I./vendor \
$(shell pkg-config --cflags glfw3)
CFLAGS_DEBUG := $(CFLAGS_COMMON) -g3 -O0 -DDEBUG
CFLAGS_RELEASE := $(CFLAGS_COMMON) -O3 -DNDEBUG -march=native
LDFLAGS := $(shell pkg-config --libs glfw3) -lGL -lm -fsanitize=address
# Default: debug
CFLAGS := $(CFLAGS_DEBUG)
LFLAGS := $(LDFLAGS)
# ── Targets ───────────────────────────────────────────────
.PHONY: all release clean
all: $(TARGET)
release: CFLAGS := $(CFLAGS_RELEASE)
release: LFLAGS := $(LDFLAGS)
release: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(OBJS) $(LFLAGS) -o $@
@echo "Built: $(TARGET)"
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
find . -name "*.o" -delete
rm -f $(TARGET)
@echo "Cleaned"