From 25358444adad1d653381fe24a363bffe7055ac02 Mon Sep 17 00:00:00 2001 From: Hui Zhu Date: Wed, 12 Dec 2018 10:47:07 +0800 Subject: [PATCH] make: Add "GOPATH not set" Most of the projects, they can be built with "make". After that, "sudo make install" can install the application. It is not work for kata-runtime because kata-runtime's make must work with golang in the environment that default sudo cannot supply it. But "make install" doesn't need golang. So add "GOPATH not set" to handle the issue. Fixes: #1008 Signed-off-by: Hui Zhu --- Makefile | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 354ab66c66..32a46b97b3 100644 --- a/Makefile +++ b/Makefile @@ -12,27 +12,33 @@ for file in /etc/os-release /usr/lib/os-release; do \ fi \ done) -GOARCH=$(shell go env GOARCH) HOST_ARCH=$(shell arch) -SKIP_GO_VERSION_CHECK= +ifeq ($(GOPATH),) + SKIP_GO_VERSION_CHECK=y +else + SKIP_GO_VERSION_CHECK= +endif ifeq ($(SKIP_GO_VERSION_CHECK),) include golang.mk endif -ifeq ($(ARCH),) - ARCH = $(GOARCH) +ifneq ($(GOPATH),) + GOARCH=$(shell go env GOARCH) + ifeq ($(ARCH),) + ARCH = $(GOARCH) + endif + + ARCH_DIR = arch + ARCH_FILE_SUFFIX = -options.mk + ARCH_FILE = $(ARCH_DIR)/$(ARCH)$(ARCH_FILE_SUFFIX) + ARCH_FILES = $(wildcard arch/*$(ARCH_FILE_SUFFIX)) + ALL_ARCHES = $(patsubst $(ARCH_DIR)/%$(ARCH_FILE_SUFFIX),%,$(ARCH_FILES)) + + # Load architecture-dependent settings + include $(ARCH_FILE) endif -ARCH_DIR = arch -ARCH_FILE_SUFFIX = -options.mk -ARCH_FILE = $(ARCH_DIR)/$(ARCH)$(ARCH_FILE_SUFFIX) -ARCH_FILES = $(wildcard arch/*$(ARCH_FILE_SUFFIX)) -ALL_ARCHES = $(patsubst $(ARCH_DIR)/%$(ARCH_FILE_SUFFIX),%,$(ARCH_FILES)) - -# Load architecture-dependent settings -include $(ARCH_FILE) - PROJECT_TYPE = kata PROJECT_NAME = Kata Containers PROJECT_TAG = kata-containers @@ -490,6 +496,7 @@ show-footer: @printf "\tBugs: $(PROJECT_BUG_URL)\n\n" show-summary: show-header +ifneq ($(GOPATH),) @printf "• architecture:\n" @printf "\tHost: $(HOST_ARCH)\n" @printf "\tgolang: $(GOARCH)\n" @@ -498,6 +505,10 @@ show-summary: show-header @printf "• golang:\n" @printf "\t" @go version +else + @printf "• GOPATH not set:\n" + @printf "\tCan only install prebuilt binaries\n" +endif @printf "\n" @printf "• Summary:\n" @printf "\n"