.PHONY: build test vet lint clean docker push all devserver

MCR     := mcr.svc.mcp.metacircular.net:8443
VERSION := $(shell git describe --tags --always --dirty)
LDFLAGS := -trimpath -ldflags="-s -w -X main.version=$(VERSION)"

mcdoc:
	CGO_ENABLED=0 go build $(LDFLAGS) -o mcdoc ./cmd/mcdoc

build:
	go build ./...

test:
	go test ./...

vet:
	go vet ./...

lint:
	golangci-lint run ./...

clean:
	rm -f mcdoc

docker:
	docker build --build-arg VERSION=$(VERSION) -t $(MCR)/mcdoc:$(VERSION) -f Dockerfile .

push: docker
	docker push $(MCR)/mcdoc:$(VERSION)

devserver: mcdoc
	@mkdir -p srv
	@if [ ! -f srv/mcdoc.toml ]; then cp deploy/examples/mcdoc.toml srv/mcdoc.toml; echo "Created srv/mcdoc.toml from example — edit before running."; fi
	./mcdoc server --config srv/mcdoc.toml

all: vet lint test mcdoc
