-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (51 loc) · 1.02 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
NAME := philo
# Directories
INCL_DIR := -I./includes
SRCS_DIR := sources
OBJS_DIR := objects
VPATH := $(subst $(space),:,$(shell find $(SRCS_DIR) -type d))
# Sources and objects
MAIN := main.c
export SRCS := philosophers.c \
init_all.c \
play_game.c \
time.c \
philo_utils.c \
ft_atoi.c \
ft_isdigit.c
ALL_SRCS := $(MAIN) $(SRCS)
ALL_OBJS := $(addprefix $(OBJS_DIR)/, $(ALL_SRCS:.c=.o))
# Config
ifdef debug
FLAGS := -Wall -Wextra -g3 -fsanitize=address
COMPILE := clang -c
LINK := clang
else
ifdef thread
FLAGS := -Wall -Wextra -g3 -fsanitize=thread
COMPILE := gcc -c
LINK := gcc
else
FLAGS := -Wall -Wextra -Werror -g3
COMPILE := gcc -c
LINK := gcc
endif
endif
# Config
all: $(NAME)
$(NAME): $(OBJS_DIR) $(ALL_OBJS)
$(LINK) $(FLAGS) $(ALL_OBJS) -o $@
$(OBJS_DIR)/%.o: %.c
$(COMPILE) $(FLAGS) $< $(INCL_DIR) -o $@
run: all
./$(NAME)
drun: all
lldb $(NAME)
$(OBJS_DIR):
mkdir -p $@
clean:
rm -rf $(OBJS_DIR)
fclean: clean
rm -f $(NAME)
re: fclean all
.PHONY: all clean fclean re