gontrol/Makefile

44 lines
1.1 KiB
Makefile

# 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
BUILD_DIR = build
BINARY = $(BUILD_DIR)/$(APP_NAME)
.PHONY: all build help clean install uninstall test #build-static
all: build
build: ## Build the application
@echo "Building $(APP_NAME)..."
$(GO_BUILD) -o $(BINARY)
install: build ## Install the application
@echo "Installing $(APP_NAME)..."
GOBIN=$(GOBIN) $(GO_INSTALL)
# build-static: ## Build a static application
# @echo "Building static $(APP_NAME)..."
# CGO_ENABLED=0 $(GO_BUILD) --ldflags '-extldflags=-static -w -s' -o $(BINARY)-static
uninstall: clean ## Remove build artifacts
@echo "Removing installed binary..."
rm -f $(GOBIN)/$(APP_NAME)
test: build
@echo "Executing tests..."
go test ./... -v -race -cover
clean: ## Remove installed application
@echo "Cleaning up build artifacts..."
$(GO_CLEAN)
rm -f $(BINARY)
help: ## Print the make targets
@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}'