-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (80 loc) · 2.44 KB
/
Makefile
File metadata and controls
99 lines (80 loc) · 2.44 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
TARGET_EXEC := game
BUILD_DIR := build
SRC_DIR := src
INC_DIR := src
CPP_SRCS := $(shell find $(SRC_DIR) -name '*.cpp')
C_SRCS := $(shell find $(SRC_DIR) -name '*.c')
CPP_OBJS := $(CPP_SRCS:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o)
C_OBJS := $(C_SRCS:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o)
#SRCS := $(CPP_SRCS) $(C_SRCS)
OBJS := $(CPP_OBJS) $(C_OBJS)
DEPS := $(OBJS:.o=.d)
INCS := $(shell find $(INC_DIR) -type d) external/glm external/glew/include external/glfw/include external/stb
INC_FLAGS := $(addprefix -I,$(INCS))
# (C Preprocessor Flags)
CPPFLAGS := $(INC_FLAGS) -MMD -MP
# (External Libraries and Linker Flags)
LDFLAGS := \
external/glew/lib/libGLEW.a \
external/glfw/lib/libglfw3.a \
-lGL -lX11 -lXrandr -lXi -lXcursor -lXinerama \
-ldl -pthread
# (C++ Compiler Flags)
CXXFLAGS := -std=c++17
Warning_FLAGS := -Wall -Wextra -Wpedantic -Wshadow -Wnon-virtual-dtor -Woverloaded-virtual -Wnull-dereference -Wold-style-cast -Wsuggest-override -Wpessimizing-move -Wmisleading-indentation -Wduplicated-cond -Woverloaded-virtual -Wunused -Wcast-align
# -Wconversion, -Wsign-conversion, -Wdouble-promotion
# (C Compiler Flags)
CFLAGS :=
CXX := g++
CC := gcc
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
mkdir -p $(BUILD_DIR)
$(CXX) $(OBJS) -o $@ $(LDFLAGS)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
mkdir -p $(dir $@)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
mkdir -p $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
run: $(BUILD_DIR)/$(TARGET_EXEC)
./$(BUILD_DIR)/$(TARGET_EXEC)
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
setup:
@mkdir -p external
@# ---- GLEW ----
@if [ ! -d external/glew ]; then \
echo "Cloning GLEW..."; \
git clone https://github.com/nigels-com/glew.git external/glew; \
else \
echo "GLEW already cloned"; \
fi
cd external/glew && \
make extensions && \
make
@# ---- GLFW ----
@if [ ! -d external/glfw ]; then \
echo "Cloning GLFW..."; \
git clone https://github.com/glfw/glfw.git external/glfw; \
else \
echo "GLFW already cloned"; \
fi
cd external/glfw && \
cmake -S . -B build \
-DBUILD_SHARED_LIBS=OFF \
-DGLFW_BUILD_WAYLAND=OFF \
-DGLFW_BUILD_EXAMPLES=OFF \
-DGLFW_BUILD_TESTS=OFF \
-DGLFW_BUILD_DOCS=OFF && \
cmake --build build && \
mkdir -p lib && \
cp build/src/libglfw3.a lib/
@# ---- GLM ----
@if [ ! -d external/glm ]; then \
echo "Cloning GLM..."; \
git clone https://github.com/g-truc/glm.git external/glm; \
else \
echo "GLM already cloned"; \
fi
-include $(DEPS)