-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
109 lines (91 loc) · 2.14 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
.PHONY: all re clean fclean bonus
# Program file name
NAME = cub3D
# Mode
BONUS = 0
# Compiler and compilation flags
CC = gcc
CFLAGS = -Werror -Wextra -Wall -g3 #-fsanitize=address
# Minilibx
MLX_PATH = minilibx-linux/
MLX_NAME = libmlx.a
MLX = $(MLX_PATH)$(MLX_NAME)
# Libft
LIBFT_PATH = libft/
LIBFT_NAME = libft.a
LIBFT = $(LIBFT_PATH)$(LIBFT_NAME)
# Sources
SRC_PATH = ./sources/
SRC = main.c \
error.c \
init/init_data.c \
init/init_mlx.c \
init/init_textures.c \
parsing/check_args.c \
parsing/parse_data.c \
parsing/get_file_data.c \
parsing/create_game_map.c \
parsing/check_textures.c \
parsing/check_map.c \
parsing/check_map_borders.c \
parsing/fill_color_textures.c \
parsing/parsing_utils.c \
movement/input_handler.c \
movement/player_dir.c \
movement/player_pos.c \
movement/player_move.c \
movement/player_rotate.c \
render/raycasting.c \
render/render.c \
render/texture.c \
render/image_utils.c \
render/minimap_render.c \
render/minimap_image.c \
exit/exit.c \
exit/free_data.c \
debug/debug.c
SRCS = $(addprefix $(SRC_PATH), $(SRC))
# Objects
OBJ_PATH = ./objects/
OBJ = $(SRC:.c=.o)
OBJS = $(addprefix $(OBJ_PATH), $(OBJ))
# Includes
INC = -I ./includes/\
-I ./libft/\
-I ./minilibx-linux/
# Main rule
all: $(OBJ_PATH) $(MLX) $(LIBFT) $(NAME)
# Objects directory rule
$(OBJ_PATH):
mkdir -p $(OBJ_PATH)
mkdir -p $(OBJ_PATH)/init
mkdir -p $(OBJ_PATH)/parsing
mkdir -p $(OBJ_PATH)/movement
mkdir -p $(OBJ_PATH)/render
mkdir -p $(OBJ_PATH)/debug
mkdir -p $(OBJ_PATH)/exit
# Objects rule
$(OBJ_PATH)%.o: $(SRC_PATH)%.c
$(CC) $(CFLAGS) -DBONUS=$(BONUS) -c $< -o $@ $(INC)
# Project file rule
$(NAME): $(OBJS)
$(CC) $(CFLAGS) -DBONUS=$(BONUS) $(OBJS) -o $@ $(INC) $(LIBFT) $(MLX) -lXext -lX11 -lm
# Libft rule
$(LIBFT):
make -sC $(LIBFT_PATH)
# MLX rule
$(MLX):
make -sC $(MLX_PATH)
bonus:
make all BONUS=1
# Clean up build files rule
clean:
rm -rf $(OBJ_PATH)
make -C $(LIBFT_PATH) clean
make -C $(MLX_PATH) clean
# Remove program executable
fclean: clean
rm -f $(NAME)
make -C $(LIBFT_PATH) fclean
# Clean + remove executable
re: fclean all