From 166c8470d47096c5cbb63ef32a355da39683c44d Mon Sep 17 00:00:00 2001 From: Alexey Date: Wed, 30 Jul 2025 15:01:01 +0300 Subject: [PATCH] add -ldflags "-w -s" and binary compression --- Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 28c97ff..4237e72 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,14 @@ build: @# @echo "CGO_CFLAGS is: '$(CGO_CFLAGS)'" @# @echo "CGO_LDFLAGS is: '$(CGO_LDFLAGS)'" @# CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" - go build -trimpath -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/$(APP_NAME) ./ + @go build -trimpath -ldflags "-w -s $(LDFLAGS)" -o $(BIN_DIR)/$(APP_NAME) ./ + @if ! command -v upx >/dev/null 2>&1; then \ + echo "upx not found, skipping compression."; \ + elif upx -t $(BIN_DIR)/$(APP_NAME) >/dev/null 2>&1; then \ + echo "$(BIN_DIR)/$(APP_NAME) already compressed, skipping."; \ + else \ + upx $(BIN_DIR)/$(APP_NAME) >/dev/null 2>&1 || true; \ + fi run: build @echo "Running!"