# The gate. Green is the definition of done (novox/hq how-we-build §5).
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo development)
LDFLAGS := -s -w -X main.version=$(VERSION)

.PHONY: check test vet fmt build clean

check: fmt vet test build

fmt:
	@test -z "$$(gofmt -l . )" || { echo "unformatted:"; gofmt -l . ; exit 1; }

vet:
	go vet ./...

# Structure and logic, and the same checks against this machine. The boundary is never mocked.
test:
	go test ./... -count=1

# Static on purpose: copy it onto a machine and run it is the whole installation.
build:
	CGO_ENABLED=0 go build -ldflags="$(LDFLAGS)" -o mesh-host ./cmd/mesh-host

clean:
	rm -f mesh-host
