~nabijaczleweli/voreutils

e9db514acd52547bbc9a5f56e64d833163540197 — наб a month ago fc0570e
Generate index HTML page
2 files changed, 30 insertions(+), 8 deletions(-)

M Makefile
M README.md
M Makefile => Makefile +27 -7
@@ 49,6 49,16 @@ else
$(error VOREUTILS_DATE_MODE=$(VOREUTILS_DATE_MODE) must be any of git-{global,file}, stat, constant-{epoch,literal})
endif

ifeq "$(VOREUTILS_DATE_MODE)" "git-file"
# Same as git-global
INDEX_PAGE_DATE := $(shell $(DATE_EPOCH)$(shell git log -1 --no-show-signature --format=%at) +"%B %e, %Y")
else ifeq "$(VOREUTILS_DATE_MODE)" "stat"
INDEX_PAGE_DATE := $(shell date +"%B %e, %Y")
else
INDEX_PAGE_DATE := $(DATE_F)
endif


ifneq "$(subst constant-,,$(VOREUTILS_DATE_MODE))" "$(VOREUTILS_DATE_MODE)"
ifeq "$(VOREUTILS_DATE)" ""
$(error VOREUTILS_DATE_MODE=$(VOREUTILS_DATE_MODE) and no date specified)


@@ 59,7 69,7 @@ endif
AS_NEEDED := -Wl,--as-needed
SO := .so
SONAME := -soname
SYSTEM := $(shell uname -s)
SYSTEM := $(shell uname)
ifeq "$(SYSTEM)" "NetBSD"
	#
else ifeq "$(SYSTEM)" "OpenBSD"


@@ 111,7 121,7 @@ CPPAR = -Iinclude/ -DVOREUTILS_VERSION='"$(VOREUTILS_VERSION)"' -DVOREUTILS_DATE
BINARIES := $(filter-out cmd/aliases,$(wildcard cmd/*))
LIBRARIES := $(wildcard lib/*)
INCLUDES := $(wildcard include/*)
MANPAGES := $(wildcard man/*.[138])
MANPAGES := $(wildcard man/*.?)


.PHONY : all binaries libraries manpages htmlpages clean test


@@ 128,11 138,11 @@ test : binaries libraries
	@cat $(OBJDIR)testpsko >&2
	@! [ -s $(OBJDIR)testpsko ]

rewrap_mandirs = $(patsubst %.8,man8/%.8,$(patsubst %.7,man7/%.7,$(patsubst %.6,man6/%.6,$(patsubst %.5,man5/%.5,$(patsubst %.4,man4/%.4,$(patsubst %.3,man3/%.3,$(patsubst %.2,man2/%.2,$(patsubst %.1,man1/%.1,$(patsubst man/%,%,$(1))))))))))
rewrap_mandirs = $(patsubst %.8,man8/%.8,$(patsubst %.7,man7/%.7,$(patsubst %.6,man6/%.6,$(patsubst %.5,man5/%.5,$(patsubst %.4,man4/%.4,$(patsubst %.3,man3/%.3,$(patsubst %.2,man2/%.2,$(patsubst %.1,man1/%.1,$(patsubst %.0,man0/%.0,$(patsubst man/%,%,$(1)))))))))))
binaries : $(patsubst %.sh,%,$(patsubst %.cpp,%,$(patsubst cmd/%,$(CMDDIR)%,$(BINARIES)))) $(OBJDIR)aliases
libraries : $(patsubst %.cpp,%$(SO),$(patsubst lib/%,$(LIBDIR)%,$(LIBRARIES)))
manpages : $(patsubst %,$(MANDIR)%,$(call rewrap_mandirs,$(MANPAGES))) $(OBJDIR)man/aliases
htmlpages : $(patsubst %,$(HTMLMANDIR)%.html,$(call rewrap_mandirs,$(MANPAGES))) $(OBJDIR)man/aliases $(HTMLMANDIR)style.css
htmlpages : $(patsubst %,$(HTMLMANDIR)%.html,$(call rewrap_mandirs,$(MANPAGES) index.0)) $(OBJDIR)man/aliases $(HTMLMANDIR)style.css


$(OBJDIR)man/aliases : man/aliases


@@ 166,10 176,20 @@ $(OBJDIR)man/% : man/%
$(foreach l,1 2 3 4 5 6 7 8,$(MANDIR)man$(l)/%) : $(OBJDIR)man/%
	@

$(OBJDIR)manalias/es : man/ man/aliases
	@mkdir -p $(@D)
	cd $(OBJDIR)manalias && rm -f * && touch $(sort $(subst man/,,$(MANPAGES)) $(shell cat man/aliases)) es

$(OBJDIR)man/index.0 : $(MANPAGES)
	{ \
		printf "%s\n" ".Dd $(INDEX_PAGE_DATE)" ".Dt INDEX 0" ".Os voreutils $(VOREUTILS_VERSION)" ".Sh NAME" ".Nm index" ".Nd voreutils $(VOREUTILS_VERSION) manual index" ".Sh CONTENTS" "." '.Bl -tag -compact'; \
		awk '/^\.Nm/ {sub(/\./, " ", FILENAME); sub("man/", ".It Xr ", FILENAME); print FILENAME; print}  /^\.Nd/ {sub(/\.Nd/, "\\-"); print; nextfile}' $(shell printf "%s\n" $(call rewrap_mandirs,$^) | sort -n | cut -c -3,5-); \
		echo .El; \
	} > $@

# mandoc always evaluates n to true and t to false
$(foreach l,1 2 3 4 5 6 7 8,$(HTMLMANDIR)man$(l)/%.html) : $(OBJDIR)man/%
	@mkdir -p $(@D) $(OBJDIR)manalias
	@cd $(OBJDIR)manalias && touch $(sort $(subst man/,,$(MANPAGES)) $(shell cat man/aliases))
$(foreach l,0 1 2 3 4 5 6 7 8,$(HTMLMANDIR)man$(l)/%.html) : $(OBJDIR)man/% $(OBJDIR)manalias/es
	@mkdir -p $(@D)
	printf '.ds doc-%s-font \\f[%s]\n' $(HTMLMAN_FONT_OVERRIDES) | \
		$(SED) -e 's/^\(\.i[ef]\) n/\1 0/' -e '/^\.Sh DESCRIPTION/r /dev/stdin' $< | \
		(cd $(OBJDIR)manalias; $(MANDOC) -Thtml -Ostyle="../style.css",man="../man%S/%N.%S.html;$(HTMLMAN_OUTSIDE_FORMAT)") | \

M README.md => README.md +3 -1
@@ 3,6 3,8 @@ Drop-in Policy-compatible coreutils replacement, at the very least.

This probably wants a better blurb.

## [Manual](//srhtcdn.githack.com/~nabijaczleweli/voreutils/blob/man/man0/index.0.html)

GNU coreutils provide the following 105 binaries, according to `dpkg -L coreutils | grep bin/` on Buster (8.30-3):
  * ☑ /bin/cat – actually faster for raw catting to/from pipes and to/from files, `splice(2)`s and `copy_file_range(2)`s by default
  * ☑ /bin/chgrp


@@ 129,7 131,7 @@ TODO: some sort of consistent uid/gid/pwent/grent caching?
TODO: probably want to generate each locale at most once

## Building
You'll need a non-ancient C++ toolchain, a POSIX AWK, GNU make, mandoc (linting and HTML manuals only, `MANDOC=:` to disable), and shellcheck (for shell wrappers, `SHELLCHECK=:` to disable).
You'll need a non-ancient C++ toolchain, a BSD AWK, GNU make, mandoc (linting and HTML manuals only, `MANDOC=:` to disable), and shellcheck (for shell wrappers, `SHELLCHECK=:` to disable).

`libb2` and `libcrypto` are required (searched with `pkg-config` if available). It'd be just `libcrypto` if the implementation correctly used the result size in EVP_MD.