-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
121 lines (102 loc) · 3.56 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
114
115
116
117
118
119
120
121
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: tblaase <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/01/31 15:54:32 by tblaase #+# #+# #
# Updated: 2022/02/03 15:18:33 by tblaase ### ########.fr #
# #
# **************************************************************************** #
NAME = cub3D
CC = gcc
FLAGS = -Wall -Wextra -Werror
# directories
SRC_DIR = src/
OBJ_DIR = obj/
INC_DIR = include/
LIBFT_DIR = libft/
LIBMLX_DIR = mlx/
# controll codes
RESET = \033[0m
GREEN = \033[32m
YELLOW = \033[33m
BLUE = \033[34m
RED = \033[31m
UP = \033[A
CUT = \033[K
# source files
SRC_FILES = main.c \
init.c validation_map.c minimap.c textures.c walls.c events.c \
draw.c utils.c rays.c setters.c doors.c free.c map.c \
animations.c wall_collision_y.c wall_collision_x.c \
validation_path.c validation_color.c validation_utils.c \
doors_utils.c event_hooks.c textures_utils.c draw_utils.c
# object files
OBJ_FILES = $(SRC_FILES:.c=.o)
# paths
SRC = $(addprefix $(SRC_DIR), $(SRC_FILES))
OBJ = $(addprefix $(OBJ_DIR), $(OBJ_FILES))
LIBFT = $(addprefix $(LIBFT_DIR), libft.a)
LIBMLX = $(addprefix $(LIBMLX_DIR), libmlx.a)
# libft and mlx linkers
LNK = -L $(LIBFT_DIR) -lft -L $(LIBMLX_DIR) -lmlx -framework OpenGL -framework AppKit
# all rule
all: $(LIBFT) $(LIBMLX) $(NAME)
@printf "\n"
@echo "$(GREEN) $(RESET)"
@echo "$(GREEN) _ ___ ___ $(RESET)"
@echo "$(GREEN) ___ _ _| |_|_ | |$(RESET)"
@echo "$(GREEN)| _| | | . |_ | | |$(RESET)"
@echo "$(GREEN)|___|___|___|___|___|$(RESET)"
@echo "$(GREEN) $(RESET)"
@printf "\n"
# compile cub3D
$(NAME): $(OBJ)
@echo "$(YELLOW)Compiling [$(NAME)]...$(RESET)"
@$(CC) $(OBJ) $(LNK) -lm -o $(NAME)
@echo "$(GREEN)Finished [$(NAME)]$(RESET)"
# compile objects
$(OBJ_DIR)%.o:$(SRC_DIR)%.c
@mkdir -p $(OBJ_DIR)
@echo "$(YELLOW)Compiling [$@]...$(RESET)"
@$(CC) $(FLAGS) -I $(LIBMLX_DIR) -I $(LIBFT_DIR) -I $(INC_DIR) -o $@ -c $<
@printf "$(UP)$(CUT)"
@echo "$(GREEN)Finished [$@]$(RESET)"
@printf "$(UP)$(CUT)"
# compile libft
$(LIBFT):
@echo "$(YELLOW)Compiling $(LIBFT_DIR) library...$(RESET)"
@make -C $(LIBFT_DIR)
# compile mlx
$(LIBMLX):
@echo "$(YELLOW)Compiling $(LIBMLX_DIR) library...$(RESET)"
@make -C $(LIBMLX_DIR)
# clean rule
clean:
@make -C $(LIBFT_DIR) clean
@make -C $(LIBMLX_DIR) clean
@if [ -d "$(OBJ_DIR)" ]; then \
rm -rf $(OBJ_DIR); \
echo "$(BLUE)Deleting all objects from /cub3d...$(RESET)"; else \
echo "No objects to remove from /cub3D."; \
fi;
# fclean rule
fclean: clean
@make -C $(LIBFT_DIR) fclean
@make -C $(LIBMLX_DIR) fclean
@if [ -f "$(NAME)" ]; then \
rm -f $(NAME); \
echo "$(BLUE)Deleting $(NAME) from /cub3d...$(RESET)"; else \
echo "No Executable to remove from /cub3D."; \
fi;
# re rule
re: fclean all
# added norm check
norm:
@echo $(G)Checking Norminette...$(X)
@norminette libft src include | grep Error | egrep --color '.*Error!|$$' || true
@echo $(G)Done$(X)
# phony
.PHONY: all clean fclean re norm