2021-12-23 15:17:58 +01:00
|
|
|
##
|
|
|
|
#
|
|
|
|
.DEFAULT_GOAL := help
|
2021-12-23 16:46:18 +01:00
|
|
|
.PHONY: generate
|
2021-11-12 12:03:22 +01:00
|
|
|
|
2021-12-23 15:17:58 +01:00
|
|
|
version := $(shell git describe --tags --always)
|
|
|
|
revision := $(shell git rev-parse HEAD)
|
|
|
|
branch := $(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
builduser := $(shell whoami)
|
|
|
|
builddate := $(shell date '+%FT%T_%Z')
|
|
|
|
|
|
|
|
versionPkgPrefix := mystrom-exporter/pkg/version
|
|
|
|
|
|
|
|
LDFLAGS := -w -s \
|
|
|
|
-X $(versionPkgPrefix).Version=${version} \
|
|
|
|
-X $(versionPkgPrefix).Revision=${revision} \
|
|
|
|
-X $(versionPkgPrefix).Branch=${branch} \
|
|
|
|
-X $(versionPkgPrefix).BuildUser=${builduser} \
|
|
|
|
-X $(versionPkgPrefix).BuildDate=${builddate}
|
|
|
|
GOFLAGS := -v
|
|
|
|
|
2021-12-23 16:46:18 +01:00
|
|
|
linux: generate ## builds the linux version of the exporter
|
2021-12-23 15:17:58 +01:00
|
|
|
GOOS=linux GOARCH=amd64 go build $(GOFLAGS) -ldflags '$(LDFLAGS)'
|
2021-12-23 16:46:18 +01:00
|
|
|
mac: generate ## builds the macos version of the exporter
|
2021-12-23 15:17:58 +01:00
|
|
|
GOOS=darwin GOARCH=amd64 go build $(GOFLAGS) -ldflags '$(LDFLAGS)'
|
2021-12-23 16:46:18 +01:00
|
|
|
mac-arm: generate ## builds the macos (m1) version of the exporter
|
2021-12-23 16:36:04 +01:00
|
|
|
GOOS=darwin GOARCH=arm64 go build $(GOFLAGS) -ldflags '$(LDFLAGS)'
|
2021-12-23 16:46:18 +01:00
|
|
|
arm64: generate
|
2021-12-23 15:17:58 +01:00
|
|
|
GOOS=linux GOARCH=arm64 go build $(GOFLAGS) -ldflags '$(LDFLAGS)'
|
2021-12-23 16:46:18 +01:00
|
|
|
arm: generate
|
2021-12-23 15:17:58 +01:00
|
|
|
GOOS=linux GOARCH=arm go build $(GOFLAGS) -ldflags '$(LDFLAGS)'
|
2021-11-12 12:03:22 +01:00
|
|
|
|
2021-12-23 16:46:18 +01:00
|
|
|
# -- see more info on https://pkg.go.dev/golang.org/x/tools/cmd/stringer
|
|
|
|
generate: $(GOPATH)/bin/stringer
|
|
|
|
go generate ./...
|
|
|
|
|
|
|
|
$(GOPATH)/bin/stringer:
|
|
|
|
go install golang.org/x/tools/cmd/stringer@latest
|
|
|
|
|
2021-12-23 15:17:58 +01:00
|
|
|
# --
|
|
|
|
help:
|
|
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|