.PHONY: build server cli compare test fmt lint clean generate-ogen docs help

# Build all binaries
build: server cli compare

server:
	go build -o bin/predictor ./cmd/predictor

cli:
	go build -o bin/predictor-cli ./cmd/predictor-cli

compare:
	go build -o bin/compare-tawhiri ./cmd/compare-tawhiri

# Run locally
run:
	go run ./cmd/predictor

# Run tests
test:
	go test ./...

# Format code
fmt:
	go fmt ./...

# Lint code
lint:
	golangci-lint run

# Build the numerics LaTeX doc (requires pdflatex)
docs:
	cd docs && pdflatex numerics.tex

# Regenerate ogen API code from the OpenAPI spec. The same spec is embedded by
# the api package (api/spec.go) and served at /openapi.yaml + /docs (ReDoc).
generate-ogen:
	go run github.com/ogen-go/ogen/cmd/ogen@latest --target pkg/rest --package rest --clean api/rest/predictor.swagger.yml

# Clean build artifacts
clean:
	rm -rf bin/ docs/numerics.pdf docs/numerics.aux docs/numerics.log

help:
	@echo "Available commands:"
	@echo "  build         - Build all binaries to bin/"
	@echo "  server        - Build the HTTP server (cmd/predictor)"
	@echo "  cli           - Build the CLI client (cmd/predictor-cli)"
	@echo "  compare       - Build the validation tool (cmd/compare-tawhiri)"
	@echo "  run           - Run the server with default config"
	@echo "  test          - Run unit tests"
	@echo "  fmt           - Format code"
	@echo "  lint          - Lint code (golangci-lint)"
	@echo "  docs          - Build the numerics LaTeX doc (requires pdflatex)"
	@echo "  generate-ogen - Regenerate ogen code from the OpenAPI spec"
	@echo "  clean         - Remove build artifacts"
