-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
113 lines (100 loc) · 3.9 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: eschirni <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/06/10 15:43:54 by eschirni #+# #+# #
# Updated: 2022/09/06 20:35:07 by eschirni ### ########.fr #
# #
# **************************************************************************** #
# FLAGS
BREW = $(shell which brew | rev | cut -c 9- | rev)
VERSION = $(shell ls $(BREW)/Cellar/glfw/)
CFLAGS = -Wall -Wextra -Werror -Ofast
MLX = -lglfw -L $(BREW)/Cellar/glfw/$(VERSION)/lib MLX42/libmlx42.a
# COLORS
Y = "\033[33m"
R = "\033[31m"
G = "\033[32m"
B = "\033[36m"
X = "\033[0m"
# EXECUTABLE
NAME = ./cub3D
# PATHS
SRC_PATH = ./src/
OBJ_PATH = ./obj/
UTILS_PATH = ./src/utils/
DRAW_PATH = ./src/draw_functions/
MAIN_MENU_PATH = ./src/main_menu/
MAPGEN_PATH = ./src/map_gen/
# SOURCES
SRC = $(SRC_PATH)main.c $(SRC_PATH)init_map.c \
$(SRC_PATH)char_direction.c $(SRC_PATH)hooks.c \
$(SRC_PATH)ray.c $(SRC_PATH)game_end.c \
$(SRC_PATH)enemies.c \
$(UTILS_PATH)ft_error.c $(UTILS_PATH)utils.c \
$(UTILS_PATH)free_exit.c $(UTILS_PATH)hooks_utils.c \
$(UTILS_PATH)gameplay_utils.c $(UTILS_PATH)ft_append.c\
$(UTILS_PATH)ft_itoa.c $(UTILS_PATH)ft_strcdup.c \
$(UTILS_PATH)end_utils.c \
$(DRAW_PATH)draw_game.c $(DRAW_PATH)draw_crosshair.c \
$(DRAW_PATH)draw_map.c $(DRAW_PATH)draw.c \
$(DRAW_PATH)draw_chars.c $(DRAW_PATH)draw_3d.c \
$(DRAW_PATH)torch.c $(DRAW_PATH)draw_sprites.c \
$(DRAW_PATH)draw_utils.c \
$(MAIN_MENU_PATH)main_menu.c $(MAIN_MENU_PATH)hooks.c \
$(MAIN_MENU_PATH)settings.c $(MAIN_MENU_PATH)animations.c \
$(MAIN_MENU_PATH)switch_menu.c $(MAIN_MENU_PATH)menu_sliders.c \
$(MAIN_MENU_PATH)animate_scroll_text.c $(MAIN_MENU_PATH)init_textures.c \
$(MAIN_MENU_PATH)hover.c \
$(MAPGEN_PATH)generate_map.c $(MAPGEN_PATH)mapgen_utils.c \
$(MAPGEN_PATH)mapgen_utils2.c \
# OBJECTS
OBJ = $(patsubst $(SRC_PATH)%.c, $(OBJ_PATH)%.o, $(SRC))
# RULES
all: $(NAME)
@echo $(B)
@echo " _| _|_|_| _|_|_| "
@echo " _|_|_| _| _| _|_|_| _| _| _|"
@echo " _| _| _| _| _| _|_| _| _|"
@echo " _| _| _| _| _| _| _| _|"
@echo " _|_|_| _|_|_| _|_|_| _|_|_| _|_|_| "
@echo $(X)
$(OBJ_PATH)%.o :$(SRC_PATH)%.c
@if ! [ -d $$HOME/.brew/ ] && ! [ -d $$HOME/goinfre/.brew/ ]; then \
echo $(R)"brew not found!"; \
echo $(Y)"installing brew"; \
git clone --depth=1 https://github.com/Homebrew/brew $$HOME/.brew && echo 'export PATH=$$HOME/.brew/bin:$$PATH' >> $$HOME/.zshrc && source $$HOME/.zshrc && brew update; \
fi;
@if [ -z $(VERSION) ]; then \
echo $(R)"glfw not found!"; \
echo $(Y)"installing glfw"; \
brew install glfw; \
fi;
@echo $(Y)Compiling [$@]...$(X)
@mkdir -p $(dir $@)
@gcc $(CFLAGS) -c -o $@ $<
@echo $(G)Finished [$@]$(X)
$(NAME): $(OBJ)
@echo $(Y)Compiling [$(SRC)]
@echo into [$(NAME)]...$(X)
@cd MLX42 && make
@gcc $(CFLAGS) $(MLX) $(OBJ) -o $(NAME)
@echo $(G)Finished [$(NAME)]$(X)
clean:
@if [ -d "$(OBJ_PATH)" ]; then \
rm -rf $(OBJ_PATH); \
echo $(R)Cleaning" "[$(OBJ) $(OBJ_PATH)]...$(X); else \
echo "No objects to remove."; \
fi;
@cd MLX42 && make clean
fclean: clean
@if [ -f "$(NAME)" ]; then \
rm -f $(NAME); \
echo $(R)Cleaning" "[$(NAME)]...$(X);else \
echo "No executable to remove."; \
fi;
re: fclean all
.PHONY: all, clean, fclean, re