File bsc1065109-0001-makefile-add-support-for-build_flags.patch of Package containerd.6033

From e805baf7240fbd2ba7eb12dd64a251cd7d272b7e Mon Sep 17 00:00:00 2001
From: Aleksa Sarai <asarai@suse.de>
Date: Fri, 27 Oct 2017 04:21:24 +1100
Subject: [PATCH] makefile: add support for build_flags

This is quite necessary in order for us to be able to build RPMs using
the upstream Makefile. -buildmode=pie in particular is quite an
important flag to use by default.

SUSE-Bugfix: http://bugzilla.suse.com/show_bug.cgi?id=1065109
SUSE-Bugfix: https://bugzilla.opensuse.org/show_bug.cgi?id=1053532
SUSE-Backport: https://github.com/containerd/containerd/pull/1686
Signed-off-by: Aleksa Sarai <asarai@suse.de>
---
 Makefile | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index c822bf762c8c..23f21a1ce402 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,8 @@ PROJECT=github.com/containerd/containerd
 GIT_COMMIT := $(shell git rev-parse HEAD 2> /dev/null || true)
 GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null)
 
+DYN_BUILD_FLAGS := -buildmode=pie
+STATIC_BUILD_FLAGS :=
 LDFLAGS := -X github.com/containerd/containerd.GitCommit=${GIT_COMMIT} ${LDFLAGS}
 
 TEST_TIMEOUT ?= 5m
@@ -42,22 +44,22 @@ clean:
 	rm -rf bin && rm -rf output
 
 client: bin
-	cd ctr && go build -ldflags "${LDFLAGS}" -o ../bin/ctr
+	cd ctr && go build $(DYN_BUILD_FLAGS) -ldflags "${LDFLAGS}" -o ../bin/ctr
 
 client-static:
-	cd ctr && go build -ldflags "-w -extldflags -static ${LDFLAGS}" -tags "$(BUILDTAGS)" -o ../bin/ctr
+	cd ctr && go build $(STATIC_BUILD_FLAGS) -ldflags "-w -extldflags -static ${LDFLAGS}" -tags "$(BUILDTAGS)" -o ../bin/ctr
 
 daemon: bin
-	cd containerd && go build -ldflags "${LDFLAGS}"  -tags "$(BUILDTAGS)" -o ../bin/containerd
+	cd containerd && go build $(DYN_BUILD_FLAGS) -ldflags "${LDFLAGS}"  -tags "$(BUILDTAGS)" -o ../bin/containerd
 
 daemon-static:
-	cd containerd && go build -ldflags "-w -extldflags -static ${LDFLAGS}" -tags "$(BUILDTAGS)" -o ../bin/containerd
+	cd containerd && go build $(STATIC_BUILD_FLAGS) -ldflags "-w -extldflags -static ${LDFLAGS}" -tags "$(BUILDTAGS)" -o ../bin/containerd
 
 shim: bin
-	cd containerd-shim && go build -tags "$(BUILDTAGS)" -ldflags "-w ${LDFLAGS}" -o ../bin/containerd-shim
+	cd containerd-shim && go build $(DYN_BUILD_FLAGS) -tags "$(BUILDTAGS)" -ldflags "-w ${LDFLAGS}" -o ../bin/containerd-shim
 
 shim-static:
-	cd containerd-shim && go build -ldflags "-w -extldflags -static ${LDFLAGS}" -tags "$(BUILDTAGS)" -o ../bin/containerd-shim
+	cd containerd-shim && go build $(STATIC_BUILD_FLAGS) -ldflags "-w -extldflags -static ${LDFLAGS}" -tags "$(BUILDTAGS)" -o ../bin/containerd-shim
 
 $(TESTBENCH_BUNDLE_DIR)/busybox.tar:
 	mkdir -p $(TESTBENCH_BUNDLE_DIR)
-- 
2.14.2

openSUSE Build Service is sponsored by