-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (38 loc) · 1.41 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
GOOS ?= "$$(uname | tr '[:upper:]' '[:lower:]')"
GOARCH ?= "$$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$$/arm64/')"
CGO_ENABLED ?= 0
GO_ENVs ?= GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=$(CGO_ENABLED)
GO ?= go
# Preferrably aligned with the version of OpenTelemetry collector core
OTELCOL_BUILDER_VERSION ?= 0.72.0
OTELCOL_BUILDER_DIR ?= ${HOME}/bin
OTELCOL_BUILDER ?= ${OTELCOL_BUILDER_DIR}/ocb
DISTRIBUTIONS ?= "otelcol-k8s,otelcol-vm"
ci: build
build: go ocb
@$(GO_ENVs) ./scripts/build.sh -d "${DISTRIBUTIONS}" -b ${OTELCOL_BUILDER} -g ${GO}
generate: generate-sources
generate-sources: go ocb
@$(GO_ENVs) ./scripts/build.sh -d "${DISTRIBUTIONS}" -s true -b ${OTELCOL_BUILDER} -g ${GO}
.PHONY: ocb
ocb:
ifeq (, $(shell command -v ocb 2>/dev/null))
@{ \
set -e ;\
[ ! -x '$(OTELCOL_BUILDER)' ] || exit 0; \
echo "Installing ocb $(OS)/$(ARCH) at $(OTELCOL_BUILDER_DIR)";\
mkdir -p $(OTELCOL_BUILDER_DIR) ;\
curl -sSfLo $(OTELCOL_BUILDER) "https://github.com/open-telemetry/opentelemetry-collector/releases/download/cmd%2Fbuilder%2Fv$(OTELCOL_BUILDER_VERSION)/ocb_$(OTELCOL_BUILDER_VERSION)_$(OS)_$(ARCH)" ;\
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 \
}