VERSION := $(shell awk -F\" '/^version = / { print $$2; exit }' Cargo.toml)
RELEASE_BRANCH := master
.DEFAULT_GOAL := help
.PHONY: help build install test lint docs publish-check publish
help:
@echo "Usage: make <target>"
@echo
@awk 'BEGIN { FS = ":.*## " } /^[a-z-]+:.*## / { printf " \033[1m%-14s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
build:
cargo build --release
install:
cargo install --locked --path .
bsdt man --install
test:
cargo test
lint:
cargo clippy --all-targets
@command -v mandoc >/dev/null && mandoc -T lint -W warning man/bsdt.1 || true
docs: docs/index.html
docs/index.html: man/bsdt.1
@command -v mandoc >/dev/null || { echo "mandoc not found — install it (e.g. apt install mandoc)"; exit 1; }
mandoc -T lint -W warning $<
mandoc -T html -O 'style=style.css,man=https://man.freebsd.org/cgi/man.cgi?query=%N&sektion=%S' $< > $@
publish-check:
@branch="$$(git rev-parse --abbrev-ref HEAD)"; \
test "$$branch" = "$(RELEASE_BRANCH)" || { echo "publishing is done from $(RELEASE_BRANCH), but you are on $$branch"; exit 1; }
@test -z "$$(git status --porcelain)" || { echo "working tree has uncommitted changes"; exit 1; }
@git fetch --quiet origin "$(RELEASE_BRANCH)"
@test "$$(git rev-parse HEAD)" = "$$(git rev-parse "origin/$(RELEASE_BRANCH)")" || { echo "HEAD differs from origin/$(RELEASE_BRANCH) — push or pull first"; exit 1; }
cargo test
cargo publish --dry-run
@echo "Ready to publish bsdt $(VERSION)"
publish: publish-check
cargo publish