Skip to content

Commit

Permalink
make: Add build option STATIC=1 to statically link
Browse files Browse the repository at this point in the history
Add build option STATIC=1 to statically link kata-agent.

Fixes: kata-containers#522

Signed-off-by: Hui Zhu <teawater@hyper.sh>
  • Loading branch information
teawater committed Apr 10, 2019
1 parent 801d792 commit 8b34aaf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ else
SECCOMP=no
endif
# go build common flags
BUILDFLAGS := -buildmode=pie
ifdef STATIC
LDFLAGS := -extldflags '-static'
else
BUILDFLAGS := -buildmode=pie
endif

# args for building agent image
BUILDARGS := $(if $(http_proxy), --build-arg http_proxy=$(http_proxy))
Expand All @@ -90,7 +94,7 @@ AGENT_TAG := $(if $(COMMIT_NO_SHORT),$(COMMIT_NO_SHORT),dev)

$(TARGET): $(GENERATED_FILES) $(SOURCES) $(VERSION_FILE)
go build $(BUILDFLAGS) -tags "$(BUILDTAGS)" -o $@ \
-ldflags "-X main.version=$(VERSION_COMMIT) -X main.seccompSupport=$(SECCOMP)"
-ldflags "-X main.version=$(VERSION_COMMIT) -X main.seccompSupport=$(SECCOMP) $(LDFLAGS)"

install:
install -D $(TARGET) $(DESTDIR)$(BINDIR)/$(TARGET)
Expand Down

0 comments on commit 8b34aaf

Please sign in to comment.