mirror of
https://github.com/kubernetes-sigs/kind.git
synced 2025-12-01 07:26:05 +07:00
add make install support
This commit is contained in:
8
Makefile
8
Makefile
@@ -20,6 +20,7 @@ REPO_ROOT=$(PWD)
|
||||
# autodetect host GOOS and GOARCH by default, even if go is not installed
|
||||
GOOS=$(shell hack/util/goos.sh)
|
||||
GOARCH=$(shell hack/util/goarch.sh)
|
||||
INSTALL_DIR=$(shell hack/util/goinstalldir.sh)
|
||||
# use the official module proxy by default
|
||||
GOPROXY=https://proxy.golang.org
|
||||
# default build image
|
||||
@@ -31,6 +32,7 @@ CACHE_VOLUME=kind-build-cache
|
||||
# variables for consistent logic, don't override these
|
||||
CONTAINER_REPO_DIR=/src/kind
|
||||
CONTAINER_OUT_DIR=$(CONTAINER_REPO_DIR)/_output/bin
|
||||
HOST_OUT_DIR=$(REPO_ROOT)/_output/bin
|
||||
|
||||
# standard "make" target -> builds
|
||||
all: build
|
||||
@@ -62,7 +64,11 @@ kind: make-cache
|
||||
# alias for building kind
|
||||
build: kind
|
||||
|
||||
# use: make install INSTALL_DIR=/usr/local/bin
|
||||
install: build
|
||||
cp $(HOST_OUT_DIR)/kind $(INSTALL_DIR)/kind
|
||||
|
||||
# standard cleanup target
|
||||
clean: clean-cache
|
||||
|
||||
.PHONY: make-cache clean-cache kind build all clean
|
||||
.PHONY: all make-cache clean-cache kind build install clean
|
||||
|
||||
47
hack/util/goinstalldir.sh
Executable file
47
hack/util/goinstalldir.sh
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/bin/sh
|
||||
# Copyright 2019 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# this utility prints out the golang install dir even if go is not installed
|
||||
|
||||
# if we have go, just ask go!
|
||||
if which go >/dev/null 2>&1; then
|
||||
DIR=$(go env GOBIN)
|
||||
if [ -n "${DIR}" ]; then
|
||||
echo "${DIR}"
|
||||
exit 0
|
||||
fi
|
||||
DIR=$(go env GOPATH)
|
||||
if [ -n "${DIR}" ]; then
|
||||
echo "${DIR}/bin"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# mimic go behavior
|
||||
|
||||
# check if GOBIN is set anyhow
|
||||
if [ -n "${GOBIN}" ]; then
|
||||
echo "GOBIN"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# check if GOPATH is set anyhow
|
||||
if [ -n "${GOPATH}" ]; then
|
||||
echo "${GOPATH}/bin"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# finally use default for no $GOPATH or $GOBIN
|
||||
echo "${HOME}/go/bin"
|
||||
Reference in New Issue
Block a user