From 5779216b77d2cbeaf257065f7c435b8cf05053c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=BCbner?= Date: Wed, 8 Mar 2023 21:21:42 +0100 Subject: [PATCH] link static --- Makefile | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 5f059ef..ea447d6 100644 --- a/Makefile +++ b/Makefile @@ -2,22 +2,23 @@ MOD_NAME = $(shell go list -m) BIN_NAME = $(shell basename $(MOD_NAME)) GIT_TAG = $(shell git describe --tags --abbrev=0 --dirty --match v[0-9]* 2> /dev/null || echo "v0.0.0-indev") VERSION = $(GIT_TAG:v%=%) -LDFLAGS = -ldflags="-X '$(MOD_NAME)/version=$(VERSION)'" +GOFLAGS = -tags osusergo,netgo +LDFLAGS = -ldflags="-w -extldflags=-static -X '$(MOD_NAME)/version=$(VERSION)'" out/$(BIN_NAME): $(shell ls go.mod go.sum *.go) $(info dev build of $(VERSION)) - go build $(LDFLAGS) -race -o out/$(BIN_NAME) + go build $(GOFLAGS) -race $(LDFLAGS) -o out/$(BIN_NAME) .PHONY: release release: clean $(info release builds of $(VERSION)) - GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_linux-amd64 - GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_linux-arm64 + GOOS=linux GOARCH=amd64 go build $(GOFLAGS) $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_linux-amd64 + GOOS=linux GOARCH=arm64 go build $(GOFLAGS) $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_linux-arm64 ./deb.sh $(VERSION) amd64 ./deb.sh $(VERSION) arm64 - GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_darwin-amd64 - GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_darwin-arm64 - GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_windows-amd64.exe + GOOS=darwin GOARCH=amd64 go build $(GOFLAGS) $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_darwin-amd64 + GOOS=darwin GOARCH=arm64 go build $(GOFLAGS) $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_darwin-arm64 + GOOS=windows GOARCH=amd64 go build $(GOFLAGS) $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_windows-amd64.exe .PHONY: clean clean: