CC = cc

CFLAGS = -Wall -Wextra -Werror -O3 -g3 -fPIC

SRCS = ./ft_isalnum.c ./ft_isalpha.c ./ft_isascii.c ./ft_isdigit.c \
	./ft_isprint.c ./ft_memset.c ./ft_strlen.c ./ft_bzero.c ./ft_memcpy.c \
	./ft_memmove.c ./ft_strlcpy.c ./ft_strlcat.c ./ft_toupper.c \
	./ft_tolower.c ./ft_strchr.c ./ft_strrchr.c ./ft_strncmp.c \
	./ft_memchr.c ./ft_memcmp.c ./ft_strnstr.c ./ft_atoi.c \
	./ft_strdup.c ./ft_calloc.c ./ft_substr.c ./ft_strjoin.c \
	./ft_strtrim.c ./ft_split.c ./ft_itoa.c ./ft_strmapi.c \
	./ft_striteri.c ./ft_putchar_fd.c ./ft_putstr_fd.c \
	./ft_putendl_fd.c ./ft_putnbr_fd.c ./ft_int_utils.c \
	./ft_safe_int_math.c ./ft_split2.c ./ft_long_utils.c \
	./ft_safe_long_math.c

SRCSBONUS = ./ft_lstnew_bonus.c ./ft_lstadd_front_bonus.c ./ft_lstsize_bonus.c ./ft_lstlast_bonus.c ./ft_lstadd_back_bonus.c ./ft_lstdelone_bonus.c ./ft_lstclear_bonus.c ./ft_lstiter_bonus.c ./ft_lstmap_bonus.c ./ft_vector.c ./ft_itoa_base.c ./ft_addr_to_str.c ./ft_utoa.c ./ft_strnonchr.c ./ft_utoa_base.c ./ft_strcmp.c ./ft_vecint.c ./ft_power.c

SRCS_GNL = ./get_next_line/get_next_line.c ./get_next_line/get_next_line_utils.c ./get_next_line/get_next_line_utils_two.c

FT_PRINTF_PATH = ./ft_printf/
SRC_PRINTF = ft_printf.c ft_cases_mandatory_one.c ft_cases_mandatory_two.c ft_printf_bonus.c ft_cases_easy_bonus.c ft_case_lowx_bonus.c ft_case_uppx_bonus.c ft_case_u_bonus.c ft_case_s_bonus.c ft_case_p_bonus.c ft_case_d_bonus.c ft_case_d_utils_bonus.c ft_arglist_bonus.c ft_padding_bonus.c
SRCS_PRINTF = $(addprefix $(FT_PRINTF_PATH), $(SRC_PRINTF))

FT_HASHMAP_PATH = ./ft_hashmap/
SRC_HASHMAP = ft_hashmap.c ft_hashmap_utils.c ft_hashmap_utils_two.c ft_hashmap_basic_type_hash.c ft_hashmap_advanced_type_hash.c ft_hashmap_basic_cmp.c
SRCS_HASHMAP = $(addprefix $(FT_HASHMAP_PATH), $(SRC_HASHMAP))

FT_PQ_PATH = ./ft_priority_queue/
SRC_PQ = ft_priority_queue.c ft_priority_queue_utils.c
SRCS_PQ = $(addprefix $(FT_PQ_PATH), $(SRC_PQ))

FT_SORTING_PATH = ./sorting/
SRC_SORTING = ft_radixsort.c ft_sorting.c
SRCS_SORTING = $(addprefix $(FT_SORTING_PATH), $(SRC_SORTING))

OBJS = $(SRCS:.c=.o)

OBJSBONUS = $(SRCSBONUS:.c=.o)

OBJS_GNL = $(SRCS_GNL:.c=.o)

OBJS_PRINTF = $(SRCS_PRINTF:.c=.o)

OBJS_HASHMAP = $(SRCS_HASHMAP:.c=.o)

OBJS_PQ = $(SRCS_PQ:.c=.o)

OBJS_SORTING = $(SRCS_SORTING:.c=.o)

NAME = libft.a

RED    := \033[0;31m
GREEN  := \033[0;32m
YELLOW := \033[0;33m
BLUE   := \033[0;34m
NC     := \033[0m


all: $(NAME)

$(NAME): $(OBJS) $(OBJSBONUS) $(OBJS_GNL) $(OBJS_PRINTF) $(OBJS_HASHMAP) $(OBJS_PQ) $(OBJS_SORTING)
	@ar rcs $(NAME) $(OBJS) $(OBJSBONUS) $(OBJS_GNL) $(OBJS_PRINTF) $(OBJS_HASHMAP) $(OBJS_PQ) $(OBJS_SORTING)
	@echo "$(GREEN)finished compiling $(NAME)!$(NC)"

bonus: $(NAME)

./%.o: ./%.c
	@$(CC) $(CFLAGS) -c $< -o $@

clean:
	@rm -f $(OBJS) $(OBJSBONUS) $(OBJS_GNL) $(OBJS_PRINTF) $(OBJS_HASHMAP) $(OBJS_PQ) $(OBJS_SORTING)
	@echo "$(YELLOW)deleted object files from $(NAME)$(NC)"

fclean: clean
	@rm -f $(NAME)
	@echo "$(YELLOW)deleted $(NAME)$(NC)"

re: fclean all
