diff options
author | Ivan Voronchihin <bege13mot@gmail.com> | 2018-05-25 01:31:48 +0400 |
---|---|---|
committer | Johannes 'fish' Ziemke <github@freigeist.org> | 2018-05-24 23:31:48 +0200 |
commit | 606568314befb8127ce48de29ecb647bd9d8507a (patch) | |
tree | c622e270f2e13d9fc9f626591bb2fe65d7db2c21 /Makefile | |
parent | 04d69158b40cc89fb34b0a6f08d6e136b1a9fde9 (diff) | |
download | prometheus_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-- | Makefile | 48 |
1 files changed, 6 insertions, 42 deletions
@@ -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 | ||
14 | include Makefile.common | ||
15 | |||
14 | GO ?= GO15VENDOREXPERIMENT=1 go | 16 | GO ?= GO15VENDOREXPERIMENT=1 go |
15 | GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH))) | ||
16 | GOARCH := $(shell $(GO) env GOARCH) | 17 | GOARCH := $(shell $(GO) env GOARCH) |
17 | GOHOSTARCH := $(shell $(GO) env GOHOSTARCH) | 18 | GOHOSTARCH := $(shell $(GO) env GOHOSTARCH) |
18 | 19 | ||
19 | PROMTOOL ?= $(GOPATH)/bin/promtool | 20 | PROMTOOL ?= $(FIRST_GOPATH)/bin/promtool |
20 | PROMU ?= $(GOPATH)/bin/promu | ||
21 | STATICCHECK ?= $(GOPATH)/bin/staticcheck | ||
22 | pkgs = $(shell $(GO) list ./... | grep -v /vendor/) | ||
23 | 21 | ||
24 | PREFIX ?= $(shell pwd) | ||
25 | BIN_DIR ?= $(shell pwd) | ||
26 | DOCKER_IMAGE_NAME ?= node-exporter | 22 | DOCKER_IMAGE_NAME ?= node-exporter |
27 | DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) | ||
28 | MACH ?= $(shell uname -m) | 23 | MACH ?= $(shell uname -m) |
29 | DOCKERFILE ?= Dockerfile | 24 | DOCKERFILE ?= Dockerfile |
30 | 25 | ||
@@ -75,10 +70,6 @@ $(eval $(call goarch_pair,mips64el,mipsel)) | |||
75 | 70 | ||
76 | all: style vet staticcheck checkmetrics build test $(cross-test) $(test-e2e) | 71 | all: style vet staticcheck checkmetrics build test $(cross-test) $(test-e2e) |
77 | 72 | ||
78 | style: | ||
79 | @echo ">> checking code style" | ||
80 | @! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' | ||
81 | |||
82 | test: collector/fixtures/sys/.unpacked | 73 | test: 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 | ||
110 | format: | ||
111 | @echo ">> formatting code" | ||
112 | @$(GO) fmt $(pkgs) | ||
113 | |||
114 | vet: | ||
115 | @echo ">> vetting code" | ||
116 | @$(GO) vet $(pkgs) | ||
117 | |||
118 | staticcheck: $(STATICCHECK) | ||
119 | @echo ">> running staticcheck" | ||
120 | @$(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs) | ||
121 | |||
122 | build: $(PROMU) | ||
123 | @echo ">> building binaries" | ||
124 | @$(PROMU) build --prefix $(PREFIX) | ||
125 | |||
126 | tarball: $(PROMU) | ||
127 | @echo ">> building release tarball" | ||
128 | @$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR) | ||
129 | |||
130 | docker: | 101 | docker: |
131 | ifeq ($(MACH), ppc64le) | 102 | ifeq ($(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 |