GOPATH can have multiple : separated paths in it.
This means that simply adding /bin to the end is not enough. Instead of setting GOBIN, this version prepends things to the PATH. If GOBIN is already set, simply prepends GOBIN to PATH. If not, appends /bin to each component of GOPATH, then prepends that to PATH.
This commit is contained in:
parent
970bfce997
commit
2f8f999331
18
Makefile
18
Makefile
|
@ -1,30 +1,32 @@
|
||||||
UNAME := $(shell sh -c 'uname')
|
UNAME := $(shell sh -c 'uname')
|
||||||
VERSION := $(shell sh -c 'git describe --always --tags')
|
VERSION := $(shell sh -c 'git describe --always --tags')
|
||||||
ifndef GOBIN
|
ifdef GOBIN
|
||||||
GOBIN = $(GOPATH)/bin
|
PATH := $(GOBIN):$(PATH)
|
||||||
|
else
|
||||||
|
PATH := $(subst :,/bin:,$(GOPATH))/bin:$(PATH)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Standard Telegraf build
|
# Standard Telegraf build
|
||||||
build: prepare
|
build: prepare
|
||||||
$(GOBIN)/godep go build -o telegraf -ldflags \
|
godep go build -o telegraf -ldflags \
|
||||||
"-X main.Version=$(VERSION)" \
|
"-X main.Version=$(VERSION)" \
|
||||||
./cmd/telegraf/telegraf.go
|
./cmd/telegraf/telegraf.go
|
||||||
|
|
||||||
# Build with race detector
|
# Build with race detector
|
||||||
dev: prepare
|
dev: prepare
|
||||||
$(GOBIN)/godep go build -race -o telegraf -ldflags \
|
godep go build -race -o telegraf -ldflags \
|
||||||
"-X main.Version=$(VERSION)" \
|
"-X main.Version=$(VERSION)" \
|
||||||
./cmd/telegraf/telegraf.go
|
./cmd/telegraf/telegraf.go
|
||||||
|
|
||||||
# Build linux 64-bit, 32-bit and arm architectures
|
# Build linux 64-bit, 32-bit and arm architectures
|
||||||
build-linux-bins: prepare
|
build-linux-bins: prepare
|
||||||
GOARCH=amd64 GOOS=linux $(GOBIN)/godep go build -o telegraf_linux_amd64 \
|
GOARCH=amd64 GOOS=linux godep go build -o telegraf_linux_amd64 \
|
||||||
-ldflags "-X main.Version=$(VERSION)" \
|
-ldflags "-X main.Version=$(VERSION)" \
|
||||||
./cmd/telegraf/telegraf.go
|
./cmd/telegraf/telegraf.go
|
||||||
GOARCH=386 GOOS=linux $(GOBIN)/godep go build -o telegraf_linux_386 \
|
GOARCH=386 GOOS=linux godep go build -o telegraf_linux_386 \
|
||||||
-ldflags "-X main.Version=$(VERSION)" \
|
-ldflags "-X main.Version=$(VERSION)" \
|
||||||
./cmd/telegraf/telegraf.go
|
./cmd/telegraf/telegraf.go
|
||||||
GOARCH=arm GOOS=linux $(GOBIN)/godep go build -o telegraf_linux_arm \
|
GOARCH=arm GOOS=linux godep go build -o telegraf_linux_arm \
|
||||||
-ldflags "-X main.Version=$(VERSION)" \
|
-ldflags "-X main.Version=$(VERSION)" \
|
||||||
./cmd/telegraf/telegraf.go
|
./cmd/telegraf/telegraf.go
|
||||||
|
|
||||||
|
@ -86,6 +88,6 @@ test: docker-kill prepare docker-run
|
||||||
|
|
||||||
# Run "short" unit tests
|
# Run "short" unit tests
|
||||||
test-short: prepare
|
test-short: prepare
|
||||||
$(GOBIN)/godep go test -short ./...
|
godep go test -short ./...
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
|
|
Loading…
Reference in New Issue