-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
115 lines (88 loc) · 1.94 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
### COLOURS ###
COLOUR_GREEN=\033[0;32m
COLOUR_RED=\033[0;31m
COLOUR_BLUE=\033[0;34m
COLOUR_END=\033[0m
### SET UP ###
CC = cc
CFLAGS = -I$I -Wall -Wextra -Werror
RM = /bin/rm -f
RMDIR = /bin/rmdir -p
LIBFT = libft/libft.a
S = src
O = obj
I = includes
FILES = main\
end\
render\
render_utils\
mini_map\
ray_calculate\
event\
key_event\
walls\
parser\
utils\
free_utils\
line\
display\
init\
get_color\
get_map \
get_matrix\
get_back\
get_direction\
get_texture\
validator\
flood_fill\
is_inland\
valid_char\
valid_filetype\
valid_utils\
texture
HEADER = cub3D.h libft.h mlx.h get_next_line.h render.h color.h
HEADER := $(addprefix $I/,$(HEADER))
SRCS := $(foreach FILE,$(FILES),$(shell find $S -type f -name '$(FILE).c'))
OBJS = $(patsubst $S/%,$O/%,$(SRCS:.c=.o))
O_DIRS = $(dir $(OBJS))
# Minilibx
MLX_PATH = mlx/
MLX_NAME = libmlx.a
MLX = $(MLX_PATH)$(MLX_NAME)
MLX_LNK = -L ./mlx -lmlx -framework OpenGL -framework AppKit
NAME = cub3D
### RULES ###
all: $(MLX) $(LIBFT) $(NAME)
$O/%.o: $S/%.c $(HEADER)
@mkdir -p $(O_DIRS)
@$(CC) $(CFLAGS) -Imlx -c $< -o $@
$(NAME): $(OBJS)
@echo "Compiling cub3D..."
@$(CC) $(CFLAGS) $(MLX) $(MLX_LNK) $(LIBFT) $(OBJS) -o $(NAME)
@echo "$(COLOUR_GREEN) $(NAME) created$(COLOUR_END)"
### MLX
$(MLX):
@echo "Making MiniLibX..."
@make -sC $(MLX_PATH)
@echo "$(COLOUR_GREEN) $(MLX) created$(COLOUR_END)"
### LIBFT
libft: $(LIBFT)
$(LIBFT):
@echo "Making libft..."
@$(MAKE) -C libft
@echo "$(COLOUR_GREEN) $(LIBFT) created$(COLOUR_END)"
### CLEANING
clean:
@cd libft && $(MAKE) clean
@echo "$(COLOUR_RED) $(LIBFT) removed$(COLOUR_END)"
@cd mlx && $(MAKE) clean
@echo "$(COLOUR_RED) $(MLX) removed$(COLOUR_END)"
@$(RM) $(OBJS)
@if [ -d $O ]; then $(RM) -rf $(O_DIRS) $O; fi
fclean : clean
@cd libft && $(MAKE) fclean
@echo "$(COLOUR_RED) $(LIBFT) removed$(COLOUR_END)"
@$(RM) $(NAME)
@echo "$(COLOUR_RED) $(NAME) removed$(COLOUR_END)"
re: fclean all
.PHONY: all clean fclean re