#******************************************************************************#
#                                                                              #
#                                                         :::      ::::::::    #
#    Makefile                                           :+:      :+:    :+:    #
#                                                     +:+ +:+         +:+      #
#    By: bchanot <bchanot@students.42.fr>           +#+  +:+       +#+         #
#                                                 +#+#+#+#+#+   +#+            #
#    Created: 2016/07/24 00:00:08 by bchanot           #+#    #+#              #
#*   Updated: 2018/10/26 11:18:16 by bchanot          ###   ########.fr       *#
#                                                                              #
#******************************************************************************#

NAME = ft_ssl
MAKE_LIBS = make --no-print-directory
SRCS_DIR = srcs/
OBJS_DIR = .objects/
LIBS_DIR = libs/
CC = gcc -Wall -Wextra -Werror -g
LIB = -L./$(LIBS_DIR)/libft/ -lft
INC = -I./includes -I./$(LIBS_DIR)/libft/includes
FILES = main \
		sl_get_inf \
		sl_core \
		sl_hash \
		sl_md5 \
		sl_sha2 \
		sl_sha3_5 \
		sl_sha_init \
		sl_sha_registers
SRCS = $(FILES)
OBJS = $(addprefix $(OBJS_DIR), $(addsuffix .o, $(SRCS)))
RED = \033[1;31m
BLUE = \033[1;34m
CYAN = \033[0;36m
GREEN = \033[1;32m
YELLOW = \033[1;33m
EOC = \033[0m

all: libs $(NAME)

libs:
	@$(MAKE_LIBS) -C $(LIBS_DIR)/libft

$(NAME): $(OBJS)
	@echo -e "$(GREEN)Objects created.$(EOC)"
	@$(CC) $(OBJS) $(LIB) $(INC) -o $(NAME)
	@echo -e "$(GREEN)Compilation complete.$(EOC)"

$(OBJS_DIR)%.o: $(SRCS_DIR)%.c
	@mkdir -p $(dir $@)
	$(CC) -c $< $(INC) -o $@

clean:
	@echo -e "$(RED)Deleting objects.$(EOC)"
	@/bin/rm -rf $(OBJS_DIR)
	@$(MAKE_LIBS) clean -C $(LIBS_DIR)/libft

fclean: clean
	@echo -e "$(RED)Deleting binary.$(EOC)"
	@/bin/rm -rf $(NAME)
	@$(MAKE_LIBS) fclean -C $(LIBS_DIR)/libft

re: fclean all

.PHONY: all libs clean fclean re
