aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Schmidt <ts@soundcloud.com>2016-01-22 20:27:04 +0000
committerTobias Schmidt <ts@soundcloud.com>2016-01-25 11:57:56 -0500
commita05966a3a94d066208e81ff1d2f6a31fdf4a9d71 (patch)
tree549e217384a00155c171d55a8eddf377bd88d2b1
parentb30806ef41b18e51db48e3b719473ca2142b54c1 (diff)
downloadprometheus_node_collector-a05966a3a94d066208e81ff1d2f6a31fdf4a9d71.tar.bz2
prometheus_node_collector-a05966a3a94d066208e81ff1d2f6a31fdf4a9d71.tar.xz
prometheus_node_collector-a05966a3a94d066208e81ff1d2f6a31fdf4a9d71.zip
Update Makefile.COMMON0.12.0rc2
Go expects to build a project from a location like `.../src/github.com/prometheus/node_exporter`.
-rw-r--r--Makefile.COMMON19
1 files changed, 9 insertions, 10 deletions
diff --git a/Makefile.COMMON b/Makefile.COMMON
index f8aa1b3..ac286fd 100644
--- a/Makefile.COMMON
+++ b/Makefile.COMMON
@@ -45,20 +45,23 @@ GOOS ?= $(shell uname | tr A-Z a-z)
45GOARCH ?= $(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) 45GOARCH ?= $(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m)))
46 46
47GO_VERSION ?= 1.5.3 47GO_VERSION ?= 1.5.3
48GOPATH ?= $(CURDIR)/.build/gopath
49ROOTPKG ?= github.com/prometheus/$(TARGET)
50SELFLINK ?= $(GOPATH)/src/$(ROOTPKG)
48 51
49# Check for the correct version of go in the path. If we find it, use it. 52# Check for the correct version of go in the path. If we find it, use it.
50# Otherwise, prepare to build go locally. 53# Otherwise, prepare to build go locally.
51ifeq ($(shell command -v "go" >/dev/null && go version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/'), $(GO_VERSION)) 54ifeq ($(shell command -v "go" >/dev/null && go version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/'), $(GO_VERSION))
52 GOCC ?= $(shell command -v "go") 55 GOCC ?= $(shell command -v "go")
53 GOFMT ?= $(shell command -v "gofmt") 56 GOFMT ?= $(shell command -v "gofmt")
54 GO ?= $(GOCC) 57 GO ?= GOPATH=$(GOPATH) $(GOCC)
55else 58else
56 GOURL ?= https://golang.org/dl 59 GOURL ?= https://golang.org/dl
57 GOPKG ?= go$(GO_VERSION).$(GOOS)-$(GOARCH).tar.gz 60 GOPKG ?= go$(GO_VERSION).$(GOOS)-$(GOARCH).tar.gz
58 GOROOT ?= $(CURDIR)/.build/go$(GO_VERSION) 61 GOROOT ?= $(CURDIR)/.build/go$(GO_VERSION)
59 GOCC ?= $(GOROOT)/bin/go 62 GOCC ?= $(GOROOT)/bin/go
60 GOFMT ?= $(GOROOT)/bin/gofmt 63 GOFMT ?= $(GOROOT)/bin/gofmt
61 GO ?= GOROOT=$(GOROOT) $(GOCC) 64 GO ?= GOPATH=$(GOPATH) GOROOT=$(GOROOT) $(GOCC)
62endif 65endif
63 66
64# Use vendored dependencies if available. Otherwise try to download them. 67# Use vendored dependencies if available. Otherwise try to download them.
@@ -66,11 +69,7 @@ ifneq (,$(wildcard vendor))
66 DEPENDENCIES := $(shell find vendor/ -type f -iname '*.go') 69 DEPENDENCIES := $(shell find vendor/ -type f -iname '*.go')
67 GO := GO15VENDOREXPERIMENT=1 $(GO) 70 GO := GO15VENDOREXPERIMENT=1 $(GO)
68else 71else
69 GOPATH := $(CURDIR)/.build/gopath
70 ROOTPKG ?= github.com/prometheus/$(TARGET)
71 SELFLINK ?= $(GOPATH)/src/$(ROOTPKG)
72 DEPENDENCIES := dependencies-stamp 72 DEPENDENCIES := dependencies-stamp
73 GO := GOPATH=$(GOPATH) $(GO)
74endif 73endif
75 74
76# Never honor GOBIN, should it be set at all. 75# Never honor GOBIN, should it be set at all.
@@ -82,8 +81,8 @@ ARCHIVE ?= $(TARGET)-$(VERSION).$(SUFFIX).tar.gz
82 81
83default: $(BINARY) 82default: $(BINARY)
84 83
85$(BINARY): $(GOCC) $(SRC) $(DEPENDENCIES) Makefile Makefile.COMMON 84$(BINARY): $(GOCC) $(SRC) $(DEPENDENCIES) Makefile Makefile.COMMON | $(SELFLINK)
86 $(GO) build $(GOFLAGS) -o $@ 85 cd $(SELFLINK) && $(GO) build $(GOFLAGS) -o $@
87 86
88.PHONY: archive 87.PHONY: archive
89archive: $(ARCHIVE) 88archive: $(ARCHIVE)
@@ -97,8 +96,8 @@ tag:
97 git push --tags 96 git push --tags
98 97
99.PHONY: test 98.PHONY: test
100test: $(GOCC) $(DEPENDENCIES) 99test: $(GOCC) $(DEPENDENCIES) | $(SELFLINK)
101 $(GO) test $$($(GO) list ./... | grep -v /vendor/) 100 cd $(SELFLINK) && $(GO) test $$($(GO) list ./... | grep -v /vendor/)
102 101
103.PHONY: format 102.PHONY: format
104format: $(GOCC) 103format: $(GOCC)