forked from giantswarm/prometheus-pingdom-exporter
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
79 lines (61 loc) · 1.8 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
PROJECT=prometheus-pingdom-exporter
GOVERSION=1.15
BIN := $(PROJECT)
VERSION := $(shell cat VERSION)
COMMIT := $(shell git rev-parse --short HEAD)
.PHONY: all clean install
SOURCE=$(shell find . -name '*.go')
ifndef GOOS
GOOS := $(shell go env GOOS)
endif
ifndef GOARCH
GOARCH := $(shell go env GOARCH)
endif
BUILD_COMMAND=go build -a \
-tags netgo \
-ldflags \
"-X github.com/giantswarm/prometheus-pingdom-exporter/cmd.version=$(VERSION) \
-X github.com/giantswarm/prometheus-pingdom-exporter/cmd.goVersion=$(GOVERSION) \
-X github.com/giantswarm/prometheus-pingdom-exporter/cmd.gitCommit=$(COMMIT) \
-X github.com/giantswarm/prometheus-pingdom-exporter/cmd.osArch=$(GOOS)/$(GOARCH) \
-w" \
-o $(BIN)
all: $(BIN)
deps:
GO111MODULE=on go get -v ./...
clean:
rm -rf $(BIN) bin-dist/ build/
$(BIN): $(SOURCE) VERSION
CGO_ENABLED=0
@echo Building inside Docker container for $(GOOS)/$(GOARCH)
docker run \
--rm \
-v $(shell pwd):/go/src/github.com/giantswarm/$(PROJECT) \
-e GOPATH=/go \
-e GOOS=$(GOOS) \
-e GOARCH=$(GOARCH) \
-e GO111MODULE=on \
-w /go/src/github.com/giantswarm/$(PROJECT) \
golang:$(GOVERSION) \
$(BUILD_COMMAND)
ci-build: $(SOURCE) VERSION
CGO_ENABLED=0
@echo Building for $(GOOS)/$(GOARCH)
GO111MODULE=on $(BUILD_COMMAND)
docker-image: $(BIN)
docker build -t giantswarm/$(PROJECT):$(VERSION) .
bin-dist: $(SOURCE) VERSION
# Remove any old bin-dist or build directories
rm -rf bin-dist build
# Build for all supported OSs
for OS in darwin linux; do \
rm -f $(BIN); \
GOOS=$$OS make $(BIN); \
mkdir -p build/$$OS bin-dist; \
cp README.md build/$$OS/; \
cp LICENSE build/$$OS/; \
cp $(BIN) build/$$OS/; \
tar czf bin-dist/$(BIN).$(VERSION).$$OS.tar.gz -C build/$$OS .; \
done
install: $(BIN)
cp $(BIN) /usr/local/bin/