NAME := minishell
CC := cc
CFLAGS := -Wall -Wextra -Werror -g
INCLUDES := -Iinclude
READLINE_LIBS := -lreadline -lncurses

SRCS := $(shell find src -name '*.c')
OBJS := $(SRCS:src/%.c=build/%.o)

all: $(NAME)

$(NAME): $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) $(READLINE_LIBS) -o $(NAME)

build/%.o: src/%.c
	@mkdir -p $(dir $@)
	$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@

clean:
	rm -rf build

fclean: clean
	rm -f $(NAME)

re: fclean all

.PHONY: all clean fclean re
