NAME =		woody_woodpacker

SRC_FILE =	main.c \

OBJ_FILE =	$(SRC_FILE:.c=.o)

INC_FILE =	woody.h \

SRC_DIR =	src/
OBJ_DIR =	obj/
INC_DIR =	inc/
SRC =		$(addprefix $(SRC_DIR), $(SRC_FILE))
OBJ =		$(addprefix $(OBJ_DIR), $(OBJ_FILE))
INC =		$(addprefix $(INC_DIR), $(INC_FILE))

CC =		gcc
CFLAGS =	-Wall -Werror -Wextra

LIB =		ft_printf/libftprintf.a

GREEN =		\033[32m
RED =		\033[31m
ORANGE =	\033[33m
PURPLE =	\033[35m
CYAN =		\033[36m
WHITE =		\033[0m

all: $(NAME)

$(NAME): $(OBJ) $(INC)
	@echo -e "$(PURPLE)[MAKE]$(WHITE) ft_printf"
	@make --no-print-directory -C ft_printf
	@$(CC) $(CFLAGS) -I $(INC_DIR) -c $(SRC)
	@mv $(OBJ_FILE) $(OBJ_DIR)
	@$(CC) $(CFLAGS) $(OBJ) $(LIB) -o $(NAME)
	@echo -e "$(GREEN)[OK]$(WHITE) $(NAME)"

$(OBJ_DIR)%.o: $(SRC_DIR)%.c $(INC)
	@if [ ! -d ./obj ]; then \
		mkdir -p ./obj; \
	fi;
	@$(CC) $(CFLAGS) -I $(INC_DIR) -o $@ -c $<
	@echo -e "$(CYAN)[CC]$(WHITE) $<"

clean:
	@make --no-print-directory -C ft_printf clean
	@echo -e "$(ORANGE)[CLEAN]$(WHITE) $(NAME)"
	@rm -rf $(OBJ_DIR)

fclean: clean
	@make --no-print-directory -C ft_printf fclean
	@echo -e "$(RED)[DELETE]$(WHITE) $(NAME)"
	@rm -f $(NAME)

re: fclean all

.PHONY: all clean fclean re