This repository has been archived by the owner on Oct 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (90 loc) · 2.99 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
CC = cc
RM = rm -rf
CFLAGS = -Wall -Wextra -Werror -MMD -O2
NAME = minishell
READLINE = ./lib/libhistory.a ./lib/libreadline.a
SRCDIR = ./src
BUILTIN_SRCDIR = $(SRCDIR)/builtin
EXECUTOR_SRCDIR = $(SRCDIR)/executor
HASHTABLE_SRCDIR = $(SRCDIR)/hashtable
LEXER_SRCDIR = $(SRCDIR)/lexer
PARSER_SRCDIR = $(SRCDIR)/parser
PROMPT_SRCDIR = $(SRCDIR)/prompt
UTILS_SRCDIR = $(SRCDIR)/utils
HISTORY_SRCDIR = $(SRCDIR)/history
SIGNAL_SRCDIR = $(SRCDIR)/signal
OBJDIR = ./build
BUILTIN_OBJDIR = $(OBJDIR)/builtin
EXECUTOR_OBJDIR = $(OBJDIR)/executor
HASHTABLE_OBJDIR = $(OBJDIR)/hashtable
LEXER_OBJDIR = $(OBJDIR)/lexer
PARSER_OBJDIR = $(OBJDIR)/parser
PROMPT_OBJDIR = $(OBJDIR)/prompt
UTILS_OBJDIR = $(OBJDIR)/utils
HISTORY_OBJDIR = $(OBJDIR)/history
SIGNAL_OBJDIR = $(OBJDIR)/signal
INCDIR = ./includes
BUILTIN_SRC = $(BUILTIN_SRCDIR)/assignment.c \
$(BUILTIN_SRCDIR)/cd.c \
$(BUILTIN_SRCDIR)/echo.c \
$(BUILTIN_SRCDIR)/env.c \
$(BUILTIN_SRCDIR)/exit.c \
$(BUILTIN_SRCDIR)/export.c \
$(BUILTIN_SRCDIR)/pwd.c \
$(BUILTIN_SRCDIR)/unset.c
EXECUTOR_SRC = $(EXECUTOR_SRCDIR)/executor.c \
$(EXECUTOR_SRCDIR)/executor_data.c \
$(EXECUTOR_SRCDIR)/executor_utils.c \
$(EXECUTOR_SRCDIR)/exec_bin.c
HASHTABLE_SRC = $(HASHTABLE_SRCDIR)/hashtable.c \
$(HASHTABLE_SRCDIR)/insert_hashtable.c \
$(HASHTABLE_SRCDIR)/pair.c \
$(HASHTABLE_SRCDIR)/hash.c \
$(HASHTABLE_SRCDIR)/hashtable_to_sorted_array.c
LEXER_SRC = $(LEXER_SRCDIR)/lexer.c \
$(LEXER_SRCDIR)/tokenize_dollar.c \
$(LEXER_SRCDIR)/tokenize_word.c \
$(LEXER_SRCDIR)/tokenize_utils.c \
$(LEXER_SRCDIR)/get_next_token.c \
$(LEXER_SRCDIR)/source.c \
$(LEXER_SRCDIR)/source_utils.c \
$(LEXER_SRCDIR)/token.c \
$(LEXER_SRCDIR)/wildcard.c
PARSER_SRC = $(PARSER_SRCDIR)/parser.c \
$(PARSER_SRCDIR)/command_table.c \
$(PARSER_SRCDIR)/parser_utils.c \
$(PARSER_SRCDIR)/simple_cmd.c
PROMPT_SRC = $(PROMPT_SRCDIR)/prompt.c
UTILS_SRC = $(UTILS_SRCDIR)/ft_split.c \
$(UTILS_SRCDIR)/error_manager.c \
$(UTILS_SRCDIR)/utils.c \
$(UTILS_SRCDIR)/utils2.c \
$(UTILS_SRCDIR)/utils3.c \
$(UTILS_SRCDIR)/utils4.c
HISTORY_SRC = $(HISTORY_SRCDIR)/history.c
SIGNAL_SRC = $(SIGNAL_SRCDIR)/signal.c
SRC = $(BUILTIN_SRC) \
$(EXECUTOR_SRC) \
$(HASHTABLE_SRC) \
$(LEXER_SRC) \
$(PARSER_SRC) \
$(PROMPT_SRC) \
$(UTILS_SRC) \
$(HISTORY_SRC) \
$(SIGNAL_SRC) \
$(SRCDIR)/main.c \
OBJ = $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(SRC))
DEP = $(OBJ:.o=.d)
all: $(NAME)
$(NAME): $(OBJ)
$(CC) $(CFLAGS) $(OBJ) $(READLINE) -ltermcap -o $(NAME)
$(OBJDIR)/%.o : $(SRCDIR)/%.c Makefile
@mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@ -I$(INCDIR)
clean:
$(RM) $(OBJDIR)
fclean: clean
$(RM) $(NAME)
re: fclean all
-include $(DEP)
.PHONY: all clean fclean re bonus