| 1 |
|
| 2 |
MAKEFLAGS += --no-builtin-rules |
| 3 |
.SUFFIXES: |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
.DELETE_ON_ERROR: |
| 8 |
|
| 9 |
.ONESHELL: |
| 10 |
|
| 11 |
SHELL := bash |
| 12 |
.SHELLFLAGS := -o pipefail -euc |
| 13 |
|
| 14 |
version := $(shell git rev-parse --short HEAD) |
| 15 |
tag := $(shell git tag --points-at HEAD) |
| 16 |
ifneq (,$(tag)) |
| 17 |
version := $(tag)-$(version) |
| 18 |
endif |
| 19 |
LDFLAGS := -ldflags "-X main.version=$(version)" |
| 20 |
export CGO_ENABLED := 0 |
| 21 |
|
| 22 |
ifeq ($(origin GOBIN), undefined) |
| 23 |
GOBIN := ${PWD}/bin |
| 24 |
export GOBIN |
| 25 |
PATH := ${GOBIN}:${PATH} |
| 26 |
export PATH |
| 27 |
endif |
| 28 |
|
| 29 |
toolsBins := $(addprefix bin/,$(notdir $(shell grep '^\s*_' tooling/tools.go | awk -F'"' '{print $$2}'))) |
| 30 |
|
| 31 |
|
| 32 |
$(toolsBins): tooling/go.mod tooling/go.sum tooling/tools.go |
| 33 |
$(toolsBins): CMD=$(shell awk -F'"' '/$(@F)"/ {print $$2}' tooling/tools.go) |
| 34 |
$(toolsBins): |
| 35 |
cd tooling && go install $(CMD) |
| 36 |
|
| 37 |
.PHONY: gofumpt |
| 38 |
gofumpt: bin/gofumpt |
| 39 |
gofumpt -s -d . |
| 40 |
|
| 41 |
gofumpt-fix: bin/gofumpt |
| 42 |
gofumpt -s -w . |
| 43 |
|
| 44 |
.PHONY: prettier prettier-fix |
| 45 |
prettier: |
| 46 |
prettier --list-different --ignore-path .gitignore . |
| 47 |
|
| 48 |
prettier-fix: |
| 49 |
prettier --write --ignore-path .gitignore . |