-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (109 loc) · 6.05 KB
/
Makefile
File metadata and controls
133 lines (109 loc) · 6.05 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
# · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·#
# #
# COLORS #
# #
# · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·#
RESET = \033[0m
BLACK = \033[1;30m
RED = \033[1;31m
GREEN = \033[1;32m
YELLOW = \033[1;33m
BLUE = \033[1;34m
PURPLE = \033[1;35m
CYAN = \033[1;36m
WHITE = \033[1;37m
# · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·#
# #
# COMMANDS #
# #
# · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·#
CC = cc
RM = rm -rf
AR = ar -rcs
# · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·#
# #
# FLAGS #
# #
# · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·#
CFLAGS = -g -Wall -Werror -Wextra
INCLUDE = -I./includes
INCLUDE += -I/opt/homebrew/opt/readline/include
# · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·#
# #
# FOLDERS #
# #
# · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·#
SRC_DIR = srcs
OBJ_DIR = obj
LIBFT = libft
LIBFT_LIB = $(LIBFT)/libft.a
LIBS = -lncurses -lreadline
LIBS_MAC = -ltermcap -lncurses -L/opt/homebrew/opt/readline/lib -lreadline
# · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·#
# #
# FILES #
# #
# · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·#
NAME = minishell
SRC_FILES = builtins/cd.c builtins/echo.c builtins/env.c builtins/export.c \
builtins/export_utils.c builtins/export_utils_2.c builtins/pwd.c \
builtins/unset.c environment/environment.c \
environment/environment_utils.c environment/environment_utils_2.c \
execution/execution.c execution/execution_utils.c execution/redir_handler.c \
execution/redir_handler_utils.c heredoc/heredoc.c heredoc/heredoc_utils.c \
signals/signal.c utils/expander.c utils/expander_utils.c utils/expander_utils_1.c \
utils/expander_utils_2.c utils/expander_utils_3.c utils/expander_utils_4.c utils/expander_utils_5.c \
utils/free.c utils/split2.c utils/split2_utils.c utils/split2_utils_2.c \
utils/token_utils.c utils/utils.c utils/utils1.c utils/utils2.c utils/utils3.c \
utils/utils4.c utils/validations.c utils/validations_1.c \
exit.c main.c parser.c parser_utils.c pipes.c redirections.c
SRC = $(addprefix $(SRC_DIR)/, $(SRC_FILES))
OBJ = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRC))
# · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·#
# #
# RULES #
# #
# · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·#
OS := $(shell uname)
ifeq ($(OS), Darwin)
LIBS_USED = $(LIBS_MAC)
else
LIBS_USED = $(LIBS)
endif
all: $(NAME)
# @printf "\n"
# @echo $(G)" _ _ _ _ _ "$(X)
# @echo $(G)" _____|_|___|_|___| |_ ___| | |"$(X)
# @echo $(G)"| | | | |_ -| | -_| | |"$(X)
# @echo $(G)"|_|_|_|_|_|_|_|___|_|_|___|_|_|"$(X)
# @printf "\n\n"
$(NAME): $(OBJ)
@make -C $(LIBFT) --no-print-directory
$(CC) $(CFLAGS) $(INCLUDE) $(OBJ) $(LIBFT_LIB) $(LIBS_USED) -o $@
@echo "$(GREEN)$(NAME)$(RESET) Created"
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(@D)
@$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
clean:
@make clean -C $(LIBFT) --no-print-directory
@$(RM) $(OBJ_DIR)
@echo "$(YELLOW)$(NAME)$(RESET) Objects Deleted"
fclean: clean
@make fclean -C $(LIBFT) --no-print-directory
@$(RM) $(NAME)
@echo "$(RED)$(NAME)$(RESET) Deleted"
re: fclean all
BUILDID=$(shell date +%Y%m%d-%H:%M:%S)
commit: fclean
git add -A .
git commit -m 'Automatic commit of successful build $(BUILDID)'
git push origin main
run: re
@./$(NAME)
valgrind: re
@clear
@echo "[$(RED)looking for valgrind leaks$(RESET)] $(GREEN)$(RESET)"
@sleep 1
@valgrind -s --suppressions=readline.supp --leak-check=full --show-leak-kinds=all ./minishell
.PHONY: all clean fclean re
#.SILENT: