-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
110 lines (81 loc) · 2.72 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: lumenthi <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2017/12/22 14:06:43 by lumenthi #+# #+# #
# Updated: 2022/07/27 17:34:20 by lumenthi ### ########.fr #
# #
# **************************************************************************** #
.PHONY : all clean fclean re
NAME = ft_nm
CC = gcc
FLAGS = -Wall -Werror -Wextra -g
GREEN = '\033[4;32m'
RED = '\033[4;31m'
BLANK = '\033[0m'
YELLOW = '\033[4;33m'
CYAN = '\033[4;38;5;51m'
TICK = '\033[1;32m~\033[0m'
CROSS = '\033[1;31mx\033[0m'
###### FOLDERS ######
LIBDIR = libft
SRCDIR = sources
HEADDIR = headers
OBJDIR = objs
#####################
###### LIBRARY ######
LIBFT = $(LIBDIR)/libft.a
#####################
###### HEADERS ######
HEADS = nm.h
HEADERS = $(addprefix $(HEADDIR)/, $(HEADS))
#####################
###### SOURCES ######
SRCS = nm.c \
map.c \
list.c \
display.c \
swap.c \
section.c \
symbol.c
SOURCES = $(addprefix $(SRCDIR)/, $(SRCS))
#####################
###### OBJECTS ######
OBJS = $(addprefix $(OBJDIR)/, $(SRCS:.c=.o))
#####################
all: $(NAME)
###### FT_NM COMPILATION ######
$(NAME): $(OBJS) ${HEADERS}
@ make -sC $(LIBDIR)
$(CC) $(OBJS) -o $(NAME) $(LIBFT)
@ printf " %b | Compiled %b%b%b\n" $(TICK) $(GREEN) $(NAME) $(BLANK)
###############################
$(OBJDIR)/%.o: $(SRCDIR)/%.c
mkdir -p $(OBJDIR)
$(CC) -c $(FLAGS) -I$(HEADDIR) -I$(LIBDIR) -o $@ $<
clean:
@ make -sC $(LIBDIR) clean
@ test -d $(OBJDIR) && \
rm -rf $(OBJDIR) && \
printf " %b | " $(TICK) && \
printf "Removed %bobjects%b folders\n" $(YELLOW) $(BLANK) \
|| (printf " %b | " $(CROSS) && \
printf "No %bobjects%b folders\n" $(YELLOW) $(BLANK))
fclean: clean
@ test -f $(LIBFT) && \
rm -rf $(LIBFT) && \
printf " %b | " $(TICK) && \
printf "Removed %blibft%b library\n" $(RED) $(BLANK) \
|| (printf " %b | " $(CROSS) && \
printf "No %blibft%b library\n" $(RED) $(BLANK))
@ test -f $(NAME) && \
rm -rf $(NAME) && \
printf " %b | " $(TICK) && \
printf "Removed %b%b%b binary\n" $(RED) $(NAME) $(BLANK) \
|| (printf " %b | " $(CROSS) && \
printf "No %b%b%b binary\n" $(RED) $(NAME) $(BLANK))
re: fclean
@ $(MAKE) all