-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
119 lines (95 loc) · 2.42 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
#
# Macros
#
NAME = minishell
CC = cc
CFLAGS = -Wall -Wextra -Werror
SRC = src/
INCLUDE = include/
HEADER = minishell.h executor.h parser.h lexer.h
HEADER := $(addprefix $(INCLUDE), $(HEADER))
UTILS_FILES = utils/io_utils1.c \
utils/io_utils2.c \
utils/error_utils.c \
utils/env_utils1.c \
utils/env_utils2.c \
utils/env_utils3.c \
utils/global_utils1.c \
utils/global_utils2.c \
utils/global_utils3.c \
utils/global_utils4.c \
utils/display_utils.c
BUILTINS_FILES = builtins/cd_cmd.c \
builtins/pwd_cmd.c \
builtins/echo_cmd.c \
builtins/exit_cmd.c \
builtins/unset_cmd.c \
builtins/env_cmd.c \
builtins/export_cmd.c
TOKENZIER_FILES = tokenizer/lexer.c \
tokenizer/tokenizer.c \
tokenizer/tokenizer_utils.c \
tokenizer/list_constructor_utils.c \
tokenizer/list_destructor_utils.c
EXECUTOR_FILES = executor/ft_execvp.c \
executor/exec_utils.c \
executor/executor.c \
executor/executor_utils1.c \
executor/executor_utils2.c
PARSER_FILES = parser/astree_constructors.c \
parser/parser_helpers.c \
parser/parser_utils1.c \
parser/parser_utils2.c \
parser/parser.c
SYNTAX_UTILS = syntax_analyser/syntax_analyser.c \
syntax_analyser/syntax_utils.c
EXPANDER_FILES = expander/expander.c \
expander/expander_utils1.c \
expander/expander_utils2.c \
expander/wildcard_matching.c
FILES = minishell.c \
$(UTILS_FILES) \
$(BUILTINS_FILES) \
$(TOKENZIER_FILES) \
$(SYNTAX_UTILS) \
$(EXPANDER_FILES) \
$(PARSER_FILES) \
$(EXECUTOR_FILES) \
OBJS = $(FILES:%.c=%.o)
OBJS := $(addprefix $(SRC), $(OBJS))
RL_DIR = $(addprefix $(shell brew --prefix readline), /)
LIBFT_PATH = libft/
LIBFT = $(addprefix $(LIBFT_PATH), libft.a)
LIBGC_PATH = libgc/
LIBGC = $(addprefix $(LIBGC_PATH), libgc.a)
#
# Rules
#
# All
all: $(NAME)
# Debug
debug: CFLAGS+=-g
debug: clean $(NAME)
# minishell
$(NAME): $(LIBFT) $(LIBGC)
$(NAME): $(OBJS)
$(CC) $(CFLAGS) $^ -o $@ -lreadline -L$(addprefix $(RL_DIR), lib)
# libft
$(LIBFT): $(addprefix $(LIBFT_PATH), libft.h)
make -C $(LIBFT_PATH) all clean
# libgc
$(LIBGC): $(addprefix $(LIBGC_PATH), include/gc.h)
make -C $(LIBGC_PATH) all clean
# object files
%.o: %.c $(HEADER)
$(CC) $(CFLAGS) -c $< -o $@ -I $(INCLUDE) -I $(addprefix $(RL_DIR), include) -I $(LIBFT_PATH) -I $(addprefix $(LIBGC_PATH), include)
# clean
clean:
rm -f $(OBJS)
# full clean
fclean: clean
rm -f $(NAME)
make -C $(LIBFT_PATH) fclean
make -C $(LIBGC_PATH) fclean
# remake
re: fclean all