-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
139 lines (111 loc) · 2.63 KB
/
Makefile
File metadata and controls
139 lines (111 loc) · 2.63 KB
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
## COLORS ##
DEFAULT = \e[39m
GREEN = \e[92m
YELLOW = \e[93m
MAGENTA = \e[95m
CYAN = \e[96m
# **************************************************************************** #
NAME = minishell
# LIBRARY #
LIBFT = libft.a
LIBFT_DIR = ./libft/
HEADER = -I includes -I $(LIBFT_DIR)includes
LIB_FLAGS = -L $(LIBFT_DIR) -lft
READLINE_FLAG = -lreadline
# COMPILATION #
CC = gcc
CFLAGS = -Wall -Wextra -Werror
# DELETE #
RM = rm -rf
# DIRECTORIES #
SRC_DIR = ./src/
VPATH = $(SRC_DIR)\
$(SRC_DIR)builtins\
$(SRC_DIR)parser\
$(SRC_DIR)quotes\
$(SRC_DIR)system\
$(SRC_DIR)utils\
$(SRC_DIR)variable\
$(SRC_DIR)command_table\
$(SRC_DIR)expand\
$(SRC_DIR)exec
# FILES #
FILES = main.c\
get_prompt.c\
tokenizer.c\
env_lst.c\
save_env.c\
token_lst.c\
lexer.c\
str_withou_quotes.c\
validate_quote.c\
put_msg.c\
remove_spaces_around_str.c\
validate_var.c\
var_utils.c\
error.c\
parser.c\
builtin_exit.c\
builtin.c\
exec_cmd.c\
get_path.c\
free_minishell.c\
init_minishell.c\
cmd_table_lst.c\
cmd_table_utils.c\
create_cmd_table.c\
check_cmd.c\
syntax_error.c\
split_cmd.c\
skip_with_quotes.c\
reserved_word.c\
save_reserved_word.c\
save_word_with_quotes.c\
open_redirection.c\
expand.c\
exec_cmd_utils.c\
error_exit.c\
heredoc.c\
strcmp_eq.c\
expand_utils.c\
signal.c\
clear_minishell.c\
builtin_echo.c\
builtin_unset.c\
builtin_pwd.c\
builtin_export.c\
builtin_export_utils.c\
builtin_env.c\
builtin_cd.c\
get_prompt_utils.c\
save_expand_utils.c
# COMPILED_SOURCES #
OBJ_DIR = ./obj/
OBJS = $(addprefix $(OBJ_DIR), $(notdir $(FILES:.c=.o)))
# **************************************************************************** #
## RULES ##
$(OBJ_DIR)%.o: %.c
@$(CC) $(CFLAGS) $(HEADER) -c $< -o $@
all: $(NAME)
$(NAME): $(OBJS)
@make -C $(LIBFT_DIR)
@echo "\n$(CYAN)----------------------------------------"
@echo "------------ MAKE MINISHELL ------------"
@echo "----------------------------------------\n$(DEFAULT)"
@$(CC) $(CFLAGS) $(OBJS) $(LIB_FLAGS) $(READLINE_FLAG) $(HEADER) -o $(NAME)
$(OBJS): | $(OBJ_DIR)
$(OBJ_DIR):
@mkdir $(OBJ_DIR)
clean:
@make clean --no-print-directory -C $(LIBFT_DIR)
@$(RM) $(OBJ_DIR) $(TEST_OBJS) *.gc*
fclean: clean
@make fclean --no-print-directory -C $(LIBFT_DIR)
@$(RM) $(NAME) $(TEST_DIR)bin/ valgrind-out.txt
@echo "\n$(MAGENTA)----------------------------------------"
@echo "------------- CLEANING DONE ------------"
@echo "----------------------------------------\n$(DEFAULT)"
re: fclean all
leaks: re
valgrind --leak-check=full --log-file="leaks.txt" ./$(NAME)
.PHONY: all clean fclean re leaks