Files
wg-admin/Makefile
2026-01-12 18:54:55 +01:00

81 lines
2.0 KiB
Makefile

# WireGuard Admin TUI
.PHONY: help build clean install test fmt lint run deps
# Binary name
BINARY=wg-tui
CMD_PATH=./cmd/$(BINARY)
# Build directory
BUILD_DIR=build
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
build: ## Build the binary
@echo "Building $(BINARY)..."
@$(GOBUILD) -o $(BINARY) $(CMD_PATH)/main.go
@echo "Build complete: $(BINARY)"
build-all: ## Build all binaries
@echo "Building all binaries..."
@$(GOBUILD) -o $(BINARY) ./...
clean: ## Clean build artifacts
@echo "Cleaning..."
@$(GOCLEAN)
@rm -f $(BINARY)
@echo "Clean complete"
install: ## Install the binary to $GOPATH/bin
@echo "Installing $(BINARY)..."
@$(GOBUILD) -o $$($(GOCMD) env GOPATH)/bin/$(BINARY) $(CMD_PATH)/main.go
@echo "Install complete"
test: ## Run tests
@echo "Running tests..."
@$(GOTEST) -v ./...
test-coverage: ## Run tests with coverage
@echo "Running tests with coverage..."
@$(GOTEST) -v -coverprofile=coverage.out ./...
@$(GOCMD) tool cover -html=coverage.out -o coverage.html
fmt: ## Format Go code
@echo "Formatting code..."
@$(GOCMD) fmt ./...
lint: ## Run golangci-lint (if installed)
@echo "Running linter..."
@if command -v golangci-lint > /dev/null; then \
golangci-lint run; \
else \
echo "golangci-lint not found. Install from https://golangci-lint.run/usage/install/"; \
fi
deps: ## Download dependencies
@echo "Downloading dependencies..."
@$(GOMOD) download
@$(GOMOD) tidy
run: build ## Build and run the binary
@echo "Running $(BINARY)..."
@./$(BINARY)
dev: ## Run in development mode with hot reload (requires air)
@if command -v air > /dev/null; then \
air; \
else \
echo "air not found. Install with: go install github.com/cosmtrek/air@latest"; \
fi