.PHONY: all build swagger test clean dev # Version injection - can be overridden via make build VERSION=v1.0.0 VERSION ?= $(shell git describe --tags --always 2>/dev/null || echo "v0.1.0-dev") LDFLAGS := -X github.com/ez-api/ez-api/internal/api.Version=$(VERSION) # Default target all: swagger build # Generate swagger documentation using go run (no install needed) swagger: @echo "Generating Swagger documentation..." go run github.com/swaggo/swag/cmd/swag@latest init -g cmd/server/main.go -o docs --parseDependency --parseInternal # Build the binary build: swagger @echo "Building ez-api $(VERSION)..." go build -ldflags "$(LDFLAGS)" -o ez-api ./cmd/server # Build without swagger regeneration (for quick iteration) build-fast: go build -ldflags "$(LDFLAGS)" -o ez-api ./cmd/server # Run tests test: go test -v ./... # Clean build artifacts clean: rm -f ez-api rm -rf docs/ # Run in development mode dev: swagger go run -ldflags "$(LDFLAGS)" ./cmd/server # Format code fmt: go fmt ./... # Lint code lint: @which golangci-lint > /dev/null || go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest golangci-lint run # Generate swagger only (alias) docs: swagger # Help help: @echo "Available targets:" @echo " all - Generate swagger docs and build (default)" @echo " build - Generate swagger and build binary" @echo " build-fast - Build binary without swagger regeneration" @echo " swagger - Generate Swagger documentation" @echo " docs - Alias for swagger" @echo " test - Run tests" @echo " dev - Run in development mode" @echo " clean - Remove build artifacts" @echo " fmt - Format code" @echo " lint - Run linter" @echo " help - Show this help"