-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
104 lines (87 loc) · 2.09 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
NAME=so_long
BONUS=bonus
UNAME_S := $(shell uname -s)
CYAN=\033[0;36m
GREEN=\033[0;32m
MAGENTA=\033[0;35m
ENDCOLOR=\033[0m
CC= cc
FLAGS= -g -Wall -Werror -Wextra
OBJ= obj/main.o \
obj/wall_check.o \
obj/component_check.o \
obj/filename_check.o \
obj/read_map.o \
obj/path_check.o \
obj/errors.o \
obj/loop.o \
obj/draw_map.o \
obj/coord_tools.o \
obj/struct_utils.o \
obj/map_check.o \
obj/tiles.o \
obj/tiles_utils.o \
obj/player.o \
obj/collectable.o \
obj/put_tiles.o \
BONUS_OBJ= obj/bonus/enemy.o \
obj/bonus/loop_bonus.o \
obj/bonus/draw_map.o \
obj/main.o \
obj/wall_check.o \
obj/component_check.o \
obj/filename_check.o \
obj/read_map.o \
obj/path_check.o \
obj/errors.o \
obj/coord_tools.o \
obj/struct_utils.o \
obj/map_check.o \
obj/tiles.o \
obj/tiles_utils.o \
obj/player.o \
obj/collectable.o \
obj/put_tiles.o \
MLX= lib/MLX42/libmlx42.a
MLX_DIR= lib/MLX42/
LIBFT= obj/libft/libft.o
LIBFT_DIR= src/libft
NAME_H= include/so_long.h
ifeq ($(UNAME_S),Linux)
MLX_FLAGS= -ldl -lglfw -pthread -lm
endif
ifeq ($(UNAME_S),Darwin)
MLX_FLAGS= -lglfw -L ~/.brew/Cellar/glfw/3.3.8/lib
endif
all: $(NAME)
$(NAME): $(LIBFT) $(OBJ) $(NAME_H) $(MLX)
$(CC) $(OBJ) $(LIBFT) $(MLX) $(MLX_FLAGS) -o $(NAME)
$(BONUS): $(LIBFT) $(BONUS_OBJ) $(NAME_H) $(MLX)
$(CC) $(BONUS_OBJ) $(LIBFT) $(MLX) $(MLX_FLAGS) -o $(BONUS)
obj/%.o: src/%.c
$(CC) -g -Wall -Wextra -Werror -c $< -o $@
obj/bonus/%.o: src/bonus/%.c
$(CC) -g -Wall -Wextra -Werror -c $< -o $@
$(LIBFT): $(LIBFT_DIR)/*.c
@if [ ! -d obj/bonus ]; then \
mkdir -p obj/bonus; \
fi
@if [ ! -d obj/libft ]; then \
mkdir -p obj/libft; \
fi
@make -C $(LIBFT_DIR)
@cp $(LIBFT_DIR)/libft.a $(LIBFT)
@make fclean -C $(LIBFT_DIR)
$(MLX): $(MLX_DIR)
@if [ ! -d obj/mlx ]; then \
mkdir -p obj/mlx; \
fi
@make -C $(MLX_DIR)
clean:
@echo "$(MAGENTA)Cleaning object files.. $(ENDCOLOR)"
@$(RM) $(OBJ) $(BONUS_OBJ) $(LIBFT) $(MLX)
fclean: clean
@echo "$(MAGENTA)Cleaning all.. $(ENDCOLOR)"
@$(RM) $(NAME) $(BONUS)
re: clean all
.PHONY: all clean fclean re