aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 23:55:57 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 23:55:57 +0200
commit04f46bf180cf506ceadb76b5afacf9c02700cc65 (patch)
treeeee384915f80b8243ff807b239515d1c7525095c /Makefile
parent0b155e8df3205aebf129091b517f4116665a5adc (diff)
downloadkrino-04f46bf180cf506ceadb76b5afacf9c02700cc65.tar.gz
krino-04f46bf180cf506ceadb76b5afacf9c02700cc65.zip
build: VERSION checked for build and install, cross names without v, dependency gate covers tests and BSDs, tarball install, examples and extractor list tested
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile24
1 files changed, 11 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 1a713b7..6d5d488 100644
--- a/Makefile
+++ b/Makefile
@@ -8,8 +8,13 @@ SHAREDIR = $(DESTDIR)$(PREFIX)/share
MANDIR = $(SHAREDIR)/man
DOCDIR = $(SHAREDIR)/doc/krino
BIN = krino
-VERSION != git describe --tags --always --dirty 2>/dev/null || echo dev
+# The tag's "v" is dropped, so dist directories read krino-0.0.8-..., as
+# `make release VERSION=0.0.8` names them.
+VERSION != (git describe --tags --always --dirty 2>/dev/null || echo dev) | sed 's/^v//'
LDFLAGS = -s -w -X main.version=$(VERSION)
+# VERSION reaches -ldflags and directory names, so every target using it
+# refuses anything but a plain version string.
+CHECK_VERSION = case '$(VERSION)' in ''|*[!A-Za-z0-9._+-]*) echo "refusing: VERSION must contain only letters, digits, and the characters . - _ +" >&2; exit 1 ;; esac
CROSS_PLATFORMS = linux/amd64 linux/arm64 freebsd/amd64 openbsd/amd64
.PHONY: all help build install uninstall test vet fmt lint ci bench fuzz race vulncheck cross dist release deps install-hooks clean
@@ -22,6 +27,7 @@ help: ## show this help
@echo " version: $(VERSION) prefix: $(PREFIX)"
build: ## build ./krino; Go fetches module dependencies itself; reports missing optional extractors
+ @$(CHECK_VERSION)
CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o $(BIN) ./cmd/krino
@missing=""; \
for t in pdftotext antiword catdoc xls2csv catppt; do \
@@ -70,7 +76,7 @@ ci: ## the gate: gofmt, vet, tests, dependencies, no personal data staged, man p
GOOS=freebsd CGO_ENABLED=0 go vet ./...
GOOS=openbsd CGO_ENABLED=0 go vet ./...
go test ./...
- @deps=$$(go list -deps -f '{{with .Module}}{{.Path}}{{end}}' ./... | sort -u | grep -vxE '(krino|golang\.org/x/(term|text|sys))?' || true); \
+ @deps=$$(for os in linux freebsd openbsd; do GOOS=$$os CGO_ENABLED=0 go list -deps -test -f '{{with .Module}}{{.Path}}{{end}}' ./... || echo "go list failed for $$os"; done | sort -u | grep -vxE '(krino|golang\.org/x/(term|text|sys))?' || true); \
test -z "$$deps" || { echo "unexpected dependencies:"; echo "$$deps"; exit 1; }
@scripts/leak-check
@scripts/man-lint
@@ -116,11 +122,7 @@ vulncheck: ## check the standard library and dependencies against the Go vulnera
go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./...
cross: ## cross-compile linux/amd64, linux/arm64, freebsd/amd64, openbsd/amd64 into dist/krino-$(VERSION)-<os>-<arch>/
- @case '$(VERSION)' in \
- ''|*[!A-Za-z0-9._+-]*) \
- echo "refusing: VERSION must contain only letters, digits, and the characters . - _ +" >&2; \
- exit 1 ;; \
- esac
+ @$(CHECK_VERSION)
@for t in $(CROSS_PLATFORMS); do \
os=$${t%/*}; arch=$${t#*/}; \
dir=dist/krino-$(VERSION)-$$os-$$arch; \
@@ -153,12 +155,8 @@ dist: cross
$$SUM $$tarballs > SHA256SUMS
release: ## make cross + tarballs + SHA256SUMS in dist/, then tag v$(VERSION) (annotated; never pushes) - usage: make release VERSION=0.0.1
- @case '$(VERSION)' in \
- ''|*[!A-Za-z0-9._+-]*) \
- echo "refusing: VERSION must contain only letters, digits, and the characters . - _ +" >&2; \
- exit 1 ;; \
- esac
- @default_version=$$(git describe --tags --always --dirty 2>/dev/null || echo dev); \
+ @$(CHECK_VERSION)
+ @default_version=$$( (git describe --tags --always --dirty 2>/dev/null || echo dev) | sed 's/^v//'); \
test -n "$(VERSION)" && test "$(VERSION)" != "$$default_version" || \
{ echo "refusing: pass an explicit VERSION, e.g. make release VERSION=0.0.1"; exit 1; }
@test -z "$$(git status --porcelain)" || \