.PHONY: setup build run clean lint format test # Build variables VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev") COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown") BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") LDFLAGS := -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(BUILD_DATE) # Note: Static linking is not used because SQLite requires CGO, which links dynamically # to system libraries. Attempting static linking causes getaddrinfo warnings and # potential runtime compatibility issues. # Default target all: build # Install development tools setup: @echo "Installing development tools..." @go install mvdan.cc/gofumpt@latest @go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest @echo "✅ Development tools installed" # Build the application build: @echo "Building {{PROJECT_NAME}}..." @CGO_ENABLED=1 go build -ldflags "$(LDFLAGS)" -o {{PROJECT_NAME}} . @echo "✅ Built: {{PROJECT_NAME}}" # Run the application run: build ./{{PROJECT_NAME}} # Clean build artifacts clean: @rm -f {{PROJECT_NAME}} @rm -f *.db @echo "✅ Cleaned" # Lint code lint: @test -f $(HOME)/go/bin/golangci-lint || { \ echo "❌ golangci-lint not found. Install with: make setup"; \ exit 1; \ } @echo "Running linters..." @$(HOME)/go/bin/golangci-lint run --timeout 5m @echo "✅ Lint complete" # Format code format: @go fmt ./... @test -f $(HOME)/go/bin/gofumpt || { \ echo "❌ gofumpt not found. Install with: make setup"; \ exit 1; \ } @$(HOME)/go/bin/gofumpt -l -w . @echo "✅ Format complete" # Run tests test: @echo "Running tests..." @go test ./... @echo "✅ Tests complete"