-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
143 lines (109 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# -- PROJECT VARIABLES & COMMANDS --
NAME = fdf
CC = gcc
CFLAGS = -Wall -Werror -Wextra
CPPFLAGS = -I $(INC_DIR) -I $(LIBFT_DIR) -I $(LIBGR_DIR)
DEPFLAGS = -MMD
SHELL = /bin/bash
LDMAKE = make -C
MKDIR = mkdir -p
RMDIR = rm -rf
RM = rm -f
NORM = norminette
# -- LIBRARIES --
LDLIBS = -lft -lgraphic -lpthread -framework OpenGL -framework AppKit
LDFLAGS = -L $(LIBFT_DIR) -L $(LIBGR_DIR)
LIBFT_DIR = libft
LIBFT_LIB = $(LIBFT_DIR)/libft.a
LIBGR_DIR = libgraphic
LIBGR_LIB = $(LIBGR_DIR)/libgraphic.a
# -- PATHS NAMES --
SRC_DIR = sources
INC_DIR = includes
OBJ_DIR = .objects
# -- PROJECT FILES --
FILES = main_fdf \
hook_mlx \
hook_utils \
parse_input \
parse_utils \
env_utils \
draw_utils \
color_init \
color_utils \
help_utils \
help_texts \
debug_utils \
world_utils \
window_utils \
clear_frame \
fastline_fdf \
OBJECTS = $(patsubst %,$(OBJ_DIR)/%,$(FILES:=.o))
# -- IMPLICIT RULES / LINKING --
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c Makefile
@$(eval DONE=$(shell echo $$(($(INDEX)*20/$(NB)))))
@$(eval PERCENT=$(shell echo $$(($(INDEX)*100/$(NB)))))
@$(eval TO_DO=$(shell echo $$((20-$(INDEX)*20/$(NB) - 1))))
@$(eval COLOR=$(shell list=(160 196 202 208 215 221 226 227 190 154 118 82 46); index=$$(($(PERCENT) * $${#list[@]} / 100)); echo "$${list[$$index]}"))
@printf "\r> $(YELLOW)$(NAME)$(EOC) : Building objects... %2d%% $(CNO)[`printf '#%.0s' {0..$(DONE)}`%*s]$(YELLOW)%*.*s%s$(EOC)$(ERASELN)" $(PERCENT) $(COLOR) $(TO_DO) "" $(DELTA) $(DELTA) "$(shell echo "$@" | sed 's/^.*\///')"
@$(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS) $(DEPFLAGS)
@$(eval INDEX=$(shell echo $$(($(INDEX)+1))))
# -- RULES --
all: $(LIBFT_LIB) $(LIBGR_LIB)
@$(MAKE) -j $(NAME)
$(NAME): $(LIBFT_LIB) $(LIBGR_LIB) $(OBJ_DIR) $(OBJECTS)
@$(CC) $(LDLIBS) $(LDFLAGS) $(OBJECTS) -o $@
@printf "\r$(ERASELN)$(GREEN_B)✓$(EOC) $(YELLOW)$(NAME)$(EOC) : Binary created\n"
$(LIBFT_LIB):
@$(MAKE) -C $(LIBFT_DIR)
$(LIBGR_LIB):
@$(MAKE) -C $(LIBGR_DIR)
$(OBJ_DIR):
@$(MKDIR) $(OBJ_DIR)
clean: libclean
@if [ -e $(OBJ_DIR) ]; \
then \
$(RMDIR) $(OBJ_DIR); \
printf "$(RED_B)✗$(EOC) $(YELLOW)$(NAME)$(EOC) : Objects deleted\n"; \
fi;
fclean: clean libfclean
@if [ -e $(NAME) ]; \
then \
$(RM) $(NAME); \
printf "$(RED_B)✗$(EOC) $(YELLOW)$(NAME)$(EOC) : Binary deleted\n"; \
fi;
re: fclean all
norm:
@$(NORM) $(SRC_DIR)
@$(NORM) $(INC_DIR)
lib:
@$(MAKE) $(LIBFT_LIB)
@$(MAKE) $(LIBGR_LIB)
libclean:
@$(MAKE) -C $(LIBFT_DIR) clean
@$(MAKE) -C $(LIBGR_DIR) clean
libfclean:
@$(MAKE) -C $(LIBFT_DIR) fclean
@$(MAKE) -C $(LIBGR_DIR) fclean
libre: libfclean lib
libnorm:
@$(MAKE) -C $(LIBFT_DIR) norm
@$(MAKE) -C $(LIBGR_DIR) norm
.PHONY: all clean libclean fclean libfclean re libre norm libnorm
-include $(OBJECTS:.o=.d)
# -- DISPLAY --
LEN_NAME = `printf "%s" $(NAME) |wc -c`
DELTA = $$(echo "$$(tput cols)-54-$(LEN_NAME)"|bc)
NB = $(words $(FILES))
INDEX= 0
ERASELN = \033[K
CNO = \033[38;5;%dm
YELLOW = \e[31;33m
YELLOW_B = \e[31;33;1m
GREEN = \e[32m
GREEN_B = \e[32;1m
RED = \e[31m
RED_B = \e[31;1m
WHITE = \e[37m
WHITE_B = \e[37;1m
EOC = \e[0m