forked from bddkalle/minishell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
143 lines (125 loc) · 3.6 KB
/
Makefile
File metadata and controls
143 lines (125 loc) · 3.6 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
140
141
142
143
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: fschnorr <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/02/13 14:10:53 by fschnorr #+# #+# #
# Updated: 2025/05/05 01:54:42 by fschnorr ### ########.fr #
# #
# **************************************************************************** #
NAME = minishell
INCLUDE = -I include $(LIBFT_INCLUDES)
SRC = $(addsuffix .c, \
$(addprefix src/, \
main \
)) \
$(addsuffix .c, \
$(addprefix src/builtins/, \
echo \
cd \
pwd \
env \
export \
unset \
exit \
builtin_utils \
builtin_utils2 \
)) \
$(addsuffix .c, \
$(addprefix src/error/, \
error \
)) \
$(addsuffix .c, \
$(addprefix src/executor/, \
executor \
executables \
operators \
operators2 \
redirections \
heredoc \
heredoc2 \
e_utils \
e_utils2 \
e_utils3 \
)) \
$(addsuffix .c, \
$(addprefix src/parser/, \
p_debug \
lexer \
p_free \
p_free2 \
p_init \
p_utils \
p_utils2 \
p_utils3 \
p_utils4 \
p_utils5 \
p_utils6 \
p_utils7 \
p_utils8 \
p_utils9 \
parser \
)) \
$(addsuffix .c, \
$(addprefix src/signals/, \
signals \
signals_shell \
signals_child \
)) \
$(addsuffix .c, \
$(addprefix src/utils/, \
free \
init \
prompt \
utils \
envp_utils \
envp_utils2 \
envp_utils3 \
))
OBJS_DIR = obj
OBJS := $(addprefix $(OBJS_DIR)/, $(notdir $(SRC:.c=.o)))
LIBFT_INCLUDES = -I $(LIBFT_DIR)/includes
LIBFT_DIR = lib/libft
LIBFT_AR = $(LIBFT_DIR)/libft.a
CC = cc
CFLAGS = -Wall -Wextra
MFLAGS = --no-print-directory
VFLAGS = -g -O0
vpath %.c src src/builtins src/error src/executor src/parser src/signals src/utils
all: $(NAME)
$(NAME): $(OBJS)
@make -C $(LIBFT_DIR) $(MFLAGS)
@echo -n "run cc for minishell..."
@$(CC) $^ $(LIBFT_AR) -o $(NAME) $(CFLAGS) $(INCLUDE) -lreadline
@echo "done"
$(OBJS_DIR):
@mkdir -p $(OBJS_DIR)
$(OBJS_DIR)/%.o: %.c | $(OBJS_DIR)
@$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDE)
clean:
@rm -rf $(OBJS_DIR)
fclean: clean
@echo -n "run fclean for minishell..."
@rm -f $(NAME)
@echo "done"
@make fclean -C $(LIBFT_DIR) $(MFLAGS)
re: fclean all
debug: CFLAGS += -g -O0
debug: $(NAME)
@gdb so_long
run: re
@./$(NAME) $(ARG) || true
valgrind: CFLAGS += -g -O0
valgrind: re
@valgrind --quiet --leak-check=full --show-leak-kinds=all --suppressions=readline.supp --track-origins=yes --track-fds=yes -s ./$(NAME) $(ARG)
checkup: CFLAGS += -Werror
checkup:
@echo "Checking for memory leaks..."
@make valgrind || true
@make norm
norm:
@echo "Checking for norm compliance..."
@norminette
.PHONY: all clean fclean re debug run valgrind checkup norm