-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·100 lines (83 loc) · 2.22 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
#Variables
USERNAME = $(shell whoami)
NAME = minishell
INCLUDE = include
LIBFT = lib/libft
SRC_DIR = src/
OBJ_DIR = obj/
CC = gcc
CFLAGS = -Wall -Werror -Wextra -g
AR = ar rcs
# Colors
DEF_COLOR = $(shell tput sgr0)
GRAY = $(shell tput setaf 0)
RED = $(shell tput setaf 1)
GREEN = $(shell tput setaf 2)
YELLOW = $(shell tput setaf 3)
BLUE = $(shell tput setaf 4)
MAGENTA = $(shell tput setaf 5)
CYAN = $(shell tput setaf 6)
WHITE = $(shell tput setaf 7)
#Sources
SRC_FILES = main cleanup utils \
parse/loop \
parse/loop_utils \
parse/quotes \
parse/expansion \
parse/heredoc_main \
parse/heredoc_sub \
parse/heredoc_utils \
parse/redirections \
parse/setup_nodes \
parse/setup_nodes_utils \
builtin/built_ins \
builtin/exit_status \
builtin/echo \
builtin/cd \
builtin/cd_utils \
builtin/cd_utils2 \
builtin/pwd \
builtin/export \
builtin/export_utils \
builtin/unset \
builtin/env \
builtin/exit \
builtin/ps_functions \
builtin/ft_strjoin_mod \
builtin/preset_env_utils \
builtin/preset_env \
executor/path \
executor/executor \
executor/executor_utils \
SRC = $(addprefix $(SRC_DIR), $(addsuffix .c, $(SRC_FILES)))
OBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(SRC_FILES)))
OBJF = .cache_exists
###
all: $(NAME)
$(NAME): $(OBJ)
@make -C $(LIBFT)
@$(CC) -I./$(INCLUDE) $(CFLAGS) $(OBJ) -L$(LIBFT) -lft -o $(NAME) -lreadline -L/Users/$(USERNAME)/.brew/opt/readline/lib
@echo "$(GREEN)$(NAME) compiled!$(DEF_COLOR)"
$(OBJ_DIR)%.o: $(SRC_DIR)%.c | $(OBJF)
@mkdir -p $(dir $@)
@echo "$(YELLOW)Compiling: $< $(DEF_COLOR)"
@$(CC) -I./$(INCLUDE) -I/Users/$(USERNAME)/.brew/opt/readline/include $(CFLAGS) -c $< -o $@
$(OBJF):
@mkdir -p $(OBJ_DIR)
clean:
@rm -rf $(OBJ_DIR)
@make clean -C $(LIBFT)
@echo "$(BLUE)$(NAME) object files cleaned!$(DEF_COLOR)"
fclean:
@rm -rf $(OBJ_DIR)
@rm -f $(NAME)
@rm -rf $(NAME).dSYM
@make fclean -C $(LIBFT)
@echo "$(BLUE)$(NAME) executable cleaned!$(DEF_COLOR)"
re: fclean all
@echo "$(MAGENTA)$(NAME) recompiled!$(DEF_COLOR)"
norm:
@norminette $(SRC) $(INCLUDE) $(LIBFT)
test:
@make && valgrind --leak-check=full --track-fds=yes ./minishell
.PHONY: all clean fclean re norm