forked from Ginger-Leo/Cub3D
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
92 lines (75 loc) · 2.65 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: lstorey <lstorey@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/09/19 11:57:20 by lstorey #+# #+# #
# Updated: 2024/11/13 11:18:00 by lstorey ### ########.fr #
# #
# **************************************************************************** #
NAME = cub3D
CC = cc
FLAGS = -Wall -Wextra -Werror -Wunreachable-code -Ofast
SRC_DIR = ./
OBJ_DIR = obj
LIBFT = ./includes/libft
LIBMLX = ./includes/MLX42
INCLUDES = -I./
HEADERS = -I $(LIBMLX)/include
LIBS = $(LIBMLX)/build/libmlx42.a -ldl -lglfw -pthread -lm
FILES = src/utils.c \
src/utils_2.c \
src/utils_3.c \
src/core_functions.c \
src/main.c\
src/init_info.c\
src/map_checking_a.c \
src/map_checking_b.c \
src/free_a.c \
src/free_b.c \
src/texture_info.c \
src/texture_info_utils.c \
src/flood_fill.c \
src/map_utils.c \
src/mlx_functions.c \
src/moves.c \
src/rotate.c \
src/image_init.c \
src/build_mini_map.c \
src/raycaster.c \
src/hit_check.c \
src/intersects.c \
src/render.c \
src/raycast_utils_1.c \
src/raycast_utils_2.c \
OBJ_FILES = $(addprefix $(OBJ_DIR)/, $(FILES:.c=.o))
all: libmlx $(NAME)
$(LIBMLX):
@if [ ! -d "$(LIBMLX)" ]; then git clone https://github.com/codam-coding-college/MLX42.git $(LIBMLX); fi
libmlx: $(LIBMLX)
@if [ ! -d $(LIBMLX)/build ]; then \
cmake $(LIBMLX) -B $(LIBMLX)/build && make -C $(LIBMLX)/build -j4; \
fi
$(NAME): $(OBJ_FILES) $(LIBFT) $(LIBMLX)/build/libmlx42.a
make -C $(LIBFT) > /dev/null
$(CC) $(FLAGS) $(HEADERS) -o $(NAME) $(OBJ_FILES) -L$(LIBFT) $(LIBS) -lft
@echo "\033[32m$(NAME) has been built successfully!\033[0m"
fsanitize:
$(CC) -o $(NAME) $(FILES) -L$(LIBFT) $(LIBS) $(INCLUDES) -lft -g -fsanitize=address
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(SRC_DIR)includes/cub3D.h | $(OBJ_DIR)
$(CC) $(FLAGS) $(INCLUDES) -c $< -o $@
$(OBJ_FILES): | $(OBJ_DIR)
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
@mkdir -p $(OBJ_DIR)/src
clean:
make clean -C $(LIBFT)
rm -rf $(OBJ_DIR)
rm -rf $(LIBMLX)/build
fclean: clean
rm -f $(LIBFT)/libft.a
rm -f $(NAME)
re: fclean all
.PHONY: all clean fclean re libmlx