-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
140 lines (111 loc) · 2.83 KB
/
Copy pathMakefile
File metadata and controls
140 lines (111 loc) · 2.83 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
135
136
137
138
139
140
NAME := libft.a
SRC_DIR := ./src
OBJ_DIR := ./obj
INC_DIR := ./include
INCLUDE := -I $(INC_DIR)
COMPILE = $(CC) $(FLAGS)
#===============================================#
#=================== SOURCES ===================#
#===============================================#
SRC_DIR_ASCII := /ascii
SRC_ASCII := ft_isalnum.c \
ft_isalpha.c \
ft_isascii.c \
ft_isdigit.c \
ft_isprint.c \
SRC_DIR_CONVERT := /convert
SRC_CONVERT := ft_atoi.c \
ft_itoa.c \
ft_tolower.c \
ft_toupper.c
SRC_DIR_LST := /list
SRC_LST := ft_lstadd_back.c \
ft_lstclear.c \
ft_lstiter.c \
ft_lstmap.c \
ft_lstsize.c \
ft_lstadd_front.c \
ft_lstdelone.c \
ft_lstlast.c \
ft_lstnew.c
SRC_DIR_MEM := /mem
SRC_MEM := ft_bzero.c \
ft_calloc.c \
ft_memchr.c \
ft_memcmp.c \
ft_memcpy.c \
ft_memmove.c \
ft_memset.c
SRC_DIR_PRINTF := /printf
SRC_PRINTF := ft_printf.c \
helpers.c \
hex_helpers.c \
num_helpers.c
SRC_DIR_GNL := /gnl
SRC_GNL := get_next_line.c \
get_next_line_utils.c
SRC_DIR_PUT := /put
SRC_PUT := ft_putchar_fd.c \
ft_putendl_fd.c \
ft_putnbr_fd.c \
ft_putstr_fd.c
SRC_DIR_STR := /string
SRC_STR := ft_free_split.c \
ft_split.c \
ft_strchr.c \
ft_strdup.c \
ft_striteri.c \
ft_strjoin.c \
ft_strlcat.c \
ft_strlcpy.c \
ft_strlen.c \
ft_strmapi.c \
ft_strncmp.c \
ft_strnstr.c \
ft_strrchr.c \
ft_strtrim.c \
ft_substr.c
SRC := $(addprefix $(SRC_DIR_ASCII)/,$(SRC_ASCII)) \
$(addprefix $(SRC_DIR_CONVERT)/,$(SRC_CONVERT)) \
$(addprefix $(SRC_DIR_LST)/,$(SRC_LST)) \
$(addprefix $(SRC_DIR_GNL)/,$(SRC_GNL)) \
$(addprefix $(SRC_DIR_MEM)/,$(SRC_MEM)) \
$(addprefix $(SRC_DIR_PRINTF)/,$(SRC_PRINTF)) \
$(addprefix $(SRC_DIR_PUT)/,$(SRC_PUT)) \
$(addprefix $(SRC_DIR_STR)/,$(SRC_STR))
SRC := $(SRC:%=$(SRC_DIR)%)
OBJ := $(SRC:$(SRC_DIR)%.c=$(OBJ_DIR)%.o)
OBJ_SUB_DIRS := $(sort $(dir $(OBJ)))
DEP := $(OBJ:%.o=%.d)
#===============================================#
#=================== UTENSILS ==================#
#===============================================#
CC = gcc
FLAGS = -Wall -Werror -Wextra
RM = rm -rf
#===============================================#
#=================== RECIPES ===================#
#===============================================#
-include $(DEP)
echo:
@echo $(OBJ)
echo
@echo $(SRC)
echo
@echo $(DEP)
all : $(NAME)
$(NAME) : $(OBJ)
@ar -crs $(NAME) $^
@echo "ar rcs $(NAME) $(OBJ_DIR)/*/*.o"
$(OBJ_SUB_DIRS):
@mkdir -p $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_SUB_DIRS)
@$(CC) $(FLAGS) $(INCLUDE) -c $< -o $@
$(OBJ_DIR)/%.o : %.c
@$(COMPILE) -MMD $(HEADER) -c $< -o $@
re: fclean all
clean :
@rm -rf $(OBJ)
fclean : clean
@rm -f $(NAME)
.DEFAULT_GOAL := all