-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
106 lines (79 loc) · 2.39 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: thdelmas <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2019/05/12 15:20:07 by thdelmas #+# #+# #
# Updated: 2019/11/02 15:45:29 by thdelmas ### ########.fr #
# #
# **************************************************************************** #
NAME := libft.a
PROJECT := LIBFT
RM = /bin/rm
### Directories ###
SRC_DIR := ./srcs
INC_DIR := ./includes
OBJ_DIR := ./.obj
### SUB FILES ###
SUB_DIRS := \
conv \
int \
opt \
lst \
math \
mem \
str \
print \
tab_str
### INCLUDE SRC MAKEFILE ###
include $(SRC_DIR)/sources.mk
### INCLUDE INC MAKEFILE ###
include $(INC_DIR)/includes.mk
### ALL SUB DIRS ###
SRC_SUB_DIRS = $(addprefix $(SRC_DIR)/,$(SUB_DIRS))
OBJ_SUB_DIRS = $(addprefix $(OBJ_DIR)/,$(SUB_DIRS))
INC_SUB_DIRS = $(addprefix $(INC_DIR)/,$(SUB_DIRS))
### MAIN AND SUB FILES ###
O_FILES = $(C_FILES:.c=.o)
### Full Paths ###
SRC = $(addprefix $(SRC_DIR)/,$(C_FILES))
OBJ = $(addprefix $(OBJ_DIR)/,$(O_FILES))
INC = $(addprefix $(INC_DIR)/,$(H_FILES))
### CC && FLAGS ###
CC = clang
DEBUG_FLAGS= -g3
CFLAGS = $(addprefix -I ,$(INC_DIR) $(INC_SUB_DIRS)) \
$(DEBUG_FLAGS) \
-Wall -Werror -Wextra
LFLAGS = \
.PHONY: all clean fclean re
all: hey_msg $(FT_LIB) $(NAME) bye_msg
### Mkdir obj ###
.ONESHELL:
$(OBJ_DIR): mkdir_msg
mkdir -p $(OBJ_DIR) $(OBJ_SUB_DIRS)
### Compilation ###
.ONESHELL:
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(INC) Makefile | compil_msg
@echo "$(RCURSOR)$(ERASEL)$(@F) \c"
@$(CC) $(LFlAGS) $(CFLAGS) -o $@ -c $<
### Link ###
.ONESHELL:
$(NAME): $(OBJ_DIR) $(OBJ) | link_msg
@ar rcs $(NAME) $(OBJ)
@printf "$@: Done !\n"
.ONESHELL:
test: re
./$(NAME)
### Clean ###
.ONESHELL:
clean: clean_msg
$(RM) -rf $(OBJ_DIR)
.ONESHELL:
fclean: clean fclean_msg
$(RM) -rf $(NAME)
re: fclean all
### INCLUDE TOOLS MAKEFILE ###
include ./tools.mk