-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
121 lines (91 loc) · 3.2 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: amitcul <amitcul@student.42porto.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/02/16 11:02:30 by amitcul #+# #+# #
# Updated: 2023/06/25 12:44:45 by amitcul ### ########.fr #
# #
# **************************************************************************** #
NAME = minishell
CC = cc -fPIE
CFLAGS = -Wall -Wextra -Werror -g -fsanitize=address
RM = rm -rf
OS := $(shell uname)
LIBDIR = ./libft
ifeq ($(OS), Darwin)
LIB = $(LIBDIR)/libft.a -lreadline -L/Users/alexmitcul/.brew/opt/readline/lib
else
LIB = $(LIBDIR)/libft.a -lreadline -L/Users/alexmitcul/.brew/opt/readline/lib
endif
INCLUDES = ./includes/
ifeq ($(OS), Darwin)
INCLUDES_LIB = ./libft/includes/ -I/Users/alexmitcul/.brew/opt/readline/include/
else
INCLUDES_LIB = ./libft/includes/ -I/Users/alexmitcul/.brew/opt/readline/include/
endif
HEADER += $(INCLUDES)minishell.h
HEADER += $(INCLUDES)utils.h
HEADER += $(INCLUDES)lexer.h
HEADER += $(INCLUDES)parser.h
HEADER += $(INCLUDES)expander.h
LIB_TERMCAP = -lreadline
SRCS += main.c
# Error files
SRCS += error.c parser_error.c
# Lexer source files
SRCS += quotes.c tokens.c lexer_utils.c
# Parser source files
SRCS += parser.c command.c parser_utils.c redirections.c
# Expander files
SRCS += expander.c double_quotes.c expander_utils.c expanders.c
# Utils source files
SRCS += doubly_linked_list_utils.c env_list.c count_symbol_in_string.c \
main_utils.c
# Builtins source files
SRCS += unset.c env.c echo.c export.c export_utils.c pwd.c exit.c cd.c \
sig_config.c env_list_utils.c \
# Executer source files
SRCS += commands.c exec_builtin.c exec_utils.c executor.c fds.c heredoc.c \
heredoc_signals.c prompt.c redirector.c subshells.c \
OBJ_DIR = ./obj/
vpath %.c src/
vpath %.c src/error/
vpath %.c src/lexer/
vpath %.c src/parser/
vpath %.c src/expander/
vpath %.c src/executor/
vpath %.c src/error/
vpath %.c src/utils/
vpath %.c src/builtin/unset
vpath %.c src/builtin/env
vpath %.c src/builtin/echo
vpath %.c src/builtin/export
vpath %.c src/builtin/pwd
vpath %.c src/builtin/exit
vpath %.c src/builtin/cd
vpath %.c src/builtin/builtin_utils
vpath %.c src/builtin/
OBJS = $(patsubst %.c, $(OBJ_DIR)%.o, $(SRCS))
all: $(LIB)
$(MAKE) $(NAME)
$(OBJS): $(OBJ_DIR)%.o: %.c $(HEADER)
$(CC) $(CFLAGS) -c $< -I $(INCLUDES) -I $(INCLUDES_LIB) -o $@
$(NAME): $(OBJ_DIR) $(OBJS)
@echo $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -I$(INCLUDES) -I$(INCLUDES_LIB) $(LIB) -L./libft -lft -o $@
$(OBJ_DIR):
mkdir $@
$(LIB):
$(MAKE) -C $(LIBDIR)
fclean : clean
$(MAKE) fclean -C $(LIBDIR)
$(RM) $(NAME)
$(RM) -R $(OBJ_DIR)
clean : clean
$(MAKE) fclean -C $(LIBDIR)
$(RM) $(NAME)
re : fclean
$(MAKE)