2021-08-24 17:23:31 +03:00
|
|
|
SCRIPTS = $(shell awk '/#!\/bin\/(ba)?sh/&&FNR==1{print FILENAME}' $(shell git ls-files))
|
2021-06-01 08:49:39 +03:00
|
|
|
GODEPS = $(shell git ls-files '*.go' go.mod go.sum)
|
2021-06-01 09:07:32 +03:00
|
|
|
GOBIN = $(shell go env GOPATH)/bin/
|
2021-08-25 08:53:03 +03:00
|
|
|
GOOSARCHS = $(sort darwin/amd64 linux/amd64)
|
2021-08-24 06:47:38 +03:00
|
|
|
|
2021-08-24 13:57:30 +03:00
|
|
|
VSN ?= $(shell git describe --dirty)
|
2021-08-24 07:02:12 +03:00
|
|
|
VSNHASH = $(shell git rev-parse --verify HEAD)
|
|
|
|
LDFLAGS = -ldflags "-X main.Version=$(VSN) -X main.VersionHash=$(VSNHASH)"
|
|
|
|
|
2021-08-25 08:53:03 +03:00
|
|
|
undocker: ## builds binary for the current architecture
|
|
|
|
CGO_ENABLED=0 go build $(LDFLAGS) -o $@
|
|
|
|
|
2021-08-24 07:02:12 +03:00
|
|
|
.PHONY: test
|
|
|
|
test:
|
|
|
|
go test -race -cover ./...
|
2021-08-23 16:29:41 +03:00
|
|
|
|
|
|
|
define undockertarget
|
2021-08-25 08:53:03 +03:00
|
|
|
UNDOCKERS += undocker-$(1)-$(2)-$(VSN)
|
|
|
|
undocker-$(1)-$(2)-$(VSN): $(GODEPS)
|
2021-08-24 06:47:38 +03:00
|
|
|
CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build $(LDFLAGS) -o $$@
|
2021-08-23 16:29:41 +03:00
|
|
|
endef
|
|
|
|
|
2021-08-23 16:32:00 +03:00
|
|
|
$(foreach goosarch,$(GOOSARCHS),\
|
2021-08-25 08:53:03 +03:00
|
|
|
$(eval $(call undockertarget,$(word 1,$(subst /, ,$(goosarch))),$(word 2,$(subst /, ,$(goosarch))))))
|
2021-06-01 19:54:55 +03:00
|
|
|
|
2021-08-23 16:29:41 +03:00
|
|
|
.PHONY: all
|
2021-08-29 18:23:43 +03:00
|
|
|
all: $(UNDOCKERS) sha256sum-$(VSN).txt
|
2021-06-01 09:00:27 +03:00
|
|
|
|
2021-09-01 09:38:13 +03:00
|
|
|
.PHONY: sha256sum-asc
|
|
|
|
sha256sum-asc: sha256sum-$(VSN).txt.asc
|
|
|
|
|
2021-06-01 09:00:27 +03:00
|
|
|
.PHONY: lint
|
2021-08-24 17:23:31 +03:00
|
|
|
lint:
|
2021-06-01 09:00:27 +03:00
|
|
|
go vet ./...
|
2021-06-01 09:10:10 +03:00
|
|
|
$(GOBIN)staticcheck -f stylish ./...
|
2021-08-24 17:23:31 +03:00
|
|
|
shellcheck $(SCRIPTS)
|
2021-06-01 08:42:23 +03:00
|
|
|
|
|
|
|
.INTERMEDIATE: coverage.out
|
2021-06-01 08:49:39 +03:00
|
|
|
coverage.out: $(GODEPS)
|
2021-06-01 08:42:23 +03:00
|
|
|
go test -coverprofile $@ ./...
|
|
|
|
|
|
|
|
coverage.html: coverage.out
|
|
|
|
go tool cover -html=$< -o $@
|
2021-06-01 19:54:55 +03:00
|
|
|
|
2021-08-29 07:48:31 +03:00
|
|
|
sha256sum-$(VSN).txt: $(UNDOCKERS)
|
2021-08-23 16:42:57 +03:00
|
|
|
sha256sum $(UNDOCKERS) > $@
|
|
|
|
|
2021-08-29 07:48:31 +03:00
|
|
|
sha256sum-$(VSN).txt.asc: sha256sum-$(VSN).txt
|
2021-08-23 16:42:57 +03:00
|
|
|
gpg --clearsign $<
|
|
|
|
|
2021-06-01 19:54:55 +03:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2021-08-29 07:48:31 +03:00
|
|
|
rm -f undocker-*-v* coverage.html sha256sum*.txt sha256sum*.txt.asc
|