gontrol/Makefile

44 lines
1.1 KiB
Makefile
Raw Permalink Normal View History

2025-01-14 16:09:09 +01:00
# Define variables
APP_NAME = gontrol
GO_CMD = go
GO_BUILD = $(GO_CMD) build
GO_INSTALL = $(GO_CMD) install
GO_CLEAN = $(GO_CMD) clean
GOBIN := /usr/bin
2025-01-14 16:09:09 +01:00
BUILD_DIR = build
BINARY = $(BUILD_DIR)/$(APP_NAME)
2025-07-04 16:47:21 +02:00
.PHONY: all build help clean install uninstall test #build-static
2025-01-14 16:09:09 +01:00
all: build
build: ## Build the application
2025-01-14 16:09:09 +01:00
@echo "Building $(APP_NAME)..."
$(GO_BUILD) -o $(BINARY)
install: build ## Install the application
2025-01-14 16:09:09 +01:00
@echo "Installing $(APP_NAME)..."
2025-06-24 12:14:31 +02:00
GOBIN=$(GOBIN) $(GO_INSTALL)
2025-01-14 16:09:09 +01:00
# build-static: ## Build a static application
# @echo "Building static $(APP_NAME)..."
# CGO_ENABLED=0 $(GO_BUILD) --ldflags '-extldflags=-static -w -s' -o $(BINARY)-static
2025-06-24 12:14:31 +02:00
uninstall: clean ## Remove build artifacts
@echo "Removing installed binary..."
rm -f $(GOBIN)/$(APP_NAME)
2025-07-04 16:47:21 +02:00
test: build
@echo "Executing tests..."
go test ./... -v -race -cover
2025-06-24 12:14:31 +02:00
clean: ## Remove installed application
2025-01-14 16:09:09 +01:00
@echo "Cleaning up build artifacts..."
$(GO_CLEAN)
rm -f $(BINARY)
help: ## Print the make targets
2025-01-14 16:09:09 +01:00
@echo "Makefile for $(APP_NAME)"
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'