-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
110 lines (79 loc) · 1.8 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
#MAIN VARS
CC = cc -g
CFLAGS = -Wall -Wextra -Werror
NAME = push_swap
BONUS_NAME = checker
FUNC_DIR = functions/
#FILES NAME
MAIN_FILE = push_swap.c \
FUNC_FILES = family_utils_one.c \
family_utils_two.c \
push_swap_entry.c \
push_swap_exit.c \
push_swap_error.c \
push_swap_utils.c \
push_swap_fixer.c \
ft_op_a.c \
ft_op_b.c \
ft_op_ab.c \
ft_pseudo_op_a.c \
ft_pseudo_op_b.c \
ft_pseudo_op_ab.c \
ft_turk_one.c \
ft_turk_two.c \
ft_utils_one.c \
ft_utils_two.c \
BONUS_FILE = checker.c \
FUNC = $(addprefix $(FUNC_DIR), $(FUNC_FILES))
#OBJECTS
MAIN_OBJ = $(MAIN_FILE:%.c=output/%.o)
BONUS_OBJ = $(BONUS_FILE:%.c=output/%.o)
FUNC_OBJS = $(FUNC:$(FUNC_DIR)%.c=output/%.o)
# Colors variables
GREEN = \033[0;32m
RED = \033[0;31m
BLUE = \033[0;34m
END = \033[0m
#DEPENDECIES
LIBFT_DIR = libft
#LIBRARIES
LIBFT_LIB = -L$(LIBFT_DIR) -lft
LIBS = $(LIBFT_LIB)
#INCLUDES
LIBFT_INC = -I$(LIBFT_DIR)/includes
PUSH_SWAP_INC = -Iincludes
INCLUDES = $(LIBFT_INC) $(PUSH_SWAP_INC)
#MAKE FUNCTIONS
define Compile
$(CC) $(CFLAGS) $(INCLUDES) -c $(1) -o $(2)
endef
define MakeLibs
make $(1) -C $(LIBFT_DIR)
endef
define Makebin
$(call MakeLibs,all)
$(CC) $(CFLAGS) $(1) $(LIBS) -o $(2)
endef
#MAIN RULES
all: $(NAME)
output:
mkdir -p output
output/%.o: %.c | output
$(call Compile,$<,$@)
output/%.o: $(FUNC_DIR)%.c | output
$(call Compile,$<,$@)
output/%.o: $(BONUS_DIR)%.c | output
$(call Compile,$<,$@)
$(NAME): $(MAIN_OBJ) $(FUNC_OBJS)
$(call Makebin,$^,$@)
clean:
$(call MakeLibs,clean)
rm -rf output/*.o
fclean: clean
$(call MakeLibs,fclean)
rm -rf $(NAME) $(BONUS_NAME)
re: fclean all
bonus: $(BONUS_NAME)
$(BONUS_NAME): $(BONUS_OBJ) $(FUNC_OBJS)
$(call Makebin,$^,$@)
.PHONY: all clean fclean re bonus