# 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