Make building static binaries simpler

This commit adds STATIC makefile variable to adjust LDFLAGS and build
tags accordingly.

Fixes #5824.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
This commit is contained in:
Kazuyoshi Kato
2022-06-04 03:26:06 +00:00
parent 455b45708c
commit 00eb74a4ca
3 changed files with 15 additions and 5 deletions

View File

@@ -21,7 +21,9 @@ COMMANDS += containerd-shim containerd-shim-runc-v1 containerd-shim-runc-v2
# check GOOS for cross compile builds
ifeq ($(GOOS),linux)
ifneq ($(GOARCH),$(filter $(GOARCH),mips mipsle mips64 mips64le ppc64))
GO_GCFLAGS += -buildmode=pie
ifeq ($(STATIC),)
GO_GCFLAGS += -buildmode=pie
endif
endif
endif