VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
GO_ENV  := CGO_ENABLED=0

.PHONY: build install clean help

help:
	@echo "Dialectic.PlexumPlugin build targets:"
	@echo "  build    - compile binary + bundle manifest into dist/"
	@echo "  install  - copy binary + manifest into ~/.plexum/plugins/dialectic/"
	@echo "  clean    - rm -rf dist/"

build:
	mkdir -p dist
	$(GO_ENV) go build -ldflags="-X main.Version=$(VERSION)" \
		-o dist/plexum-dialectic-plugin ./cmd/plexum-dialectic-plugin
	cp manifest.json dist/manifest.json
	@echo "Built to dist/ (version=$(VERSION))"

install: build
	mkdir -p ~/.plexum/plugins/dialectic
	cp dist/plexum-dialectic-plugin ~/.plexum/plugins/dialectic/
	cp dist/manifest.json ~/.plexum/plugins/dialectic/
	@echo "Installed to ~/.plexum/plugins/dialectic/"
	@echo "Add to ~/.plexum/plexum.json .plugins.allow: 'dialectic'"
	@echo "Config goes at ~/.plexum/plugins/dialectic/config.json (see README)"

clean:
	rm -rf dist/
