aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorIvan Voronchihin <bege13mot@gmail.com>2018-05-25 01:31:48 +0400
committerJohannes 'fish' Ziemke <github@freigeist.org>2018-05-24 23:31:48 +0200
commit606568314befb8127ce48de29ecb647bd9d8507a (patch)
treec622e270f2e13d9fc9f626591bb2fe65d7db2c21 /Makefile
parent04d69158b40cc89fb34b0a6f08d6e136b1a9fde9 (diff)
downloadprometheus_node_collector-606568314befb8127ce48de29ecb647bd9d8507a.tar.bz2
prometheus_node_collector-606568314befb8127ce48de29ecb647bd9d8507a.tar.xz
prometheus_node_collector-606568314befb8127ce48de29ecb647bd9d8507a.zip
Add Makefile.common (#940)
* Add Makefile.common Signed-off-by: bege13mot <bege13mot@gmail.com> * Change Makefile.common to initial Prometheus common Signed-off-by: bege13mot <bege13mot@gmail.com> * fix checkmetrics Signed-off-by: bege13mot <bege13mot@gmail.com> * fix promu Signed-off-by: bege13mot <bege13mot@gmail.com> * Add test to common Signed-off-by: bege13mot <bege13mot@gmail.com> * Fix GOPATH Signed-off-by: bege13mot <bege13mot@gmail.com> * Initial Makefile.common Signed-off-by: bege13mot <bege13mot@gmail.com> * original Makefile.common Signed-off-by: bege13mot <bege13mot@gmail.com> * delete promu Signed-off-by: bege13mot <bege13mot@gmail.com> * delete redundant .PRONY params Signed-off-by: bege13mot <bege13mot@gmail.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile48
1 files changed, 6 insertions, 42 deletions
diff --git a/Makefile b/Makefile
index 031698e..a254ef7 100644
--- a/Makefile
+++ b/Makefile
@@ -11,20 +11,15 @@
11# See the License for the specific language governing permissions and 11# See the License for the specific language governing permissions and
12# limitations under the License. 12# limitations under the License.
13 13
14include Makefile.common
15
14GO ?= GO15VENDOREXPERIMENT=1 go 16GO ?= GO15VENDOREXPERIMENT=1 go
15GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
16GOARCH := $(shell $(GO) env GOARCH) 17GOARCH := $(shell $(GO) env GOARCH)
17GOHOSTARCH := $(shell $(GO) env GOHOSTARCH) 18GOHOSTARCH := $(shell $(GO) env GOHOSTARCH)
18 19
19PROMTOOL ?= $(GOPATH)/bin/promtool 20PROMTOOL ?= $(FIRST_GOPATH)/bin/promtool
20PROMU ?= $(GOPATH)/bin/promu
21STATICCHECK ?= $(GOPATH)/bin/staticcheck
22pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
23 21
24PREFIX ?= $(shell pwd)
25BIN_DIR ?= $(shell pwd)
26DOCKER_IMAGE_NAME ?= node-exporter 22DOCKER_IMAGE_NAME ?= node-exporter
27DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
28MACH ?= $(shell uname -m) 23MACH ?= $(shell uname -m)
29DOCKERFILE ?= Dockerfile 24DOCKERFILE ?= Dockerfile
30 25
@@ -75,10 +70,6 @@ $(eval $(call goarch_pair,mips64el,mipsel))
75 70
76all: style vet staticcheck checkmetrics build test $(cross-test) $(test-e2e) 71all: style vet staticcheck checkmetrics build test $(cross-test) $(test-e2e)
77 72
78style:
79 @echo ">> checking code style"
80 @! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
81
82test: collector/fixtures/sys/.unpacked 73test: collector/fixtures/sys/.unpacked
83 @echo ">> running tests" 74 @echo ">> running tests"
84 $(GO) test -short $(test-flags) $(pkgs) 75 $(GO) test -short $(test-flags) $(pkgs)
@@ -107,26 +98,6 @@ checkmetrics: $(PROMTOOL)
107 @echo ">> checking metrics for correctness" 98 @echo ">> checking metrics for correctness"
108 ./checkmetrics.sh $(PROMTOOL) $(e2e-out) 99 ./checkmetrics.sh $(PROMTOOL) $(e2e-out)
109 100
110format:
111 @echo ">> formatting code"
112 @$(GO) fmt $(pkgs)
113
114vet:
115 @echo ">> vetting code"
116 @$(GO) vet $(pkgs)
117
118staticcheck: $(STATICCHECK)
119 @echo ">> running staticcheck"
120 @$(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs)
121
122build: $(PROMU)
123 @echo ">> building binaries"
124 @$(PROMU) build --prefix $(PREFIX)
125
126tarball: $(PROMU)
127 @echo ">> building release tarball"
128 @$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR)
129
130docker: 101docker:
131ifeq ($(MACH), ppc64le) 102ifeq ($(MACH), ppc64le)
132 $(eval DOCKERFILE=Dockerfile.ppc64le) 103 $(eval DOCKERFILE=Dockerfile.ppc64le)
@@ -138,20 +109,13 @@ test-docker:
138 @echo ">> testing docker image" 109 @echo ">> testing docker image"
139 ./test_image.sh "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" 9100 110 ./test_image.sh "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" 9100
140 111
141$(GOPATH)/bin/promtool promtool: 112$(FIRST_GOPATH)/bin/promtool promtool:
142 @GOOS= GOARCH= $(GO) get -u github.com/prometheus/prometheus/cmd/promtool 113 @GOOS= GOARCH= $(GO) get -u github.com/prometheus/prometheus/cmd/promtool
143 114
144$(GOPATH)/bin/promu promu: 115.PHONY: test-e2e promtool checkmetrics
145 @GOOS= GOARCH= $(GO) get -u github.com/prometheus/promu
146
147$(GOPATH)/bin/staticcheck:
148 @GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck
149
150
151.PHONY: all style format build test test-e2e vet tarball docker promtool promu staticcheck checkmetrics
152 116
153# Declaring the binaries at their default locations as PHONY targets is a hack 117# Declaring the binaries at their default locations as PHONY targets is a hack
154# to ensure the latest version is downloaded on every make execution. 118# to ensure the latest version is downloaded on every make execution.
155# If this is not desired, copy/symlink these binaries to a different path and 119# If this is not desired, copy/symlink these binaries to a different path and
156# set the respective environment variables. 120# set the respective environment variables.
157.PHONY: $(GOPATH)/bin/promtool $(GOPATH)/bin/promu $(GOPATH)/bin/staticcheck 121.PHONY: $(FIRST_GOPATH)/bin/promtool