# Standalone build for the data part (04-data.md). Header-only library;
# this compiles and runs the integration tests. Outputs go to build/.
CXX ?= g++
CXXFLAGS ?= -std=c++23 -Wall -Wextra -O1 -g -pthread
ROOT := ../..
SRC := $(ROOT)/src/data
TESTDIR := $(ROOT)/tests/src/data
BUILD := $(ROOT)/build/data
INCLUDES := -I$(SRC) -I$(TESTDIR)

TESTS := value_error pg_wire sqlite pool_txn orm sync_heal_migrate kv_cache pubsub
BINS := $(addprefix $(BUILD)/test_,$(TESTS))

all: $(BINS)

$(BUILD)/test_%: $(TESTDIR)/test_%.cpp $(shell find $(SRC) -name '*.hpp') $(TESTDIR)/mini.hpp
	@mkdir -p $(BUILD)
	$(CXX) $(CXXFLAGS) $(INCLUDES) $< -o $@

test: all
	@for t in $(BINS); do echo "== $$t"; "$$t" || exit 1; done
	@echo "data: all suites green"

clean:
	rm -rf $(BUILD)

.PHONY: all test clean
