summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:40:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:40:15 +0000
commit399644e47874bff147afb19c89228901ac39340e (patch)
tree1c4c0b733f4c16b5783b41bebb19194a9ef62ad1 /share
parentInitial commit. (diff)
downloadmanpages-ac8a94b90d5cf454cd6648203aaf1c44d642788f.tar.xz
manpages-ac8a94b90d5cf454cd6648203aaf1c44d642788f.zip
Adding upstream version 6.05.01.upstream/6.05.01
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'share')
-rw-r--r--share/lint/groff/man.ignore.grep3
-rw-r--r--share/lint/mandoc/man.ignore.grep6
-rw-r--r--share/lint/mandoc/mdoc.ignore.grep5
-rw-r--r--share/mk/build/_.mk52
-rw-r--r--share/mk/build/catman.mk89
-rw-r--r--share/mk/build/groff.mk39
-rw-r--r--share/mk/build/html.mk42
-rw-r--r--share/mk/build/pdf.mk68
-rw-r--r--share/mk/build/pre.mk47
-rw-r--r--share/mk/build/ps.mk68
-rw-r--r--share/mk/build/src.mk117
-rw-r--r--share/mk/check/_.mk18
-rw-r--r--share/mk/check/catman.mk51
-rw-r--r--share/mk/cmd.mk40
-rw-r--r--share/mk/compress.mk40
-rw-r--r--share/mk/dist.mk96
-rw-r--r--share/mk/install/_.mk37
-rw-r--r--share/mk/install/html.mk36
-rw-r--r--share/mk/install/man.mk202
-rw-r--r--share/mk/lint/_.mk18
-rw-r--r--share/mk/lint/c.mk102
-rw-r--r--share/mk/lint/man/_.mk16
-rw-r--r--share/mk/lint/man/man.mk69
-rw-r--r--share/mk/lint/man/mdoc.mk44
-rw-r--r--share/mk/src.mk37
-rw-r--r--share/mk/verbose.mk19
-rw-r--r--share/mk/version.mk20
27 files changed, 1381 insertions, 0 deletions
diff --git a/share/lint/groff/man.ignore.grep b/share/lint/groff/man.ignore.grep
new file mode 100644
index 0000000..912eb57
--- /dev/null
+++ b/share/lint/groff/man.ignore.grep
@@ -0,0 +1,3 @@
+style: .TH missing fifth argument and second argument
+style: use of deprecated macro: .PD$
+style: use of deprecated macro: .UC$
diff --git a/share/lint/mandoc/man.ignore.grep b/share/lint/mandoc/man.ignore.grep
new file mode 100644
index 0000000..a2f91bc
--- /dev/null
+++ b/share/lint/mandoc/man.ignore.grep
@@ -0,0 +1,6 @@
+STYLE: lower case character in document title:
+UNSUPP: ignoring macro in table:
+WARNING: cannot parse date, using it verbatim: TH (date)
+WARNING: empty block: UR
+WARNING: missing date, using "": TH
+WARNING: undefined escape, printing literally: \\\\
diff --git a/share/lint/mandoc/mdoc.ignore.grep b/share/lint/mandoc/mdoc.ignore.grep
new file mode 100644
index 0000000..3fe2831
--- /dev/null
+++ b/share/lint/mandoc/mdoc.ignore.grep
@@ -0,0 +1,5 @@
+STYLE: legacy man(7) date format: Dd
+STYLE: lower case character in document title: Dt
+STYLE: operating system explicitly specified: Os
+STYLE: referenced manual not found: Xr
+WARNING: cross reference to self: Xr
diff --git a/share/mk/build/_.mk b/share/mk/build/_.mk
new file mode 100644
index 0000000..bdce760
--- /dev/null
+++ b/share/mk/build/_.mk
@@ -0,0 +1,52 @@
+########################################################################
+# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_BUILD_INCLUDED
+MAKEFILE_BUILD_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/cmd.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+builddir := .tmp
+
+SYSCONFDIR := $(srcdir)/etc
+
+_MANDIR := $(builddir)/man
+
+
+MKDIR := mkdir -p
+RM := rm
+
+
+NONSO_MAN := $(shell $(FIND) $(MANDIR)/* -type f \
+ | $(GREP) '$(MANEXT)' \
+ | $(XARGS) $(GREP) -l '^\.TH ' \
+ | $(SORT) \
+ | $(SED) 's,:,\\:,g')
+NONSO_MDOC := $(shell $(FIND) $(MANDIR)/* -type f \
+ | $(GREP) '$(MANEXT)' \
+ | $(XARGS) $(GREP) -l '^\.Dt ' \
+ | $(SORT) \
+ | $(SED) 's,:,\\:,g')
+
+
+$(builddir)/%/:
+ +$(info MKDIR $@)
+ +$(MKDIR) $@
+
+
+.PHONY: build
+build: build-catman build-html build-pdf build-ps build-src;
+
+.PHONY: clean
+clean:
+ $(info RM -rf $(builddir))
+ $(RM) -rf $(builddir)
+
+
+endif # include guard
diff --git a/share/mk/build/catman.mk b/share/mk/build/catman.mk
new file mode 100644
index 0000000..7b8766e
--- /dev/null
+++ b/share/mk/build/catman.mk
@@ -0,0 +1,89 @@
+########################################################################
+# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_BUILD_CATMAN_INCLUDED
+MAKEFILE_BUILD_CATMAN_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/build/groff.mk
+include $(MAKEFILEDIR)/cmd.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+groff_man_ignore_grep := $(DATAROOTDIR)/lint/groff/man.ignore.grep
+
+MANWIDTH ?= 80
+TROFF_CHECKSTYLE_LVL := 3
+NROFF_LINE_LENGTH := $(shell $(EXPR) $(MANWIDTH) - 2)
+NROFF_OUT_DEVICE := $(shell $(LOCALE) charmap \
+ | $(GREP) -i 'utf-*8' >/dev/null \
+ && $(ECHO) utf8 \
+ || $(ECHO) ascii)
+
+DEFAULT_NROFFFLAGS := \
+ -T$(NROFF_OUT_DEVICE) \
+ -rLL=$(NROFF_LINE_LENGTH)n \
+ -rCHECKSTYLE=$(TROFF_CHECKSTYLE_LVL) \
+ -ww
+EXTRA_NROFFFLAGS :=
+NROFFFLAGS := $(DEFAULT_NROFFFLAGS) $(EXTRA_NROFFFLAGS)
+
+DEFAULT_GROTTYFLAGS := -c
+EXTRA_GROTTYFLAGS :=
+GROTTYFLAGS := $(DEFAULT_GROTTYFLAGS) $(EXTRA_GROTTYFLAGS)
+GROTTY := grotty
+
+
+_CATMAN_troff := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.cat.troff,$(NONSO_MAN) $(NONSO_MDOC))
+_CATMAN_MAN_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.cat.set,$(NONSO_MAN))
+_CATMAN_MDOC_set:= $(patsubst $(MANDIR)/%,$(_MANDIR)/%.cat.set,$(NONSO_MDOC))
+_CATMAN := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.cat,$(NONSO_MAN) $(NONSO_MDOC))
+
+
+$(_CATMAN_troff): %.cat.troff: %.eqn | $$(@D)/
+ $(info EQN $@)
+ ! ($(EQN) -T$(NROFF_OUT_DEVICE) $(EQNFLAGS) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+$(_CATMAN_MAN_set): %.cat.set: %.cat.troff $(groff_man_ignore_grep) | $$(@D)/
+ $(info TROFF $@)
+ ! ($(TROFF) $(TROFFFLAGS_MAN) $(NROFFFLAGS) <$< 2>&1 >$@ \
+ | $(GREP) -v -f '$(groff_man_ignore_grep)' \
+ ||:; \
+ ) \
+ | $(GREP) ^ >&2
+
+$(_CATMAN_MDOC_set): %.cat.set: %.cat.troff | $$(@D)/
+ $(info TROFF $@)
+ ! ($(TROFF) $(TROFFFLAGS_MDOC) $(NROFFFLAGS) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+$(_CATMAN): %.cat: %.cat.set | $$(@D)/
+ $(info GROTTY $@)
+ $(GROTTY) $(GROTTYFLAGS) <$< >$@
+
+
+.PHONY: build-catman-eqn
+build-catman-eqn: $(_CATMAN_troff);
+
+.PHONY: build-catman-troff-man
+build-catman-troff-man: $(_CATMAN_MAN_set);
+
+.PHONY: build-catman-troff-mdoc
+build-catman-troff-mdoc: $(_CATMAN_MDOC_set);
+
+.PHONY: build-catman-troff
+build-catman-troff: build-catman-troff-man build-catman-troff-mdoc;
+
+.PHONY: build-catman-grotty
+build-catman-grotty: $(_CATMAN);
+
+.PHONY: build-catman
+build-catman: build-catman-grotty;
+
+
+endif # include guard
diff --git a/share/mk/build/groff.mk b/share/mk/build/groff.mk
new file mode 100644
index 0000000..2a5a3de
--- /dev/null
+++ b/share/mk/build/groff.mk
@@ -0,0 +1,39 @@
+########################################################################
+# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_BUILD_GROFF_INCLUDED
+MAKEFILE_BUILD_GROFF_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/cmd.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+DEFAULT_EQNFLAGS :=
+EXTRA_EQNFLAGS :=
+EQNFLAGS := $(DEFAULT_EQNFLAGS) $(EXTRA_EQNFLAGS)
+EQN := eqn
+
+DEFAULT_TROFFFLAGS := -wbreak
+EXTRA_TROFFFLAGS :=
+TROFFFLAGS := $(DEFAULT_TROFFFLAGS) $(EXTRA_TROFFFLAGS)
+TROFF := troff
+
+DEFAULT_TROFFFLAGS_MAN := \
+ $(TROFFFLAGS) \
+ -man
+EXTRA_TROFFFLAGS_MAN :=
+TROFFFLAGS_MAN := $(DEFAULT_TROFFFLAGS_MAN) $(EXTRA_TROFFFLAGS_MAN)
+
+DEFAULT_TROFFFLAGS_MDOC := \
+ $(TROFFFLAGS) \
+ -mdoc
+EXTRA_TROFFFLAGS_MDOC :=
+TROFFFLAGS_MDOC := $(DEFAULT_TROFFFLAGS_MDOC) $(EXTRA_TROFFFLAGS_MDOC)
+
+
+endif # include guard
diff --git a/share/mk/build/html.mk b/share/mk/build/html.mk
new file mode 100644
index 0000000..084654d
--- /dev/null
+++ b/share/mk/build/html.mk
@@ -0,0 +1,42 @@
+########################################################################
+# Copyright 2021-2022, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_BUILD_HTML_INCLUDED
+MAKEFILE_BUILD_HTML_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/cmd.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+htmlext := .html
+_HTMLDIR := $(builddir)/html
+
+
+DEFAULT_MAN2HTMLFLAGS :=
+EXTRA_MAN2HTMLFLAGS :=
+MAN2HTMLFLAGS := $(DEFAULT_MAN2HTMLFLAGS) $(EXTRA_MAN2HTMLFLAGS)
+MAN2HTML := man2html
+
+
+_HTMLPAGES := $(patsubst $(MANDIR)/%,$(_HTMLDIR)/%$(htmlext),$(MANPAGES))
+
+
+# Use with
+# make MAN2HTMLFLAGS=whatever html
+# The sed removes the lines "Content-type: text/html\n\n"
+$(_HTMLPAGES): $(_HTMLDIR)/%$(htmlext): $(MANDIR)/% | $$(@D)/
+ $(info MAN2HTML $@)
+ $(MAN2HTML) $(MAN2HTMLFLAGS) $< \
+ | $(SED) -e 1,2d >$@
+
+
+.PHONY: build-html html
+build-html html: $(_HTMLPAGES);
+
+
+endif # include guard
diff --git a/share/mk/build/pdf.mk b/share/mk/build/pdf.mk
new file mode 100644
index 0000000..380c6c6
--- /dev/null
+++ b/share/mk/build/pdf.mk
@@ -0,0 +1,68 @@
+########################################################################
+# Copyright 2023, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_BUILD_PDF_INCLUDED
+MAKEFILE_BUILD_PDF_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/build/groff.mk
+include $(MAKEFILEDIR)/cmd.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+DEFAULT_GROPDFFLAGS :=
+EXTRA_GROPDFFLAGS :=
+GROPDFFLAGS := $(DEFAULT_GROPDFFLAGS) $(EXTRA_GROPDFFLAGS)
+GROPDF := gropdf
+
+
+_PDFMAN_troff := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.pdf.troff,$(NONSO_MAN) $(NONSO_MDOC))
+_PDFMAN_MAN_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.pdf.set,$(NONSO_MAN))
+_PDFMAN_MDOC_set:= $(patsubst $(MANDIR)/%,$(_MANDIR)/%.pdf.set,$(NONSO_MDOC))
+_PDFMAN := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.pdf,$(NONSO_MAN) $(NONSO_MDOC))
+
+
+$(_PDFMAN_troff): %.pdf.troff: %.eqn | $$(@D)/
+ $(info EQN $@)
+ ! ($(EQN) -Tpdf $(EQNFLAGS) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+$(_PDFMAN_MAN_set): %.pdf.set: %.pdf.troff | $$(@D)/
+ $(info TROFF $@)
+ ! ($(TROFF) -Tpdf $(TROFFFLAGS_MAN) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+$(_PDFMAN_MDOC_set): %.pdf.set: %.pdf.troff | $$(@D)/
+ $(info TROFF $@)
+ ! ($(TROFF) -Tpdf $(TROFFFLAGS_MDOC) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+$(_PDFMAN): %.pdf: %.pdf.set | $$(@D)/
+ $(info GROPDF $@)
+ $(GROPDF) $(GROPDFFLAGS) <$< >$@
+
+
+.PHONY: build-pdf-eqn
+build-pdf-eqn: $(_PDFMAN_troff);
+
+.PHONY: build-pdf-troff-man
+build-pdf-troff-man: $(_PDFMAN_MAN_set);
+
+.PHONY: build-pdf-troff-mdoc
+build-pdf-troff-mdoc: $(_PDFMAN_MDOC_set);
+
+.PHONY: build-pdf-troff
+build-pdf-troff: build-pdf-troff-man build-pdf-troff-mdoc;
+
+.PHONY: build-pdf-gropdf
+build-pdf-gropdf: $(_PDFMAN);
+
+.PHONY: build-pdf
+build-pdf: build-pdf-gropdf;
+
+
+endif # include guard
diff --git a/share/mk/build/pre.mk b/share/mk/build/pre.mk
new file mode 100644
index 0000000..4c458fa
--- /dev/null
+++ b/share/mk/build/pre.mk
@@ -0,0 +1,47 @@
+########################################################################
+# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_BUILD_PRE_INCLUDED
+MAKEFILE_BUILD_PRE_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/cmd.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+DEFAULT_PRECONVFLAGS :=
+EXTRA_PRECONVFLAGS :=
+PRECONVFLAGS := $(DEFAULT_PRECONVFLAGS) $(EXTRA_PRECONVFLAGS)
+PRECONV := preconv
+
+TBL := tbl
+
+
+_MAN_tbl := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.tbl,$(NONSO_MAN) $(NONSO_MDOC))
+_MAN_eqn := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.eqn,$(NONSO_MAN) $(NONSO_MDOC))
+
+
+$(_MAN_tbl): $(_MANDIR)/%.tbl: $(MANDIR)/% | $$(@D)/
+ $(info PRECONV $@)
+ $(PRECONV) $(PRECONVFLAGS) $< >$@
+
+$(_MAN_eqn): %.eqn: %.tbl | $$(@D)/
+ $(info TBL $@)
+ $(TBL) <$< >$@
+
+
+.PHONY: build-pre-preconv
+build-pre-preconv: $(_MAN_tbl);
+
+.PHONY: build-pre-tbl
+build-pre-tbl: $(_MAN_eqn);
+
+.PHONY: build-pre
+build-pre: build-pre-tbl;
+
+
+endif # include guard
diff --git a/share/mk/build/ps.mk b/share/mk/build/ps.mk
new file mode 100644
index 0000000..5b29dc1
--- /dev/null
+++ b/share/mk/build/ps.mk
@@ -0,0 +1,68 @@
+########################################################################
+# Copyright 2023, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_BUILD_PS_INCLUDED
+MAKEFILE_BUILD_PS_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/build/groff.mk
+include $(MAKEFILEDIR)/cmd.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+DEFAULT_GROPSFLAGS :=
+EXTRA_GROPSFLAGS :=
+GROPSFLAGS := $(DEFAULT_GROPSFLAGS) $(EXTRA_GROPSFLAGS)
+GROPS := grops
+
+
+_PSMAN_troff := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.ps.troff,$(NONSO_MAN) $(NONSO_MDOC))
+_PSMAN_MAN_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.ps.set,$(NONSO_MAN))
+_PSMAN_MDOC_set:= $(patsubst $(MANDIR)/%,$(_MANDIR)/%.ps.set,$(NONSO_MDOC))
+_PSMAN := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.ps,$(NONSO_MAN) $(NONSO_MDOC))
+
+
+$(_PSMAN_troff): %.ps.troff: %.eqn | $$(@D)/
+ $(info EQN $@)
+ ! ($(EQN) -Tps $(EQNFLAGS) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+$(_PSMAN_MAN_set): %.ps.set: %.ps.troff | $$(@D)/
+ $(info TROFF $@)
+ ! ($(TROFF) -Tps $(TROFFFLAGS_MAN) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+$(_PSMAN_MDOC_set): %.ps.set: %.ps.troff | $$(@D)/
+ $(info TROFF $@)
+ ! ($(TROFF) -Tps $(TROFFFLAGS_MDOC) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+$(_PSMAN): %.ps: %.ps.set | $$(@D)/
+ $(info GROPS $@)
+ $(GROPS) $(GROPSFLAGS) <$< >$@
+
+
+.PHONY: build-ps-eqn
+build-ps-eqn: $(_PSMAN_troff);
+
+.PHONY: build-ps-troff-man
+build-ps-troff-man: $(_PSMAN_MAN_set);
+
+.PHONY: build-ps-troff-mdoc
+build-ps-troff-mdoc: $(_PSMAN_MDOC_set);
+
+.PHONY: build-ps-troff
+build-ps-troff: build-ps-troff-man build-ps-troff-mdoc;
+
+.PHONY: build-ps-grops
+build-ps-grops: $(_PSMAN);
+
+.PHONY: build-ps
+build-ps: build-ps-grops;
+
+
+endif # include guard
diff --git a/share/mk/build/src.mk b/share/mk/build/src.mk
new file mode 100644
index 0000000..365c256
--- /dev/null
+++ b/share/mk/build/src.mk
@@ -0,0 +1,117 @@
+########################################################################
+# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_BUILD_SRC_INCLUDED
+MAKEFILE_BUILD_SRC_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/cmd.mk
+include $(MAKEFILEDIR)/src.mk
+include $(MAKEFILEDIR)/verbose.mk
+
+
+PKGCONF_LIBS := libbsd-overlay
+
+
+DEFAULT_CPPFLAGS := $(shell $(PKGCONF) --cflags $(PKGCONF_LIBS) $(HIDE_ERR))
+EXTRA_CPPFLAGS :=
+CPPFLAGS := $(DEFAULT_CPPFLAGS) $(EXTRA_CPPFLAGS)
+
+DEFAULT_CFLAGS := \
+ -std=gnu17 \
+ -Wall \
+ -Wextra \
+ -Wstrict-prototypes \
+ -Wdeclaration-after-statement \
+ -Werror \
+ -Wno-error=unused-parameter \
+ -Wno-error=sign-compare \
+ -Wno-error=format \
+ -Wno-error=uninitialized
+ #-Wno-error=declaration-after-statement
+EXTRA_CFLAGS :=
+CFLAGS := $(DEFAULT_CFLAGS) $(EXTRA_CFLAGS)
+
+DEFAULT_LDFLAGS := \
+ -Wl,--as-needed \
+ -Wl,--no-allow-shlib-undefined \
+ -Wl,--no-copy-dt-needed-entries \
+ -Wl,--no-undefined \
+ $(shell $(PKGCONF) --libs-only-L $(PKGCONF_LIBS) $(HIDE_ERR)) \
+ $(shell $(PKGCONF) --libs-only-other $(PKGCONF_LIBS) $(HIDE_ERR))
+EXTRA_LDFLAGS :=
+LDFLAGS := $(DEFAULT_LDFLAGS) $(EXTRA_LDFLAGS)
+
+DEFAULT_LDLIBS := \
+ -lc \
+ $(shell $(PKGCONF) --libs-only-l $(PKGCONF_LIBS) $(HIDE_ERR))
+EXTRA_LDLIBS :=
+LDLIBS := $(DEFAULT_LDLIBS) $(EXTRA_LDLIBS)
+
+
+CC := cc
+LD := $(CC) $(CFLAGS)
+
+
+_SRCPAGEDIRS := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.d/,$(NONSO_MAN))
+
+_UNITS_src_src := $(patsubst $(MANDIR)/%,$(_MANDIR)/%,$(shell \
+ $(FIND) $(MANDIR)/* -type f \
+ | $(GREP) '$(MANEXT)' \
+ | $(XARGS) $(GREP) -H '^\.\\" SRC BEGIN ' \
+ | $(SED) 's,:\.\\" SRC BEGIN (,.d/,' \
+ | $(SED) 's/)//' \
+ | $(SORT) \
+ | $(SED) 's,:,\\:,g'))
+_UNITS_src_h := $(filter %.h,$(_UNITS_src_src))
+_UNITS_src_c := $(filter %.c,$(_UNITS_src_src))
+_UNITS_src_o := $(patsubst %.c,%.o,$(_UNITS_src_c))
+_UNITS_src_bin := $(patsubst %.c,%,$(_UNITS_src_c))
+
+
+$(_SRCPAGEDIRS): $(_MANDIR)/%.d/: $(MANDIR)/%
+ +$(info MKDIR $@)
+ +$(MKDIR) $@
+ +touch $@
+
+$(_UNITS_src_src): $$(patsubst $(_MANDIR)/%.d,$(MANDIR)/%,$$(@D)) | $$(@D)/
+$(_UNITS_src_c): $$(filter $$(@D)/%.h,$(_UNITS_src_h))
+$(_UNITS_src_src):
+ $(info SED $@)
+ <$< \
+ $(SED) -n \
+ -e '/^\.TH/,/^\.SH/{/^\.SH/!p}' \
+ -e '/^\.SH EXAMPLES/p' \
+ -e "/^\... SRC BEGIN ($(@F))$$/,/^\... SRC END$$/p" \
+ | $(MANDOC) -Tutf8 \
+ | $(SED) '/^[^ ]/d' \
+ | $(SED) 's/^ //' \
+ >$@
+
+$(_UNITS_src_o): %.o: %.c
+ $(info CC $@)
+ $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
+
+$(_UNITS_src_bin): %: %.o
+ $(info LD $@)
+ $(LD) $(LDFLAGS) -o $@ $< $(LDLIBS)
+
+
+.PHONY: build-src-c
+build-src-c: $(_UNITS_src_c);
+
+.PHONY: build-src-cc
+build-src-cc: $(_UNITS_src_o);
+
+.PHONY: build-src-ld
+build-src-ld: $(_UNITS_src_bin);
+
+.PHONY: build-src
+build-src: build-src-ld
+
+
+endif # include guard
diff --git a/share/mk/check/_.mk b/share/mk/check/_.mk
new file mode 100644
index 0000000..6326d1f
--- /dev/null
+++ b/share/mk/check/_.mk
@@ -0,0 +1,18 @@
+########################################################################
+# Copyright 2023, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_CHECK_INCLUDED
+MAKEFILE_CHECK_INCLUDED := 1
+
+
+check := check-catman
+
+
+.PHONY: check
+check: $(check);
+
+
+endif # include guard
diff --git a/share/mk/check/catman.mk b/share/mk/check/catman.mk
new file mode 100644
index 0000000..8a0d3b6
--- /dev/null
+++ b/share/mk/check/catman.mk
@@ -0,0 +1,51 @@
+########################################################################
+# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_CHECK_CATMAN_INCLUDED
+MAKEFILE_CHECK_CATMAN_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/cmd.mk
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/build/catman.mk
+include $(MAKEFILEDIR)/check/_.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+DEFAULT_COLFLAGS := \
+ -b \
+ -p \
+ -x
+EXTRA_COLFLAGS :=
+COLFLAGS := $(DEFAULT_COLFLAGS) $(EXTRA_COLFLAGS)
+COL := col
+
+
+_CHECK_catman_grep := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.cat.grep,$(NONSO_MAN) $(NONSO_MDOC))
+_CHECK_catman := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.check-catman.touch,$(NONSO_MAN) $(NONSO_MDOC))
+
+
+$(_CHECK_catman_grep): %.grep: % | $$(@D)/
+ $(info COL $@)
+ $(COL) $(COLFLAGS) <$< >$@
+
+$(_CHECK_catman): %.check-catman.touch: %.cat.grep | $$(@D)/
+ $(info GREP $@)
+ ! $(GREP) -n '.\{$(MANWIDTH)\}.' $< /dev/null >&2
+ touch $@
+
+
+.PHONY: check-catman-col
+check-catman-col: $(_CHECK_catman_grep);
+
+.PHONY: check-catman-grep
+check-catman-grep: $(_CHECK_catman);
+
+.PHONY: check-catman
+check-catman: check-catman-grep;
+
+
+endif # include guard
diff --git a/share/mk/cmd.mk b/share/mk/cmd.mk
new file mode 100644
index 0000000..aa7c07c
--- /dev/null
+++ b/share/mk/cmd.mk
@@ -0,0 +1,40 @@
+########################################################################
+# Copyright 2022, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_CMD_INCLUDED
+MAKEFILE_CMD_INCLUDED := 1
+
+
+BZIP2 := bzip2
+CP := cp
+ECHO := echo
+EXPR := expr
+FIND := find
+GIT := git
+GREP := grep
+GZIP := gzip
+HEAD := head
+INSTALL := install
+LN := ln
+LOCALE := locale
+LZIP := lzip
+MANDOC := mandoc
+PKGCONF := pkgconf
+SED := sed
+SORT := sort
+SPONGE := sponge
+TAC := tac
+TAIL := tail
+TAR := tar
+TEST := test
+XARGS := xargs
+XZ := xz
+
+INSTALL_DATA := $(INSTALL) -m 644
+INSTALL_DIR := $(INSTALL) -m 755 -d
+
+
+endif # include guard
diff --git a/share/mk/compress.mk b/share/mk/compress.mk
new file mode 100644
index 0000000..6502930
--- /dev/null
+++ b/share/mk/compress.mk
@@ -0,0 +1,40 @@
+########################################################################
+# Copyright 2023 Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_COMPRESS_INCLUDED
+MAKEFILE_COMPRESS_INCLUDED := 1
+
+
+Z :=
+ifeq ($(Z),)
+else ifeq ($(Z),.bz2)
+else ifeq ($(Z),.gz)
+else ifeq ($(Z),.lz)
+else ifeq ($(Z),.xz)
+else
+$(warning "Z": "$(Z)")
+$(error Valid values for "Z": ["", ".bz2", ".gz", ".lz", ".xz"])
+endif
+
+
+DEFAULT_BZIP2FLAGS :=
+EXTRA_BZIP2FLAGS :=
+BZIP2FLAGS := $(DEFAULT_BZIP2FLAGS) $(EXTRA_BZIP2FLAGS)
+
+DEFAULT_GZIPFLAGS :=
+EXTRA_GZIPFLAGS :=
+GZIPFLAGS := $(DEFAULT_GZIPFLAGS) $(EXTRA_GZIPFLAGS)
+
+DEFAULT_LZIPFLAGS :=
+EXTRA_LZIPFLAGS :=
+LZIPFLAGS := $(DEFAULT_LZIPFLAGS) $(EXTRA_LZIPFLAGS)
+
+DEFAULT_XZFLAGS :=
+EXTRA_XZFLAGS :=
+XZFLAGS := $(DEFAULT_XZFLAGS) $(EXTRA_XZFLAGS)
+
+
+endif # include guard
diff --git a/share/mk/dist.mk b/share/mk/dist.mk
new file mode 100644
index 0000000..b18197d
--- /dev/null
+++ b/share/mk/dist.mk
@@ -0,0 +1,96 @@
+########################################################################
+# Copyright 2021-2022, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_DIST_INCLUDED
+MAKEFILE_DIST_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/cmd.mk
+include $(MAKEFILEDIR)/compress.mk
+include $(MAKEFILEDIR)/install/_.mk
+include $(MAKEFILEDIR)/version.mk
+include $(MAKEFILEDIR)/verbose.mk
+
+
+_DISTDIR := $(builddir)/dist
+
+
+DEFAULT_TARFLAGS := \
+ --sort=name \
+ --owner=root:0 \
+ --group=root:0 \
+ --mtime='$(DISTDATE)'
+EXTRA_TARFLAGS :=
+TARFLAGS := $(DEFAULT_TARFLAGS) $(EXTRA_TARFLAGS)
+
+
+DISTFILES := $(shell $(GIT) ls-files $(HIDE_ERR) \
+ | $(SED) 's,^,$(srcdir)/,' \
+ | $(SED) 's,:,\\:,g')
+_DISTFILES := $(patsubst $(srcdir)/%,$(_DISTDIR)/%,$(DISTFILES))
+_DISTPAGES := $(filter $(_DISTDIR)/man%,$(_DISTFILES))
+_DISTOTHERS := $(filter-out $(_DISTDIR)/man%,$(_DISTFILES))
+
+DISTFILE := $(builddir)/$(DISTNAME).tar
+compression := bz2 gz lz xz
+dist := $(foreach x,$(compression),dist-$(x))
+
+
+$(builddir)/dist/%/:
+ +$(info INSTALL $@)
+ +$(INSTALL_DIR) $@
+
+
+$(_DISTPAGES): $(_DISTDIR)/man%: $(srcdir)/man% | $$(@D)/
+ $(info INSTALL $@)
+ $(INSTALL_DATA) -T $< $@
+ $(SED) -i '/^.TH/s/(unreleased)/$(DISTVERSION)/' $@
+ $(SED) -i "/^.TH/s/(date)/$$(git log --format=%cs -1 -- $< $(HIDE_ERR))/" $@
+
+$(_DISTOTHERS): $(_DISTDIR)/%: $(srcdir)/% | $$(@D)/
+ $(info CP $@)
+ $(CP) -T $< $@
+
+
+$(DISTFILE): $(_DISTFILES) | $$(@D)/
+ $(info TAR $@)
+ $(TAR) $(TARFLAGS) -cf $@ -T /dev/null
+ $(GIT) ls-files \
+ | $(SED) 's,^,$(_DISTDIR)/,' \
+ | $(XARGS) $(TAR) $(TARFLAGS) -rf $@ -C $(srcdir) \
+ --transform 's,^$(_DISTDIR),$(DISTNAME),'
+
+$(DISTFILE).bz2: %.bz2: % | $$(@D)/
+ $(info BZIP2 $@)
+ $(BZIP2) $(BZIP2FLAGS) -kf $<
+ touch $@
+
+$(DISTFILE).gz: %.gz: % | $$(@D)/
+ $(info GZIP $@)
+ $(GZIP) $(GZIPFLAGS) -knf $<
+
+$(DISTFILE).lz: %.lz: % | $$(@D)/
+ $(info LZIP $@)
+ $(LZIP) $(LZIPFLAGS) -kf $<
+ touch $@
+
+$(DISTFILE).xz: %.xz: % | $$(@D)/
+ $(info XZ $@)
+ $(XZ) $(XZFLAGS) -kf $<
+
+
+.PHONY: dist-tar
+dist-tar: $(DISTFILE);
+
+.PHONY: $(dist)
+$(dist): dist-%: $(DISTFILE).%;
+
+.PHONY: dist
+dist: $(dist);
+
+
+endif # include guard
diff --git a/share/mk/install/_.mk b/share/mk/install/_.mk
new file mode 100644
index 0000000..751ab97
--- /dev/null
+++ b/share/mk/install/_.mk
@@ -0,0 +1,37 @@
+########################################################################
+# Copyright 2021-2022, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_INSTALL_INCLUDED
+MAKEFILE_INSTALL_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/cmd.mk
+
+
+DESTDIR :=
+prefix := /usr/local
+
+datarootdir := $(prefix)/share
+docdir := $(datarootdir)/doc
+
+
+$(DESTDIR)%/:
+ +$(info INSTALL $@)
+ +$(INSTALL_DIR) $@
+
+%-rm:
+ $(info RM $*)
+ $(RM) $*
+
+
+.PHONY: install
+install: install-man;
+
+.PHONY: uninstall
+uninstall: uninstall-man;
+
+
+endif # include guard
diff --git a/share/mk/install/html.mk b/share/mk/install/html.mk
new file mode 100644
index 0000000..97e00ce
--- /dev/null
+++ b/share/mk/install/html.mk
@@ -0,0 +1,36 @@
+########################################################################
+# Copyright 2021-2022, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_INSTALL_HTML_INCLUDED
+MAKEFILE_INSTALL_HTML_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/html.mk
+include $(MAKEFILEDIR)/install/_.mk
+
+
+htmldir := $(docdir)
+htmldir_ := $(htmldir)/man
+_htmldir := $(DESTDIR)$(htmldir_)
+
+
+_htmlpages := $(patsubst $(_HTMLDIR)/%,$(_htmldir)/%,$(_HTMLPAGES))
+_htmlpages_rm := $(addsuffix -rm,$(wildcard $(_htmlpages)))
+
+
+$(_htmlpages): $(_htmldir)/%: $(_HTMLDIR)/% | $$(@D)/
+ $(info INSTALL $@)
+ $(INSTALL_DATA) -T $< $@
+
+
+.PHONY: install-html
+install-html: $(_htmlpages);
+
+.PHONY: uninstall-html
+uninstall-html: $(_htmlpages_rm);
+
+
+endif # include guard
diff --git a/share/mk/install/man.mk b/share/mk/install/man.mk
new file mode 100644
index 0000000..a135788
--- /dev/null
+++ b/share/mk/install/man.mk
@@ -0,0 +1,202 @@
+########################################################################
+# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_INSTALL_MAN_INCLUDED
+MAKEFILE_INSTALL_MAN_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/cmd.mk
+include $(MAKEFILEDIR)/compress.mk
+include $(MAKEFILEDIR)/install/_.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+LINK_PAGES := .so
+ifeq ($(LINK_PAGES),.so)
+else ifeq ($(LINK_PAGES),symlink)
+else
+$(warning "LINK_PAGES": "$(LINK_PAGES)")
+$(error Valid values for "LINK_PAGES": [".so", "symlink"])
+endif
+
+
+mandir := $(datarootdir)/man
+man1dir := $(mandir)/man1
+man2dir := $(mandir)/man2
+man2typedir := $(mandir)/man2type
+man3dir := $(mandir)/man3
+man3constdir:= $(mandir)/man3const
+man3headdir := $(mandir)/man3head
+man3typedir := $(mandir)/man3type
+man4dir := $(mandir)/man4
+man5dir := $(mandir)/man5
+man6dir := $(mandir)/man6
+man7dir := $(mandir)/man7
+man8dir := $(mandir)/man8
+man1ext := .1$(Z)
+man2ext := .2$(Z)
+man2typeext := .2type$(Z)
+man3ext := .3$(Z)
+man3constext:= .3const$(Z)
+man3headext := .3head$(Z)
+man3typeext := .3type$(Z)
+man4ext := .4$(Z)
+man5ext := .5$(Z)
+man6ext := .6$(Z)
+man7ext := .7$(Z)
+man8ext := .8$(Z)
+
+
+_mandir := $(DESTDIR)$(mandir)
+_man1dir := $(DESTDIR)$(man1dir)
+_man2dir := $(DESTDIR)$(man2dir)
+_man2typedir := $(DESTDIR)$(man2typedir)
+_man3dir := $(DESTDIR)$(man3dir)
+_man3constdir := $(DESTDIR)$(man3constdir)
+_man3headdir := $(DESTDIR)$(man3headdir)
+_man3typedir := $(DESTDIR)$(man3typedir)
+_man4dir := $(DESTDIR)$(man4dir)
+_man5dir := $(DESTDIR)$(man5dir)
+_man6dir := $(DESTDIR)$(man6dir)
+_man7dir := $(DESTDIR)$(man7dir)
+_man8dir := $(DESTDIR)$(man8dir)
+
+_man1pages := $(patsubst $(MANDIR)/man1/%,$(_man1dir)/%$(Z),$(MAN1PAGES))
+_man2pages := $(patsubst $(MANDIR)/man2/%,$(_man2dir)/%$(Z),$(MAN2PAGES))
+_man2typepages := $(patsubst $(MANDIR)/man2type/%,$(_man2typedir)/%$(Z),$(MAN2TYPEPAGES))
+_man3pages := $(patsubst $(MANDIR)/man3/%,$(_man3dir)/%$(Z),$(MAN3PAGES))
+_man3constpages := $(patsubst $(MANDIR)/man3const/%,$(_man3constdir)/%$(Z),$(MAN3CONSTPAGES))
+_man3headpages := $(patsubst $(MANDIR)/man3head/%,$(_man3headdir)/%$(Z),$(MAN3HEADPAGES))
+_man3typepages := $(patsubst $(MANDIR)/man3type/%,$(_man3typedir)/%$(Z),$(MAN3TYPEPAGES))
+_man4pages := $(patsubst $(MANDIR)/man4/%,$(_man4dir)/%$(Z),$(MAN4PAGES))
+_man5pages := $(patsubst $(MANDIR)/man5/%,$(_man5dir)/%$(Z),$(MAN5PAGES))
+_man6pages := $(patsubst $(MANDIR)/man6/%,$(_man6dir)/%$(Z),$(MAN6PAGES))
+_man7pages := $(patsubst $(MANDIR)/man7/%,$(_man7dir)/%$(Z),$(MAN7PAGES))
+_man8pages := $(patsubst $(MANDIR)/man8/%,$(_man8dir)/%$(Z),$(MAN8PAGES))
+_manpages := $(_man1pages) \
+ $(_man2pages) $(_man2typepages) \
+ $(_man3pages) $(_man3constpages) $(_man3headpages) $(_man3typepages) \
+ $(_man4pages) \
+ $(_man5pages) \
+ $(_man6pages) \
+ $(_man7pages) \
+ $(_man8pages)
+
+_man1pages_rm := $(addsuffix -rm,$(wildcard $(_man1pages)))
+_man2pages_rm := $(addsuffix -rm,$(wildcard $(_man2pages)))
+_man2typepages_rm := $(addsuffix -rm,$(wildcard $(_man2typepages)))
+_man3pages_rm := $(addsuffix -rm,$(wildcard $(_man3pages)))
+_man3constpages_rm:= $(addsuffix -rm,$(wildcard $(_man3constpages)))
+_man3headpages_rm := $(addsuffix -rm,$(wildcard $(_man3headpages)))
+_man3typepages_rm := $(addsuffix -rm,$(wildcard $(_man3typepages)))
+_man4pages_rm := $(addsuffix -rm,$(wildcard $(_man4pages)))
+_man5pages_rm := $(addsuffix -rm,$(wildcard $(_man5pages)))
+_man6pages_rm := $(addsuffix -rm,$(wildcard $(_man6pages)))
+_man7pages_rm := $(addsuffix -rm,$(wildcard $(_man7pages)))
+_man8pages_rm := $(addsuffix -rm,$(wildcard $(_man8pages)))
+
+MAN_SECTIONS := 1 2 2type 3 3const 3head 3type 4 5 6 7 8
+install_manX := $(foreach x,$(MAN_SECTIONS),install-man$(x))
+uninstall_manX := $(foreach x,$(MAN_SECTIONS),uninstall-man$(x))
+
+
+$(_man1pages): $(_man1dir)/%$(Z): $(MANDIR)/man1/% | $$(@D)/
+$(_man2pages): $(_man2dir)/%$(Z): $(MANDIR)/man2/% | $$(@D)/
+$(_man2typepages): $(_man2typedir)/%$(Z): $(MANDIR)/man2type/% | $$(@D)/
+$(_man3pages): $(_man3dir)/%$(Z): $(MANDIR)/man3/% | $$(@D)/
+$(_man3constpages): $(_man3constdir)/%$(Z): $(MANDIR)/man3const/% | $$(@D)/
+$(_man3headpages): $(_man3headdir)/%$(Z): $(MANDIR)/man3head/% | $$(@D)/
+$(_man3typepages): $(_man3typedir)/%$(Z): $(MANDIR)/man3type/% | $$(@D)/
+$(_man4pages): $(_man4dir)/%$(Z): $(MANDIR)/man4/% | $$(@D)/
+$(_man5pages): $(_man5dir)/%$(Z): $(MANDIR)/man5/% | $$(@D)/
+$(_man6pages): $(_man6dir)/%$(Z): $(MANDIR)/man6/% | $$(@D)/
+$(_man7pages): $(_man7dir)/%$(Z): $(MANDIR)/man7/% | $$(@D)/
+$(_man8pages): $(_man8dir)/%$(Z): $(MANDIR)/man8/% | $$(@D)/
+
+
+$(_manpages):
+ $(info INSTALL $@)
+ $(INSTALL_DATA) -T $< $@
+ $(SED) -i \
+ -e '/^\.so /s, man1/\(.*\)\.1$$, $(notdir $(man1dir))/\1$(man1ext),' \
+ -e '/^\.so /s, man2/\(.*\)\.2$$, $(notdir $(man2dir))/\1$(man2ext),' \
+ -e '/^\.so /s, man2type/\(.*\)\.2type$$, $(notdir $(man2typedir))/\1$(man2typeext),' \
+ -e '/^\.so /s, man3/\(.*\)\.3$$, $(notdir $(man3dir))/\1$(man3ext),' \
+ -e '/^\.so /s, man3const/\(.*\)\.3const$$, $(notdir $(man3constdir))/\1$(man3constext),' \
+ -e '/^\.so /s, man3head/\(.*\)\.3head$$, $(notdir $(man3headdir))/\1$(man3headext),' \
+ -e '/^\.so /s, man3type/\(.*\)\.3type$$, $(notdir $(man3typedir))/\1$(man3typeext),' \
+ -e '/^\.so /s, man4/\(.*\)\.4$$, $(notdir $(man4dir))/\1$(man4ext),' \
+ -e '/^\.so /s, man5/\(.*\)\.5$$, $(notdir $(man5dir))/\1$(man5ext),' \
+ -e '/^\.so /s, man6/\(.*\)\.6$$, $(notdir $(man6dir))/\1$(man6ext),' \
+ -e '/^\.so /s, man7/\(.*\)\.7$$, $(notdir $(man7dir))/\1$(man7ext),' \
+ -e '/^\.so /s, man8/\(.*\)\.8$$, $(notdir $(man8dir))/\1$(man8ext),' \
+ $@
+ifeq ($(LINK_PAGES),symlink)
+ if $(GREP) '^\.so ' <$@ >/dev/null; then \
+ $(GREP) '^\.so ' <$@ \
+ | $(SED) 's,^\.so \(.*\),../\1,' \
+ | $(XARGS) -I tgt $(LN) -fsT tgt $@; \
+ fi
+endif
+ifeq ($(Z),.bz2)
+ if ! $(TEST) -L $@; then \
+ $(BZIP2) $(BZIP2FLAGS) <$@ \
+ | $(SPONGE) $@; \
+ fi
+else ifeq ($(Z),.gz)
+ if ! $(TEST) -L $@; then \
+ $(GZIP) $(GZIPFLAGS) - <$@ \
+ | $(SPONGE) $@; \
+ fi
+else ifeq ($(Z),.lz)
+ if ! $(TEST) -L $@; then \
+ $(LZIP) $(LZIPFLAGS) - <$@ \
+ | $(SPONGE) $@; \
+ fi
+else ifeq ($(Z),.xz)
+ if ! $(TEST) -L $@; then \
+ $(XZ) $(XZFLAGS) - <$@ \
+ | $(SPONGE) $@; \
+ fi
+endif
+
+
+.PHONY: install-man1
+install-man1: $(_man1pages);
+.PHONY: install-man2
+install-man2: $(_man2pages);
+.PHONY: install-man2type
+install-man2type: $(_man2typepages);
+.PHONY: install-man3
+install-man3: $(_man3pages);
+.PHONY: install-man3const
+install-man3const: $(_man3constpages);
+.PHONY: install-man3head
+install-man3head: $(_man3headpages);
+.PHONY: install-man3type
+install-man3type: $(_man3typepages);
+.PHONY: install-man4
+install-man4: $(_man4pages);
+.PHONY: install-man5
+install-man5: $(_man5pages);
+.PHONY: install-man6
+install-man6: $(_man6pages);
+.PHONY: install-man7
+install-man7: $(_man7pages);
+.PHONY: install-man8
+install-man8: $(_man8pages);
+
+.PHONY: install-man
+install-man: $(install_manX);
+
+.PHONY: $(uninstall_manX)
+$(uninstall_manX): uninstall-man%: $$(_man%pages_rm);
+
+.PHONY: uninstall-man
+uninstall-man: $(uninstall_manX);
+
+
+endif # include guard
diff --git a/share/mk/lint/_.mk b/share/mk/lint/_.mk
new file mode 100644
index 0000000..9d93bd3
--- /dev/null
+++ b/share/mk/lint/_.mk
@@ -0,0 +1,18 @@
+########################################################################
+# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_LINT_INCLUDED
+MAKEFILE_LINT_INCLUDED := 1
+
+
+lint := lint-c lint-man lint-mdoc
+
+
+.PHONY: lint
+lint: $(lint);
+
+
+endif # include guard
diff --git a/share/mk/lint/c.mk b/share/mk/lint/c.mk
new file mode 100644
index 0000000..b7d80a9
--- /dev/null
+++ b/share/mk/lint/c.mk
@@ -0,0 +1,102 @@
+########################################################################
+# Copyright 2021-2022, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_LINT_C_INCLUDED
+MAKEFILE_LINT_C_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/src.mk
+include $(MAKEFILEDIR)/cmd.mk
+include $(MAKEFILEDIR)/lint/_.mk
+
+
+DEFAULT_CHECKPATCHFLAGS :=
+EXTRA_CHECKPATCHFLAGS :=
+CHECKPATCHFLAGS := $(DEFAULT_CHECKPATCHFLAGS) $(EXTRA_CHECKPATCHFLAGS)
+CHECKPATCH := checkpatch
+
+clang-tidy_config := $(SYSCONFDIR)/clang-tidy/config.yaml
+DEFAULT_CLANG-TIDYFLAGS := \
+ --config-file=$(clang-tidy_config) \
+ --quiet \
+ --use-color
+EXTRA_CLANG-TIDYFLAGS :=
+CLANG-TIDYFLAGS := $(DEFAULT_CLANG-TIDYFLAGS) $(EXTRA_CLANG-TIDYFLAGS)
+CLANG-TIDY := clang-tidy
+
+CPPCHECK_SUPPRESS := $(SYSCONFDIR)/cppcheck/cppcheck.suppress
+DEFAULT_CPPCHECKFLAGS := \
+ --enable=all \
+ --error-exitcode=2 \
+ --inconclusive \
+ --quiet \
+ --suppressions-list=$(CPPCHECK_SUPPRESS)
+EXTRA_CPPCHECKFLAGS :=
+CPPCHECKFLAGS := $(DEFAULT_CPPCHECKFLAGS) $(EXTRA_CPPCHECKFLAGS)
+CPPCHECK := cppcheck
+
+DEFAULT_CPPLINTFLAGS :=
+EXTRA_CPPLINTFLAGS :=
+CPPLINTFLAGS := $(DEFAULT_CPPLINTFLAGS) $(EXTRA_CPPLINTFLAGS)
+CPPLINT := cpplint
+
+DEFAULT_IWYUFLAGS := \
+ -Xiwyu --no_fwd_decls \
+ -Xiwyu --error
+EXTRA_IWYUFLAGS :=
+IWYUFLAGS := $(DEFAULT_IWYUFLAGS) $(EXTRA_IWYUFLAGS)
+IWYU := iwyu
+
+
+_LINT_c_checkpatch := $(patsubst %.c,%.lint-c.checkpatch.touch,$(_UNITS_src_c))
+_LINT_c_clang-tidy := $(patsubst %.c,%.lint-c.clang-tidy.touch,$(_UNITS_src_c))
+_LINT_c_cppcheck := $(patsubst %.c,%.lint-c.cppcheck.touch,$(_UNITS_src_c))
+_LINT_c_cpplint := $(patsubst %.c,%.lint-c.cpplint.touch,$(_UNITS_src_c))
+_LINT_c_iwyu := $(patsubst %.c,%.lint-c.iwyu.touch,$(_UNITS_src_c))
+
+
+linters_c := checkpatch clang-tidy cppcheck cpplint iwyu
+lint_c := $(foreach x,$(linters_c),lint-c-$(x))
+
+
+$(_LINT_c_checkpatch): %.lint-c.checkpatch.touch: %.c
+ $(info LINT (checkpatch) $@)
+ $(CHECKPATCH) $(CHECKPATCHFLAGS) -f $<
+ touch $@
+
+$(_LINT_c_clang-tidy): %.lint-c.clang-tidy.touch: %.c
+ $(info LINT (clang-tidy) $@)
+ $(CLANG-TIDY) $(CLANG-TIDYFLAGS) $< -- $(CPPFLAGS) $(CFLAGS) 2>&1 \
+ | $(SED) '/generated\.$$/d'
+ touch $@
+
+$(_LINT_c_cppcheck): %.lint-c.cppcheck.touch: %.c
+ $(info LINT (cppcheck) $@)
+ $(CPPCHECK) $(CPPCHECKFLAGS) $<
+ touch $@
+
+$(_LINT_c_cpplint): %.lint-c.cpplint.touch: %.c
+ $(info LINT (cpplint) $@)
+ $(CPPLINT) $(CPPLINTFLAGS) $< >/dev/null
+ touch $@
+
+$(_LINT_c_iwyu): %.lint-c.iwyu.touch: %.c
+ $(info LINT (iwyu) $@)
+ $(IWYU) $(IWYUFLAGS) $(CPPFLAGS) $(CFLAGS) $< 2>&1 \
+ | $(TAC) \
+ | $(SED) '/correct/{N;d}' \
+ | $(TAC)
+ touch $@
+
+
+.PHONY: $(lint_c)
+$(lint_c): lint-c-%: $$(_LINT_c_%);
+
+.PHONY: lint-c
+lint-c: $(lint_c);
+
+
+endif # include guard
diff --git a/share/mk/lint/man/_.mk b/share/mk/lint/man/_.mk
new file mode 100644
index 0000000..8bbc01c
--- /dev/null
+++ b/share/mk/lint/man/_.mk
@@ -0,0 +1,16 @@
+########################################################################
+# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_LINT_MAN_INCLUDED
+MAKEFILE_LINT_MAN_INCLUDED := 1
+
+
+DEFAULT_MANDOCFLAGS := -Tlint
+EXTRA_MANDOCFLAGS :=
+MANDOCFLAGS := $(DEFAULT_MANDOCFLAGS) $(EXTRA_MANDOCFLAGS)
+
+
+endif # include guard
diff --git a/share/mk/lint/man/man.mk b/share/mk/lint/man/man.mk
new file mode 100644
index 0000000..cb1bf53
--- /dev/null
+++ b/share/mk/lint/man/man.mk
@@ -0,0 +1,69 @@
+########################################################################
+# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_LINT_MAN_MAN_INCLUDED
+MAKEFILE_LINT_MAN_MAN_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/cmd.mk
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/lint/_.mk
+include $(MAKEFILEDIR)/lint/man/_.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+mandoc_man_ignore_grep := $(DATAROOTDIR)/lint/mandoc/man.ignore.grep
+
+_LINT_man_mandoc :=$(patsubst $(MANDIR)/%,$(_MANDIR)/%.lint-man.mandoc.touch,$(NONSO_MAN))
+_LINT_man_tbl :=$(patsubst $(MANDIR)/%,$(_MANDIR)/%.lint-man.tbl.touch,$(NONSO_MAN))
+
+
+linters_man := mandoc tbl
+lint_man := $(foreach x,$(linters_man),lint-man-$(x))
+
+
+$(_LINT_man_mandoc): $(_MANDIR)/%.lint-man.mandoc.touch: $(MANDIR)/% $(mandoc_man_ignore_grep) | $$(@D)/
+ $(info LINT (mandoc) $@)
+ ! ($(MANDOC) -man $(MANDOCFLAGS) $< 2>&1 \
+ | $(GREP) -v -f '$(mandoc_man_ignore_grep)' \
+ ||:; \
+ ) \
+ | $(GREP) ^ >&2
+ touch $@
+
+$(_LINT_man_tbl): $(_MANDIR)/%.lint-man.tbl.touch: $(MANDIR)/% | $$(@D)/
+ $(info LINT (tbl comment) $@)
+ if $(GREP) -q '^\.TS$$' $< && ! $(HEAD) -n1 $< | $(GREP) -q '\\" t$$'; \
+ then \
+ >&2 $(ECHO) "$<:1: missing '\\\" t' comment:"; \
+ >&2 $(HEAD) -n1 <$<; \
+ exit 1; \
+ fi
+ if $(HEAD) -n1 $< | $(GREP) -q '\\" t$$' && ! $(GREP) -q '^\.TS$$' $<; \
+ then \
+ >&2 $(ECHO) "$<:1: spurious '\\\" t' comment:"; \
+ >&2 $(HEAD) -n1 <$<; \
+ exit 1; \
+ fi
+ if $(TAIL) -n+2 <$< | $(GREP) -q '\\" t$$'; \
+ then \
+ >&2 $(ECHO) "$<: spurious '\\\" t' not in first line:"; \
+ >&2 $(GREP) -n '\\" t$$' $< /dev/null; \
+ exit 1; \
+ fi
+ touch $@
+
+
+.PHONY: lint-man-mandoc
+lint-man-mandoc: $(_LINT_man_mandoc);
+.PHONY: lint-man-tbl
+lint-man-tbl: $(_LINT_man_tbl);
+
+.PHONY: lint-man
+lint-man: $(lint_man);
+
+
+endif # include guard
diff --git a/share/mk/lint/man/mdoc.mk b/share/mk/lint/man/mdoc.mk
new file mode 100644
index 0000000..9b5f5b4
--- /dev/null
+++ b/share/mk/lint/man/mdoc.mk
@@ -0,0 +1,44 @@
+########################################################################
+# Copyright 2023, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_LINT_MAN_MDOC_INCLUDED
+MAKEFILE_LINT_MAN_MDOC_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/cmd.mk
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/lint/_.mk
+include $(MAKEFILEDIR)/lint/man/_.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+mandoc_mdoc_ignore_grep := $(DATAROOTDIR)/lint/mandoc/mdoc.ignore.grep
+
+_LINT_mdoc_mandoc:=$(patsubst $(MANDIR)/%,$(_MANDIR)/%.lint-mdoc.mandoc.touch,$(NONSO_MDOC))
+
+
+linters_mdoc := mandoc
+lint_mdoc := $(foreach x,$(linters_mdoc),lint-mdoc-$(x))
+
+
+$(_LINT_mdoc_mandoc): $(_MANDIR)/%.lint-mdoc.mandoc.touch: $(MANDIR)/% $(mandoc_mdoc_ignore_grep) | $$(@D)/
+ $(info LINT (mandoc) $@)
+ ! ($(MANDOC) -mdoc $(MANDOCFLAGS) $< 2>&1 \
+ | $(GREP) -v -f '$(mandoc_mdoc_ignore_grep)' \
+ ||:; \
+ ) \
+ | $(GREP) ^ >&2
+ touch $@
+
+
+.PHONY: $(lint_mdoc)
+$(lint_mdoc): lint-mdoc-%: $$(_LINT_mdoc_%);
+
+.PHONY: lint-mdoc
+lint-mdoc: $(lint_mdoc);
+
+
+endif # include guard
diff --git a/share/mk/src.mk b/share/mk/src.mk
new file mode 100644
index 0000000..65825b5
--- /dev/null
+++ b/share/mk/src.mk
@@ -0,0 +1,37 @@
+########################################################################
+# Copyright 2021-2022, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_SRC_INCLUDED
+MAKEFILE_SRC_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/cmd.mk
+
+
+MANDIR := $(srcdir)
+MANEXT := \.[0-9]\w*\(\.man\)\?\(\.in\)\?$
+
+
+MANPAGES := $(shell $(FIND) $(MANDIR)/* -type f \
+ | $(GREP) '$(MANEXT)' \
+ | $(SORT) \
+ | $(SED) 's,:,\\:,g')
+
+MAN1PAGES := $(filter $(MANDIR)/man1/%,$(filter %.1,$(MANPAGES)))
+MAN2PAGES := $(filter $(MANDIR)/man2/%,$(filter %.2,$(MANPAGES)))
+MAN2TYPEPAGES := $(filter $(MANDIR)/man2type/%,$(filter %.2type,$(MANPAGES)))
+MAN3PAGES := $(filter $(MANDIR)/man3/%,$(filter %.3,$(MANPAGES)))
+MAN3CONSTPAGES := $(filter $(MANDIR)/man3const/%,$(filter %.3const,$(MANPAGES)))
+MAN3HEADPAGES := $(filter $(MANDIR)/man3head/%,$(filter %.3head,$(MANPAGES)))
+MAN3TYPEPAGES := $(filter $(MANDIR)/man3type/%,$(filter %.3type,$(MANPAGES)))
+MAN4PAGES := $(filter $(MANDIR)/man4/%,$(filter %.4,$(MANPAGES)))
+MAN5PAGES := $(filter $(MANDIR)/man5/%,$(filter %.5,$(MANPAGES)))
+MAN6PAGES := $(filter $(MANDIR)/man6/%,$(filter %.6,$(MANPAGES)))
+MAN7PAGES := $(filter $(MANDIR)/man7/%,$(filter %.7,$(MANPAGES)))
+MAN8PAGES := $(filter $(MANDIR)/man8/%,$(filter %.8,$(MANPAGES)))
+
+
+endif # include guard
diff --git a/share/mk/verbose.mk b/share/mk/verbose.mk
new file mode 100644
index 0000000..2cc4450
--- /dev/null
+++ b/share/mk/verbose.mk
@@ -0,0 +1,19 @@
+########################################################################
+# Copyright 2022, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_VERBOSE_INCLUDED
+MAKEFILE_VERBOSE_INCLUDED := 1
+
+
+ifdef V
+HIDE_ERR :=
+else
+HIDE_ERR := 2>/dev/null
+.SILENT:
+endif
+
+
+endif # include guard
diff --git a/share/mk/version.mk b/share/mk/version.mk
new file mode 100644
index 0000000..af3c0cb
--- /dev/null
+++ b/share/mk/version.mk
@@ -0,0 +1,20 @@
+########################################################################
+# Copyright 2022, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: GPL-3.0-or-later
+########################################################################
+
+
+ifndef MAKEFILE_VERSION_INCLUDED
+MAKEFILE_VERSION_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/cmd.mk
+include $(MAKEFILEDIR)/verbose.mk
+
+
+DISTNAME := $(shell $(GIT) describe $(HIDE_ERR))
+DISTVERSION := $(patsubst man-pages-%,%,$(DISTNAME))
+DISTDATE := $(shell $(GIT) log -1 --format='%aD')
+
+
+endif # include guard