-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
97 lines (77 loc) · 3.07 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: tschmitt <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/08/25 21:06:07 by tschmitt #+# #+# #
# Updated: 2021/09/07 16:26:09 by tschmitt ### ########.fr #
# #
# **************************************************************************** #
NAME = so_long
CC = clang
CCFLAGS = -Wall -Werror -Wextra
LIBFT_PATH = ./libs/libft/
MLX_PATH = ./libs/mlx/
SRC_PATH = ./src/
OBJ_PATH = ./obj/
SRC_UTILS_PATH = $(SRC_PATH)utils/
OBJ_UTILS_PATH = $(OBJ_PATH)utils/
SRC_MAP_PATH = $(SRC_PATH)map/
OBJ_MAP_PATH = $(OBJ_PATH)map/
INCLUDE = ./include/
LIBFT_INCLUDE = $(LIBFT_PATH)include/
MLX_INCLUDE = $(MLX_PATH)
LIBFT_NAME = $(LIBFT_PATH)lib/libft.a
MLX_NAME = $(MLX_PATH)libmlx.a
SRC = $(SRC_PATH)main.c $(SRC_PATH)handle_input.c $(SRC_PATH)move_player.c
OBJ = $(patsubst $(SRC_PATH)%.c, $(OBJ_PATH)%.o, $(SRC))
SRC_UTILS = $(SRC_UTILS_PATH)utils.c $(SRC_UTILS_PATH)free_utils.c
OBJ_UTILS = $(patsubst $(SRC_UTILS_PATH)%.c, $(OBJ_UTILS_PATH)%.o, $(SRC_UTILS))
SRC_MAP = $(SRC_MAP_PATH)draw_map.c $(SRC_MAP_PATH)parse_map.c $(SRC_MAP_PATH)validate_map.c $(SRC_MAP_PATH)utils.c
OBJ_MAP = $(patsubst $(SRC_MAP_PATH)%.c, $(OBJ_MAP_PATH)%.o, $(SRC_MAP))
MLX_FLAGS = -L $(MLX_PATH) -lmlx -framework OpenGL -framework AppKit
INCLUDE_FLAGS = -I $(INCLUDE) -I $(LIBFT_INCLUDE) -I $(MLX_INCLUDE)
Y = "\033[33m"
R = "\033[31m"
G = "\033[32m"
B = "\033[34m"
X = "\033[0m"
UP = "\033[A"
CUT = "\033[K"
all: $(NAME)
$(NAME): $(OBJ) $(OBJ_UTILS) $(OBJ_MAP) $(LIBFT_NAME) $(MLX_NAME)
@echo $(Y)Compiling [$(NAME)]...$(X)
@$(CC) $(CCFLAGS) $(INCLUDE_FLAGS) $(MLX_FLAGS) $(OBJ) $(OBJ_UTILS) $(OBJ_MAP) $(LIBFT_NAME) $(MLX_NAME) -o $(NAME)
@echo $(G)Finished [$(NAME)]$(X)
$(LIBFT_NAME):
@echo $(Y)Compiling [$(LIBFT_NAME)]...$(X)
@make -C $(LIBFT_PATH)
@printf $(UP)$(CUT)
@echo $(G)Finished [$(LIBFT_NAME)]$(X)
$(MLX_NAME):
@echo $(Y)Compiling [$(MLX_NAME)]...$(X)
@make -C $(MLX_PATH)
@printf $(UP)$(CUT)
@echo $(G)Finished [$(MLX_NAME)]$(X)
$(OBJ_PATH)%.o: $(SRC_PATH)%.c
@echo $(Y)Compiling [$@]...$(X)
@mkdir -p $(OBJ_PATH)
@mkdir -p $(OBJ_MAP_PATH)
@mkdir -p $(OBJ_UTILS_PATH)
@$(CC) $(CCFLAGS) $(INCLUDE_FLAGS) -Imlx -c $< -o $@
@printf $(UP)$(CUT)
@echo $(G)Finished [$@]$(X)
@printf $(UP)$(CUT)
clean:
@echo $(R)Cleaning" "[$(OBJ_PATH)]...$(X)
@make -C $(LIBFT_PATH) clean
@make -C $(MLX_PATH) clean
@rm -rf $(OBJ_PATH)
fclean: clean
@echo $(R)Cleaning" "[$(NAME)]...$(X)
@make -C $(LIBFT_PATH) fclean
@rm -f $(NAME)
re: fclean all
.PHONY: all clean fclean re