-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
134 lines (120 loc) · 4.08 KB
/
Makefile
File metadata and controls
134 lines (120 loc) · 4.08 KB
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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: jseijo-p <jseijo-p@student.42malaga.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/04/19 23:24:18 by jseijo-p #+# #+# #
# Updated: 2022/11/01 18:21:57 by cmac ### ########.fr #
# #
# **************************************************************************** #
NAME = libft.a
HEAD := -I inc/
#CFLAGS = -fsanitize=address -Wall -Wextra -Werror
CFLAGS = -Wall -Wextra -Werror
#CFLAGS = -fsanitize=address
SRCS = src/maths/ft_atoi.c \
src/maths/ft_itoa.c \
src/memory/ft_bzero.c \
src/memory/ft_calloc.c \
src/memory/ft_memchr.c \
src/memory/ft_memcmp.c \
src/memory/ft_memcpy.c \
src/memory/ft_memmove.c \
src/memory/ft_memset.c \
src/print/ft_putchar_fd.c \
src/print/ft_putstr_fd.c \
src/print/ft_putnbr_fd.c \
src/print/ft_putendl_fd.c \
src/strings/ft_array_join.c \
src/strings/ft_array_len.c \
src/strings/ft_concat_char.c \
src/strings/ft_isalnum.c \
src/strings/ft_isalpha.c \
src/strings/ft_isascii.c \
src/strings/ft_isdigit.c \
src/strings/ft_strrchr.c \
src/strings/ft_strdup.c \
src/strings/ft_isprint.c \
src/strings/ft_isset.c \
src/strings/ft_free_array.c \
src/strings/ft_split.c \
src/strings/ft_str_is_numeric.c \
src/strings/ft_strchr.c \
src/strings/ft_strlen.c \
src/strings/ft_strncmp.c \
src/strings/ft_strnstr.c \
src/strings/ft_tolower.c \
src/strings/ft_toupper.c \
src/strings/ft_strlcpy.c \
src/strings/ft_strlcat.c \
src/strings/ft_substr.c \
src/strings/ft_strjoin.c \
src/strings/ft_strtrim.c \
src/strings/ft_strmapi.c \
src/strings/ft_striteri.c \
src/lists/ft_lstadd_front.c \
src/lists/ft_lstsize.c \
src/lists/ft_lstlast.c \
src/lists/ft_lstadd_back.c \
src/lists/ft_lstnew.c \
src/lists/ft_lstdelone.c \
src/lists/ft_lstclear.c \
src/lists/ft_lstiter.c \
src/lists/ft_lstmap.c \
src/utils/ft_print_int.c \
src/utils/ft_print_p.c \
src/utils/ft_print_unint.c \
src/utils/ft_print_x.c \
src/utils/ft_printf.c \
src/utils/get_next_line.c
#color
COM_COLOR = \033[0;34m
OBJ_COLOR = \033[0;36m
OK_COLOR = \033[0;32m
ERROR_COLOR = \033[0;31m
WARN_COLOR = \033[0;33m
NO_COLOR = \033[m
OK_STRING = "[OK]"
ERROR_STRING = "[ERROR]"
WARN_STRING = "[WARNING]"
COM_STRING = "Compiling"
OBJS = $(addprefix objs/, $(SRCS:.c=.o))
define run_and_test
printf "%b" "$(COM_COLOR)$(COM_STRING) $(OBJ_COLOR)$(@F)$(NO_COLOR)\r"; \
$(1) 2> $@.log; \
RESULT=$$?; \
if [ $$RESULT -ne 0 ]; then \
printf "%-60b%b" "$(COM_COLOR)$(COM_STRING)$(OBJ_COLOR) $@" "$(ERROR_COLOR)$(ERROR_STRING)$(NO_COLOR)\n" ; \
elif [ -s $@.log ]; then \
printf "%-60b%b" "$(COM_COLOR)$(COM_STRING)$(OBJ_COLOR) $@" "$(WARN_COLOR)$(WARN_STRING)$(NO_COLOR)\n" ; \
else \
printf "%-60b%b" "$(COM_COLOR)$(COM_STRING)$(OBJ_COLOR) $(@F)" "$(OK_COLOR)$(OK_STRING)$(NO_COLOR)\n" ; \
fi; \
cat $@.log; \
rm -f $@.log; \
exit $$RESULT
endef
all: $(NAME)
$(NAME): $(OBJS)
@ar rcs $(NAME) $(OBJS)
@echo ' '
@echo '......( \_/ ) '
@echo '......( o_o ) '
@echo '..../""""""""""""\======░ ▒▓▓█D' "$(WARN_COLOR)\t$(NAME)\t $(OK_COLOR) [Happy coding]$(NO_COLOR)";
@echo '/"""""""""""""""""""\ '
@echo '\_@_@_@_@_@_@_@_@_@_/'
@echo ' '
objs/%.o: %.c
@mkdir -p $(dir $@)
@$(call run_and_test,gcc $(CFLAGS) $(HEAD) -c $< -o $@)
clean:
/bin/rm -f $(OBJS)
@echo $(OBJS) cleaned.
fclean: clean
rm -f $(NAME)
@echo $(NAME) cleaned.
re: fclean
$(MAKE)
.PHONY: all, clean, fclean, re