# **************************************************************************** #
#                                                                              #
#                                                         :::      ::::::::    #
#    Makefile                                           :+:      :+:    :+:    #
#                                                     +:+ +:+         +:+      #
#    By: cchauvet <cchauvet@student.42angouleme.fr  +#+  +:+       +#+         #
#                                                 +#+#+#+#+#+   +#+            #
#    Created: 2023/01/20 14:41:36 by cchauvet          #+#    #+#              #
#    Updated: 2023/01/20 14:41:42 by cchauvet         ###   ########.fr        #
#                                                                              #
# **************************************************************************** #

SRCS = mandatory/asset.c mandatory/draw.c mandatory/key.c mandatory/main.c mandatory/map.c mandatory/parsing2.c mandatory/parsing.c mandatory/xpm.c

BSRCS = bonus/asset.c bonus/draw.c bonus/key.c bonus/main.c bonus/map.c bonus/parsing2.c bonus/parsing.c bonus/xpm.c

OBJS = ${SRCS:.c=.o}

BOBJS = ${BSRCS:.c=.o}

NAME = so_long

LIBS = libftx/libftx.a minilibx-linux/libmlx.a

CC = clang

FLAG = -Wall -Wextra -Werror

%.o: %.c
	${CC} ${FLAG} -c $< -o $@

all: ${NAME}

bonus: ${BOBJS}
	make -C libftx
	make -C minilibx-linux
	${CC} ${BOBJS} -o ${NAME} ${LIBS} -lXext -lX11

${NAME}: ${OBJS}
	make -C libftx
	make -C minilibx-linux
	${CC} ${OBJS} -o ${NAME} ${LIBS} -lXext -lX11

clean: 
	rm -f ${OBJS} ${BOBJS}
	rm -f textures/*
	make -C libftx clean
	make -C minilibx-linux clean

fclean: clean
		rm -f ${NAME}
		make -C libftx fclean
		make -C minilibx-linux clean

re: fclean
	make all

.PHONY: all clean fclean re bonus
