Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·112 lines (96 loc) · 2.89 KB
/
Copy pathMakefile
File metadata and controls
executable file
·112 lines (96 loc) · 2.89 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
NAME = minishell
SRCDIR = src
OBJDIR = .obj
INCDIR = include
LIBFT_DIR = libft
LIBFT = $(LIBFT_DIR)/libft.a
CC = cc
CFLAGS = -Wall -Wextra -Werror -I$(INCDIR) -I$(LIBFT_DIR) -Wshadow -Wstrict-prototypes -Wpointer-arith
VAL_FLAGS = -g3 -O0
ASAN_FLAGS = -fsanitize=address,undefined -fno-omit-frame-pointer
SRC = main.c \
historer.c \
shell.c \
shell_display.c \
prompt.c \
signals.c \
director.c \
execution/closer.c \
execution/utils.c \
execution/pexiter.c \
execution/pipex.c \
execution/multi_pipe.c \
execution/heredoc.c \
execution/redir_exec.c \
parsing/expansion.c \
parsing/parser.c \
parsing/lexer.c \
parsing/tokens.c \
parsing/redirections.c \
parsing/validation.c \
parsing/build_cmds.c \
parsing/word_split.c \
execution/lib.c \
builtins/export.c \
builtins/export_utils.c \
builtins/exit.c \
builtins/env.c \
builtins/pwd.c \
builtins/cd.c \
builtins/builtex.c \
builtins/bu2.c \
builtins/unset.c \
builtins/env_utils.c \
builtins/echo.c
OBJ = $(addprefix $(OBJDIR)/, $(SRC:.c=.o))
################################################################################
# PROGRESS BAR #
################################################################################
CNT = .mini_cnt
RESET := $(shell echo 0 > $(CNT))
C = \033[1;36m
Y = \033[1;33m
R = \033[1;31m
B = \033[1m
X = \033[0m
define progress
n=$$(($$(cat $(CNT)) + 1)); echo $$n > $(CNT); \
t=$(1); pct=$$((n * 100 / t)); f=$$((n * 20 / t)); \
bar=""; i=0; \
while [ $$i -lt $$f ]; do bar="$${bar}█"; i=$$((i+1)); done; \
while [ $$i -lt 20 ]; do bar="$${bar}░"; i=$$((i+1)); done; \
printf "\r\033[K $(C)🔧 [$(NAME)] $(Y)$$bar $(B)$$pct%%$(X)"
endef
################################################################################
# RULES #
################################################################################
all: $(NAME)
@if [ $$(cat $(CNT)) -gt 0 ]; then printf "\n"; fi
@printf " $(C)✅ [$(NAME)] $(B)Build complete$(X)\n"
$(NAME): $(OBJ) $(LIBFT)
@$(CC) $(CFLAGS) -L$(LIBFT_DIR) $(OBJ) $(LIBFT) -lreadline -ltermcap -lncurses -o $(NAME)
$(OBJDIR):
@mkdir -p $(OBJDIR)/execution $(OBJDIR)/parsing $(OBJDIR)/builtins
$(LIBFT):
@$(MAKE) --silent -C $(LIBFT_DIR)
$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)
@$(CC) $(CFLAGS) -c $< -o $@
@$(call progress,$(words $(SRC)))
clean:
@printf "$(R)🗑️ [$(NAME)] Cleaned$(X)\n"
@rm -rf $(OBJDIR)
@$(MAKE) --silent -C $(LIBFT_DIR) clean
fclean: clean
@rm -f $(NAME)
@$(MAKE) --silent -C $(LIBFT_DIR) fclean
@rm -f debug.log minishell .minishell_history
re: fclean all
debug: CFLAGS += $(VAL_FLAGS)
debug: re
asan: CFLAGS += $(VAL_FLAGS) $(ASAN_FLAGS)
asan: re
run: re
./$(NAME)
norm:
norminette | grep "Error"
.PHONY: all clean fclean re debug asan