NAME = philo CC = clang CFLAGS = -Wall -Wextra -Werror $(INCLUDES) -g3 VPATH = $(DIR_SRCS) DIR_SRCS = srcs INCLUDES = -I$(HEADERS_D) HEADERS_D = . HEADERS = philo.h \ philo_struct.h \ philo_proto.h \ philo_macro.h LIBS = -lpthread SRCS = main.c \ init.c \ launch.c \ exec.c \ utils.c \ generic.c DIR_OBJS = builds OBJS = $(SRCS:%.c=$(DIR_OBJS)/%.o) # -------------------- # ------ RULES ------- # -------------------- all: $(NAME) $(DIR_OBJS)/%.o: %.c | $(DIR_OBJS) $(CC) $(CFLAGS) -c $< -o $@ $(DIR_OBJS): mkdir $@ $(OBJS): $(HEADERS:%=$(HEADERS_D)/%) $(NAME): $(OBJS) $(CC) $(OBJS) -o $(NAME) $(LIBS) clean: rm -rf $(OBJS) rm -rf $(DIR_OBJS) fclean: clean rm -f $(NAME) re: fclean all valgrind: $(NAME) valgrind --leak-check=full --leak-resolution=low --show-reachable=yes ./$(NAME) run: $(NAME) ./$(NAME) .PHONY : all clean fclean re bonus subsystem run valgrind