aboutsummaryrefslogtreecommitdiff
path: root/Makefile.common
diff options
context:
space:
mode:
authorSimon Pasquier <spasquie@redhat.com>2019-03-25 12:47:57 +0100
committerJohannes 'fish' Ziemke <github@freigeist.org>2019-03-25 12:47:57 +0100
commitdbe7badc7c37da1ddaaa33db4860e51a73c4c44a (patch)
tree9fad12c85f6537992e4f7051a90d2c3ffa44732d /Makefile.common
parent2f87b7cba6d6eb729a78724335fd59e746fcdff4 (diff)
downloadprometheus_node_collector-dbe7badc7c37da1ddaaa33db4860e51a73c4c44a.tar.bz2
prometheus_node_collector-dbe7badc7c37da1ddaaa33db4860e51a73c4c44a.tar.xz
prometheus_node_collector-dbe7badc7c37da1ddaaa33db4860e51a73c4c44a.zip
Update Makefile.common (#1288)
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Diffstat (limited to 'Makefile.common')
-rw-r--r--Makefile.common34
1 files changed, 27 insertions, 7 deletions
diff --git a/Makefile.common b/Makefile.common
index 79001dd..ed29aa8 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -60,7 +60,6 @@ $(warning Some recipes may not work as expected as the current Go runtime is '$(
60 endif 60 endif
61endif 61endif
62PROMU := $(FIRST_GOPATH)/bin/promu 62PROMU := $(FIRST_GOPATH)/bin/promu
63STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck
64pkgs = ./... 63pkgs = ./...
65 64
66ifeq (arm, $(GOHOSTARCH)) 65ifeq (arm, $(GOHOSTARCH))
@@ -72,8 +71,17 @@ endif
72 71
73PROMU_VERSION ?= 0.3.0 72PROMU_VERSION ?= 0.3.0
74PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz 73PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz
75STATICCHECK_VERSION ?= 2019.1 74
76STATICCHECK_URL := https://github.com/dominikh/go-tools/releases/download/$(STATICCHECK_VERSION)/staticcheck_$(GOHOSTOS)_$(GOHOSTARCH) 75STATICCHECK :=
76# staticcheck only supports linux, freebsd, darwin and windows platforms on i386/amd64
77# windows isn't included here because of the path separator being different.
78ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux freebsd darwin))
79 ifeq ($(GOHOSTARCH),$(filter $(GOHOSTARCH),amd64 i386))
80 STATICCHECK := $(FIRST_GOPATH)/bin/staticcheck
81 STATICCHECK_VERSION ?= 2019.1
82 STATICCHECK_URL := https://github.com/dominikh/go-tools/releases/download/$(STATICCHECK_VERSION)/staticcheck_$(GOHOSTOS)_$(GOHOSTARCH)
83 endif
84endif
77 85
78PREFIX ?= $(shell pwd) 86PREFIX ?= $(shell pwd)
79BIN_DIR ?= $(shell pwd) 87BIN_DIR ?= $(shell pwd)
@@ -87,14 +95,14 @@ ifeq ($(GOHOSTARCH),amd64)
87 endif 95 endif
88endif 96endif
89 97
90.PHONY: all
91all: precheck style staticcheck unused build test
92
93# This rule is used to forward a target like "build" to "common-build". This 98# This rule is used to forward a target like "build" to "common-build". This
94# allows a new "build" target to be defined in a Makefile which includes this 99# allows a new "build" target to be defined in a Makefile which includes this
95# one and override "common-build" without override warnings. 100# one and override "common-build" without override warnings.
96%: common-% ; 101%: common-% ;
97 102
103.PHONY: common-all
104common-all: precheck style check_license staticcheck unused build test
105
98.PHONY: common-style 106.PHONY: common-style
99common-style: 107common-style:
100 @echo ">> checking code style" 108 @echo ">> checking code style"
@@ -116,6 +124,15 @@ common-check_license:
116 exit 1; \ 124 exit 1; \
117 fi 125 fi
118 126
127.PHONY: common-deps
128common-deps:
129 @echo ">> getting dependencies"
130ifdef GO111MODULE
131 GO111MODULE=$(GO111MODULE) $(GO) mod download
132else
133 $(GO) get $(GOOPTS) -t ./...
134endif
135
119.PHONY: common-test-short 136.PHONY: common-test-short
120common-test-short: 137common-test-short:
121 @echo ">> running short tests" 138 @echo ">> running short tests"
@@ -138,6 +155,7 @@ common-vet:
138 155
139.PHONY: common-staticcheck 156.PHONY: common-staticcheck
140common-staticcheck: $(STATICCHECK) 157common-staticcheck: $(STATICCHECK)
158ifdef STATICCHECK
141 @echo ">> running staticcheck" 159 @echo ">> running staticcheck"
142 chmod +x $(STATICCHECK) 160 chmod +x $(STATICCHECK)
143ifdef GO111MODULE 161ifdef GO111MODULE
@@ -148,6 +166,7 @@ ifdef GO111MODULE
148else 166else
149 $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs) 167 $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs)
150endif 168endif
169endif
151 170
152.PHONY: common-unused 171.PHONY: common-unused
153common-unused: $(GOVENDOR) 172common-unused: $(GOVENDOR)
@@ -205,9 +224,11 @@ proto:
205 @echo ">> generating code from proto files" 224 @echo ">> generating code from proto files"
206 @./scripts/genproto.sh 225 @./scripts/genproto.sh
207 226
227ifdef STATICCHECK
208$(STATICCHECK): 228$(STATICCHECK):
209 mkdir -p $(FIRST_GOPATH)/bin 229 mkdir -p $(FIRST_GOPATH)/bin
210 curl -s -L $(STATICCHECK_URL) > $(STATICCHECK) 230 curl -s -L $(STATICCHECK_URL) > $(STATICCHECK)
231endif
211 232
212ifdef GOVENDOR 233ifdef GOVENDOR
213.PHONY: $(GOVENDOR) 234.PHONY: $(GOVENDOR)
@@ -221,7 +242,6 @@ precheck::
221define PRECHECK_COMMAND_template = 242define PRECHECK_COMMAND_template =
222precheck:: $(1)_precheck 243precheck:: $(1)_precheck
223 244
224
225PRECHECK_COMMAND_$(1) ?= $(1) $$(strip $$(PRECHECK_OPTIONS_$(1))) 245PRECHECK_COMMAND_$(1) ?= $(1) $$(strip $$(PRECHECK_OPTIONS_$(1)))
226.PHONY: $(1)_precheck 246.PHONY: $(1)_precheck
227$(1)_precheck: 247$(1)_precheck: