APP     := pgtidy
CMD     := ./cmd/pgtidy
DIST    := dist

.PHONY: build test lint vet fmt clean

## build: compile binary for the current platform
build:
	go build -trimpath -ldflags "-s -w -X main.version=$$(git describe --tags --abbrev=0 2>/dev/null || echo dev)" -o $(DIST)/$(APP) $(CMD)

## test: run tests (incl. corpus safety harness)
test:
	go test ./...

## vet: static analysis
vet:
	go vet ./...

## fmt: format Go code
fmt:
	go fmt ./...

## lint: vet + format check
lint: vet
	test -z "$$(gofmt -l .)" || (echo "gofmt needed:"; gofmt -l .; exit 1)

## clean: remove build artifacts
clean:
	rm -rf $(DIST)
