-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (65 loc) · 2.03 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
# ************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: jcorneli <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/11/30 02:05:25 by jcorneli #+# #+# #
# Updated: 202# Updated: 2021/12/15 04:29:23 by jcorneli ### ########.fr # #
# ************************************************************************** #
NAME = philo
SHARED = philosopher.c \
parser.c \
init.c \
timing.c \
act.c \
talk.c \
talk2.c \
utils.c
DO_BONUS = monitor.c \
child.c
NO_BONUS = threads.c
ifdef BONUS
SRC_DIR = src/philo_bonus
SRC = $(SHARED) $(DO_BONUS)
else
SRC = $(SHARED) $(NO_BONUS)
SRC_DIR = src/philo
$(info )
endif
OBJ_DIR = $(SRC_DIR)/obj
INCL = -I$(SRC_DIR)/incl
C_FLAGS = -Wall -Wextra -Werror
OBJ = $(SRC:%.c=$(OBJ_DIR)/%.o)
all: $(NAME)
@echo
@echo "\033[32mDone building Philosophers (no bonus)\033[0m"
@echo
@touch src/philo_bonus/philosopher.c
ball: $(NAME)
@echo
@echo "\033[32mDone building Philosophers (bonus)\033[0m"
@echo
@touch src/philo_bonus/philosopher.c
bonus:
@$(MAKE) BONUS=1 ball
@touch src/philo/philosopher.c
$(NAME): $(OBJ)
@echo
@echo "\033[36mLinking binary file: $@\033[0m"
@$(CC) $^ $(C_FLAGS) -o $@
$(OBJ_DIR)/%.o:$(SRC_DIR)/%.c
@mkdir -p $(@D)
@echo "\033[34mCompiling object file: $@\033[0m"
@$(CC) $< $(C_FLAGS) $(INCL) -c -o $@
clean:
@echo "\033[31mRemoving object files\033[0m"
@echo
@rm -rf src/philo/obj
@rm -rf src/philo_bonus/obj
fclean: clean
@echo "\033[31mRemoving binary\033[0m"
@echo
@rm -f $(NAME)
re: clean all