-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
134 lines (109 loc) · 4.85 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
122
123
124
125
126
127
128
129
130
131
132
133
134
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: apriego- <apriego-@student.42barcel> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/08/14 11:57:58 by apriego- #+# #+# #
# Updated: 2023/09/22 11:25:01 by apriego- ### ########.fr #
# #
# **************************************************************************** #
#==================COLORS==================#
GREEN = \033[38;5;154m
RED = \033[38;5;197m
PURPLE = \033[38;5;171m
BLUE = \033[38;5;14m
NC = \033[0m
YELLOW = \033[38;5;190m
#=================COMMANDS=================#
CC = gcc
CFLAGS = -Wall -Wextra -Werror
INCLUDE = -I./inc -I./readline
RM = rm -fr
#==================FILES===================#
NAME = minishell
COMP = ./libft/libft.a
FILES_ENTRY = entry.c signals.c
FILES_BUILT = built_ins.c built_ins2.c built_ins3.c utils_pwd.c utils_export.c
FILES_GEN = main.c utils.c utils2.c utils3.c utils4.c
FILES_EXPAN = expansor.c expansor_utils.c expansor_utils2.c expand_files.c expand_files_utils.c expansor_utils_redirect.c
FILES_LEXER = tokenizer.c tokenizer_utils.c tokenizer_lists.c
FILES_PARSE = parser.c parser_syntax.c cmd_lists.c redirect_lists.c
FILES_EXEC = executor.c executor_utils.c find_path.c find_path_utils.c redirections.c\
executor_utils2.c
FILES_HERE = heredoc.c
HEADER = ./inc/minishell.h
LIBFT_ROOT := libft/
RDLINE_ROOT := readline/
DIR_OBJ := temp/
INC_ROOT := inc/m
SRC_DIR = src/
ENTRY_DIR = entry/
HERE_DIR = heredoc/
BUILT_DIR = built-ins/
LEXER_DIR = lexer/
PARSER_DIR = parser/
EXPAN_DIR = expansor/
EXEC_DIR = executor/
SRC_EXPAN = $(addprefix $(SRC_DIR),$(addprefix $(EXPAN_DIR),$(FILES_EXPAN)))
SRC_ENTRY = $(addprefix $(SRC_DIR),$(addprefix $(ENTRY_DIR),$(FILES_ENTRY)))
SRC_BUILT = $(addprefix $(SRC_DIR),$(addprefix $(BUILT_DIR),$(FILES_BUILT)))
SRC_LEXER = $(addprefix $(SRC_DIR),$(addprefix $(LEXER_DIR),$(FILES_LEXER)))
SRC_PARSER = $(addprefix $(SRC_DIR),$(addprefix $(PARSER_DIR),$(FILES_PARSE)))
SRC_EXEC = $(addprefix $(SRC_DIR),$(addprefix $(EXEC_DIR),$(FILES_EXEC)))
SRC_HERE = $(addprefix $(SRC_DIR),$(addprefix $(HERE_DIR),$(FILES_HERE)))
SRC_GEN = $(addprefix $(SRC_DIR), $(FILES_GEN))
OBJ_EXPAN = $(addprefix $(DIR_OBJ),$(SRC_EXPAN:.c=.o))
OBJ_ENTRY = $(addprefix $(DIR_OBJ),$(SRC_ENTRY:.c=.o))
OBJ_BUILT = $(addprefix $(DIR_OBJ),$(SRC_BUILT:.c=.o))
OBJ_LEXER = $(addprefix $(DIR_OBJ),$(SRC_LEXER:.c=.o))
OBJ_PARSER = $(addprefix $(DIR_OBJ),$(SRC_PARSER:.c=.o))
OBJ_EXEC = $(addprefix $(DIR_OBJ),$(SRC_EXEC:.c=.o))
OBJ_HERE = $(addprefix $(DIR_OBJ),$(SRC_HERE:.c=.o))
OBJ = $(addprefix $(DIR_OBJ),$(SRC_GEN:.c=.o))
LIB_A := $(RDLINE_ROOT)libreadline.a $(RDLINE_ROOT)libhistory.a \
$(LIBFT_ROOT)libft.a
LIB_ADD_DIR := -L$(RDLINE_ROOT) -L$(LIBFT_ROOT)
LIB_SEARCH := -lreadline -lhistory -ltermcap -lft
#=================HEADERS==================#
HEADERS := $(INC_ROOT)
HEADERS += $(addsuffix $(INC_ROOT),$(LIBFT_ROOT))
#==================RULES===================#
all : temp librarys $(NAME)
librarys :
@$(MAKE) -C $(LIBFT_ROOT) --no-print-directory
@$(MAKE) rdline --no-print-directory
$(NAME) : $(OBJ) $(OBJ_BUILT) $(OBJ_ENTRY) $(OBJ_LEXER) $(OBJ_PARSER) $(OBJ_EXPAN) $(OBJ_EXEC) $(OBJ_HERE)
@$(CC) $(CFLAGS) $(OBJ) $(OBJ_BUILT) $(OBJ_ENTRY) $(OBJ_LEXER) $(OBJ_PARSER) $(OBJ_EXPAN) $(OBJ_HERE) $(OBJ_EXEC) $(LIB_ADD_DIR) $(LIB_SEARCH) $(LIB_A) -o $@
@echo "${GREEN}Minishell Compiled${NC}"
rdline :
@echo "${YELLOW}Compiling Readline...${NC}"
@cd ./readline/ &> /dev/null && ./configure &> /dev/null
@make -C ./readline/ &> /dev/null
@echo "${GREEN}Readline Compiled${NC}"
$(DIR_OBJ)%.o: %.c Makefile $(LIB_A) $(HEADER)
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) -DREADLINE_LIBRARY=1 $(INCLUDE) -c $< -o $@
@echo "${YELLOW}Compiling obj $@...${NC}"
temp :
@mkdir -p $(DIR_OBJ)
clean :
@$(MAKE) -C libft clean --no-print-directory
@$(RM) $(DIR_OBJ)
@printf "${RED}Objs deleted\n${NC}"
fclean : clean
@$(MAKE) -C libft cleaname --no-print-directory
@$(RM) $(NAME)
@printf "${RED}Minishell deleted\n${NC}"
@$(MAKE) -C readline clean --no-print-directory
norm :
@printf "${PURPLE}SEARCHING FOR A PRINTF IN THE PROJECT: "
@printf "%i \n${NC}" $(shell grep " printf" *.c | wc -l)
@printf "${YELLOW}Norminette...\n${NC}"
@printf "${RED}"
@norminette src/*/*.c src/*.c inc/*.h > test && printf "$(GREEN)\t[OK]\n" || grep Error test
@printf "${NC}"
@rm test
re : fclean all
.PHONY : all clean fclean re librarys rdline