-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
155 lines (131 loc) · 4.81 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: oohnivch <@student.42vienna.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/12/02 11:07:54 by oohnivch #+# #+# #
# Updated: 2024/12/16 18:41:08 by hanjkim ### ########.fr #
# #
# **************************************************************************** #
# Variables #
# **************************************************************************** #
CC = cc
CFLAGS = -Wall -Wextra -Werror -g
MFLAGS = --no-print-directory -C
HEADER = -I./includes
# HEADER_BONUS = -I./includes_bonus/
NAME = minishell
# BONUS = pipex_bonus
LIBDIR = ./libft
LIB = $(LIBDIR)/libft.a
LINKFLAG = -lreadline
NORMAL = \033[0m
GREEN = \033[1;32m
PURPLE = \033[1;35m
RED = \033[0;31m
YELLOW = \033[0;33m
# **************************************************************************** #
# Source Files #
# **************************************************************************** #
SRC_PATH = src/
# SRC_PATH_BONUS = src_bonus/
OBJ_PATH = obj/
# OBJ_PATH_BONUS = obj_bonus/
SRC = main.c \
argv.c \
cd.c \
clean.c \
cmd_path.c \
echo.c \
env.c \
env_utils.c \
exec_init.c \
exec_utils.c \
execution.c \
general_utils.c \
here_doc.c \
lexer.c \
lexer_create_tokens.c \
lexer_process_words.c \
lexer_set_token_types.c \
lexer_create_segment.c \
parser.c \
parser_split_tokens.c \
parser_replace_split_token.c \
parser_expander.c \
parser_expansion_cases.c \
parser_utils.c \
syntax_checker.c \
syntax_checker_utils.c \
path.c \
reroute.c \
free.c \
pwd.c \
signal.c \
exit.c \
export.c \
unset.c \
expander.c \
debug_utils.c \
# SRC_BONUS = main_bonus.c annihilate_bonus.c extract_bonus.c access_bonus.c \
# general_utils_bonus.c process_bonus.c reroute_bonus.c here_doc_bonus.c
OBJ = $(SRC:%.c=%.o)
# OBJ_BONUS = $(SRC_BONUS:%.c=%.o)
OBJS = $(addprefix $(OBJ_PATH), $(OBJ))
# OBJS_BONUS = $(addprefix $(OBJ_PATH_BONUS), $(OBJ_BONUS))
# **************************************************************************** #
# Rules #
# **************************************************************************** #
all: $(OBJ_PATH) $(NAME)
# bonus: $(OBJ_PATH_BONUS) $(BONUS)
# $(NAME): $(OBJS) $(LIB) | bernhard
$(NAME): $(OBJS) $(LIB) | logo
@$(CC) $(CFLAGS) $(OBJS) $(LIB) -o $(NAME) $(LINKFLAG)
@echo "\n$(GREEN)******** $(NAME) Created! ********$(NORMAL)\n"
# $(BONUS): $(OBJS_BONUS) $(LIB)
# @$(CC) $(CFLAGS) $(OBJS_BONUS) $(LIB) -o $(BONUS)
# @echo "\n$(PURPLE)******** $(BONUS) Created! ********$(NORMAL)\n"
$(OBJ_PATH)%.o: $(SRC_PATH)%.c $(LIB)
@if ! $(CC) $(CFLAGS) -o $@ -c $< $(HEADER) 2> error.txt; then\
echo "$(RED)!!!!!!!! ERROR !!!!!!!!$(NORMAL)"; \
echo "$(YELLOW)Error caused by $<$(NORMAL)\n"; \
sed '$$d' error.txt; \
echo "\n$(RED)Aborting makefile........$(NORMAL)"; \
exit 1; \
fi
# $(OBJ_PATH_BONUS)%.o: $(SRC_PATH_BONUS)%.c $(LIB)
# @if ! $(CC) $(CFLAGS) -o $@ -c $< $(HEADER_BONUS) 2> error.txt; then\
# echo "$(RED)!!!!!!!! ERROR !!!!!!!!$(NORMAL)"; \
# echo "$(YELLOW)Error caused by $<$(NORMAL)\n"; \
# sed '$$d' error.txt; \
# echo "\n$(RED)Aborting makefile........$(NORMAL)"; \
# exit 1; \
# fi
$(OBJ_PATH):
@mkdir $(OBJ_PATH)
# $(OBJ_PATH_BONUS):
# @mkdir $(OBJ_PATH_BONUS)
$(LIB):
@make $(MFLAGS) $(LIBDIR) all
clean:
@make $(MFLAGS) $(LIBDIR) clean
@rm -rf $(OBJ_PATH)
@rm -f error.txt
@echo "$(YELLOW)Deleting $(words $(OBJ)) object file(s) $(NORMAL)"
@echo "$(GREEN)Deletion success! $(NORMAL)"
fclean:
@make $(MFLAGS) $(LIBDIR) fclean
@rm -rf $(OBJ_PATH)
@rm -f $(NAME) $(BONUS) error.txt
@echo "$(YELLOW)Deleting $(NAME) and $(words $(OBJ)) object file(s) $(NORMAL)"
@echo "$(GREEN)Deletion success! $(NORMAL)"
re: fclean all
logo:
@echo "\n$(RED)▗▖ ▗▖▗▄▄▄▖▗▖ ▗▖▗▄▄▄▖▗▖ ▗▖▗▄▄▄▖▗▖ ▗▖ "
@echo "▐▛▚▞▜▌ █ ▐▛▚▖▐▌ █ ▐▌ ▐▌▐▌ ▐▌ ▐▌ "
@echo "▐▌ ▐▌ █ ▐▌ ▝▜▌ █ ▐▛▀▜▌▐▛▀▀▘▐▌ ▐▌ "
@echo "▐▌ ▐▌▗▄█▄▖▐▌ ▐▌▗▄█▄▖▐▌ ▐▌▐▙▄▄▖▐▙▄▄▖▐▙▄▄▖$(NORMAL)\n"
rebonus: fclean bonus
.PHONY: all clean fclean re logo