Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit 8b34aaf

Browse files
committed
make: Add build option STATIC=1 to statically link
Add build option STATIC=1 to statically link kata-agent. Fixes: #522 Signed-off-by: Hui Zhu <teawater@hyper.sh>
1 parent 801d792 commit 8b34aaf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ else
7979
SECCOMP=no
8080
endif
8181
# go build common flags
82-
BUILDFLAGS := -buildmode=pie
82+
ifdef STATIC
83+
LDFLAGS := -extldflags '-static'
84+
else
85+
BUILDFLAGS := -buildmode=pie
86+
endif
8387

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

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

9599
install:
96100
install -D $(TARGET) $(DESTDIR)$(BINDIR)/$(TARGET)

0 commit comments

Comments
 (0)