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

make: Add build option STATIC=1 to statically link #523

Merged
merged 1 commit into from
Apr 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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