Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

Commit ba3f8ef

Browse files
committed
Makefile: Respect GOBIN
GOBIN (documented in [1]) defaults to DIR/bin, but it's a configurable variable in its own right. This command updates our calculations, using ?= (documented in [2]) to avoid expensive shell operations when we don't actually need the result (because a different target was called or because the user provided their own value). I've also used 'go env GOPATH' to get the (platform-specific [1]) default value when the environment variable is not set. And I've used cut [3] instead of awk [4] to pull out the first component of GOPATH. Both are in POSIX, but cut is a simpler tool for this particular problem. [1]: https://golang.org/cmd/go/#hdr-GOPATH_environment_variable [2]: https://www.gnu.org/software/make/manual/html_node/Setting.html [3]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cut.html [4]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html
1 parent fbcb680 commit ba3f8ef

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Documentation/development.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
## Requirements
44

55
* Go 1.8+
6-
* Configured [GOPATH](http://golang.org/doc/code.html#GOPATH)
76

87
## Building
98

10-
First, clone the repo into the proper location in your $GOPATH:
9+
First, clone the repo into the proper location in your [`GOPATH`][GOPATH]:
1110

1211
```
1312
go get -u github.com/kubernetes-incubator/bootkube
14-
cd $GOPATH/src/github.com/kubernetes-incubator/bootkube
13+
cd $(go env GOPATH | cut -d: -f1)/src/github.com/kubernetes-incubator/bootkube
1514
```
1615

1716
Then, to build (only Go verson 1.8 is supported now):
@@ -71,3 +70,5 @@ Commenting on the PR:
7170
* `coreosbot run e2e checkpointer`: can be used to specifically test new checkpointer code.
7271
* This will build a new checkpointer image from the PR, and includes that image as part of the checkpointer daemonset.
7372
* `coreosbot run conformance`: run upstream Kubernetes conformance tests
73+
74+
[GOPATH]: https://golang.org/cmd/go/#hdr-GOPATH_environment_variable

Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ export PATH:=$(PATH):$(PWD)
66
SHELL:=$(shell which bash)
77
LOCAL_OS:=$(shell uname | tr A-Z a-z)
88
GOFILES:=$(shell find . -name '*.go' | grep -v -E '(./vendor)')
9-
GOPATH_BIN:=$(shell echo ${GOPATH} | awk 'BEGIN { FS = ":" }; { print $1 }')/bin
9+
GOPATH ?= $(shell go env GOPATH)
10+
PRIMARY_GOPATH ?= $(shell echo ${GOPATH} | cut -d : -f 1)
11+
GOBIN ?= $(PRIMARY_GOPATH)/bin
1012
LDFLAGS=-X github.com/kubernetes-incubator/bootkube/pkg/version.Version=$(shell $(CURDIR)/build/git-version.sh)
1113
TERRAFORM:=$(shell command -v terraform 2> /dev/null)
1214

@@ -42,7 +44,7 @@ endif
4244
@go test -v $(shell go list ./... | grep -v '/vendor/\|/e2e')
4345

4446
install: _output/bin/$(LOCAL_OS)/bootkube
45-
cp $< $(GOPATH_BIN)
47+
cp $< $(GOBIN)
4648

4749
_output/bin/%: GOOS=$(word 1, $(subst /, ,$*))
4850
_output/bin/%: GOARCH=$(word 2, $(subst /, ,$*))

0 commit comments

Comments
 (0)