CXX := clang++
CXXFLAGS := -fdiagnostics-color=always -g \
	-Wall -Wextra \
	-Werror=uninitialized \
	-Werror=return-type \
	-Wno-sign-compare \
	-Wno-unused-const-variable \
	-fsanitize=undefined \
	-D_GLIBCXX_DEBUG \
	-pg \
	-DLOCAL \
	-std=c++23 \
	-pipe

SRC ?= template.cpp
TARGET := tmp/$(basename $(notdir $(SRC)))
PCH := tmp/precompiled.pch
PCH_HEADER := .pch.cpp

all: $(TARGET)

$(TARGET): $(SRC) $(PCH) | tmp
	$(CXX) $(CXXFLAGS) -include-pch $(PCH) $(SRC) -o $(TARGET)

tmp:
	mkdir -p tmp

$(PCH): $(PCH_HEADER) | tmp
	$(CXX) $(CXXFLAGS) -x c++-header $(PCH_HEADER) -o $(PCH)

clean:
	rm -rf tmp

