-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
162 lines (146 loc) · 5.34 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# **************************************************************************** #
# LE - / #
# / #
# Makefile .:: .:/ . .:: #
# +:+:+ +: +: +:+:+ #
# By: wblondel <[email protected]> +:+ +: +: +:+ #
# #+# #+ #+ #+# #
# Created: 2018/03/29 22:47:41 by wblondel #+# ## ## #+# #
# Updated: 2018/04/24 17:20:10 by wblondel ### #+. /#+ ###.fr #
# / #
# / #
# **************************************************************************** #
# Compiler configuration
CC = gcc
CFLAGS = -Wall -Wextra -Werror -O2
## Flags for the C preprocessor
CPPFLAGS = -I$(INC_PATH)
## Name of the library
NAME = libft.a
# Project related variables
SRC_PATH = src
SRC_NAME =\
basics/chars/check/ft_isalnum.c\
basics/chars/check/ft_isalpha.c\
basics/chars/check/ft_isascii.c\
basics/chars/check/ft_isblank.c\
basics/chars/check/ft_iscntrl.c\
basics/chars/check/ft_isdigit.c\
basics/chars/check/ft_isgraph.c\
basics/chars/check/ft_islower.c\
basics/chars/check/ft_isprint.c\
basics/chars/check/ft_ispunct.c\
basics/chars/check/ft_isspace.c\
basics/chars/check/ft_isupper.c\
basics/chars/output/ft_putchar_fd.c\
basics/chars/output/ft_putchar.c\
basics/chars/transform/ft_tolower.c\
basics/chars/transform/ft_toupper.c\
basics/maths/ft_abs.c\
basics/maths/ft_factorial.c\
basics/maths/ft_gcd.c\
basics/maths/ft_labs.c\
basics/maths/ft_lcm.c\
basics/maths/ft_sqrt.c\
basics/memory/create/ft_memalloc.c\
basics/memory/delete/ft_memdel.c\
basics/memory/iterate/ft_memchr.c\
basics/memory/iterate/ft_memcmp.c\
basics/memory/transform/ft_bzero.c\
basics/memory/transform/ft_memccpy.c\
basics/memory/transform/ft_memcpy.c\
basics/memory/transform/ft_memmove.c\
basics/memory/transform/ft_memset.c\
basics/memory/transform/ft_swap_c.c\
basics/memory/transform/ft_swap_i.c\
basics/memory/transform/ft_swap.c\
basics/numbers/convers/ft_atoi.c\
basics/numbers/convers/ft_itoa.c\
basics/numbers/maths/ft_intlen.c\
basics/numbers/output/integers/ft_putnbr_fd.c\
basics/numbers/output/integers/ft_putnbr.c\
basics/strings/create/ft_strdup.c\
basics/strings/create/ft_strjoin.c\
basics/strings/create/ft_strmap.c\
basics/strings/create/ft_strmapi.c\
basics/strings/create/ft_strndup.c\
basics/strings/create/ft_strnew.c\
basics/strings/create/ft_strnjoin.c\
basics/strings/create/ft_strsplit.c\
basics/strings/create/ft_strsub.c\
basics/strings/create/ft_strtrim.c\
basics/strings/delete/ft_strdel.c\
basics/strings/iterate/ft_str_endswith.c\
basics/strings/iterate/ft_str_startswith.c\
basics/strings/iterate/ft_strchr.c\
basics/strings/iterate/ft_strcmp.c\
basics/strings/iterate/ft_strcountwords.c\
basics/strings/iterate/ft_strequ.c\
basics/strings/iterate/ft_striter.c\
basics/strings/iterate/ft_striteri.c\
basics/strings/iterate/ft_strlen.c\
basics/strings/iterate/ft_strncmp.c\
basics/strings/iterate/ft_strnequ.c\
basics/strings/iterate/ft_strnstr.c\
basics/strings/iterate/ft_strrchr.c\
basics/strings/iterate/ft_strstr.c\
basics/strings/output/ft_putendl_fd.c\
basics/strings/output/ft_putendl.c\
basics/strings/output/ft_putstr_fd.c\
basics/strings/output/ft_putstr.c\
basics/strings/transform/ft_strcat.c\
basics/strings/transform/ft_strclr.c\
basics/strings/transform/ft_strcpy.c\
basics/strings/transform/ft_strlcat.c\
basics/strings/transform/ft_strmerge.c\
basics/strings/transform/ft_strncat.c\
basics/strings/transform/ft_strncpy.c\
basics/strings/transform/ft_strrev.c\
basics/strings/transform/ft_strtolower.c\
basics/strings/transform/ft_strtoupper.c\
containers/list/ft_lstadd.c\
containers/list/ft_lstdel.c\
containers/list/ft_lstdelone.c\
containers/list/ft_lstiter.c\
containers/list/ft_lstmap.c\
containers/list/ft_lstnew.c\
utils/file/ft_readline.c
SRC = $(addprefix $(SRC_PATH)/,$(SRC_NAME))
OBJ_PATH = obj
OBJ_NAME = $(SRC_NAME:.c=.o)
OBJ = $(addprefix $(OBJ_PATH)/,$(OBJ_NAME))
OBJS_DIRS = $(sort $(dir $(OBJ)))
INC_PATH = inc
INC_NAME =\
libft/basics/booleans.h\
libft/basics/chars.h\
libft/basics/maths.h\
libft/basics/memory.h\
libft/basics/numbers.h\
libft/basics/strings.h\
libft/containers/list.h
HEADER = $(addprefix $(INC_PATH)/,$(INC_NAME))
# Entry point
all: $(NAME)
# Compiles libft
$(NAME): $(OBJ)
ar rcs $(NAME) $(OBJ)
# Creates obj/ directory
# It's a prerequisite to compile any OBJ
$(OBJS_DIRS):
mkdir -p $@
# Adds the dependency to create the directory
# before to compile an object
$(OBJ): | $(OBJS_DIRS)
# Compiles all the src into obj
$(OBJ_PATH)/%.o: $(SRC_PATH)/%.c $(HEADER)
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
.PHONY: clean
clean:
$(RM) -r $(OBJ_PATH)
.PHONY: fclean
fclean: clean
$(RM) -r $(NAME) $(NAME).dSYM
.PHONY: re
re: fclean
$(MAKE) all