-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
87 lines (61 loc) · 2.35 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
NAME = so_long
NAME_BON = so_long_bonus
SRC_DIR = src/
SRCS = $(shell find ${SRC_DIR} -name *.c)
OBJS = $(patsubst %.c,%.o,${SRCS})
D_FILES = $(patsubst %.c,%.d,${SRCS})
SRC_BON_DIR = src_bonus/
SRCS_BON = $(shell find ${SRC_BON_DIR} -name *bonus.c)
OBJS_BON = $(patsubst %.c,%.o,${SRCS_BON})
D_FILES_BON = $(patsubst %.c,%.d,${SRCS_BON})
CFLAGS = -Wall -Werror -Wextra -O2 -MMD
INCLUDES = -I includes/ -I ${MINILIBIX_DIR} -I ${LIBFT_DIR}
INCLUDES_BON = -I includes_bonus/ -I ${MINILIBIX_DIR} -I ${LIBFT_DIR}
MINILIBIX_DIR = ./minilibx
GREENBG = \033[42m
NOBG = \033[0m
GREENTXT = \033[1;32m
NOCOLORTXT = \033[0m
LIBFT_DIR = libft/
LIBS = -lmlx -L${MINILIBIX_DIR} -L${LIBFT_DIR} -lft
%bonus.o: %bonus.c Makefile
@${CC} ${CFLAGS} -c $< -o $@ ${INCLUDES_BON}
%.o: %.c Makefile
@${CC} ${CFLAGS} -c $< -o $@ ${INCLUDES}
all: ${NAME}
$(NAME): ${OBJS}
echo "${GREENTXT}Compiling MINILIB${NOCOLORTXT}\n"
make -sC $(MINILIBIX_DIR)
echo "${GREENTXT}MINILIB is compiled${NOCOLORTXT}\n"
echo "${GREENTXT}Compiling LIBFT${NOCOLORTXT}\n"
make -sC ${LIBFT_DIR}
echo "${GREENTXT}LIBFT is compiled${NOCOLORTXT}\n"
${CC} ${CFLAGS} ${OBJS} ${LIBS} -framework OpenGL -framework AppKit -o $(NAME)
mv $(MINILIBIX_DIR)/libmlx.dylib .
echo "${GREENTXT}solong is compiled${NOCOLORTXT}\n"
bonus: ${NAME_BON}
$(NAME_BON): ${OBJS_BON}
echo "${GREENTXT}Compiling MINILIB${NOCOLORTXT}\n"
make -sC $(MINILIBIX_DIR)
echo "${GREENTXT}MINILIB is compiled${NOCOLORTXT}\n"
echo "${GREENTXT}Compiling LIBFT${NOCOLORTXT}\n"
make -sC ${LIBFT_DIR}
echo "${GREENTXT}LIBFT is compiled${NOCOLORTXT}\n"
${CC} ${CFLAGS} ${OBJS_BON} ${LIBS} -framework OpenGL -framework AppKit -o $(NAME_BON)
mv $(MINILIBIX_DIR)/libmlx.dylib .
echo "${GREENTXT}solong is compiled${NOCOLORTXT}\n"
clean:
rm -rf ${OBJS} ${D_FILES}
rm -rf ${OBJS_BON} ${D_FILES_BON}
echo "${GREENTXT}Cleaning complete${NOCOLORTXT} \n"
fclean: clean
${RM} ${NAME}
${RM} ${NAME_BON}
${RM} libmlx.dylib
make fclean -sC ${MINILIBIX_DIR}
make fclean -sC ${LIBFT_DIR}
echo "${GREENTXT}Full cleaning is complete too${NOCOLORTXT} \n"
re: fclean all
include $(wildcard $(D_FILES)) $(wildcard $(D_FILES_BON))
.PHONY: all clean fclean re bonus
.SILENT: all clean fclean re bonus $(NAME) $(NAME_BON)