-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.mk
59 lines (49 loc) · 1.62 KB
/
build.mk
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
GO ?= go
GORELEASER ?= goreleaser
OTELCOL_BUILDER_VERSION ?= 0.108.0
OTELCOL_BUILDER_DIR ?= ${HOME}/bin
OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/ocb
DISTRIBUTIONS ?= "nr-otel-collector"
ci: build
build: go ocb
@./scripts/build.sh -d "${DISTRIBUTIONS}" -b ${OTELCOL_BUILDER} -g ${GO}
generate: generate-sources
generate-sources: go ocb
@./scripts/build.sh -d "${DISTRIBUTIONS}" -s true -b ${OTELCOL_BUILDER} -g ${GO}
goreleaser-verify: goreleaser
@${GORELEASER} release --snapshot --rm-dist
.PHONY: ocb
ocb:
ifeq (, $(shell command -v ocb 2>/dev/null))
@{ \
[ ! -x '$(OTELCOL_BUILDER)' ] || exit 0; \
set -e ;\
os=$$(uname | tr A-Z a-z) ;\
machine=$$(uname -m) ;\
[ "$${machine}" != x86 ] || machine=386 ;\
[ "$${machine}" != x86_64 ] || machine=amd64 ;\
[ "$${machine}" != aarch64 ] || machine=arm64 ;\
echo "Installing ocb ($${os}/$${machine}) at $(OTELCOL_BUILDER_DIR)";\
mkdir -p $(OTELCOL_BUILDER_DIR) ;\
curl -sLo $(OTELCOL_BUILDER) "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/cmd%2Fbuilder%2Fv$(OTELCOL_BUILDER_VERSION)/ocb_$(OTELCOL_BUILDER_VERSION)_$${os}_$${machine}" ;\
chmod +x $(OTELCOL_BUILDER) ;\
}
else
OTELCOL_BUILDER=$(shell command -v ocb)
endif
.PHONY: go
go:
@{ \
if ! command -v '$(GO)' >/dev/null 2>/dev/null; then \
echo >&2 '$(GO) command not found. Please install golang. https://go.dev/doc/install'; \
exit 1; \
fi \
}
.PHONY: goreleaser
goreleaser:
@{ \
if ! command -v '$(GORELEASER)' >/dev/null 2>/dev/null; then \
echo >&2 '$(GORELEASER) command not found. Please install goreleaser. https://goreleaser.com/install/'; \
exit 1; \
fi \
}