-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (50 loc) · 1.4 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
NAME := SCOP
SRC_DIR := src
SRC_FILES := main.cpp \
Camera.cpp \
Input.cpp \
Material.cpp \
Mesh.cpp \
Model.cpp \
MtlParser.cpp \
ObjParser.cpp \
Renderer.cpp \
Shader.cpp \
Texture.cpp \
Window.cpp \
program_options.cpp \
utils.cpp \
math/Vec3f.cpp \
math/Mat4f.cpp \
stb_image.cpp
SRCS := $(addprefix $(SRC_DIR)/, $(SRC_FILES))
BUILD_DIR := build
OBJS := $(SRC_FILES:%.cpp=$(BUILD_DIR)/%.o)
DEPS := $(SRC_FILES:%.cpp=$(BUILD_DIR)/%.d)
CXX_DEFS := NAME=\"$(NAME)\"
LIB_DIR := ./lib
CXX := g++
CXX_FLAGS := -Wextra -Werror -Wall -std=c++17 -O2 -g3
CXX_LINKS := -L$(LIB_DIR)
CXX_LIBS := -lglfw -lGLEW -lGL -ldl -lX11 -lpthread -lXrandr -lXi
CXX_HEADERS := -I./lib/GLEW/include -I./lib/GLFW/include -I./inc -I./inc/math
CXX_DEPS_FLAGS := -MP -MMD
CXX_DEFS_FLAGS := $(foreach def,$(CXX_DEFS),-D $(def))
LIB_DEPS := $(shell find $(LIB_DIR) -type f)
all: $(NAME)
$(NAME): $(OBJS)
$(CXX) $(CXX_FLAGS) $(CXX_HEADERS) $(CXX_LINKS) $(OBJS) $(CXX_LIBS) -o $@
-include $(DEPS)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp $(LIB_DEPS)
@mkdir -p $(@D)
$(CXX) $(CXX_FLAGS) $(CXX_DEPS_FLAGS) $(CXX_DEFS_FLAGS) $(CXX_HEADERS) -c $< -o $@
42: all
./$(NAME) resources/42.obj
teapot: all
./$(NAME) resources/teapot.obj
clean:
@rm -rf $(BUILD_DIR)
fclean: clean
@rm -rf $(NAME)
re: fclean all
.PHONY: all clean fclean re 42 teapot