CXX = g++

CXXFLAGS = -std=c++20 -O2 -Wall -Wextra -I./include -I./src -I./src/private -I./src/public

LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi

BUILDDIR = build
OBJDIR = $(BUILDDIR)/obj

SOURCES = $(shell find ./src -name "*.cpp")

OBJECTS = $(SOURCES:./src/%.cpp=$(OBJDIR)/%.o)

TARGET = LearningVulkan

$(OBJDIR):
	@mkdir -p $@

$(OBJDIR)/%.o: ./src/%.cpp | $(OBJDIR)
	@mkdir -p $(@D)
	$(CXX) $(CXXFLAGS) -c $< -o $@   

$(TARGET): $(OBJECTS)
	$(CXX) $(OBJECTS) -o $@ $(LDFLAGS)

.PHONY: test clean

test: $(TARGET)
	./$(TARGET)

clean:
	rm -rf $(BUILDDIR)
