Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
107 lines (91 loc) · 2.56 KB
/
Copy pathMakefile
File metadata and controls
107 lines (91 loc) · 2.56 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
NAME = minishell
RED = \033[31m
GREEN = \033[32m
YELLOW = \033[33m
BLUE = \033[34m
RESET = \033[0m
# Detect OS
UNAME_S := $(shell uname -s)
SRCS = \
./src/signal/signals_01.c \
./src/signal/signals_02.c \
\
./src/token/token.c \
./src/token/token_utils.c \
./src/token/handle_operators.c \
./src/token/handle_word.c \
./src/token/handle_word_utils.c \
./src/token/ft_realloc_token.c \
\
./src/ast/ast.c \
./src/ast/ast_norm.c \
./src/ast/ast_utils.c \
./src/ast/free_ast.c \
\
./src/builtins/env_utils_01.c \
./src/builtins/sh_cd.c \
./src/builtins/sh_env.c \
./src/builtins/sh_pwd.c \
./src/builtins/sh_echo.c \
./src/builtins/sh_exit.c \
./src/builtins/sh_unset.c \
./src/builtins/sh_export.c \
\
./src/init/init_builtins.c \
./src/init/init_app.c \
./src/init/init_env.c \
\
./src/exec/status_res.c \
./src/exec/sh_exec.c \
./src/exec/exec_external.c \
./src/exec/exec_builtin.c \
\
./src/utils/utils_01_dpp.c \
\
./src/handlers/pipe.c \
./src/handlers/heredoc.c \
./src/handlers/heredoc_utils.c \
./src/handlers/redirection.c \
./src/handlers/redirection_utils.c \
\
./src/main.c
OBJS = $(SRCS:.c=.o)
CC = cc
CFLAGS = -Wall -Wextra -Werror -g
# Add readline paths for macOS
ifeq ($(UNAME_S),Darwin)
CFLAGS += -I$(shell brew --prefix readline)/include
LDFLAGS = -lreadline -L$(shell brew --prefix readline)/lib
else
LDFLAGS = -lreadline
endif
RM = rm -f
LIBFT_NAME = libft.a
LIBFT_DIR = ./libft
LIBFT = $(LIBFT_DIR)/$(LIBFT_NAME)
all: $(NAME)
%.o: %.c
@printf "$(BLUE)Compiling$(RESET): %-50s" "$<"
@$(CC) $(CFLAGS) -c $< -o $@ && printf "$(GREEN)✔\n$(RESET)" || printf "$(RED)✖\n$(RESET)"
$(NAME): $(OBJS)
@printf "\n$(YELLOW)Building libft library...$(RESET)\n"
@make -C $(LIBFT_DIR)
@printf "$(BLUE)Linking$(RESET): %-50s" "$(NAME)"
@$(CC) $(OBJS) $(LIBFT) $(LDFLAGS) -o $(NAME) \
&& printf "$(GREEN)✔\n$(RESET)" \
|| printf "$(RED)✖\n$(RESET)"
@printf "$(GREEN)Done! $(NAME) is ready to go!$(RESET)\n"
clean:
@printf "$(YELLOW)Cleaning objects...$(RESET)\n"
@make -C $(LIBFT_DIR) clean
@$(RM) $(OBJS)
@printf "$(GREEN)Cleaned all object files.$(RESET)\n"
fclean: clean
@printf "$(YELLOW)Removing binaries...$(RESET)\n"
@make -C $(LIBFT_DIR) fclean
@$(RM) $(NAME)
@printf "$(GREEN)Removed $(NAME).$(RESET)\n"
re: fclean all
@printf "$(YELLOW)Rebuilding everything...$(RESET)\n"
@$(MAKE) all
.PHONY: all clean fclean re