-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
177 lines (157 loc) · 5.23 KB
/
Copy pathMakefile
File metadata and controls
177 lines (157 loc) · 5.23 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: nsehnoun <nsehnoun@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2018/06/07 14:24:02 by antoipom #+# #+# #
# Updated: 2018/09/18 22:42:31 by kernel_pa ### ########.fr #
# #
# **************************************************************************** #
COLOR_CLEAR = \033[2K
COLOR_UP = \033[A
COLOR_NOCOLOR = \033[0m
COLOR_BOLD = \033[1m
COLOR_UNDERLINE = \033[4m
COLOR_BLINKING = \033[5m
COLOR_BLACK = \033[1;30m
COLOR_RED = \033[1;31m
COLOR_GREEN = \033[1;32m
COLOR_YELLOW = \033[1;33m
COLOR_BLUE = \033[1;34m
COLOR_VIOLET = \033[1;35m
COLOR_CYAN = \033[1;36m
COLOR_WHITE = \033[1;37m
################################################################################
SRC_FILES = main.c \
main_loop.c \
\
lexer/lexer.c \
\
parser/parser.c \
parser/execute.c \
parser/error.c \
parser/parser_validation.c \
parser/redirections.c \
parser/redirect_implementation.c \
parser/redirect_construct.c \
parser/redirect_heredoc.c \
parser/arg_table.c \
parser/is_fd.c \
parser/pipes.c \
parser/token2str.c \
parser/token2str_init.c \
parser/token2str2.c \
parser/ast_evaluate.c \
parser/ast_construct.c \
parser/ast_free.c \
\
builtins/add_to_mod.c \
builtins/bin.c \
builtins/cd.c \
builtins/cd_canon.c \
builtins/cd_canon_dotdot.c \
builtins/cd_options.c \
builtins/env.c \
builtins/env_exec.c \
builtins/env_mod.c \
builtins/env_setup.c \
builtins/error.c \
builtins/free.c \
builtins/path.c \
builtins/pwd.c \
builtins/setenv.c \
builtins/unsetenv.c \
builtins/history.c \
builtins/history_builtins_0.c \
builtins/history_builtins_1.c \
builtins/history_builtins_2.c \
builtins/history_builtins_3.c \
builtins/history_builtins_4.c \
builtins/history_builtins_5.c \
builtins/history_options.c \
builtins/history_flags.c \
builtins/sh_close.c \
\
line_edit/line_edit_main_loop.c \
line_edit/termanip.c \
line_edit/manage_data.c \
line_edit/advanced_cursor_motion.c \
line_edit/cursor_motion.c \
line_edit/react.c \
line_edit/history.c \
line_edit/selection_mode.c \
line_edit/struct_alloc.c \
line_edit/signals_le.c \
line_edit/signals_le_mode.c \
line_edit/search_mode.c \
line_edit/implem_complet.c \
line_edit/write_data.c\
line_edit/autocompletion.c \
line_edit/cmpltn_utils.c \
line_edit/fetch_utils.c \
line_edit/cmplt_misc.c \
line_edit/prompt_utils.c \
line_edit/sig_ignore.c \
\
heredoc/heredoc.c \
heredoc/heredoc_fill.c \
\
lexer/check_history_token.c \
lexer/history_token.c \
lexer/get_tokens_loop.c
INC_FILES = lexer.h \
parser.h \
builtins.h \
sh_line_edit.h \
shell_structs.h \
heredoc.h
NAME ?= 42sh
#ASAN =
#ifeq ($(ASAN), yes)
# SANITIZER ?= -fsanitize=address -fno-omit-frame-pointer
#endif
LIB_DIR = libft
SRC_DIR = srcs
OBJ_DIR = objs
LOCAL_INC = -Iinclude
LIB_INC = -I$(LIB_DIR)/include
OPTIMIZATION ?= -O0
CC ?= gcc
CCFLAGS ?= -Wall -Wextra -Werror
LDFLAGS = -L$(LIB_DIR) -lft -ltermcap
INCLUDES = $(LOCAL_INC) $(LIB_INC)
INCLUDES_DEP = $(addprefix ./include/, $(INC_FILES))
SRCS = $(addprefix $(SRC_DIR)/,$(SRC_FILES:.c=.c))
OBJS = $(addprefix $(OBJ_DIR)/,$(SRC_FILES:.c=.o))
################################################################################
.phony: all hello_word lib $(OBJ_DIR) $(NAME) clean fclean re
all: hello_word lib $(OBJ_DIR) $(NAME) $(INCLUDES_DEP)
@printf "$(COLOR_CLEAR)$(COLOR_GREEN)successfully created $(COLOR_BLUE)$(NAME)$(COLOR_NOCOLOR)\n"
hello_word:
@printf "$(COLOR_VIOLET)$(COLOR_UNDERLINE)compiling$(COLOR_NOCOLOR) $(COLOR_BLUE)$(NAME) ...$(COLOR_NOCOLOR)\n"
lib:
@make -C $(LIB_DIR) APPEND="$(APPEND)" OPTIMIZATION="$(OPTIMIZATION)" CC="$(CC)"
$(NAME): $(OBJS)
@printf "$(COLOR_GREEN)successfully created objects files for binary $(COLOR_BLUE)$(NAME)$(COLOR_NOCOLOR)\n"
@printf "$(COLOR_VIOLET)creating $(NAME) ... $(COLOR_NOCOLOR)\n"
@$(CC) $(CCFLAGS) -o $(NAME) $(OBJS) $(LDFLAGS) $(INCLUDES) $(SANITIZER) $(OPTIMIZATION)
$(OBJ_DIR):
@/bin/mkdir -p $(OBJ_DIR)
@/bin/mkdir -p $(OBJ_DIR)/lexer
@/bin/mkdir -p $(OBJ_DIR)/parser
@/bin/mkdir -p $(OBJ_DIR)/builtins
@/bin/mkdir -p $(OBJ_DIR)/line_edit
@/bin/mkdir -p $(OBJ_DIR)/heredoc
clean:
@make -C $(LIB_DIR) clean
@/bin/rm -rf $(OBJ_DIR)
fclean: clean
@make -C $(LIB_DIR) fclean
@/bin/rm -f $(NAME)
re: fclean all
$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c
@printf "$(COLOR_VIOLET)creating objects files for library $(COLOR_BLUE)$(NAME) ... \n$(COLOR_CYAN)"
$(CC) $(OPTIMIZATION) $(CCFLAGS) $(INCLUDES) $(SANITIZER) -c -o $@ $^
@printf "\n$(COLOR_NOCOLOR)$(COLOR_UP)$(COLOR_CLEAR)$(COLOR_UP)$(COLOR_CLEAR)$(COLOR_UP)$(COLOR_CLEAR)"