-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
114 lines (88 loc) · 3.33 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: ajordan- <ajordan-@student.42urduliz.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/07/27 09:39:13 by ajordan- #+# #+# #
# Updated: 2021/10/20 10:00:41 by ajordan- ### ########.fr #
# #
# **************************************************************************** #
#Standard
NAME = libft.a
INCLUDES = include/
SRC_DIR = src/
OBJ_DIR = obj/
CC = gcc
CFLAGS = -Wall -Werror -Wextra -I
RM = rm -f
AR = ar rcs
#Colors
DEF_COLOR = \033[0;39m
GRAY = \033[0;90m
RED = \033[0;91m
GREEN = \033[0;92m
YELLOW = \033[0;93m
BLUE = \033[0;94m
MAGENTA = \033[0;95m
CYAN = \033[0;96m
WHITE = \033[0;97m
#Sources
FTIS_DIR = ft_is/
FTIS = ft_isalnum ft_isalpha ft_isascii ft_isdigit ft_isprint
FTMEM_DIR = ft_mem/
FTMEM = ft_bzero ft_calloc ft_memchr ft_memcmp ft_memmove ft_memset
FTPUT_DIR = ft_put/
FTPUT = ft_putchar_fd ft_putendl_fd ft_putnbr_fd ft_putstr_fd
FTTO_DIR = ft_to/
FTTO = ft_atoi ft_itoa ft_tolower ft_toupper
FTSTR_DIR = ft_str/
FTSTR = ft_split ft_strchr ft_strdup ft_striteri ft_strjoin \
ft_strlcat ft_strlcpy ft_strlen ft_strmapi ft_strncmp \
ft_strnstr ft_strrchr ft_strtrim ft_substr
FTLST_DIR = ft_lst/
FTLST = ft_lstadd_back ft_lstadd_front ft_lstclear ft_lstdelone \
ft_lstiter ft_lstlast ft_lstmap ft_lstnew ft_lstsize
SRC_FILES+=$(addprefix $(FTIS_DIR),$(FTIS))
SRC_FILES+=$(addprefix $(FTMEM_DIR),$(FTMEM))
SRC_FILES+=$(addprefix $(FTPUT_DIR),$(FTPUT))
SRC_FILES+=$(addprefix $(FTTO_DIR),$(FTTO))
SRC_FILES+=$(addprefix $(FTSTR_DIR),$(FTSTR))
BONUS_FILES+=$(addprefix $(FTLST_DIR),$(FTLST))
SRC = $(addprefix $(SRC_DIR), $(addsuffix .c, $(SRC_FILES)))
OBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(SRC_FILES)))
BONUS_OBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(BONUS_FILES)))
###
OBJF = .cache_exists
all: $(NAME)
$(NAME): $(OBJ)
@$(AR) $(NAME) $(OBJ)
@ranlib $(NAME)
@echo "$(GREEN)Libft compiled!$(DEF_COLOR)"
$(OBJ_DIR)%.o : $(SRC_DIR)%.c | $(OBJF)
@echo "$(YELLOW)Compiling: $< $(DEF_COLOR)"
@$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(OBJF):
@mkdir -p $(OBJ_DIR)
@mkdir -p $(OBJ_DIR)$(FTIS_DIR)
@mkdir -p $(OBJ_DIR)$(FTMEM_DIR)
@mkdir -p $(OBJ_DIR)$(FTPUT_DIR)
@mkdir -p $(OBJ_DIR)$(FTTO_DIR)
@mkdir -p $(OBJ_DIR)$(FTSTR_DIR)
@mkdir -p $(OBJ_DIR)$(FTLST_DIR)
bonus: $(BONUS_OBJ)
@$(AR) $(NAME) $(BONUS_OBJ)
@echo "$(GREEN)Libft bonus compiled!$(DEF_COLOR)"
clean:
@$(RM) -rf $(OBJ_DIR)
@$(RM) -f $(OBJF)
@echo "$(BLUE)Libft objects files cleaned!$(DEF_COLOR)"
fclean: clean
@$(RM) -f $(NAME)
@echo "$(CYAN)Libft executable files cleaned!$(DEF_COLOR)"
re: fclean all
@echo "$(GREEN)Cleaned and rebuilt everything for libft!$(DEF_COLOR)"
norm:
@norminette $(SRC) $(INCLUDES) | grep -v Norme -B1 || true
.PHONY: all clean fclean re norm