-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
76 lines (59 loc) · 2.24 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
NAME = minishell
OBJ_DIR = obj/
CC = gcc
CFLAGS = -Wall -Wextra -Werror -g
RM = rm -rf
READLINE = -lreadline
LIB = minishell.h
SUCCESS = @echo "\033[32mSuccessfull !\033[0m"
CLEANED = @echo "\033[34mCleaned !\033[0m"
BUILTIN_DIR = builtin/
BUILTIN_FILES = builtin cd echo env exit export pwd unset
BUSINESS_DIR = business/
BUSINESS_FILES = executor expander lexer main parser wildcard add_wildcards
ERROR_DIR = err/
ERROR_FILES = err
FREE_DIR = free/
FREE_FILES = free
UTILS_DIR = utils/
UTILS_FILES = find_pair ft_atoi ft_bzero ft_calloc ft_itoa ft_split ft_strcmp ft_strchr ft_strdup ft_strjoin ft_strlcpy ft_strcpy ft_strlen ft_strncmp ft_strnsearch ft_substr get_env get_path is_whitespace key_val list_len set_env set_paths strnstr_wildcard
B_FILES = $(addprefix $(BUILTIN_DIR), $(BUILTIN_FILES))
BS_FILES = $(addprefix $(BUSINESS_DIR), $(BUSINESS_FILES))
E_FILES = $(addprefix $(ERROR_DIR), $(ERROR_FILES))
F_FILES = $(addprefix $(FREE_DIR), $(FREE_FILES))
U_FILES = $(addprefix $(UTILS_DIR), $(UTILS_FILES))
BUILTIN = $(addsuffix .c, $(B_FILES))
BOBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(B_FILES)))
BUSINESS = $(addsuffix .c, $(BS_FILES))
BSOBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(BS_FILES)))
ERROR = $(addsuffix .c, $(E_FILES))
EOBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(E_FILES)))
FREE = $(addsuffix .c, $(F_FILES))
FOBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(F_FILES)))
UTILS = $(addsuffix .c, $(U_FILES))
UOBJ = $(addprefix $(OBJ_DIR), $(addsuffix .o, $(U_FILES)))
OBJF = .cache_exists
all: $(NAME) $(LIB)
$(NAME): $(OBJF) $(BOBJ) $(BSOBJ) $(EOBJ) $(FOBJ) $(UOBJ)
@$(CC) $(CFLAGS) $(BOBJ) $(BSOBJ) $(EOBJ) $(FOBJ) $(UOBJ) $(READLINE) -o $(NAME)
$(SUCCESS)
$(OBJ_DIR)%.o: %.c
@$(CC) $(CFLAGS) -c $< -o $@
$(OBJF):
@mkdir -p $(OBJ_DIR)
@mkdir -p $(OBJ_DIR)$(BUILTIN_DIR)
@mkdir -p $(OBJ_DIR)$(BUSINESS_DIR)
@mkdir -p $(OBJ_DIR)$(ERROR_DIR)
@mkdir -p $(OBJ_DIR)$(FREE_DIR)
@mkdir -p $(OBJ_DIR)$(UTILS_DIR)
@touch $(OBJF)
clean:
@$(RM) $(OBJ_DIR)
@$(RM) $(OBJF)
$(CLEANED)
fclean: clean
@$(RM) $(NAME)
@$(RM) *.dSYM
@find . -name ".DS_Store" -delete
re: fclean all
.PHONY: all clean fclean re