BINARY := nxstats MODULE := github.com/mr0xb/nxstats VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev") LDFLAGS := -ldflags "-s -w -X main.version=$(VERSION)" OUTDIR := dist TARGETS := \ darwin/amd64 \ darwin/arm64 \ linux/amd64 \ linux/arm64 \ linux/arm .PHONY: all clean test test-verbose test-cover build $(TARGETS) all: test build ## build — compile for all target platforms build: $(TARGETS) #darwin/amd64: # GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o $(OUTDIR)/$(BINARY)-darwin-amd64 . #darwin/arm64: # GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o $(OUTDIR)/$(BINARY)-darwin-arm64 . linux/amd64: GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o $(OUTDIR)/$(BINARY)-linux-amd64 . linux/arm64: GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o $(OUTDIR)/$(BINARY)-linux-arm64 . #linux/arm: # GOOS=linux GOARCH=arm GOARM=7 go build $(LDFLAGS) -o $(OUTDIR)/$(BINARY)-linux-armv7 . ## test — run all tests test: go test ./... ## test-verbose — run all tests with per-test output test-verbose: go test -v ./... ## test-cover — run all tests and open an HTML coverage report test-cover: go test -coverprofile=coverage.out ./... go tool cover -html=coverage.out -o coverage.html @echo "Coverage report: coverage.html" ## clean — remove build artefacts and coverage files clean: rm -rf $(OUTDIR) coverage.out coverage.html $(OUTDIR): mkdir -p $(OUTDIR) # Ensure output directory exists before any build target runs darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 linux/arm: | $(OUTDIR) ## help — list available targets help: @grep -E '^## ' Makefile | sed 's/## / /'