-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
168 lines (138 loc) · 4.58 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
166
167
168
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: nkim <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/09/29 20:02:38 by nkim #+# #+# #
# Updated: 2022/09/29 20:34:06 by nkim ### ########.fr #
# #
# **************************************************************************** #
NAME = cub3D
CC = cc
ifdef DEBUG
CFLAGS = -g3 -fsanitize=address
else ifdef LEAKS
CFLAGS = -g
else
CFLAGS = -Wall -Wextra -Werror
endif
AR = ar rcs
RM = rm -rf
LIBFT_DIR = ./lib/libft/
LIBFT_INC = -I$(LIBFT_DIR)/include
LIBFT_FLAGS = -L./$(LIBFT_DIR) -lft
MLX_DIR = ./lib/mlx/
MLX_INC = -I$(MLX_DIR)
MLX_FLAGS = -L./$(MLX_DIR) -lmlx -framework OpenGL -framework Appkit
INCS_DIR = ./include/
INCS = -I$(INCS_DIR)
SRC_UTIL_DIR = util/
SRC_UTIL = $(addprefix $(SRC_UTIL_DIR), ft_get_line.c \
ft_trim_line.c \
ft_strtrim_back.c \
ft_make_img.c \
ft_put_img.c \
ft_str_to_rgb.c \
ft_get_valid_rgb.c)
SRC_PARSE_DIR = parse/
SRC_PARSE = $(addprefix $(SRC_PARSE_DIR), parse.c \
parse_map_info.c \
parse_graphic_info.c \
parse_state.c \
valid_extension.c \
valid_map.c \
valid_edge_wall.c \
valid_inner_wall.c)
SRC_HANDLER_DIR = handler/
SRC_HANDLER = $(addprefix $(SRC_HANDLER_DIR), keypress_handler.c \
check_wall_collision.c)
SRC_ERROR_DIR = error/
SRC_ERROR = $(addprefix $(SRC_ERROR_DIR), throw_error.c)
SRC_DRAW_DIR = draw/
SRC_DRAW = $(addprefix $(SRC_DRAW_DIR), draw_minimap.c \
draw_line.c \
draw_square.c \
draw_game.c \
draw_ray.c\
draw_pixel.c \
draw_wall.c)
SRC_GAME_DIR = game/
SRC_GAME = $(addprefix $(SRC_GAME_DIR), start_game.c \
close_game.c)
SRC_RAYCAST_DIR = raycast/
SRC_RAYCAST = $(addprefix $(SRC_RAYCAST_DIR), raycast.c \
set_ray.c \
update_ray.c)
SRC_INIT_DIR = init/
SRC_INIT = $(addprefix $(SRC_INIT_DIR), init.c \
init_state.c \
init_info.c)
SRC_MAIN_DIR = main/
SRC_MAIN = $(addprefix $(SRC_MAIN_DIR), main.c)
SRC = $(SRC_MAIN) \
$(SRC_PARSE) \
$(SRC_HANDLER) \
$(SRC_DRAW) \
$(SRC_ERROR) \
$(SRC_GAME) \
$(SRC_UTIL) \
$(SRC_RAYCAST) \
$(SRC_INIT)
SRCS_DIR = ./src/
SRCS = $(addprefix $(SRCS_DIR), $(SRC))
OBJS = $(SRCS:.c=.o)
.c.o :
@$(CC) $(CFLAGS) $(INCS) $(LIBFT_INC) $(MLX_INC) -o $@ -c $?
@echo $(CUT)$(BOLD)$(MINT) Compiling with $(CFLAGS)...$(RESET)
@echo $(CUT)$(MAUVE) [$(notdir $^)] to [$(notdir $@)] $(RESET)
@printf $(UP)$(UP)
$(NAME) : $(OBJS)
@printf $(DOWN)$(CUT)
@echo $(BOLD)$(GREEN)"📕 Creating libft"$(RESET)
@make -s -C $(LIBFT_DIR)
@echo $(BOLD)$(GREEN)"📘 Creating mlx_opengl"$(RESET)
@make -s -C $(MLX_DIR)
@echo $(BOLD)$(GREEN)"🔮 Creating cub3D"$(RESET)
@$(CC) $(CFLAGS) $(OBJS) -o $(NAME) $(LIBFT_FLAGS) $(MLX_FLAGS)
@printf $(CUT)$(CUT)
@echo $(BOLD)$(MINT) 🎮 $(NAME) 🎮 $(RESET)$(BOLD)is ready 🎉 $(RESET)
.PHONY : all
all : $(NAME)
.PHONY : clean
clean :
@make -s -C $(LIBFT_DIR) clean
@make -s -C $(MLX_DIR) clean
@$(RM) $(OBJS) $(NAME).dSYM
@echo $(BOLD)$(MAUVE) 🗒 object files $(RESET)$(BOLD)have been cleaned....🗑️$(RESET)
.PHONY : fclean
fclean : clean
@make -s -C $(LIBFT_DIR) fclean
@$(RM) $(NAME)
@echo $(BOLD)$(MINT) 🎮 $(NAME) 🎮 $(RESET)$(BOLD)has been cleaned....🗑️$(RESET)
.PHONY : cc
cc : $(NAME) $(SOURCES)
.PHONY : re
re : fclean all
.PHONY : debug
debug :
@make DEBUG=1 all
.PHONY : leaks
leaks :
@make LEAKS=1 all
######################### Color #########################
GREEN="\033[32m"
MINT="\033[38;5;51m"
L_PURPLE="\033[38;5;55m"
MAUVE="\033[38;5;147m"
PINK="\033[38;5;175m"
RESET="\033[0m"
BOLD="\033[1m"
UP = "\033[A"
DOWN = "\033[B"
RIGHT = "\033[C"
LEFT = "\033[D"
CUT = "\033[K"
SAVE = "\033[s"
RESTORE = "\033[u"