exporter-go-mystrom/Makefile

49 lines
1.3 KiB
Makefile
Raw Permalink Normal View History

2021-12-23 15:17:58 +01:00
##
#
.DEFAULT_GOAL := help
2021-12-23 17:43:20 +01:00
.PHONY: generate go-tools
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
2021-12-23 17:43:20 +01:00
BINDIR := $(CURDIR)/output
GO ?= go
GOPATH ?= $(shell $(GO) env GOPATH)
2021-12-23 15:17:58 +01:00
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 17:43:20 +01:00
GO_BUILD_FLAGS := -v
export GO111MODULE := on
2021-12-23 15:17:58 +01:00
build: go-tools generate ## build mystrom-exporter for your local system
$(GO) build \
-o ${BINDIR}/mystrom-exporter \
-gcflags "$(GO_BUILD_FLAGS)" \
-ldflags '$(LDFLAGS)' \
-tags '$(TAGS)' \
.
2021-11-12 12:03:22 +01:00
2021-12-23 17:43:20 +01:00
run:
${BINDIR}/mystrom-exporter
2021-12-23 17:43:20 +01:00
generate: go-tools
$(GO) generate ./...
2021-12-23 16:46:18 +01:00
go-tools: $(GOPATH)/bin/stringer
2021-12-23 17:43:20 +01:00
# -- see more info on https://pkg.go.dev/golang.org/x/tools/cmd/stringer
2021-12-23 16:46:18 +01:00
$(GOPATH)/bin/stringer:
2021-12-23 17:43:20 +01:00
$(GO) install golang.org/x/tools/cmd/stringer@latest
2021-12-23 16:46:18 +01:00
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}'