-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
91 lines (70 loc) · 2.42 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
NAME = cub3d
INC = inc
HEADER = -I inc
LIBFT = lib/libft/
MINILIBX = lib/mlx/
SRC_DIR = src/
OBJ_DIR = obj/
CC = gcc
CFLAGS = -Wall -Werror -Wextra -g
RM = rm -f
OPENGL = -framework OpenGL -framework AppKit
CUB_DIR = cub3d/
MAND_NAMES = parse map_creation map_creation2 map_validation set_width \
map_validation2 player set_colors set_textures
UTIL_DIR = util/
UTIL_NAMES = lines free texture_split
MLX_DIR = mlx_process/
MLX_NAMES = keyboard_interaction mlx_init
PLAY_DIR = play/
PLAY_NAMES = move
RAY_DIR = raycast/
RAY_NAMES = casting drawing
SRC_FILES = $(addprefix $(CUB_DIR), $(MAND_NAMES))
UTIL_FILES = $(addprefix $(UTIL_DIR), $(UTIL_NAMES))
MLX_FILES = $(addprefix $(MLX_DIR), $(MLX_NAMES))
PLAY_FILES = $(addprefix $(PLAY_DIR), $(PLAY_NAMES))
RAY_FILES = $(addprefix $(RAY_DIR), $(RAY_NAMES))
SRC = $(addprefix $(SRC_DIR), $(addsuffix .c, $(SRC_FILES)))
OBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(SRC_FILES)))
UTIL = $(addprefix $(SRC_DIR), $(addsuffix .c, $(UTIL_FILES)))
UTIL_OBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(UTIL_FILES)))
MLX = $(addprefix $(SRC_DIR), $(addsuffix .c, $(MLX_FILES)))
MLX_OBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(MLX_FILES)))
PLAY = $(addprefix $(SRC_DIR), $(addsuffix .c, $(PLAY_FILES)))
PLAY_OBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(PLAY_FILES)))
RAY = $(addprefix $(SRC_DIR), $(addsuffix .c, $(RAY_FILES)))
RAY_OBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(RAY_FILES)))
OBJF = .cache_exists
all: $(NAME)
$(NAME): $(OBJ) $(UTIL_OBJ) $(MLX_OBJ) $(PLAY_OBJ) $(RAY_OBJ) $(OBJF)
@make -C $(LIBFT)
@cp lib/libft/libft.a .
@make -C $(MINILIBX)
@cp lib/mlx/libmlx.a .
@$(CC) $(CFLAGS) $(OBJ) $(UTIL_OBJ) $(MLX_OBJ) $(PLAY_OBJ) $(RAY_OBJ) $(HEADER) $(OPENGL) libft.a libmlx.a -o $(NAME)
$(OBJ_DIR)%.o: $(SRC_DIR)%.c $(OBJF)
@$(CC) $(CFLAGS) $(HEADER) -c $< -o $@
$(OBJF):
@mkdir -p $(OBJ_DIR)
@mkdir -p $(OBJ_DIR)$(CUB_DIR)
@mkdir -p $(OBJ_DIR)$(UTIL_DIR)
@mkdir -p $(OBJ_DIR)$(MLX_DIR)
@mkdir -p $(OBJ_DIR)$(PLAY_DIR)
@mkdir -p $(OBJ_DIR)$(RAY_DIR)
@touch $(OBJF)
clean:
@$(RM) -r $(OBJ_DIR)
@make clean -C $(LIBFT)
@$(RM) $(OBJF)
fclean: clean
@$(RM) $(NAME)
@$(RM) $(BNAME)
@$(RM) libft.a
@$(RM) $(LIBFT)/libft.a
@$(RM) libmlx.a
@$(RM) $(MINILIBX)/libmlx.a
@$(RM) -rf *.dSYM
@find . -name ".DS_Store" -delete
re: fclean all
.PHONY: all clean fclean re