-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
113 lines (102 loc) · 3.74 KB
/
Makefile
File metadata and controls
113 lines (102 loc) · 3.74 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: tutku <tutku@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/04/19 02:03:22 by tutku #+# #+# #
# Updated: 2025/04/19 02:03:22 by tutku ### ########.fr #
# #
# **************************************************************************** #
NAME = minishell
HEADER = -I $(INC_DIR)
#/opt/homebrew/opt/readline/include
CC = cc
FLAGS = -Wall -Wextra -Werror -g
#LFLAGS = -L/opt/homebrew/opt/readline/lib -lreadline -lhistory
#LFLAGS = -L/usr/lib/x86_64-linux-gnu -lreadline #linux
LFLAGS = -lreadline
LIBFT_DIR = libft/
INC_DIR = includes/
OBJ_DIR = obj/
SRC_DIR = src/
SRC_FILES = main.c\
free.c\
signals.c\
init/init_readline_utils.c\
init/init_shell.c\
env/create_env_list.c\
env/create_env_node.c\
parsing/parse_env.c\
parsing/heredoc/hd_fork.c\
parsing/heredoc/hd_init.c\
parsing/heredoc/hd_input.c\
parsing/heredoc/hd_utils.c\
parsing/heredoc/parse_heredoc.c\
parsing/parse_pipe.c\
parsing/parser.c\
parsing/parse_util.c\
parsing/parse_word_util.c\
parsing/parse_word_append.c\
parsing/parse_word.c\
parsing/parse_redir.c\
tokenization/init_env.c\
tokenization/init_pipe.c\
tokenization/init_redirections.c\
tokenization/init_space.c\
tokenization/init_word.c\
tokenization/token_error.c\
tokenization/tokenization.c\
tokenization/tokenization_utils.c\
execution/handle_input.c \
execution/handle_output.c \
execution/ft_fork.c \
execution/ft_execute.c \
execution/ft_execute_utils.c \
execution/ft_heredoc.c \
execution/handle_redirections.c \
execution/envp_array.c \
execution/envp_functions.c \
execution/utils/close_utils.c \
execution/utils/cmd_fork_utils.c \
execution/utils/error_utils.c \
execution/utils/main_exec_utils.c \
execution/utils/free_utils.c \
execution/utils/redir_utils.c \
execution/utils/utils.c \
execution/built_ins/call_built_in.c \
execution/built_ins/ft_cd.c \
execution/built_ins/ft_echo.c \
execution/built_ins/ft_env.c \
execution/built_ins/ft_exit.c \
execution/built_ins/ft_export.c \
execution/built_ins/ft_export_utils.c \
execution/built_ins/ft_pwd.c \
execution/built_ins/ft_unset.c \
execution/main_execution.c \
error_handling/get_error_message.c \
test.c #test file, delete later?
SRC = $(addprefix $(SRC_DIR), $(SRC_FILES))
OBJ = $(addprefix $(OBJ_DIR), $(SRC_FILES:.c=.o))
all: $(NAME)
$(NAME): $(OBJ)
@make -C $(LIBFT_DIR)
@$(CC) $(FLAGS) $(OBJ) $(LFLAGS) -L./libft -lft -o $(NAME)
@echo "\033[0;32mAll files compiled!"
# ensures the folder for the object file exists, even if it is a nested file
$(OBJ_DIR)%.o: $(SRC_DIR)%.c
@mkdir -p $(dir $@)
@echo "\033[0;33mCompiling $<.."
@$(CC) $(FLAGS) $(HEADER) -c $< -o $@
clean:
@$(RM) -rf $(OBJ_DIR)
@make clean -C $(LIBFT_DIR)
@echo "\033[0;31mAll object files removed."
fclean: clean
@$(RM) -f $(NAME)
@$(RM) -f $(LIBFT_DIR)/libft.a
@echo "\033[0;31mAll executable files removed."
re: fclean all
@echo "Object + exec files have been cleaned and rebuilt."
.PHONY: all re clean fclean