Motiejus Jakštys
984752b812
I am not using nor need arm64 and windows. Removing these from the Makefile. If you see this message and feel like they should be added back (or different archs), ping me.
51 lines
1.3 KiB
Makefile
51 lines
1.3 KiB
Makefile
SCRIPTS = $(shell awk '/#!\/bin\/(ba)?sh/&&FNR==1{print FILENAME}' $(shell git ls-files))
|
|
GODEPS = $(shell git ls-files '*.go' go.mod go.sum)
|
|
GOBIN = $(shell go env GOPATH)/bin/
|
|
GOOSARCHS = $(sort darwin/amd64 linux/amd64)
|
|
|
|
VSN ?= $(shell git describe --dirty)
|
|
VSNHASH = $(shell git rev-parse --verify HEAD)
|
|
LDFLAGS = -ldflags "-X main.Version=$(VSN) -X main.VersionHash=$(VSNHASH)"
|
|
|
|
undocker: ## builds binary for the current architecture
|
|
CGO_ENABLED=0 go build $(LDFLAGS) -o $@
|
|
|
|
.PHONY: test
|
|
test:
|
|
go test -race -cover ./...
|
|
|
|
define undockertarget
|
|
UNDOCKERS += undocker-$(1)-$(2)-$(VSN)
|
|
undocker-$(1)-$(2)-$(VSN): $(GODEPS)
|
|
CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build $(LDFLAGS) -o $$@
|
|
endef
|
|
|
|
$(foreach goosarch,$(GOOSARCHS),\
|
|
$(eval $(call undockertarget,$(word 1,$(subst /, ,$(goosarch))),$(word 2,$(subst /, ,$(goosarch))))))
|
|
|
|
.PHONY: all
|
|
all: $(UNDOCKERS)
|
|
|
|
.PHONY: lint
|
|
lint:
|
|
go vet ./...
|
|
$(GOBIN)staticcheck -f stylish ./...
|
|
shellcheck $(SCRIPTS)
|
|
|
|
.INTERMEDIATE: coverage.out
|
|
coverage.out: $(GODEPS)
|
|
go test -coverprofile $@ ./...
|
|
|
|
coverage.html: coverage.out
|
|
go tool cover -html=$< -o $@
|
|
|
|
sha256sum.txt: $(UNDOCKERS)
|
|
sha256sum $(UNDOCKERS) > $@
|
|
|
|
sha256sum.txt.asc: sha256sum.txt
|
|
gpg --clearsign $<
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
rm -f undocker-*-v* coverage.html sha256sum.txt sha256sum.txt.asc
|