-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
111 lines (87 loc) · 2.68 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: hyeonsok <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/10/25 19:17:03 by hyeonsok #+# #+# #
# Updated: 2022/02/21 23:47:20 by hyeonsok ### ########.fr #
# #
# **************************************************************************** #
CC = cc
CFLAGS = -Wall -Werror -Wextra -g3
RM = rm -f
INCLUDES = -I include/ -I$(shell brew --prefix readline)/include/ \
-I lib/libft/include/
LIBS = -L $(shell brew --prefix readline)/lib/ -lreadline \
-L lib/libft -lfthx
LIBFTHX = lib/libft/libfthx.a
OBJDIR := ./obj
# ./src
OBJS = $(addprefix $(OBJDIR)/, \
main.o)
# ./src/mush
OBJS += $(addprefix $(OBJDIR)/, \
front_signal.o \
front_prompt.o \
parser.o \
parser_buffer.o \
parser_iofile.o \
parser_pipeline.o \
parser_token.o \
parser_error.o \
exec.o \
exec_expn_word.o \
exec_expn_cmd.o \
exec_redir.o \
exec_poll.o \
exec_builtin.o \
exec_cleanup.o)
# ./src/builtin
OBJS += $(addprefix $(OBJDIR)/, \
builtin_cd.o \
builtin_echo.o \
builtin_env.o \
builtin_exit.o \
builtin_export.o \
builtin_pwd.o \
builtin_unset.o)
# ./src/utils
OBJS += $(addprefix $(OBJDIR)/, \
mush_valid_name.o \
mush_error.o \
mush_env.o)
SRC_DIR = ./src
SRC_UTILS_DIR = ./src/utils
SRC_BUILTIN_DIR = ./src/builtin
SRC_MUSH_DIR = ./src/mush
NAME = minishell
.PHONY: all
all: libfthx $(NAME)
libfthx: $(LIBFTHX)
$(LIBFTHX):
make -C lib/libft/
$(NAME): $(OBJDIR) $(OBJS)
$(CC) $(INCLUDES) $(OBJS) $(DEBUG) -o $(NAME) $(LIBS)
$(OBJDIR)/%.o : $(SRC_MUSH_DIR)/%.c
$(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
$(OBJDIR)/%.o : $(SRC_DIR)/%.c
$(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
$(OBJDIR)/%.o : $(SRC_BUILTIN_DIR)/%.c
$(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
$(OBJDIR)/%.o : $(SRC_UTILS_DIR)/%.c
$(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
$(OBJS): | $(OBJDIR)
$(OBJDIR):
mkdir $(OBJDIR)
.PHONY: clean
clean:
make clean -C lib/libft/
$(RM) -r $(OBJDIR)
.PHONY: fclean
fclean: clean
make fclean -C lib/libft/
$(RM) -r $(NAME)
.PHONY: re
re: fclean all