-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (86 loc) · 3.26 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: dselmy <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/08/27 21:46:39 by dselmy #+# #+# #
# Updated: 2022/05/19 17:22:56 by dselmy ### ########.fr #
# #
# **************************************************************************** #
NAME = cub3D
NAME_BONUS = cub3D_bonus
LIBFT_PATH = ./libft/
LIBFT_NAME = libft.a
LIBFT = $(addprefix $(LIBFT_PATH), $(LIBFT_NAME))
MLX_PATH = ./mlx_linux/
MLX_NAME = libmlx.a
MLX = $(addprefix $(MLX_PATH), $(MLX_NAME))
SRC_DIR = ./src/
SRC_BONUS_DIR = ./src_bonus/
INC_DIR = ./inc/
OBJ_DIR = ./obj/
INC_NAME = cub3d.h
SRCS_COMMON = cub3d.c \
error.c \
free.c \
init_mlx.c \
init.c \
key_handle.c \
parse_end.c \
parser_map.c \
parse_config.c \
parser_base.c \
parser_map_utils.c \
player_movement.c \
parser_player.c \
player_rotate.c \
put_ray.c \
shutdown.c \
utils.c \
utils_get_wall.c \
utils_mlx.c \
utils_parser.c \
utils_put_wall.c \
get_distance.c \
get_crossing.c
SRCS_ONLY_MANDATORY = put_screen.c \
start_game.c
SRCS_ONLY_BONUS = put_screen_bonus.c \
start_game_bonus.c
SRCS_FILE = $(SRCS_COMMON) $(SRCS_ONLY_MANDATORY)
SRCS_FILE_BONUS = $(SRCS_COMMON) $(SRCS_ONLY_BONUS)
SRCS_NAME = $(addprefix $(SRC_DIR), $(SRCS_COMMON)) $(addprefix $(SRC_DIR), $(SRCS_ONLY_MANDATORY))
SRCS_NAME_BONUS = $(addprefix $(SRC_DIR), $(SRCS_COMMON)) $(addprefix $(SRC_DIR), $(SRCS_ONLY_BONUS))
INC = $(addprefix $(INC_DIR), $(INC_NAME))
OBJ = $(addprefix $(OBJ_DIR), $(SRCS_FILE:.c=.o))
OBJ_BONUS = $(addprefix $(OBJ_DIR), $(SRCS_FILE_BONUS:.c=.o))
DEP = $(addprefix $(OBJ_DIR), $(SRCS_NAME:.c=.d))
MLX_FLAGS = -lXext -lX11 -lm -lbsd
CFLAGS = -Wall -Werror -Wextra -O3
all: libs $(OBJ_DIR) $(NAME)
bonus: libs $(OBJ_DIR) $(NAME_BONUS)
$(NAME): $(LIBFT) $(MLX) $(OBJ)
gcc -o $(NAME) $(CFLAGS) -I $(INC_DIR) $(OBJ) -L$(LIBFT_PATH) -lft -L$(MLX_PATH) -lmlx $(MLX_FLAGS)
$(NAME_BONUS): $(LIBFT) $(MLX) $(OBJ_BONUS)
gcc -o $(NAME_BONUS) $(CFLAGS) -I $(INC_DIR) $(OBJ_BONUS) -L$(LIBFT_PATH) -lft -L$(MLX_PATH) -lmlx $(MLX_FLAGS)
$(OBJ_DIR):
mkdir $(OBJ_DIR)
$(OBJ_DIR)%.o: $(SRC_DIR)%.c $(INC)
gcc -c $(CFLAGS) -I $(INC_DIR) $< -o $@ -MD
$(OBJ_DIR)%.o: $(SRC_BONUS_DIR)%.c $(INC)
gcc -c $(CFLAGS) -I $(INC_DIR) $< -o $@ -MD
libs:
@make -C $(LIBFT_PATH)
@make -C $(MLX_PATH)
clean: clean_libs
rm -rf $(OBJ_DIR) $(DEP)
clean_libs:
@make clean -C $(LIBFT_PATH)
@make clean -C $(MLX_PATH)
fclean: clean
rm -rf $(LIBFT) $(MLX) $(NAME) $(NAME_BONUS)
re: fclean all
include $(wildcard $(DEP))
.PHONY: all clean fclean re bonus