-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
112 lines (94 loc) · 2.32 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
CC = gcc
NAME = minishell
SRCS = main.c \
minishell.c
ENV_DIR = srcs/env/
ENV_FILES = env.c \
env_utils.c \
search_env.c
ENV_SRCS = $(addprefix $(ENV_DIR), $(ENV_FILES))
UTILS_DIR = srcs/utils/
UTILS_FILES = err_exit.c \
exit_output_control.c \
free_utils.c \
utils.c
UTILS_SRCS = $(addprefix $(UTILS_DIR), $(UTILS_FILES))
PARCER_DIR = srcs/parser/
PARCER_FILES = parse.c \
parse_utils.c \
parse_heredoc_utils.c \
parse_heredoc.c \
parse_redirect.c \
parse_signal.c \
syntax_error.c
PARCER_SRCS = $(addprefix $(PARCER_DIR), $(PARCER_FILES))
EXPAND_DIR = srcs/expander/
EXPAND_FILES = expansion_dollar.c \
expansion.c \
expansion_heredoc.c \
expansion_normal.c \
expansion_quote.c \
expansion_redirect.c \
expansion_utils.c
EXPAND_SRCS = $(addprefix $(EXPAND_DIR), $(EXPAND_FILES))
BUILTIN_DIR = srcs/builtins/
BUILTIN_FILES = ft_cd.c \
cd_error.c \
ft_echo.c \
ft_env.c \
ft_exit.c \
ft_export.c \
export_error.c \
export_utils.c \
ft_pwd.c \
ft_unset.c \
print_prefix_env.c
BUILTIN_SRCS = $(addprefix $(BUILTIN_DIR), $(BUILTIN_FILES))
EXEC_DIR = srcs/execution/
EXEC_FILES = execute.c \
connect_redirects.c \
exec_cmd.c \
exec_error.c \
exec_others.c \
exec_utils.c \
handle_path.c
EXEC_SRCS = $(addprefix $(EXEC_DIR), $(EXEC_FILES))
LEXER_DIR = srcs/lexer/
LEXER_FILES = lexer.c \
lexer_utils.c \
lexer_error.c
LEXER_SRCS = $(addprefix $(LEXER_DIR), $(LEXER_FILES))
OBJS = $(SRCS:.c=.o)
PARCER_OBJS = $(PARCER_SRCS:.c=.o)
EXPAND_OBJS = $(EXPAND_SRCS:.c=.o)
LEXER_OBJS = $(LEXER_SRCS:.c=.o)
BUILTIN_OBJS = $(BUILTIN_SRCS:.c=.o)
UTILS_OBJS = $(UTILS_SRCS:.c=.o)
EXEC_OBJS = $(EXEC_SRCS:.c=.o)
ENV_OBJS = $(ENV_SRCS:.c=.o)
OBJS += $(PARCER_OBJS)
OBJS += $(EXPAND_OBJS)
OBJS += $(LEXER_OBJS)
OBJS += $(BUILTIN_OBJS)
OBJS += $(EXEC_OBJS)
OBJS += $(UTILS_OBJS)
OBJS += $(ENV_OBJS)
CFLAGS = -g -Werror -Wextra -Wall -I $(shell brew --prefix readline)/include
LDFLAGS = -L$(shell brew --prefix readline)/lib -lreadline -lhistory
INCLUDE = -I includes -I ./libft/includes
LIBFT = libft/libft.a
all: $(NAME)
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
$(NAME): $(OBJS) $(LIBFT)
$(CC) $(CFLAGS) $(INCLUDE) -o $(NAME) $(OBJS) $(LIBFT) $(LDFLAGS)
$(LIBFT):
$(MAKE) -C ./libft
clean:
$(MAKE) clean -C ./libft
$(RM) $(OBJS)
fclean: clean
$(MAKE) fclean -C ./libft
$(RM) $(NAME) test
re: fclean all
.PHONY: all clean fclean re