-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
87 lines (74 loc) · 2.55 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: tom <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/03/01 00:09:38 by tom #+# #+# #
# Updated: 2022/03/17 17:36:31 by tom ### ########.fr #
# #
# **************************************************************************** #
# EXECUTABLE
NAME = ./philo
# FLAGS
CC = gcc
CFLAGS = -Wall -Wextra -Werror
# COLORS
Y = "\033[33m"
R = "\033[31m"
G = "\033[32m"
B = "\033[34m"
X = "\033[0m"
UP = "\033[A"
CUT = "\033[K"
# PATHS
SRC_PATH = ./src/
OBJ_PATH = ./obj/
UTILS_PATH = ./src/
# SOURCES
SRC = $(SRC_PATH)main.c $(SRC_PATH)utils_1.c $(SRC_PATH)utils_2.c\
$(SRC_PATH)input.c $(SRC_PATH)philos.c \
$(SRC_PATH)routine.c $(SRC_PATH)reaper.c
# OBJECTS
OBJ = $(patsubst $(SRC_PATH)%.c, $(OBJ_PATH)%.o, $(SRC))
# RULES
all: $(NAME)
@sleep 0.15
@echo $(B)" __ __ __ __ "$(X)
@sleep 0.15
@echo $(B)" .-----.| |--.|__| |.-----.-----.-----.-----.| |--.-----.----.-----. "$(X)
@sleep 0.15
@echo $(B)" | _ || || | || _ |__ --| _ | _ || | -__| _|__ --| "$(X)
@sleep 0.15
@echo $(B)" | __||__|__||__|__||_____|_____|_____| __||__|__|_____|__| |_____| "$(X)
@sleep 0.15
@echo $(B)" |__| |__| "$(X)
@sleep 0.15
@printf "\n\n"
$(OBJ_PATH)%.o :$(SRC_PATH)%.c
@echo $(Y)Compiling [$@]...$(X)
@mkdir -p $(dir $@)
@sleep 0.2
@printf $(UP)$(CUT)
@$(CC) $(CFLAGS) -c -o $@ $<
@echo $(G)Finished [$@]$(X)
@sleep 0.2
@printf $(UP)$(CUT)
$(NAME): $(OBJ)
@$(CC) $(CFLAGS) $(OBJ) -o $(NAME)
@echo $(G)Finished [$(NAME)]$(X)
clean:
@if [ -d "$(OBJ_PATH)" ]; then \
rm -f -r $(OBJ_PATH); \
echo $(R)Cleaning" "[$(OBJ) $(OBJ_PATH)]$(X); else \
echo "No objects to remove."; \
fi;
fclean: clean
@if [ -f "$(NAME)" ]; then \
rm -f $(NAME); \
echo $(R)Cleaning" "[$(NAME)]$(X);else \
echo "No executable to remove."; \
fi;
re: fclean all
.PHONY: all, clean, fclean, re