# Cyberpunk — build & deploy helpers (.so plugin workflow)
#
# Usage:
#   make                Local build: produces cyberpunk.so via CGO go build -buildmode=plugin
#   make clean          Remove built artefacts
#   make templ          Regenerate *_templ.go files (host templ)

.PHONY: all clean templ help

PLUGIN_NAME := cyberpunk
PLUGIN_SRC  := $(CURDIR)

# Default target: build the .so locally for development.
all: $(PLUGIN_NAME).so

# Local plugin build (no container).
$(PLUGIN_NAME).so: $(wildcard *.go) plugin.mod go.mod
	CGO_ENABLED=1 go build -buildmode=plugin -ldflags="-s -w" -o $(PLUGIN_NAME).so .

clean:
	rm -f $(PLUGIN_NAME).so

# Regenerate templ Go files locally.
templ:
	cd $(PLUGIN_SRC) && $(HOME)/go/bin/templ generate

help:
	@echo "Targets:"
	@echo "  all     Build $(PLUGIN_NAME).so locally (default)"
	@echo "  templ   Regenerate templ Go files"
	@echo "  clean   Remove built artefacts"
