-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
134 lines (107 loc) · 4.02 KB
/
Makefile
File metadata and controls
134 lines (107 loc) · 4.02 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
# **************************************************************************** #
# COLORS #
# **************************************************************************** #
GREEN=\033[0;32m
RED=\033[0;31m
YELLOW=\033[0;33m
NC=\033[0m
# **************************************************************************** #
# PROJECT NAME #
# **************************************************************************** #
NAME = minishell
# **************************************************************************** #
# DIRECTORIES #
# **************************************************************************** #
SRC_DIR = .
OBJ_DIR = obj
INC_DIR = includes
LIBFT_DIR = libft
# **************************************************************************** #
# FILES #
# **************************************************************************** #
# PARSER
PARSER_SRCS = parser/lexer.c \
parser/parser.c \
parser/utils.c \
parser/quote_handler.c \
parser/utils2.c \
parser/expand_utils.c \
parser/parser_utils.c
# BUILDER
BUILDER_SRCS = builder/builder_cmd.c \
builder/builder_free.c \
builder/builder_redirs.c \
builder/builder_utils.c
# BUILTIN
BUILTIN_SRCS = builtin/builtin.c \
builtin/cd.c \
builtin/echo.c \
builtin/env.c \
builtin/env_utility.c \
builtin/exit.c \
builtin/export.c \
builtin/export_utility.c \
builtin/export_utility2.c \
builtin/pwd.c \
builtin/unset.c
# EXECUTION
EXECUTION_SRCS = execution/exec_single.c \
execution/execute_pipeline.c \
execution/exec_utils.c \
execution/find_path.c \
execution/heredoc_child.c \
execution/heredoc_fork.c \
execution/heredoc_handler.c \
execution/heredoc_utils.c \
execution/pipe_child.c \
execution/pipe_fds.c \
execution/pipe_wait.c \
execution/redirections.c \
execution/run_pipeline.c
# SIGNALS
SIGNAL_SRCS = signals/signals.c
# ALL SRC
SRC = main.c \
handle_input.c \
$(PARSER_SRCS) \
$(BUILDER_SRCS) \
$(BUILTIN_SRCS) \
$(EXECUTION_SRCS) \
$(SIGNAL_SRCS)
OBJ = $(SRC:%.c=$(OBJ_DIR)/%.o)
# **************************************************************************** #
# COMPILATION #
# **************************************************************************** #
CC = gcc
CFLAGS = -Wall -Wextra -Werror \
-I$(INC_DIR) -I$(LIBFT_DIR)/includes
# **************************************************************************** #
# RULES #
# **************************************************************************** #
all: $(NAME)
$(OBJ_DIR):
@mkdir -p $(OBJ_DIR)
@mkdir -p $(OBJ_DIR)/parser
@mkdir -p $(OBJ_DIR)/builder
@mkdir -p $(OBJ_DIR)/builtin
@mkdir -p $(OBJ_DIR)/execution
@mkdir -p $(OBJ_DIR)/signals
$(OBJ_DIR)/%.o: %.c | $(OBJ_DIR)
@$(CC) $(CFLAGS) -c $< -o $@
@echo "$(GREEN)Compiled: $<$(NC)"
$(LIBFT_DIR)/libft.a:
@echo "$(YELLOW)Compiling libft...$(NC)"
@make -C $(LIBFT_DIR)
$(NAME): $(OBJ) $(LIBFT_DIR)/libft.a
@$(CC) $(CFLAGS) $(OBJ) $(LIBFT_DIR)/libft.a -lreadline -o $(NAME)
@echo "$(GREEN)Minishell compiled successfully!$(NC)"
clean:
@rm -rf $(OBJ_DIR)
@make -C $(LIBFT_DIR) clean
@echo "$(RED)Object files removed.$(NC)"
fclean: clean
@rm -f $(NAME)
@make -C $(LIBFT_DIR) fclean
@echo "$(RED)Executable removed.$(NC)"
re: fclean all
.PHONY: all clean fclean re