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:
11
Makefile
11
Makefile
@@ -90,8 +90,17 @@ endif
|
||||
GO_BUILDTAGS ?=
|
||||
GO_BUILDTAGS += urfave_cli_no_docs
|
||||
GO_BUILDTAGS += ${DEBUG_TAGS}
|
||||
ifneq ($(STATIC),)
|
||||
GO_BUILDTAGS += osusergo netgo static_build
|
||||
endif
|
||||
GO_TAGS=$(if $(GO_BUILDTAGS),-tags "$(strip $(GO_BUILDTAGS))",)
|
||||
GO_LDFLAGS=-ldflags '-X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PACKAGE) $(EXTRA_LDFLAGS)'
|
||||
|
||||
GO_LDFLAGS=-ldflags '-X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PACKAGE) $(EXTRA_LDFLAGS)
|
||||
ifneq ($(STATIC),)
|
||||
GO_LDFLAGS += -extldflags "-static"
|
||||
endif
|
||||
GO_LDFLAGS+='
|
||||
|
||||
SHIM_GO_LDFLAGS=-ldflags '-X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PACKAGE) -extldflags "-static" $(EXTRA_LDFLAGS)'
|
||||
|
||||
# Project packages.
|
||||
|
||||
Reference in New Issue
Block a user