-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
165 lines (134 loc) · 3.83 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
######################
# OS Dependent flags #
######################
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
MLX_CFLAGS = -ldl -lglfw -pthread -lm
else ifeq ($(shell uname -m),arm64)
MLX_CFLAGS = -L/opt/homebrew/lib -lglfw -framework IOKit -framework Cocoa
else ifeq ($(shell uname -m),x86_64)
MLX_CFLAGS = -lglfw3 -framework IOKit -framework Cocoa
endif
NAME := cub3D
RUN_CMD := ./$(NAME) test_maps/default_map.cub
# RUN_CMD := ./$(NAME) test_maps/small.cub
# CFLAGS += -Wall -Wextra
# CFLAGS += -g -fsanitize=address
# CFLAGS += -g
# CFLAGS += -Wall -Wextra
# CFLAGS += -Werror
CFLAGS += -Ofast -flto -march=native -fno-fast-math
LIBFT := libft/build/libft.a
LIBMLX := MLX42/build/libmlx42.a
IFLAGS := -Ilibft/include -Iinclude -IMLX42/include
SRC_DIR := src
SRCS = parser/check_elements.c \
parser/parse_elements.c \
parser/parse_textures.c \
parser/parser.c \
parser/check_colors.c \
parser/lexer.c \
parser/lexer_utils.c \
parser/map_lexer.c \
parser/map_utils.c \
parser/map_checker.c \
parser/map_parser.c \
parser/sprite_parser.c \
parser/skip_utils.c \
parser/double_utils.c \
parser/map_access_utils.c \
parser/parser_fill.c \
parser/door_parser.c \
parser/door_checker.c \
utils/logging.c \
utils/free.c \
utils/colors.c \
game/game.c \
game/game_init.c \
game/draw/draw.c \
game/draw/bresenham.c \
game/keys.c \
game/player.c \
game/player_movement.c \
game/raycaster/raycaster.c \
game/raycaster/raycaster_init.c \
game/raycaster/floorcaster.c \
renderer/font_renderer.c \
game/sprite.c \
game/world.c \
game/sprite_calc.c \
game/sprite_render.c \
game/sprite_sort.c \
game/sort_utils.c \
renderer/render_minimap.c \
renderer/minimap_interact.c \
renderer/render_minimap_utils.c \
renderer/render_viewport.c \
renderer/pixel_picker.c \
renderer/draw_func.c \
vector/vec2i.c \
vector/vec_utils.c \
cub3d.c \
timer.c \
vector/vec2d_sum.c \
vector/vec2d_calc.c \
init/set_textures.c
HEADER_DIR := include
HEADERS := meta.h \
timer.h \
vector.h \
logging.h
OBJ_DIR := obj
TEST_L_FLAGS := -L ~/.capt/root/usr/lib/x86_64-linux-gnu
TEST_I_FLAGS := -I ~/.capt/root/usr/include
TEST_SRCS := test_parser.c
TEST := tests
TEST_SRCS := $(addprefix $(TEST)/, $(TEST_SRCS))
TEST_BINS := $(patsubst $(TEST)/%.c, $(TEST)/bin/%, $(TEST_SRCS))
SRCS := $(addprefix $(SRC_DIR)/, $(SRCS))
HEADERS := $(addprefix $(HEADER_DIR)/, $(HEADERS))
OBJS := $(patsubst $(SRC_DIR)%.c, $(OBJ_DIR)%.o, $(SRCS))
OBJ_DIRS := $(dir $(OBJS))
.PHONY: make_libs
all:
# $(MAKE) make_libs -j4
$(MAKE) make_libs
# $(MAKE) $(NAME) -j4
$(MAKE) $(NAME)
$(NAME): $(LIBFT) $(LIBMLX) $(OBJS) $(SRC_DIR)/main.c
$(CC) $(SRC_DIR)/main.c $(OBJS) $(LIBFT) $(LIBMLX) $(CFLAGS) $(IFLAGS) $(MLX_CFLAGS) -o $(NAME)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(HEADERS)
@mkdir -p $(OBJ_DIRS)
$(CC) $(CFLAGS) $(IFLAGS) -c $< -o $@
make_libs: $(LIBMLX)
$(MAKE) -C MLX42/build
$(MAKE) -C libft
MLX42:
git clone [email protected]:codam-coding-college/MLX42.git
$(LIBMLX): MLX42
mkdir -p MLX42/build
cmake MLX42 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -B MLX42/build
make -C MLX42/build -j4
clean:
rm -rf $(OBJ_DIR)
tclean:
rm -rf $(TEST)/bin
fclean: clean tclean
$(MAKE) -C MLX42/build clean
$(MAKE) -C libft fclean
rm -f $(NAME)
rm -rf $(NAME).dSYM
re: fclean all
run: all
$(RUN_CMD)
compile_commands: fclean
cp MLX42/build/compile_commands.json .
$(MAKE) | compiledb
norm:
norminette libft include src
$(TEST)/bin:
mkdir $@
$(TEST)/bin/%: $(TEST)/%.c $(OBJS)
$(CC) $(CFLAGS) $(IFLAGS) $(TEST_I_FLAGS) $(TEST_L_FLAGS) $(MLX_CFLAGS) $< $(OBJS) $(LIBFT) $(LIBMLX) -o $@ -lcriterion
test: make_libs $(OBJS) $(TEST)/bin $(TEST_BINS)
for test in $(TEST_BINS) ; do ./$$test -j1 ; done