forked from astahjmo/minishell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
121 lines (108 loc) · 3.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
NAME = minishell
VPATH = ./src \
./src/parser ./src/prompt ./src/signals \
./src/utils \
./src/handler_quotes \
./src/tokenizer ./src/expansions \
./src/syntax ./src/env ./src \
./src/builtins ./src/executor ./src/redirections ./src/utils
CFLAGS = -g3 -Wall -Wextra -Werror
SOURCES = main.c wait_input.c tokenizer.c setup_hook.c\
has_unclosed_quotes.c display.c ft_linked_list.c \
init_signal.c clear_bimatrix.c retokenize.c handle_expansions.c \
find_token.c strings_utils.c strjoinfree_s1.c print_data.c\
tokenizer_operator.c init_parsers.c linked_list.c \
tokenizer_string.c analysis.c free_cmds.c recipeWord.c \
recipeOperator.c init_recipes.c lexer_strings.c \
strjoinfree.c free_all.c cd_builtin.c fmt_s.c put_end_line.c \
env_builtin.c exit_builtin.c executor.c export_builtin.c echo_builtin.c \
unset_builtin.c utils_builtins_01.c utils_builtins_02.c utils_builtins_03.c \
init_env.c init_statics.c is_llmin.c heredoc_utils.c pwd_builtin.c \
init_t_file_io.c open_redirections.c fds_utils.c \
expansion_utils.c print_tokens.c heredoc.c test_directory.c \
utils_executor.c one_command.c exec_command.c get_cmd_path.c \
split_envp.c pre_executor.c is_a_command.c \
mult_commands.c after_execution.c mult_command_utils.c \
redirections_utils.c
LIB_SRCS = ft_strlen.c ft_strdup.c ft_substr.c ft_itoa.c \
ft_split.c ft_strlcpy.c ft_isalpha.c \
ft_isalnum.c ft_putstr_fd.c ft_memmove.c ft_strncmp.c \
ft_strchr.c ft_bzero.c ft_strnstr.c ft_memset.c ft_isdigit.c \
ft_strjoin.c ft_atoull.c ft_atoi.c ft_memcpy.c ft_calloc.c \
ft_strlcat.c ft_strcmp.c ft_safe_free.c ft_printf.c ft_putendl_fd.c \
BUILDDIR = ./objs/
LINCLUDE= ./lib/include
INCLUDE = ./include
LIB = libft.a
MINILIB = lib/mini_libft.a
OBJS = $(addprefix $(BUILDDIR), $(SOURCES:.c=.o))
RCol='\033[0m'
Bla='\033[0;30m'
Red='\033[0;31m'
Gre='\033[0;32m'
Yel='\033[1;33m'
Blu='\033[0;34m'
Pur='\033[0;35m'
Cya='\033[0;36m'
Whi='\033[0;37m'
MSGBUILD="[$(Gre)+$(RCol)]"
ALT_MSGBUILD="[$(Cya)+$(RCol)]"
MSGRM="[$(Red)-$(RCol)]"
all: $(NAME)
ifdef ACTIONS
CC = clang-12
endif
$(NAME): $(OBJS)
@printf "\n"
@make --no-print-directory supp
@make minishell -C lib --no-print-directory
@printf $(Red)"\n$@ : Linking objects into the executable... "
@$(CC) $(CFLAGS) -I$(INCLUDE) $(OBJS) $(MINILIB) -lreadline -o $@
@printf $(Cya)"\n$@: Program has been created! \n"
$(BUILDDIR)%.o: %.c
@printf "\r$(MSGBUILD) $(NAME): building $@ "
@test -d $(BUILDDIR) || mkdir $(BUILDDIR)
@$(CC) $(CFLAGS) -I$(INCLUDE) -I$(LINCLUDE) -c $< -o $@
supp:
@printf "{\n\
<Readline>\n\
Memcheck:Leak\n\
match-leak-kinds: reachable\n\
...\n\
fun:readline\n\
...\n\
}\n\
{\n\
<Readline>\n\
Memcheck:Leak\n\
match-leak-kinds: definite\n\
fun:malloc\n\
fun:xmalloc\n\
fun:rl_add_undo\n\
fun:rl_insert_text\n\
fun:_rl_insert_char\n\
fun:rl_insert\n\
fun:_rl_dispatch_subseq\n\
fun:readline_internal_char\n\
fun:readline\n\
...\n\
}\n\
{\n\
<AddHistory>\n\
Memcheck:Leak\n\
match-leak-kinds: reachable\n\
fun:malloc\n\
fun:xmalloc\n\
fun:add_history\n\
...\n\
}\n" > readline.supp
clean:
@printf "$(MSGRM) removing $(BUILDDIR) dir \n"
@make --no-print-directory -C ./lib clean
@rm -rf $(BUILDDIR)
fclean: clean
@rm -f readline.supp
@printf "$(MSGRM) removing $(BUILDDIR) dir and $(NAME) bin \n"
@make --no-print-directory -C ./lib fclean
@if test -f $(NAME); then rm -f $(NAME); fi
re: fclean all