# **************************************************************************** #
#                                                                              #
#                                                         :::      ::::::::    #
#    Makefile                                           :+:      :+:    :+:    #
#                                                     +:+ +:+         +:+      #
#    By: lfirmin lfirmim@student.42.fr>             +#+  +:+       +#+         #
#                                                 +#+#+#+#+#+   +#+            #
#    Created: 2024/08/12 07:07:31 by lfirmin           #+#    #+#              #
#    Updated: 2024/08/12 09:15:05 by lfirmin          ###   ########.fr        #
#                                                                              #
# **************************************************************************** #

NAME = libftprintf.a
HEADER = ./
SRC =   ft_putchar.c ft_put_ptr.c ft_conv_ith.c ft_hex_len.c \
        ft_sorting.c ft_printf.c ft_print_ith.c ft_printchar.c \
        ft_printstr.c ft_printpercent.c ft_print_unsigned.c \
        ft_print_nbr.c ft_print_ptr.c ft_adrr_len.c ft_print_null.c \
        ft_itoa.c ft_unsigned_itoa.c ft_count.c

CC = cc
CFLAGS = -Wall -Wextra -Werror
INCLUDE = -I $(HEADER)
OBJ_DIR = obj/
OBJ = $(addprefix $(OBJ_DIR), $(SRC:.c=.o))


GREEN = \033[0;32m
YELLOW = \033[0;33m
RESET = \033[0m
WHITE = \033[0;97m

LOADING_CHARS = ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏

all: $(NAME)

$(NAME): $(OBJ)
	@printf "$(YELLOW)Compiling ft_printf, Please wait...$(RESET)"
	@for char in $(LOADING_CHARS); do \
		printf "\r$(YELLOW)Compiling ft_print, Please wait... $$char$(RESET)"; \
		sleep 0.1; \
	done
	@ar rc $(NAME) $(OBJ)``
	@ranlib $(NAME)
	@printf "\r$(GREEN)Great news ! $(WHITE)ft_printf compiled successfully !                 $(RESET)\n"

$(OBJ_DIR)%.o: %.c
	@mkdir -p $(OBJ_DIR)
	@$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@

clean:
	@rm -rf $(OBJ_DIR)
	@printf "$(WHITE)Clean process completed for $(GREEN)Ft_printf.$(RESET)\n"

fclean: clean
	@rm -f $(NAME)
	@printf "$(WHITE)Full clean process completed for $(GREEN)Ft_printf.$(RESET)\n"

re: fclean all

.PHONY: all clean fclean re
