-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
133 lines (107 loc) · 3.8 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: mrantil <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/05/04 18:22:31 by mrantil #+# #+# #
# Updated: 2022/09/21 16:22:52 by mrantil ### ########.fr #
# #
# **************************************************************************** #
#COLORS
SHELL := /bin/bash
GREEN = \033[32m
GREEN_BACKGROUND = \033[42m
WHITE_BACKGROUND = \033[47m
VIOLET_BACKGROUND = \033[0;45m
YELLOW_BACKGROUND = \033[0;43m
WHITE = \033[37m
YELLOW = \033[33m
BLACK = \033[30m
VIOLET = \033[35m
RESET = \033[0m
RED = \033[31m
CYAN = \033[36m
BOLD = \033[1m
#PRINTING TOOLS
ERASE_LINE = \033[K
UP = A
DOWN = B
RIGHT = C
LEFT = D
MOVE = \033[
#FORBID KEYBOARD INTERACT
$(shell stty -echo)
MAKEFLAGS += --no-print-directory
NAME = ft_ls
CC = gcc
CFLAGS = -Wall -Wextra -Werror
#CFLAGS += -Wunreachable-code -Wtype-limits
CFLAGS += -O3
#LEAK_CHECK = -g
#LEAK_CHECK += -fsanitize=address
SOURCES = srcs
OBJECTS = objs
INCLUDES = includes
LIBRARIES = libft
SOURCE_COUNT = $(words $(FILES))
H_FILES = ft_ls
FILES = flag_recurse \
get_data \
get_files \
init_free \
main \
print_file_props1 \
print_file_props2 \
print_files \
print_stat \
sort_it \
tools_print \
tools \
work_input
H_PATHS = $(addsuffix .h, $(addprefix $(INCLUDES)/, $(H_FILES)))
C_PATHS = $(addsuffix .c, $(addprefix $(SOURCES)/, $(FILES)))
O_PATHS = $(addsuffix .o, $(addprefix $(OBJECTS)/, $(FILES)))
LIBS = libft.a
HEADERS = -I$(INCLUDES)/ -Ilibft/includes/
ASSERT_OBJECT = && printf "$(ERASE_LINE)" && printf "$@ $(GREEN)$(BOLD) ✔$(RESET)" || printf "$@ $(RED)$(BOLD)✘$(RESET)\n"
all: libft $(NAME)
$(NAME): $(OBJECTS) $(O_PATHS)
@$(CC) $(CFLAGS) $(HEADERS) -o $@ $(O_PATHS) $(LIBS) $(LEAK_CHECK)
@printf "Compiled $(BOLD)$(GREEN)$(NAME)$(RESET)!\n\n"
$(OBJECTS):
@make -C $(LIBRARIES)
@mkdir -p $(OBJECTS)
@printf "$(GREEN)_________________________________________________________________\n$(RESET)"
@printf "$(NAME): $(GREEN)$(OBJECTS) directory was created.$(RESET)\n\n\n"
$(O_PATHS): $(OBJECTS)/%.o:$(SOURCES)/%.c $(H_PATHS) Makefile
@printf "$(MOVE)2$(UP)"
@$(CC) $(CFLAGS) $(HEADERS) -c $< -o $@ $(LEAK_CHECK) $(ASSERT_OBJECT)
@make pbar
libft:
@make -C $(LIBRARIES)
@cp $(LIBRARIES)/$(LIBS) .
clean:
@make -C $(LIBRARIES) clean
@rm -rf $(OBJECTS)
@printf "$(NAME): $(RED)$(OBJECTS) was deleted$(RESET)\n"
fclean: clean
@make -C $(LIBRARIES) fclean
@rm -f $(LIBS)
@rm -f $(NAME)
@printf "$(NAME): $(RED)binary was deleted$(RESET)\n"
re: fclean all
pbar:
$(eval LOADED_COUNT = $(words $(wildcard $(OBJECTS)/*.o)))
@printf "\r$(MOVE)76$(RIGHT)Files compiled [$(BOLD)$(GREEN)$(LOADED_COUNT)$(RESET) / $(BOLD)$(GREEN)$(SOURCE_COUNT)$(RESET)]\n"
@for ((i = 1; i <= $(LOADED_COUNT) * 100 / $(SOURCE_COUNT); i++)); do\
printf "$(GREEN_BACKGROUND) $(RESET)" ;\
done ;
@for ((i = 1; i <= 100 - ($(LOADED_COUNT) * 100 / $(SOURCE_COUNT)); i++)); do\
printf "$(WHITE_BACKGROUND) $(RESET)" ;\
done ;
@printf "$(GREEN_BACKGROUND)$(BOLD)$(WHITE)$(MOVE)55$(LEFT)[$$(($(LOADED_COUNT) * 100 / $(SOURCE_COUNT))).$$(($(LOADED_COUNT) * 1000 / $(SOURCE_COUNT) % 10))%%]$(MOVE)54$(RIGHT)$(RESET)\n"
.PHONY: all libft clean fclean re
#ALLOW KEYBOARD INTERACT
$(shell stty echo)