forked from jenningsloy318/redfish_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·60 lines (43 loc) · 2.14 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
GO ?= go
GOFMT ?= $(GO)fmt
FIRST_GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
RPM := ./scripts/build_rpm.sh
pkgs = ./...
BIN_DIR ?= $(shell pwd)/build
VERSION ?= $(shell cat VERSION)
REVERSION ?=$(shell git log -1 --pretty="%H")
BRANCH ?=$(shell git rev-parse --abbrev-ref HEAD)
TIME ?=$(shell date --rfc-3339=seconds)
HOST ?=$(shell hostname)
DOCKER := $(shell { command -v podman || command -v docker; } 2>/dev/null)
all: fmt style build docker-build rpm docker-rpm
style:
@echo ">> checking code style"
! $(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
check_license:
@echo ">> checking license header"
@licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*') ; do \
awk 'NR<=3' $$file | grep -Eq "(Copyright|generated|GENERATED)" || echo $$file; \
done); \
if [ -n "$${licRes}" ]; then \
echo "license header checking failed:"; echo "$${licRes}"; \
exit 1; \
fi
build: |
@echo ">> building binaries"
$(GO) build -o build/redfish_exporter -ldflags '-X "main.Version=$(VERSION)" -X "main.BuildRevision=$(REVERSION)" -X "main.BuildBranch=$(BRANCH)" -X "main.BuildTime=$(TIME)" -X "main.BuildHost=$(HOSTNAME)"'
docker-build-centos7:
$(DOCKER) run -v `pwd`:/go/src/github.com/jenningsloy318/redfish_exporter -w /go/src/github.com/jenningsloy318/redfish_exporter docker.io/jenningsloy318/prom-builder:centos7 make build
docker-build-centos8:
$(DOCKER) run -v `pwd`:/go/src/github.com/jenningsloy318/redfish_exporter -w /go/src/github.com/jenningsloy318/redfish_exporter docker.io/jenningsloy318/prom-builder:centos8 make build
rpm: | build
@echo ">> building binaries"
$(RPM)
docker-rpm:
$(DOCKER) run -v `pwd`:/go/src/github.com/jenningsloy318/redfish_exporter -w /go/src/github.com/jenningsloy318/redfish_exporter docker.io/jenningsloy318/prom-builder make rpm
fmt:
@echo ">> format code style"
$(GOFMT) -w $$(find . -path ./vendor -prune -o -name '*.go' -print)
clean:
rm -rf $(BIN_DIR)
.PHONY: all style check_license format build test fmt build docker-build rpm docker-rpm