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

NAME = ft_select
FILES = main.c sl_loop.c sl_take_inf.c sl_screen.c sl_signal.c
SRC = $(addprefix srcs/, $(FILES))
FOBJ = $(SRC:srcs/%.c=%.o)
OBJ = $(addprefix .objects/, $(FOBJ))
FLAGS = -Wall -Werror -Wextra
LIB = -L./libft -lft
INC	= -I./includes -I./libft/includes
NO_COLOR = \x1b[0m
OK_COLOR = \x1b[32;01m
ERROR_COLOR = \x1b[31;01m
WARN_COLOR = \x1b[33;01m

all: $(NAME)

$(NAME): disp lib
	@echo  "\t---COMPILING OBJECTS---"
	@clang $(FLAGS) -c $(SRC) $(INC)
	@mkdir -p .objects && mv $(FOBJ) .objects
	@echo "$(OK_COLOR)\t---OBJECTS CREATED---$(NO_COLOR)"
	@echo  "\t---COMPILING EXECUTABLE---"
	@clang $(FLAGS) -ltermcap -o $(NAME) $(INC) $(OBJ) $(LIB)
	@echo  "$(OK_COLOR)\t---EXECUTABLE CREATED---"
	@echo  "---COMPILATION COMPLETE---$(NO_COLOR)"

disp:
	@echo  "$(WARN_COLOR)---PLEASE-WAIT---COMPILING--- $(NO_COLOR)"

lib:
	@echo "\t---CHECKING LIBRARY---"
	@make -C libft
	@echo "$(OK_COLOR)\t---LIBRARY UP TO DATE---$(NO_COLOR)"

clean:
	@/bin/rm -rf .objects
	@make clean -C libft/
	@echo "$(OK_COLOR)---OBJECTS DELETED---$(NO_COLOR)"

fclean: clean
	@/bin/rm -rf $(NAME)
	@make fclean -C libft/
	@echo "$(OK_COLOR)---BINARY DELETED---$(NO_COLOR)"

re: fclean all
