-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
143 lines (122 loc) · 3.4 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: jre-gonz <[email protected] +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/05/25 09:47:39 by jre-gonz #+# #+# #
# Updated: 2023/04/27 21:57:47 by jre-gonz ### ########.fr #
# #
# **************************************************************************** #
# Binaries variables
BIN = bin# Bin location
SRC = src# Source location
INCLUDE_L = include# Include location
# Compiler options
CC = gcc
FLAGS = -Wall -Wextra -Werror
INCLUDE = -I./$(INCLUDE_L)
COMPILE = @$(CC) $(FLAGS) $(INCLUDE)
NAME = libft.a
# Colors:
NC = \033[0m
RED = \033[0;31m
GREEN = \033[0;32m
LRED = \033[1;31m
LGREEN = \033[1;32m
YELLOW = \033[1;33m
LBLUE = \033[1;34m
TITLE = \033[38;5;33m
# Default libft code
GNL = get_next_line.c
PRINTF = ft_printf.c
ANALYZE = ft_atoi.c \
ft_hasany.c \
ft_isalnum.c \
ft_isalpha.c \
ft_isascii.c \
ft_isdigit.c \
ft_islower.c \
ft_isnbr.c \
ft_isprint.c \
ft_isupper.c \
ft_itoa_base.c \
ft_itoa.c \
ft_memchr.c \
ft_memcmp.c \
ft_ndigits.c \
ft_ndigits_base.c \
ft_pdigits_base.c \
ft_ptoa_base.c \
ft_strchr.c \
ft_strcmp.c \
ft_strlen.c \
ft_strncmp.c \
ft_strnstr.c \
ft_strrchr.c
LIST = ft_lstadd_back_bonus.c \
ft_lstadd_front_bonus.c \
ft_lstclear_bonus.c \
ft_lstdelone_bonus.c \
ft_lstiter_bonus.c \
ft_lstlast_bonus.c \
ft_lstmap_bonus.c \
ft_lstnew_bonus.c \
ft_lstsize_bonus.c
MODIFY = ft_bzero.c \
ft_calloc.c \
ft_free_array.c \
ft_memcpy.c \
ft_memmove.c \
ft_memset.c \
ft_split.c \
ft_strdup.c \
ft_striteri.c \
ft_strjoin.c \
ft_strlcat.c \
ft_strlcpy.c \
ft_strmapi.c \
ft_strtoupper.c \
ft_strtrim.c \
ft_substr.c \
ft_tolower.c \
ft_toupper.c
PRINT = ft_putchar_fd.c \
ft_putchar_fd_l.c \
ft_putendl_fd.c \
ft_putnbr_fd.c \
ft_put_pointer_fd.c \
ft_putstr_fd.c \
ft_putstr_fd_l.c \
ft_put_memory.c
LIBFT_SRC = $(GNL:%=get_next_line/%) \
$(PRINTF:%=ft_printf/%) \
$(ANALYZE:%=analyze/%) \
$(MODIFY:%=modify/%) \
$(PRINT:%=print/%) \
$(LIST:%=list/%) # Bonus
SOURCE = $(LIBFT_SRC) # Libft files
SRC_CODE = $(SOURCE:%=$(SRC)/%)
OBJ = $(SRC_CODE:$(SRC)/%.c=$(BIN)/%.o)
# Triggers
all: $(NAME)
$(NAME): $(OBJ)
@echo "\n${TITLE}Compiling${NC} ${YELLOW}libft${NC} into ${YELLOW}$(NAME)${NC}\c"
@ar -rcs $(NAME) $(OBJ)
@echo " ${GREEN}[OK]${NC}\n"
$(BIN)/%.o: $(SRC)/%.c
@echo "- ${TITLE}Compiling${NC} $< -> $@\c"
@mkdir -p ${dir $@}
@$(COMPILE) -c $< -o $@
@echo " ${GREEN}[OK]${NC}"
# Clean logic
.PHONY: re fclean
re: fclean all
fclean: clean
@echo "- ${RED}Removing${NC} $(NAME)"
@rm -f $(NAME)
@echo "Project ${YELLOW}Libft ${GREEN}clean${NC}.\n"
clean:
@echo "- ${RED}Removing${NC} binary directory"
@rm -rf $(BIN)