-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
113 lines (93 loc) · 3.18 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
# VARIABLES
## binary
NAME = cub3D
## compilation
CC = gcc
CFLAGS = -g -Wall -Werror -Wextra
INCLUDES = $(addprefix -I,$(INCLUDES_DIR))
## bash commands
RM = rm -f
## valgrind
VALGRIND = valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes -q --tool=memcheck
## directories
INCLUDES_DIR = ./includes ./libs/libft ./libs/minilibx-linux
SRC_DIR = ./src
OBJ_DIR = ./obj
DESTROY_PATH = destroy/
KEYSTROKES_PATH = keystrokes/
INPUT_VALIDATION_PATH = input_validation/
UTILS_PATH = utils/
WINDOW_PATH = window/
RAYCASTING_PATH = ray_casting/
## libs
MLIBX_PATH = ./libs/minilibx-linux
MLIBX = $(MLIBX_PATH)/libmlx.a
MLX_FLAGS = -L$(MLIBX_PATH) -lmlx -lXext -lX11
LIBFT_PATH = ./libs/libft
LIBFT = $(LIBFT_PATH)/libft.a
LIBFT_FLAGS = -L$(LIBFT_PATH) -lft
LIBMATH_FLAGS = -lm
## source files
SRCS = cub3D.c \
error_handling.c \
hooks.c \
init_data.c \
memory_release.c \
texture_loading.c \
$(DESTROY_PATH)destroy.c \
$(INPUT_VALIDATION_PATH)input_validation_utils.c \
$(INPUT_VALIDATION_PATH)input_validation.c \
$(INPUT_VALIDATION_PATH)map_padding.c \
$(INPUT_VALIDATION_PATH)map_params_checks.c \
$(INPUT_VALIDATION_PATH)map_utils.c \
$(INPUT_VALIDATION_PATH)map_validation.c \
$(INPUT_VALIDATION_PATH)map_validation_player_position.c \
$(INPUT_VALIDATION_PATH)pathfinding.c \
$(INPUT_VALIDATION_PATH)wall_tracing_utils.c \
$(INPUT_VALIDATION_PATH)wall_tracing.c \
$(KEYSTROKES_PATH)keystrokes.c \
$(KEYSTROKES_PATH)rotate.c \
$(KEYSTROKES_PATH)move_player.c \
$(RAYCASTING_PATH)dda.c \
$(RAYCASTING_PATH)ray_casting.c \
$(RAYCASTING_PATH)ray_casting_utils.c \
$(RAYCASTING_PATH)calc_ray_casting.c \
$(RAYCASTING_PATH)texture_calcs_0.c \
$(RAYCASTING_PATH)texture_calcs_1.c \
$(UTILS_PATH)colour_encoding_util.c \
$(UTILS_PATH)params_utils.c \
$(UTILS_PATH)t_position_utils.c \
$(UTILS_PATH)ray_casting_utils.c \
$(WINDOW_PATH)window.c \
OBJS := $(addprefix $(OBJ_DIR)/,$(SRCS:.c=.o))
SRCS := $(addprefix $(SRC_DIR)/,$(SRCS))
all: $(NAME)
$(NAME): $(LIBFT) $(MLIBX) $(OBJS)
$(CC) $(CFLAGS) -o $(NAME) $(OBJS) $(INCLUDES) $(LIBFT_FLAGS) $(MLX_FLAGS) -lm
$(MLIBX):
make -C $(MLIBX_PATH)
$(LIBFT):
make -C $(LIBFT_PATH)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(OBJ_DIR)
@mkdir -p $(addprefix $(OBJ_DIR)/,$(DESTROY_PATH))
@mkdir -p $(addprefix $(OBJ_DIR)/,$(INPUT_VALIDATION_PATH))
@mkdir -p $(addprefix $(OBJ_DIR)/,$(KEYSTROKES_PATH))
@mkdir -p $(addprefix $(OBJ_DIR)/,$(RAYCASTING_PATH))
@mkdir -p $(addprefix $(OBJ_DIR)/,$(UTILS_PATH))
@mkdir -p $(addprefix $(OBJ_DIR)/,$(WINDOW_PATH))
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
make clean -C $(MLIBX_PATH)
make clean -C $(LIBFT_PATH)
$(RM) -r $(OBJ_DIR)
fclean: clean
make fclean -C $(LIBFT_PATH)
$(RM) $(NAME)
re: fclean all
run: all
clear
./$(NAME) $$MAP
valgrind: $(NAME)
$(VALGRIND) ./$(NAME) $$MAP
.PHONY: all clean fclean re go valgrind