diff --git a/Makefile b/Makefile index aa1d00cee..fab96e393 100644 --- a/Makefile +++ b/Makefile @@ -44,9 +44,15 @@ GO_TAGS=$(if $(BUILDTAGS),-tags "$(BUILDTAGS)",) GO_LDFLAGS=-ldflags '-s -w -X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PKG) $(EXTRA_LDFLAGS)' SHIM_GO_LDFLAGS=-ldflags '-s -w -X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PKG) -extldflags "-static"' +#Replaces ":" (*nix), ";" (windows) with newline for easy parsing +GOPATHS=$(shell echo ${GOPATH} | tr ":" "\n" | tr ";" "\n") + TESTFLAGS_RACE= -GO_GCFLAGS= GO_BUILD_FLAGS= +GO_GCFLAGS=$(shell \ + set -- ${GOPATHS}; \ + echo "-gcflags=-trimpath=$${1}/src"; \ + ) #include platform specific makefile -include Makefile.$(GOOS) @@ -98,7 +104,7 @@ proto-fmt: ## check format of proto files build: ## build the go packages @echo "$(WHALE) $@" - @go build ${GO_BUILD_FLAGS} ${EXTRA_FLAGS} ${GO_LDFLAGS} ${GO_GCFLAGS} ${PACKAGES} + @go build ${GO_GCFLAGS} ${GO_BUILD_FLAGS} ${EXTRA_FLAGS} ${GO_LDFLAGS} ${PACKAGES} test: ## run tests, except integration tests and tests that require root @echo "$(WHALE) $@" @@ -121,7 +127,7 @@ FORCE: # Build a binary from a cmd. bin/%: cmd/% FORCE @echo "$(WHALE) $@${BINARY_SUFFIX}" - @go build ${GO_BUILD_FLAGS} -o $@${BINARY_SUFFIX} ${GO_LDFLAGS} ${GO_TAGS} ${GO_GCFLAGS} ./$< + @go build ${GO_GCFLAGS} ${GO_BUILD_FLAGS} -o $@${BINARY_SUFFIX} ${GO_LDFLAGS} ${GO_TAGS} ./$< bin/containerd-shim: cmd/containerd-shim FORCE # set !cgo and omit pie for a static shim build: https://github.com/golang/go/issues/17789#issuecomment-258542220 @echo "$(WHALE) bin/containerd-shim" diff --git a/Makefile.linux b/Makefile.linux index 7f297a912..08db50642 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -3,7 +3,7 @@ COMMANDS += containerd-shim # check GOOS for cross compile builds ifeq ($(GOOS),linux) - GO_GCFLAGS= -buildmode=pie + GO_GCFLAGS += -buildmode=pie endif # amd64 supports go test -race