Makefile, docs: programmatically generate version for docs (i got tired of doing it myself)

This commit is contained in:
Emma Tebibyte 2024-06-23 23:47:29 -06:00
parent 8b400d8a62
commit 0fc9a6b533
Signed by: emma
GPG Key ID: 06FA419A1698C270
14 changed files with 23 additions and 16 deletions

View File

@ -29,12 +29,12 @@ RUSTLIBS = --extern getopt=build/o/libgetopt.rlib \
CFLAGS += -I$(SYSEXITS)
.PHONY: all
all: dj false fop hru intcmp mm npc rpn scrut str strcmp swab true
all: docs dj false fop hru intcmp mm npc rpn scrut str strcmp swab true
# keep build/include until bindgen(1) has stdin support
# https://github.com/rust-lang/rust-bindgen/issues/2703
build:
mkdir -p build/bin build/include build/lib build/o build/test
mkdir -p build/bin build/docs build/include build/lib build/o build/test
.PHONY: clean
clean:
@ -43,7 +43,7 @@ clean:
dist: all
mkdir -p $(DESTDIR)/$(PREFIX)/bin $(DESTDIR)/$(PREFIX)/share/man/man1
cp build/bin/* $(DESTDIR)/$(PREFIX)/bin
cp docs/*.1 $(DESTDIR)/$(PREFIX)/$(MANDIR)/man1
cp build/docs/*.1 $(DESTDIR)/$(PREFIX)/$(MANDIR)/man1
.PHONY: install
install: dist
@ -54,6 +54,13 @@ test: build
tests/posix-compat.sh
$(RUSTC) --test src/getopt-rs/lib.rs -o build/test/getopt
.PHONY: docs
docs: docs/ build
for file in docs/*; do original="$$(sed -n '/^\.TH/p' <"$$file")"; \
title="$$(printf '%s\n' "$$original" | sed \
"s/X\.X\.X/$$(git describe --tags --long | cut -d'-' -f1)/g")"; \
sed "s/$$original/$$title/g" <"$$file" >"build/$$file"; done
.PHONY: rustlibs
rustlibs: build/o/libsysexits.rlib build/o/libgetopt.rlib \
build/o/libstrerror.rlib

View File

@ -4,7 +4,7 @@
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
.\"
.TH DJ 1 2024-06-17 "Harakit 0.13.11"
.TH DJ 1 2024-06-17 "Harakit X.X.X"
.SH NAME
dj \(en disk jockey
.\"

View File

@ -4,7 +4,7 @@
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
.\"
.TH FALSE 1 2024-06-06 "Harakit 0.13.11"
.TH FALSE 1 2024-06-06 "Harakit X.X.X"
.SH NAME
false \(en do nothing, unsuccessfully
.\"

View File

@ -4,7 +4,7 @@
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
.\"
.TH FOP 1 2024-06-17 "Harakit 0.13.11"
.TH FOP 1 2024-06-17 "Harakit X.X.X"
.SH NAME
fop \(en field operator
.\"

View File

@ -3,7 +3,7 @@
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
.\"
.TH HRU 1 2024-06-17 "Harakit 0.13.11"
.TH HRU 1 2024-06-17 "Harakit X.X.X"
.SH NAME
hru \(en human readable units
.\"

View File

@ -4,7 +4,7 @@
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
.\"
.TH INTCMP 1 2024-06-06 "Harakit 0.13.11"
.TH INTCMP 1 2024-06-06 "Harakit X.X.X"
.SH NAME
intcmp \(en compare integers
.\"

View File

@ -3,7 +3,7 @@
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
.\"
.TH MM 1 2024-06-17 "Harakit 0.13.11"
.TH MM 1 2024-06-17 "Harakit X.X.X"
.SH NAME
mm \(en middleman
.\"

View File

@ -4,7 +4,7 @@
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
.\"
.TH NPC 1 2024-06-17 "Harakit 0.13.11"
.TH NPC 1 2024-06-17 "Harakit X.X.X"
.SH NAME
npc \(en show non-printing characters
.\"

View File

@ -4,7 +4,7 @@
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
.\"
.TH RPN 1 2024-06-17 "Harakit 0.13.11"
.TH RPN 1 2024-06-17 "Harakit X.X.X"
.SH NAME
rpn \(en reverse polish notation evaluation
.\"

View File

@ -4,7 +4,7 @@
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
.\"
.TH SCRUT 1 2024-06-06 "Harakit 0.13.11"
.TH SCRUT 1 2024-06-06 "Harakit X.X.X"
.SH NAME
scrut \(en scrutinize file properties
.SH SYNOPSIS

View File

@ -4,7 +4,7 @@
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
.\"
.TH STR 1 2024-06-17 "Harakit 0.13.11"
.TH STR 1 2024-06-17 "Harakit X.X.X"
.SH NAME
str \(en test string arguments
.\"

View File

@ -4,7 +4,7 @@
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
.\"
.TH STRCMP 1 2024-06-17 "Harakit 0.13.11"
.TH STRCMP 1 2024-06-17 "Harakit X.X.X"
.SH NAME
strcmp \(en compare strings
.\"

View File

@ -4,7 +4,7 @@
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
.\"
.TH SWAB 1 2024-06-17 "Harakit 0.13.11"
.TH SWAB 1 2024-06-17 "Harakit X.X.X"
.SH NAME
swab \(en swap bytes
.\"

View File

@ -4,7 +4,7 @@
.\" This work is licensed under CC BY-SA 4.0. To see a copy of this license,
.\" visit <http://creativecommons.org/licenses/by-sa/4.0/>.
.\"
.TH TRUE 1 2024-06-06 "Harakit 0.13.11"
.TH TRUE 1 2024-06-06 "Harakit X.X.X"
.SH NAME
true \(en do nothing, successfully
.\"