NAME = webserv

CXX = c++

CXXFLAGS = -Wall -Wextra -Werror
CXXFLAGS += -std=c++98
CXXFLAGS += -I$(HEADERS_D)
CXXFLAGS += -g
#CXXFLAGS += -O3

#SHELL = /bin/zsh
VPATH  = $(DIR_SRCS)
DIR_SRCS =	srcs

HEADERS_D = ./srcs
HEADERS = Webserv.hpp

DEPENDENCIES =	$(HEADERS:%=$(HEADERS_D)/%)

SRCS =	main.cpp Webserv.cpp

DIR_OBJS = builds
OBJS = $(SRCS:%.cpp=$(DIR_OBJS)/%.o)

# --------------------
# ------ RULES -------
# --------------------

all: $(NAME)

$(DIR_OBJS)/%.o: %.cpp | $(DIR_OBJS)
	$(CXX) $(CXXFLAGS) -c $< -o $@

$(DIR_OBJS):
	mkdir $@

$(OBJS): $(DEPENDENCIES)
#$(OBJS): $(DEPENDENCIES) Makefile

$(NAME) : $(OBJS)
	$(CXX) $(OBJS) -o $(NAME)

clean:
	rm -f $(OBJS)

fclean: clean
	rm -f $(NAME)

re: fclean all

#run: all

.PHONY : all clean fclean re run
