.PHONY: help build-macos build-linux release

help:
	@echo "Story Kit – cross-platform build targets"
	@echo ""
	@echo "  make build-macos    Build native macOS release binary"
	@echo "  make build-linux    Build static Linux x86_64 release binary (requires cross + Docker)"
	@echo "  make release V=x.y.z  Build both targets and publish a Gitea release"
	@echo ""
	@echo "Prerequisites:"
	@echo "  build-macos: Rust stable toolchain, pnpm"
	@echo "  build-linux: cargo install cross   AND   Docker Desktop running"
	@echo ""
	@echo "Output:"
	@echo "  macOS : target/release/story-kit"
	@echo "  Linux : target/x86_64-unknown-linux-musl/release/story-kit"

## Build a native macOS release binary.
## The frontend is compiled by build.rs (pnpm build) and embedded via rust-embed.
## Verify dynamic deps afterwards: otool -L target/release/story-kit
build-macos:
	cargo build --release

## Build a fully static Linux x86_64 binary using the musl libc target.
## cross (https://github.com/cross-rs/cross) handles the Docker-based cross-compilation.
## Install cross:  cargo install cross
## The resulting binary has zero dynamic library dependencies (ldd reports "not a dynamic executable").
build-linux:
	cross build --release --target x86_64-unknown-linux-musl

## Publish a release to Gitea with macOS and Linux binaries.
## Requires: GITEA_TOKEN env var, cross, Docker running.
## Usage: make release V=0.2.0
release:
ifndef V
	$(error Usage: make release V=x.y.z)
endif
	script/release $(V)
