From 2fe9e31aa9c5278cd48e702717a7f4e899bfb7fa Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 27 Apr 2020 13:15:44 -0700 Subject: [PATCH] Makefile: don't use -mod=vendor if GO111MODULE=off This fixes the following bug: > $ GO111MODULE=off make > go build "-mod=vendor" -buildmode=pie -tags "seccomp selinux apparmor" -ldflags "-X main.gitCommit="19ba7688cb4e0922d53029e2f7c1f2af45d40938-dirty" -X main.version=1.0.0-rc10+dev " -o runc . > build flag -mod=vendor only valid when using modules Signed-off-by: Kir Kolyshkin --- Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index feb35faa3..baa401896 100644 --- a/Makefile +++ b/Makefile @@ -12,10 +12,13 @@ COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true) COMMIT ?= $(if $(shell git status --porcelain --untracked-files=no),"$(COMMIT_NO)-dirty","$(COMMIT_NO)") VERSION := $(shell cat ./VERSION) -# TODO: rm -mod=vendor once go 1.13 will be unsupported -GO_BUILD := $(GO) build -mod=vendor -buildmode=pie $(EXTRA_FLAGS) -tags "$(BUILDTAGS)" \ +# TODO: rm -mod=vendor once go 1.13 is unsupported +ifneq ($(GO111MODULE),off) + MOD_VENDOR := "-mod=vendor" +endif +GO_BUILD := $(GO) build $(MOD_VENDOR) -buildmode=pie $(EXTRA_FLAGS) -tags "$(BUILDTAGS)" \ -ldflags "-X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) $(EXTRA_LDFLAGS)" -GO_BUILD_STATIC := CGO_ENABLED=1 $(GO) build -mod=vendor $(EXTRA_FLAGS) -tags "$(BUILDTAGS) netgo osusergo" \ +GO_BUILD_STATIC := CGO_ENABLED=1 $(GO) build $(MOD_VENDOR) $(EXTRA_FLAGS) -tags "$(BUILDTAGS) netgo osusergo" \ -ldflags "-w -extldflags -static -X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) $(EXTRA_LDFLAGS)" MAN_DIR := $(CURDIR)/man/man8