-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
102 lines (80 loc) · 2.7 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
NAME = minishell
CC = cc
CFLAGS = -Wall -Wextra -Werror -MMD -MP
# CFLAGS += -g -fsanitize=address
# sanitizeが有る無しで挙動が変わります。。謎
INCDIR = ./includes
INC = $(addprefix -I,$(INCDIR)) -I$(RL_INCDIR)
# INC 変数に-I$(RL_INCDIR)を追加
# readline.h ヘッダーファイルを見つけるためにコンパイラが
# 使用する検索パスに readline の include ディレクトリが追加されます。
# 最新版の関数rl_replace_lineが使えるようになります。
SRCSDIR = ./srcs
OBJSDIR = ./objs
SRCS = $(SRCSDIR)/builtins/cd.c \
$(SRCSDIR)/builtins/create_env_vars.c \
$(SRCSDIR)/builtins/create_env_vars_helper.c \
$(SRCSDIR)/builtins/echo.c \
$(SRCSDIR)/builtins/env.c \
$(SRCSDIR)/builtins/exit.c \
$(SRCSDIR)/builtins/export.c \
$(SRCSDIR)/builtins/export_utiles.c \
$(SRCSDIR)/builtins/export_utiles_2.c \
$(SRCSDIR)/builtins/pwd.c \
$(SRCSDIR)/builtins/unset.c \
$(SRCSDIR)/builtins/utiles.c \
$(SRCSDIR)/builtins/utiles2.c \
$(SRCSDIR)/builtins/utility_comand.c \
$(SRCSDIR)/builtins/utility_comand_helper.c \
$(SRCSDIR)/exec/exec_builtins.c \
$(SRCSDIR)/exec/execution.c \
$(SRCSDIR)/exec/exec_from_bin.c \
$(SRCSDIR)/exec/exec_utiles.c \
$(SRCSDIR)/exec/pipe.c \
$(SRCSDIR)/exec/exec_redirect.c \
$(SRCSDIR)/exec/exec_expansion.c \
$(SRCSDIR)/expansion/expansion.c \
$(SRCSDIR)/expansion/helper_expansion.c \
$(SRCSDIR)/expansion/handle_dollar.c \
$(SRCSDIR)/expansion/handle_quotation.c \
$(SRCSDIR)/expansion/helper_handle_dollar.c \
$(SRCSDIR)/expansion/helper_handle_dquote.c \
$(SRCSDIR)/expansion/helper_handle_quotation.c \
$(SRCSDIR)/lexer/lexer.c \
$(SRCSDIR)/lexer/token.c \
$(SRCSDIR)/lexer/utils.c \
$(SRCSDIR)/main.c \
$(SRCSDIR)/minishell.c \
$(SRCSDIR)/parser/parser.c \
$(SRCSDIR)/parser/parse_redirect.c \
$(SRCSDIR)/parser/parser_utils.c \
$(SRCSDIR)/signal.c \
$(SRCSDIR)/exec_signal.c
OBJS = $(patsubst $(SRCSDIR)/%.c,$(OBJSDIR)/%.o,$(SRCS))
DEPS = $(OBJS:.o=.d)
LIBFTDIR = ./libft
LIBFT = $(LIBFTDIR)/libft.a
UNAME = $(shell uname)
RL_NAME = readline
ifeq ($(UNAME),Darwin)
RL_DIR = $(shell brew --prefix readline)
RL_LIBDIR = $(addprefix $(RL_DIR)/,lib)
RL_INCDIR = $(addprefix $(RL_DIR)/,include)
endif
LDFLAGS = -L $(LIBFTDIR) -lft -L $(RL_LIBDIR) -l $(RL_NAME)
all: $(NAME)
$(NAME): $(OBJS) $(LIBFT)
$(CC) $(CFLAGS) $(OBJS) $(LIBFT) $(LDFLAGS) -o $(NAME)
$(OBJSDIR)/%.o: $(SRCSDIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(INC) -c -o $@ $<
$(LIBFT):
$(MAKE) -C $(LIBFTDIR)
-include $(DEPS)
clean:
$(MAKE) fclean -C $(LIBFTDIR)
$(RM) $(OBJS) $(DEPS)
fclean: clean
$(RM) $(NAME)
re: fclean all
.PHONY: all clean fclean re bonus