-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
194 lines (166 loc) · 5.67 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: antoda-s <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/10/24 21:23:27 by antoda-s #+# #+# #
# Updated: 2024/04/03 22:43:01 by antoda-s ### ########.fr #
# #
# **************************************************************************** #
# name
NAME = minishell
# libs and includes
LIBFT = libft.a
LFT_PATH = ./libft/
# includes dir
INCLUDES = ./include/
# sources and objects dirs
SRCDIR = srcs/
OBJDIR = build/
# sources and objects base project
# FILES = main.c # Top level function
FILES = 000_auth.c
FILES += 100_main.c
FILES += 200_signal.c
FILES += 205_signal_hd.c
FILES += 300_parser.c
FILES += 301_parser_syntax.c
FILES += 302_parser_cmd.c
FILES += 303_parser_argc.c
FILES += 304_parser_redir.c
FILES += 305_parser_heredoc.c
FILES += 400_termios.c
FILES += 500_tk_blank.c
FILES += 501_tk_builder.c
FILES += 502_tk_xpd.c
FILES += 503_tk_xpd_lst.c
FILES += 504_tk_xpd_count.c
FILES += 505_tk_xpd_filler.c
FILES += 506_tk_xpd_split.c
FILES += 507_tk_quotes.c
FILES += 508_tk_var_name.c
FILES += 600_env_setter.c
FILES += 610_env_getter.c
FILES += 700_exec_start.c
FILES += 705_exec_type.c
FILES += 710_exec_one.c
FILES += 711_exec_bi.c
FILES += 712_exec_ve.c
FILES += 720_exec_many.c
FILES += 730_exec_childs.c
FILES += 731_exec_go.c
FILES += 740_exec_redirs.c
FILES += 750_exec_heredoc.c
FILES += 760_exec_pipes.c
FILES += 810_bi_echo.c
FILES += 820_bi_cd.c
FILES += 830_bi_pwd.c
FILES += 840_bi_export.c
FILES += 845_bi_export_status.c
FILES += 850_bi_unset.c
FILES += 860_bi_env.c
FILES += 870_bi_exit.c
FILES += 880_bi_equal.c
FILES += 890_bi_append.c
FILES += 900_free.c
FILES += 910_errors_bi.c
FILES += 911_errors_exec.c
SRC = $(addprefix $(SRCDIR), $(FILES))
OBJ = $(addprefix $(OBJDIR), $(FILES:.c=.o))
#compilation
CC = cc
CF = -Wall -Wextra -Werror
I_HEADER = -I include
I_LIBFT = -I libft
LNK_LIBFT = -L $(LFT_PATH) -lft
LNK_READLINE = -lreadline
LEAKS = valgrind
LEAKS_FILE = valgrind-log.txt
LF = --leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--verbose \
--log-file=$(LEAKS_FILE) \
./$(NAME)
# common commands
RM = rm -f
#Colors:
GRN = \e[38;5;118m
YLW = \e[38;5;226m
RED = \e[38;5;196m
BLU = \e[38:5:31m
WTH = \e[0m
CYN = \33[1;36m
RESET = \033[0m
BOLD = \033[1m
# messages
_INFO = $(WTH)[$(CYN) INFO$(WTH)]
_SUCCESS = $(WTH)[$(GRN)$(BOLD)READY$(WTH)]
_WARNING = $(WTH)[$(YLW)WARNING$(WTH)]
_ERROR = $(WTH)[$(RED)ERROR$(WTH)]
# rules
all: $(LIBFT) $(NAME)
@printf "\n$(_SUCCESS) $(GRN)$(NAME) executable ready!$(WTH)\n\n"
$(NAME): $(OBJ)
@printf "\n$(_SUCCESS) $(GRN)$(NAME) objects ready! $(WTH)\n"
@printf "\n$(_INFO) $(CYN)Generating $(NAME) executable...$(WTH)\n"
$(CC) $(CF) $(OBJ) $(LNK_LIBFT) $(LNK_READLINE) -o $@
@printf "$(GRN)█$(WHT)"
mkbuilddir:
@mkdir -p $(OBJDIR)
@printf "\n$(_INFO) $(CYN)Compiling source files...$(WTH)\n"
$(OBJDIR)%.o: $(SRCDIR)%.c | mkbuilddir
# @printf "$(_INFO) $(CYN)Compiling source files...$(WTH)%-33.33s\r" $@
$(CC) $(CF) -c $(I_LIBFT) $(I_HEADER) $< -o $@
@printf "$(YLW)█$(WHT)"
$(LIBFT):
@printf "\n$(_INFO) $(CYN)Generating Libft...$(WTH)\n"
@make -s -C $(LFT_PATH)
# @printf "$(_INFO) $(GRN)Libft created!$(WTH)\n\n"
re: fclean all
leaks:
$(LEAKS) $(LF)
@printf "$(GRN)Leaks log ready! Check valgrind-out.txt $(WTH)\n\n"
cleanleaks:
@$(RM) $(LEAKS_FILE)
clean:
@printf "\n$(YLW)Cleaning all object files from project...$(WTH)\n"
$(RM) -rf $(OBJ) $(OBJDIR)
@printf "$(GRN)All object files removed!$(WTH)\n\n"
fclean: clean
@printf "\n$(YLW)Cleaning $(NAME) and additional files...$(WTH)\n"
@$(RM) -rf $(NAME)
@printf "$(GRN)$(NAME) and additional files removed!$(WTH)\n\n"
@printf "$(YLW)Cleaning Libft...$(WTH)\n"
@make fclean -s -C $(LFT_PATH)
@printf "$(GRN)All libraries removed!$(WTH)\n\n"
@printf "$(YLW)Cleaning Leaks log file.$(WTH)\n"
@make -s cleanleaks
@printf "$(GRN)Leaks log file deleted.$(WTH)\n\n"
fcleant:
@printf "\n$(YLW)Cleaning all object files from project...$(WTH)\n"
@$(RM) -rf $(OBJT) $(OBJDIRT)
@printf "$(GRN)All object files removed!$(WTH)\n\n"
@printf "\n$(YLW)Cleaning $(NAMET) and additional files...$(WTH)\n"
@$(RM) -rf $(NAMET)
@printf "$(GRN)$(NAMET) and additional files removed!$(WTH)\n\n"
show:
@echo ""
@echo "$(YLW)ALL PATHS (*invoked with > make show*) $(WTH)]"
@echo ""
@echo "$(YLW)██ Current directory : $(WTH)$(CURDIR) $(WTH)"
@echo "$(GRN)██ LIBFT Directory : $(WTH)$(LFT_PATH)$(WTH) $(WTH)"
@echo "$(RED)██ Sources directory : $(WTH)./$(SRCDIR)$(WTH)"
@echo "$(YLW)██ Include directory : $(WTH)$(INCLUDES)"
@echo "$(CYN)██ Objects Directory : $(WTH)./$(OBJDIR)$(WTH)"
@echo "$(YLW)██ Executable directory : $(WTH)$(CURDIR) $(WTH)"
@echo ""
@echo "$(GRN)██ LIBFT File : $(WTH)$(LIBFT) $(WTH)"
@echo "$(RED)██ Sources files : $(WTH)$(notdir $(FILES))"
@echo "$(CYN)██ Objects files : $(WTH)$(notdir $(OBJ))"
@echo "$(YLW)██ Executable file : $(WTH)$(notdir $(NAME))"
@echo ""
.PHONY: all mkbuilddir re leaks cleanleaks clean fclean fcleant show
.SILENT: