-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
142 lines (124 loc) · 4.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: arebelo <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/02/07 15:12:42 by arebelo #+# #+# #
# Updated: 2023/02/22 13:34:09 by arebelo ### ########.fr #
# #
# **************************************************************************** #
# NAME
# **************************************************************************** #
BINARY = minishell
# FILES
# **************************************************************************** #
SRCS = main.c\
env/init_env.c\
env/aux_env.c\
env/sort_env.c\
env/env.c\
env/free_env.c\
env/return_var.c\
env/default_env.c\
env/begin_env.c\
pipe/pipe_stru.c\
parse/parsing.c\
parse/token.c\
parse/quotes.c\
parse/token_delete.c\
parse/copy_token.c\
parse/delete_update.c\
parse/type.c\
parse/command_separation.c\
parse/free_components.c\
free/free.c\
expansions/variables_env.c\
expansions/variables_env_aux.c\
expansions/find_var.c\
expansions/home_update.c\
expansions/clean_dollar.c\
redir/initial_redir.c\
redir/outputs.c\
redir/inputs.c\
exec/exec_one.c\
exec/exec_multi.c\
exec/exec_utils.c\
exec/exec_builtin.c\
exec/get_command.c\
exec/exec.c\
heredoc/heredoc.c\
heredoc/variables_heredoc.c\
heredoc/find_var_heredoc.c\
builtins/echo.c\
builtins/pwd.c\
builtins/cd/cd.c\
builtins/cd/aux_cd.c\
builtins/env.c\
builtins/export/export.c\
builtins/export/aux_exp.c\
builtins/export/concat.c\
builtins/unset.c\
builtins/exit.c\
errors/print_error.c\
errors/common_errors.c\
utils/double_array.c\
utils/join_free.c\
utils/char_check.c\
signals/signal.c
OBJS =${addprefix ${OBJS_DIR}, ${SRCS:.c=.o}}
DEPS =${addprefix ${OBJS_DIR}, ${SRCS:.c=.d}}
# DIRECTORY
# **************************************************************************** #
READLINE_DIR = readline
LIBFT_DIR = libft
OBJS_DIR = objs/
SRCS_DIR = srcs/
# LIBRARIES
# **************************************************************************** #
LIBS_EXEC = $(LIBFT_DIR)/libft.a
LIBS_EXEC += $(READLINE_DIR)/libreadline.a
LIBS_EXEC += $(READLINE_DIR)/libhistory.a
LIBS = -L $(READLINE_DIR) -lhistory -lreadline -ltermcap
INCLUDE = -I include -I $(READLINE_DIR)
# COMPILATION
# **************************************************************************** #
LINK = gcc
CC = gcc -c
DEPFLAGS = -MMD -MP
CFLAGS = -Wall -Wextra -Werror
CFLAGS += -Wpedantic -Werror=pedantic -pedantic-errors -Wcast-align
CFLAGS += -Wcast-qual -Wdisabled-optimization -Wformat=2 -Wuninitialized
CFLAGS += -Wmissing-include-dirs -Wredundant-decls -Wshadow
CFLAGS += -Wstrict-overflow=5 -Wundef -fdiagnostics-show-option
CFLAGS += -fstack-protector-all
RM = rm -rf
# RULES
# **************************************************************************** #
all: make_libft make_readline $(BINARY)
$(OBJS_DIR)%.o: $(SRCS_DIR)%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(DEPFLAGS) $(INCLUDE) $< -o $@
make_libft:
make -C $(LIBFT_DIR)
make_readline: $(READLINE_DIR)/libreadline.a $(READLINE_DIR)/libhistory.a
$(READLINE_DIR)/libreadline.a: $(READLINE_DIR)/libhistory.a
$(READLINE_DIR)/libhistory.a:
@pwd $(TMP)
@cd $(READLINE_DIR) && ./configure
@make -C $(READLINE_DIR)
@cd $(TMP)
$(BINARY): $(OBJS) $(LIBS_EXEC)
$(LINK) $(CFLAGS) $(INCLUDE) -o $@ $^ $(LIBS)
clean:
@$(RM) $(OBJS_DIR)
@$(RM) .hdoc
@make clean -s -C $(READLINE_DIR)
@make clean -s -C $(LIBFT_DIR)
fclean: clean
@$(RM) $(BINARY)
@make fclean -s -C $(LIBFT_DIR)
re: fclean all
-include ${DEPS}
.PHONY: all bonus clean fclean re