-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
145 lines (123 loc) · 4.3 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
# VARIABLES
NAME = minishell
CC = gcc
CFLAGS = -Wall -Wextra -Werror
ifdef DEBUG
CFLAGS += -g
endif
ifdef FSAN
CFLAGS +=-fsanitize=address,undefined
endif
RM = rm -rf
SANITIZE = -fsanitize=address
RL_PATH = $(shell brew --prefix readline)
RL_INC = -I $(RL_PATH)/include
# INCLUDES
INCLUDES = -I./libft -I./libft/ft_printf -I./include -I$(RL_PATH)/include
# LIBRARIES
READLINE_LIB ?= -lreadline -L$(RL_PATH)/lib
PRINTF = ./libft/ft_printf/libftprintf.a
LIBFT = ./libft/libft.a
# SOURCES
SRC = SRC/main.c \
SRC/builtins/cd_change_path.c \
SRC/builtins/cd.c \
SRC/builtins/echo.c \
SRC/builtins/env.c \
SRC/builtins/unset.c \
SRC/builtins/export.c \
SRC/builtins/pwd.c \
SRC/builtins/exit.c \
SRC/builtins/handle_builtins.c \
SRC/environment/env_init.c \
SRC/environment/env_utils.c \
SRC/environment/update_env.c \
SRC/parser/lexer_jumptable.c \
SRC/parser/lexer.c \
SRC/parser/expander.c \
SRC/parser/parser.c \
SRC/parser/parser_jumptable.c \
SRC/parser/handle_here_doc.c \
SRC/parser/parser_utils.c \
SRC/utils/error1.c \
SRC/utils/error2.c \
SRC/utils/expander_utils1.c \
SRC/utils/expander_utils2.c \
SRC/utils/free.c \
SRC/utils/init_shell.c \
SRC/generic_list/generic_list.c \
SRC/generic_list/free_functions.c \
SRC/generic_list/compare_functions.c \
SRC/generic_list/generic_list_utils_1.c \
SRC/generic_list/generic_list_utils_2.c \
SRC/executor/executor.c \
SRC/executor/handle_errors.c \
SRC/executor/handle_multiple_commands.c \
SRC/executor/handle_single_command.c \
SRC/executor/heredoc.c \
SRC/executor/execute_non_builtin.c \
SRC/executor/redirections_check.c \
SRC/executor/redirections.c \
SRC/executor/redirections_utils.c \
SRC/executor/utils_executor.c \
SRC/signals/signals.c \
# OBJECTS
OBJ = $(SRC:.c=.o)
# COLORS
DEF_COLOR = \033[0;39m
GRAY = \033[0;90m
RED = \033[0;31m
ORANGE = \033[40m
GREEN = \033[0;92m
YELLOW = \033[0;93m
BLUE = \033[0;94m
MAGENTA = \033[0;95m
CYAN = \033[0;96m
WHITE = \033[0;97m
RESET = \033[0m
# RULES
all: $(NAME)
$(NAME): $(OBJ)
$(MAKE) -C ./libft
$(MAKE) -C ./libft/ft_printf
$(CC) $(CFLAGS) $(INCLUDES) $(OBJ) $(LIBFT) $(READLINE_LIB) $(PRINTF) -o $(NAME)
@echo "$(GREEN)minishell compiled $(DEF_COLOR)"
@echo "$(RED) _______. __ __ _______ __ __ ____ ____ _______ ___ __ __ "
@echo "$(YELLOW) / || | | | | ____|| | | | \ \ / / | ____| / \ | | | | "
@echo "$(GREEN) | (----| |__| | | |__ | | | | \ \/ / | |__ / ^ \ | |__| | "
@echo "$(CYAN) \ \ | __ | | __| | | | | \_ _/ | __| / /_\ \ | __ | "
@echo "$(BLUE) .----) | | | | | | |____ | ----.| ----. | | | |____ / _____ \ | | | | "
@echo "$(MAGENTA) |_______/ |__| |__| |_______||_______||_______| |__| |_______/__/ \__\ |__| |__| "
@echo "$(RESET)"
make go: $(OBJ)
$(CC) $(CFLAGS) $(INCLUDES) $(READLINE_LIB) $(OBJ) $(LIBFT) $(PRINTF) -o $(NAME)
$(RM) $(OBJ)
@echo "$(GREEN)minishell compiled $(DEF_COLOR)"
@echo "$(RED) _______. __ __ _______ __ __ ____ ____ _______ ___ __ __ "
@echo "$(YELLOW) / || | | | | ____|| | | | \ \ / / | ____| / \ | | | | "
@echo "$(GREEN) | (----| |__| | | |__ | | | | \ \/ / | |__ / ^ \ | |__| | "
@echo "$(CYAN) \ \ | __ | | __| | | | | \_ _/ | __| / /_\ \ | __ | "
@echo "$(BLUE) .----) | | | | | | |____ | ----.| ----. | | | |____ / _____ \ | | | | "
@echo "$(MAGENTA) |_______/ |__| |__| |_______||_______||_______| |__| |_______/__/ \__\ |__| |__| "
@echo "$(RESET)"
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDES) -o $@ -c $<
debug:
$(MAKE) DEBUG=1
rebug: fclean debug
fsan:
$(MAKE) DEBUG=1 FSAN=1
resan: fclean fsan
clean:
$(MAKE) clean -C ./libft
$(MAKE) clean -C ./libft/ft_printf
$(RM) $(OBJ)
@echo "$(YELLOW)minishell object files cleaned $(DEF_COLOR)"
fclean: clean
$(MAKE) fclean -C ./libft
$(MAKE) fclean -C ./libft/ft_printf
$(RM) $(NAME)
@echo "$(YELLOW)minishell executable removed $(DEF_COLOR)"
re: fclean all
echo:
@echo $(OBJ)