Repository navigation
Expand file tree
/
Copy pathmakefile
More file actions
63 lines (49 loc) · 1.91 KB
/
Copy pathmakefile
File metadata and controls
63 lines (49 loc) · 1.91 KB
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
# **************************************************************************** #
# #
# ::: :::::::: #
# makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: zgahrama <zgahrama@student.42prague.com +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2026/01/02 15:22:03 by zgahrama #+# #+# #
# Updated: 2026/01/07 19:34:11 by zgahrama ### ########.fr #
# #
# **************************************************************************** #
NAME := philo
CC := cc
CFLAGS := -Wall -Wextra -Werror
CPPFLAGS := -Iinclude
LDFLAGS := -pthread
SRC_DIR := src
BUILD_DIR := build
SRCS := $(SRC_DIR)/main.c \
$(SRC_DIR)/create_table.c \
$(SRC_DIR)/create_philo.c \
$(SRC_DIR)/parse_input.c \
$(SRC_DIR)/error.c \
$(SRC_DIR)/cleanup.c \
$(SRC_DIR)/lifecycle.c \
$(SRC_DIR)/death.c \
$(SRC_DIR)/safe_print.c
OBJS := $(SRCS:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o)
# Optional arguments for running under valgrind/helgrind
ARGS ?=
VG_OPTS ?= --leak-check=full --show-leak-kinds=all --track-origins=yes
HG_OPTS ?=
all: $(NAME)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR)
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
$(NAME): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $(NAME)
clean:
rm -rf $(BUILD_DIR)
fclean: clean
rm -f $(NAME)
re: fclean all
valgrind: $(NAME)
valgrind $(VG_OPTS) ./$(NAME) $(ARGS)
helgrind: $(NAME)
valgrind --tool=helgrind $(HG_OPTS) ./$(NAME) $(ARGS)
.PHONY: all clean fclean re valgrind helgrind