blob: 597fa29a1d1d93306024063d1876361312e0f04d (
plain)
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
|
# Program name
NAME := philo
# Directories
SRC_DIR := src
BUILD_DIR := ./build
INC_DIR := ./include
SRCS := $(addprefix $(SRC_DIR)/, \
main.c \
time.c \
print.c \
starve.c \
free_memory.c \
forks.c \
philos.c \
routine.c \
monitoring.c \
threads.c \
queue.c \
init.c \
destroy.c \
utils.c \
utils_routine.c \
validate_parameters.c \
scheduler.c \
sim.c)
OBJS := $(SRCS:%.c=$(BUILD_DIR)/%.o)
# Automatically generated dependency files
DEPS := $(SRCS:%.c=$(BUILD_DIR)/%.d)
# -MMD and -MP will assist the rule to create the dependencies using -include ...
#CFLAGS := -Wall -Wextra -Werror -static-libasan -fsanitize=address -g3 -pthread
#CFLAGS := -Wall -Wextra -Werror -static-libasan -fsanitize=thread -g3 -pthread -fno-sanitize=thread
#CFLAGS_DEBUG := -Wall -Wextra -Werror -g3 -O0 -MMD -MP -pthread
CFLAGS := -Wall -Wextra -Werror -MMD -MP -pthread -I$(INC_DIR)
.DEFAULT_GOAL = all
all: $(NAME)
# that goes along with DEPS := $(OBJS:.o=.d)
-include $(DEPS)
$(BUILD_DIR)/%.o: %.c
mkdir -p $(dir $@)
$(CC) -c -o $@ $< $(CFLAGS)
$(NAME) : $(OBJS)
$(CC) -o $@ $^ $(CFLAGS)
.PHONY: clean fclean re all
clean:
rm -rf $(BUILD_DIR)
fclean: clean
rm -f $(NAME)
re: fclean all
|