Skip to content

Commit

Permalink
GOPATH can have multiple : separated paths in it.
Browse files Browse the repository at this point in the history
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.

closes #386
  • Loading branch information
gotyaoi authored and sparrc committed Nov 26, 2015
1 parent 317a352 commit 40fd33d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
UNAME := $(shell sh -c 'uname')
VERSION := $(shell sh -c 'git describe --always --tags')
ifndef GOBIN
GOBIN = $(GOPATH)/bin
ifdef GOBIN
PATH := $(GOBIN):$(PATH)
else
PATH := $(subst :,/bin:,$(GOPATH))/bin:$(PATH)
endif

# Standard Telegraf build
build: prepare
$(GOBIN)/godep go build -o telegraf -ldflags \
godep go build -o telegraf -ldflags \
"-X main.Version=$(VERSION)" \
./cmd/telegraf/telegraf.go

# Build with race detector
dev: prepare
$(GOBIN)/godep go build -race -o telegraf -ldflags \
godep go build -race -o telegraf -ldflags \
"-X main.Version=$(VERSION)" \
./cmd/telegraf/telegraf.go

# Build linux 64-bit, 32-bit and arm architectures
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)" \
./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)" \
./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)" \
./cmd/telegraf/telegraf.go

Expand Down Expand Up @@ -86,6 +88,6 @@ test: docker-kill prepare docker-run

# Run "short" unit tests
test-short: prepare
$(GOBIN)/godep go test -short ./...
godep go test -short ./...

.PHONY: test

0 comments on commit 40fd33d

Please sign in to comment.