-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
158 lines (133 loc) · 4.01 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: camunozg <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/09/15 16:43:25 by juramos #+# #+# #
# Updated: 2024/05/27 08:57:17 by camunozg ### ########.fr #
# #
# **************************************************************************** #
# Name
NAME = minishell
# Compiler
CC = gcc
CFLAGS = -Wall -Werror -Wextra -g3 -fsanitize=address
# Sources
# Removed signal_handler\ for now
SRC_DIR = src/
SRC_FILES = main\
minishell_loop\
init\
history\
variables/local_variables\
variables/local_variables_utils\
variables/local_variables_checks\
variables/local_variables_utils_aux\
variables/local_variables_quotes\
variables/sh_lvl\
lexer/lexer_utils\
lexer/lexer\
lexer/tokens\
lexer/lexer_checks\
lexer/lexer_token_checks\
syntax/syntax\
syntax/comments_end\
parser/cmd_table_utils\
parser/cmd_table\
parser/parser_utils\
parser/parser\
utils/clean\
utils/clean_cmd\
utils/extra_libft\
utils/error\
exec/arr_utils\
exec/exec\
exec/error_handlers\
exec/redirections\
exec/exec_utils\
exec/heredoc\
exec/expand\
exec/expand_utils\
exec/main_exec\
builtins/mini_cd\
builtins/mini_exit\
builtins/mini_pwd\
builtins/mini_echo\
builtins/mini_env\
builtins/mini_unset/mini_unset\
builtins/mini_unset/mini_unset_utils\
builtins/mini_export/mini_export\
builtins/mini_export/mini_export_order\
builtins/mini_export/mini_export_utils\
builtins/mini_export/mini_export_utils_aux\
builtins/mini_export/mini_export_operations\
builtins/mini_export/mini_export_quotes\
builtins/mini_export/mini_export_quotes_aux\
builtins/mini_export/mini_export_dec\
builtins/utils_builtins\
signals\
SRC = $(addprefix $(SRC_DIR), $(addsuffix .c, $(SRC_FILES)))
# Objects
OBJ_DIR = obj/
OBJ_DIRS = $(sort $(dir $(OBJ)))
OBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(SRC_FILES)))
# libft
LIBFT_PATH = libft/
LIBFT_NAME = libft.a
LIBFT = $(LIBFT_PATH)$(LIBFT_NAME)
# build path
B_PATH = build/
# Includes
INC_MS = -I include/ \
-I /usr/local/Cellar/readline/8.2.10/include
# Readline Compile
RL_CMP = -L/usr/local/Cellar/readline/8.2.10/lib
# Colors
DEF_COLOR = \033[0;39m
GRAY = \033[0;90m
RED = \033[0;91m
GREEN = \033[0;92m
YELLOW = \033[0;93m
BLUE = \033[0;94m
MAGENTA = \033[0;95m
CYAN = \033[0;96m
WHITE = \033[0;97m
# Config
OBJF = .cache_exists
MAKEFLAGS += --no-print-directory
.SILENT:
###
all: $(B_PATH) $(LIBFT) $(NAME)
$(OBJ_DIR)%.o: $(SRC_DIR)%.c | $(OBJF)
@$(CC) $(CFLAGS) $(INC_MS) $(INC) -c $< -o $@
$(OBJF):
@mkdir -p $(OBJ_DIR)
@mkdir -p $(OBJ_DIRS)
$(NAME): $(OBJ)
@$(CC) $(CFLAGS) -o $(NAME) $(OBJ) $(LIBFT) $(INC) -lreadline $(RL_CMP)
@echo "$(GREEN)minishell compiled!$(DEF_COLOR)"
$(B_PATH):
@mkdir $(B_PATH)
libft:
@make -sC $(LIBFT_PATH)
$(LIBFT):
@echo "Making libft..."
@make -sC $(LIBFT_PATH)
clean:
@rm -rf $(OBJ_DIR)
@rm -rf $(B_PATH)
@make clean -sC $(LIBFT_PATH)
@echo "$(BLUE)minishell object files cleaned!$(DEF_COLOR)"
fclean: clean
@rm -f $(NAME)
@make fclean -sC $(LIBFT_PATH)
@echo "$(CYAN)minishell executable files cleaned!$(DEF_COLOR)"
re: fclean all
@echo "$(GREEN)Cleaned and rebuilt everything for minishell!$(DEF_COLOR)"
norm:
@norminette $(SRC) | grep -v Norme -B1 || true
miniexec:
make -sC src/exec
.PHONY: all clean fclean re norm libft