summaryrefslogtreecommitdiffstats
path: root/share/mk/build
diff options
context:
space:
mode:
Diffstat (limited to 'share/mk/build')
-rw-r--r--share/mk/build/_.mk47
-rw-r--r--share/mk/build/book.mk42
-rw-r--r--share/mk/build/catman.mk89
-rw-r--r--share/mk/build/catman/_.mk13
-rw-r--r--share/mk/build/catman/eqn.mk27
-rw-r--r--share/mk/build/catman/grotty.mk25
-rw-r--r--share/mk/build/catman/troff.ignore.grep3
-rw-r--r--share/mk/build/catman/troff.mk85
-rw-r--r--share/mk/build/examples/_.mk28
-rw-r--r--share/mk/build/examples/cc.mk54
-rw-r--r--share/mk/build/examples/ld.mk51
-rw-r--r--share/mk/build/examples/src.mk55
-rw-r--r--share/mk/build/groff.mk39
-rw-r--r--share/mk/build/html.mk42
-rw-r--r--share/mk/build/html/_.mk13
-rw-r--r--share/mk/build/html/post-grohtml.mk25
-rw-r--r--share/mk/build/html/troff.mk58
-rw-r--r--share/mk/build/pdf.mk68
-rw-r--r--share/mk/build/pdf/_.mk13
-rw-r--r--share/mk/build/pdf/eqn.mk27
-rw-r--r--share/mk/build/pdf/gropdf.mk25
-rw-r--r--share/mk/build/pdf/troff.mk75
-rw-r--r--share/mk/build/pre.mk47
-rw-r--r--share/mk/build/pre/_.mk13
-rw-r--r--share/mk/build/pre/preconv.mk27
-rw-r--r--share/mk/build/pre/tbl.mk25
-rw-r--r--share/mk/build/ps.mk68
-rw-r--r--share/mk/build/ps/_.mk13
-rw-r--r--share/mk/build/ps/eqn.mk27
-rw-r--r--share/mk/build/ps/grops.mk25
-rw-r--r--share/mk/build/ps/troff.mk75
-rw-r--r--share/mk/build/src.mk117
32 files changed, 834 insertions, 507 deletions
diff --git a/share/mk/build/_.mk b/share/mk/build/_.mk
index bdce760..8ced940 100644
--- a/share/mk/build/_.mk
+++ b/share/mk/build/_.mk
@@ -1,52 +1,25 @@
-########################################################################
-# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org>
-# SPDX-License-Identifier: GPL-3.0-or-later
-########################################################################
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
ifndef MAKEFILE_BUILD_INCLUDED
MAKEFILE_BUILD_INCLUDED := 1
-include $(MAKEFILEDIR)/cmd.mk
-include $(MAKEFILEDIR)/src.mk
+include $(MAKEFILEDIR)/configure/directory_variables.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)
+build: \
+ build-book \
+ build-catman \
+ build-html \
+ build-pdf \
+ build-ps \
+ build-ex;
endif # include guard
diff --git a/share/mk/build/book.mk b/share/mk/build/book.mk
new file mode 100644
index 0000000..a941ced
--- /dev/null
+++ b/share/mk/build/book.mk
@@ -0,0 +1,42 @@
+# Copyright 2023-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_BOOK_INCLUDED
+MAKEFILE_BUILD_BOOK_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk
+include $(MAKEFILEDIR)/configure/build-depends/groff.mk
+include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk
+include $(MAKEFILEDIR)/configure/build-depends/moreutils.mk
+include $(MAKEFILEDIR)/configure/src.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+LMBDIR := $(srcdir)/scripts/LinuxManBook
+BUILDLMB := $(LMBDIR)/build.sh
+
+
+_LMB := $(_MANDIR)/man-pages.pdf
+
+
+$(_LMB): $(MANPAGES) $(wildcard $(LMBDIR)/* $(LMBDIR)/*/*) | $$(@D)/
+ $(info $(INFO_)Build $@)
+ CAT='$(CAT)' \
+ PRECONV='$(PRECONV)' \
+ PIC='$(PIC)' \
+ TBL='$(TBL)' \
+ EQN='$(EQN)' \
+ TROFF='$(TROFF)' \
+ GROPDF='$(GROPDF)' \
+ $(BUILDLMB) $(MANDIR) \
+ | $(SPONGE) $@
+
+
+.PHONY: build-book
+build-book: $(_LMB);
+
+
+endif # include guard
diff --git a/share/mk/build/catman.mk b/share/mk/build/catman.mk
deleted file mode 100644
index 7b8766e..0000000
--- a/share/mk/build/catman.mk
+++ /dev/null
@@ -1,89 +0,0 @@
-########################################################################
-# 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/catman/_.mk b/share/mk/build/catman/_.mk
new file mode 100644
index 0000000..78aa862
--- /dev/null
+++ b/share/mk/build/catman/_.mk
@@ -0,0 +1,13 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_CATMAN_INCLUDED
+MAKEFILE_BUILD_CATMAN_INCLUDED := 1
+
+
+.PHONY: build-catman
+build-catman: build-catman-grotty;
+
+
+endif # include guard
diff --git a/share/mk/build/catman/eqn.mk b/share/mk/build/catman/eqn.mk
new file mode 100644
index 0000000..48b6e75
--- /dev/null
+++ b/share/mk/build/catman/eqn.mk
@@ -0,0 +1,27 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_CATMAN_EQN_INCLUDED
+MAKEFILE_BUILD_CATMAN_EQN_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/pre/tbl.mk
+include $(MAKEFILEDIR)/configure/build-depends/grep.mk
+include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk
+
+
+_CATMAN_troff := $(patsubst %.eqn,%.cat.troff,$(_MAN_eqn))
+
+
+$(_CATMAN_troff): %.cat.troff: %.eqn $(MK) | $$(@D)/
+ $(info $(INFO_)EQN $@)
+ ! ($(EQN) -T$(NROFF_OUT_DEVICE) $(EQNFLAGS) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+
+.PHONY: build-catman-eqn
+build-catman-eqn: $(_CATMAN_troff);
+
+
+endif # include guard
diff --git a/share/mk/build/catman/grotty.mk b/share/mk/build/catman/grotty.mk
new file mode 100644
index 0000000..7def414
--- /dev/null
+++ b/share/mk/build/catman/grotty.mk
@@ -0,0 +1,25 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_CATMAN_GROTTY_INCLUDED
+MAKEFILE_BUILD_CATMAN_GROTTY_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/catman/troff.mk
+include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk
+
+
+_CATMAN := $(patsubst %.cat.set,%.cat,$(_CATMAN_MAN_set) $(_CATMAN_MDOC_set))
+
+
+$(_CATMAN): %.cat: %.cat.set $(MK) | $$(@D)/
+ $(info $(INFO_)GROTTY $@)
+ $(GROTTY) $(GROTTYFLAGS) <$< >$@
+
+
+.PHONY: build-catman-grotty
+build-catman-grotty: $(_CATMAN);
+
+
+endif # include guard
diff --git a/share/mk/build/catman/troff.ignore.grep b/share/mk/build/catman/troff.ignore.grep
new file mode 100644
index 0000000..912eb57
--- /dev/null
+++ b/share/mk/build/catman/troff.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/mk/build/catman/troff.mk b/share/mk/build/catman/troff.mk
new file mode 100644
index 0000000..c38ba17
--- /dev/null
+++ b/share/mk/build/catman/troff.mk
@@ -0,0 +1,85 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_CATMAN_TROFF_INCLUDED
+MAKEFILE_BUILD_CATMAN_TROFF_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk
+include $(MAKEFILEDIR)/configure/build-depends/grep.mk
+include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk
+include $(MAKEFILEDIR)/configure/src.mk
+include $(MAKEFILEDIR)/configure/xfail.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+_XFAIL_CATMAN_MAN_set := \
+ $(_MANDIR)/man2/fanotify_init.2.cat.set \
+ $(_MANDIR)/man3/unlocked_stdio.3.cat.set \
+ $(_MANDIR)/man4/console_codes.4.cat.set \
+ $(_MANDIR)/man4/lirc.4.cat.set \
+ $(_MANDIR)/man5/proc_pid_smaps.5.cat.set \
+ $(_MANDIR)/man5/tzfile.5.cat.set \
+ $(_MANDIR)/man7/ascii.7.cat.set \
+ $(_MANDIR)/man7/bpf-helpers.7.cat.set \
+ $(_MANDIR)/man7/charsets.7.cat.set \
+ $(_MANDIR)/man7/iso_8859-1.7.cat.set \
+ $(_MANDIR)/man7/iso_8859-2.7.cat.set \
+ $(_MANDIR)/man7/iso_8859-3.7.cat.set \
+ $(_MANDIR)/man7/iso_8859-4.7.cat.set \
+ $(_MANDIR)/man7/iso_8859-5.7.cat.set \
+ $(_MANDIR)/man7/iso_8859-6.7.cat.set \
+ $(_MANDIR)/man7/iso_8859-7.7.cat.set \
+ $(_MANDIR)/man7/iso_8859-8.7.cat.set \
+ $(_MANDIR)/man7/iso_8859-9.7.cat.set \
+ $(_MANDIR)/man7/iso_8859-10.7.cat.set \
+ $(_MANDIR)/man7/iso_8859-11.7.cat.set \
+ $(_MANDIR)/man7/iso_8859-13.7.cat.set \
+ $(_MANDIR)/man7/iso_8859-14.7.cat.set \
+ $(_MANDIR)/man7/iso_8859-15.7.cat.set \
+ $(_MANDIR)/man7/iso_8859-16.7.cat.set \
+ $(_MANDIR)/man8/tzselect.8.cat.set \
+ $(_MANDIR)/man8/zdump.8.cat.set \
+ $(_MANDIR)/man8/zic.8.cat.set
+
+
+
+troff_man_ignore_grep := $(MAKEFILEDIR)/build/catman/troff.ignore.grep
+
+
+_CATMAN_MAN_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.cat.set,$(NONSO_MAN))
+_CATMAN_MDOC_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.cat.set,$(NONSO_MDOC))
+
+
+ifeq ($(SKIP_XFAIL),yes)
+_CATMAN_MAN_set := $(filter-out $(_XFAIL_CATMAN_MAN_set), $(_CATMAN_MAN_set))
+endif
+
+
+$(_CATMAN_MAN_set): %.cat.set: %.cat.troff $(troff_man_ignore_grep) $(MK) | $$(@D)/
+ $(info $(INFO_)TROFF $@)
+ ! ($(TROFF) -man $(TROFFFLAGS) $(NROFFFLAGS) <$< 2>&1 >$@ \
+ | $(GREP) -v -f '$(troff_man_ignore_grep)' \
+ || $(TRUE); \
+ ) \
+ | $(GREP) ^ >&2
+
+$(_CATMAN_MDOC_set): %.cat.set: %.cat.troff $(MK) | $$(@D)/
+ $(info $(INFO_)TROFF $@)
+ ! ($(TROFF) -mdoc $(TROFFFLAGS) $(NROFFFLAGS) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+
+.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;
+
+
+endif # include guard
diff --git a/share/mk/build/examples/_.mk b/share/mk/build/examples/_.mk
new file mode 100644
index 0000000..c01a952
--- /dev/null
+++ b/share/mk/build/examples/_.mk
@@ -0,0 +1,28 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_EX_DIR_INCLUDED
+MAKEFILE_BUILD_EX_DIR_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk
+include $(MAKEFILEDIR)/configure/src.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+_PAGEEXDIRS := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.d/,$(NONSO_MAN))
+
+
+$(_PAGEEXDIRS):
+ +$(info $(INFO_)MKDIR $@)
+ +$(MKDIR) -p $@
+ +$(TOUCH) $@
+
+
+.PHONY: build-ex
+build-ex: build-ex-ld;
+
+
+endif # include guard
diff --git a/share/mk/build/examples/cc.mk b/share/mk/build/examples/cc.mk
new file mode 100644
index 0000000..6513fbe
--- /dev/null
+++ b/share/mk/build/examples/cc.mk
@@ -0,0 +1,54 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_EX_CC_INCLUDED
+MAKEFILE_BUILD_EX_CC_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/build/examples/src.mk
+include $(MAKEFILEDIR)/configure/build-depends/cc.mk
+include $(MAKEFILEDIR)/configure/build-depends/cpp.mk
+include $(MAKEFILEDIR)/configure/xfail.mk
+
+
+_XFAIL_UNITS_ex_o := \
+ $(_MANDIR)/man2/bpf.2.d/bpf.o \
+ $(_MANDIR)/man2/seccomp.2.d/seccomp.o \
+ $(_MANDIR)/man2/sigaction.2.d/sigaction.o \
+ $(_MANDIR)/man2/spu_run.2.d/spu_run.o \
+ $(_MANDIR)/man2/_syscall.2.d/_syscall.o \
+ $(_MANDIR)/man3/circleq.3.d/circleq.o \
+ $(_MANDIR)/man3/encrypt.3.d/encrypt.o \
+ $(_MANDIR)/man3/getsubopt.3.d/getsubopt.o \
+ $(_MANDIR)/man3/hsearch.3.d/hsearch.o \
+ $(_MANDIR)/man3/malloc_info.3.d/malloc_info.o \
+ $(_MANDIR)/man3/mallopt.3.d/mallopt.o \
+ $(_MANDIR)/man3/matherr.3.d/matherr.o \
+ $(_MANDIR)/man3/mcheck.3.d/mcheck.o \
+ $(_MANDIR)/man3/mtrace.3.d/t_mtrace.o \
+ $(_MANDIR)/man3/__ppc_get_timebase.3.d/__ppc_get_timebase.o \
+ $(_MANDIR)/man3/pthread_getcpuclockid.3.d/pthread_getcpuclockid.o \
+ $(_MANDIR)/man3/rtime.3.d/rtime.o \
+ $(_MANDIR)/man3/setbuf.3.d/setbuf.o \
+ $(_MANDIR)/man3/stpncpy.3.d/stpncpy.o \
+ $(_MANDIR)/man3head/printf.h.3head.d/register_printf_specifier.o
+
+
+_UNITS_ex_o := $(patsubst %.c,%.o,$(_UNITS_ex_c))
+ifeq ($(SKIP_XFAIL),yes)
+_UNITS_ex_o := $(filter-out $(_XFAIL_UNITS_ex_o), $(_UNITS_ex_o))
+endif
+
+
+$(_UNITS_ex_o): %.o: %.c $(MK)
+ $(info $(INFO_)CC $@)
+ $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
+
+
+.PHONY: build-ex-cc
+build-ex-cc: $(_UNITS_ex_o);
+
+
+endif # include guard
diff --git a/share/mk/build/examples/ld.mk b/share/mk/build/examples/ld.mk
new file mode 100644
index 0000000..9d5535d
--- /dev/null
+++ b/share/mk/build/examples/ld.mk
@@ -0,0 +1,51 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_EX_LD_INCLUDED
+MAKEFILE_BUILD_EX_LD_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/build/examples/cc.mk
+include $(MAKEFILEDIR)/configure/build-depends/ld.mk
+include $(MAKEFILEDIR)/configure/xfail.mk
+
+
+_XFAIL_UNITS_ex_bin := \
+ $(_MANDIR)/man2/add_key.2.d/add_key \
+ $(_MANDIR)/man2/keyctl.2.d/key_instantiate \
+ $(_MANDIR)/man2/request_key.2.d/t_request_key \
+ $(_MANDIR)/man2/select_tut.2.d/select \
+ $(_MANDIR)/man2/shmop.2.d/svshm_string_read \
+ $(_MANDIR)/man3/cacos.3.d/cacos \
+ $(_MANDIR)/man3/cacosh.3.d/cacosh \
+ $(_MANDIR)/man3/catan.3.d/catan \
+ $(_MANDIR)/man3/catanh.3.d/catanh \
+ $(_MANDIR)/man3/getaddrinfo_a.3.d/async \
+ $(_MANDIR)/man3/inet_net_pton.3.d/inet_net_pton \
+ $(_MANDIR)/man3/list.3.d/list \
+ $(_MANDIR)/man3/mallinfo.3.d/mallinfo \
+ $(_MANDIR)/man3/slist.3.d/slist \
+ $(_MANDIR)/man3/stailq.3.d/stailq \
+ $(_MANDIR)/man3/strncat.3.d/strncat \
+ $(_MANDIR)/man3/tailq.3.d/tailq \
+ $(_MANDIR)/man3/tsearch.3.d/tsearch
+
+
+_UNITS_ex_bin := $(patsubst %.o,%,$(_UNITS_ex_o))
+ifeq ($(SKIP_XFAIL),yes)
+_UNITS_ex_bin := $(filter-out $(_XFAIL_UNITS_ex_bin), $(_UNITS_ex_bin))
+endif
+
+
+$(_UNITS_ex_bin): %: %.o $(MK)
+ $(info $(INFO_)LD $@)
+ $(LD) $(LDFLAGS) -o $@ $< $(LDLIBS)
+
+
+.PHONY: build-ex-ld
+build-ex-ld: $(_UNITS_ex_bin);
+
+
+endif # include guard
diff --git a/share/mk/build/examples/src.mk b/share/mk/build/examples/src.mk
new file mode 100644
index 0000000..f47a713
--- /dev/null
+++ b/share/mk/build/examples/src.mk
@@ -0,0 +1,55 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_EX_SRC_INCLUDED
+MAKEFILE_BUILD_EX_SRC_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk
+include $(MAKEFILEDIR)/configure/build-depends/findutils.mk
+include $(MAKEFILEDIR)/configure/build-depends/grep.mk
+include $(MAKEFILEDIR)/configure/build-depends/mandoc.mk
+include $(MAKEFILEDIR)/configure/build-depends/sed.mk
+include $(MAKEFILEDIR)/configure/directory_variables.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+_UNITS_ex_src := \
+ $(patsubst $(MANDIR)/%, $(_MANDIR)/%, \
+ $(shell \
+ $(FIND) $(MANDIR)/* -type f \
+ | $(GREP) '$(MANEXT)' \
+ | $(XARGS) $(GREP) -H '^\.\\" SRC BEGIN ' \
+ | $(SED) 's,:\.\\" SRC BEGIN (,.d/,' \
+ | $(SED) 's/)//' \
+ | $(SORTMAN) \
+ | $(SED) 's,:,\\:,g' \
+ ) \
+ )
+_UNITS_ex_h := $(filter %.h,$(_UNITS_ex_src))
+_UNITS_ex_c := $(filter %.c,$(_UNITS_ex_src))
+
+
+$(_UNITS_ex_src): $$(patsubst $(_MANDIR)/%.d,$(MANDIR)/%,$$(@D)) $(MK) | $$(@D)/
+$(_UNITS_ex_c): $$(filter $$(@D)/%.h,$(_UNITS_ex_h))
+$(_UNITS_ex_src):
+ $(info $(INFO_)SED $@)
+ <$< \
+ $(SED) -n \
+ -e '/^\.TH/,/^\.SH/{/^\.SH/!p}' \
+ -e '/^\.SH EXAMPLES/p' \
+ -e "/^\... SRC BEGIN ($(@F))$$/,/^\... SRC END$$/p" \
+ | $(MANDOC) -Tutf8 \
+ | $(HEAD) -n-2 \
+ | $(SED) '/^[^ ]/d' \
+ | $(SED) 's/^ //' \
+ >$@
+
+
+.PHONY: build-ex-src
+build-ex-src: $(_UNITS_ex_src);
+
+
+endif # include guard
diff --git a/share/mk/build/groff.mk b/share/mk/build/groff.mk
deleted file mode 100644
index 2a5a3de..0000000
--- a/share/mk/build/groff.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-########################################################################
-# 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
deleted file mode 100644
index 084654d..0000000
--- a/share/mk/build/html.mk
+++ /dev/null
@@ -1,42 +0,0 @@
-########################################################################
-# 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/html/_.mk b/share/mk/build/html/_.mk
new file mode 100644
index 0000000..b3e3041
--- /dev/null
+++ b/share/mk/build/html/_.mk
@@ -0,0 +1,13 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_HTML_INCLUDED
+MAKEFILE_BUILD_HTML_INCLUDED := 1
+
+
+.PHONY: build-html
+build-html: build-html-post-grohtml;
+
+
+endif # include guard
diff --git a/share/mk/build/html/post-grohtml.mk b/share/mk/build/html/post-grohtml.mk
new file mode 100644
index 0000000..fe77776
--- /dev/null
+++ b/share/mk/build/html/post-grohtml.mk
@@ -0,0 +1,25 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_HTML_POST_GROHTML_INCLUDED
+MAKEFILE_BUILD_HTML_POST_GROHTML_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/html/troff.mk
+include $(MAKEFILEDIR)/configure/build-depends/groff.mk
+
+
+_HTMLMAN := $(patsubst %.html.set,%.html,$(_HTMLMAN_MAN_set) $(_HTMLMAN_MDOC_set))
+
+
+$(_HTMLMAN): %.html: %.html.set $(MK) | $$(@D)/
+ $(info $(INFO_)POST_GROHTML $@)
+ $(POST_GROHTML) $(POST_GROHTMLFLAGS) <$< >$@
+
+
+.PHONY: build-html-post-grohtml
+build-html-post-grohtml: $(_HTMLMAN);
+
+
+endif # include guard
diff --git a/share/mk/build/html/troff.mk b/share/mk/build/html/troff.mk
new file mode 100644
index 0000000..010c211
--- /dev/null
+++ b/share/mk/build/html/troff.mk
@@ -0,0 +1,58 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_HTML_TROFF_INCLUDED
+MAKEFILE_BUILD_HTML_TROFF_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/configure/build-depends/grep.mk
+include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk
+include $(MAKEFILEDIR)/configure/src.mk
+include $(MAKEFILEDIR)/configure/xfail.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+_XFAIL_HTMLMAN_MAN_set := \
+ $(_MANDIR)/man2/fanotify_init.2.html.set \
+ $(_MANDIR)/man2/membarrier.2.html.set \
+ $(_MANDIR)/man5/proc.5.html.set \
+ $(_MANDIR)/man7/bpf-helpers.7.html.set \
+ $(_MANDIR)/man7/charsets.7.html.set \
+ $(_MANDIR)/man7/iso_8859-16.7.html.set \
+ $(_MANDIR)/man7/iso_8859-6.7.html.set \
+ $(_MANDIR)/man8/zic.8.html.set
+
+
+_HTMLMAN_MAN_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.html.set,$(NONSO_MAN))
+_HTMLMAN_MDOC_set:= $(patsubst $(MANDIR)/%,$(_MANDIR)/%.html.set,$(NONSO_MDOC))
+
+
+ifeq ($(SKIP_XFAIL),yes)
+_HTMLMAN_MAN_set := $(filter-out $(_XFAIL_HTMLMAN_MAN_set), $(_HTMLMAN_MAN_set))
+endif
+
+
+$(_HTMLMAN_MAN_set): %.html.set: %.eqn $(MK) | $$(@D)/
+ $(info $(INFO_)TROFF $@)
+ ! ($(TROFF) -man -Thtml $(TROFFFLAGS) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+$(_HTMLMAN_MDOC_set): %.html.set: %.eqn $(MK) | $$(@D)/
+ $(info $(INFO_)TROFF $@)
+ ! ($(TROFF) -mdoc -Thtml $(TROFFFLAGS) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+
+.PHONY: build-html-troff-man
+build-html-troff-man: $(_HTMLMAN_MAN_set);
+
+.PHONY: build-html-troff-mdoc
+build-html-troff-mdoc: $(_HTMLMAN_MDOC_set);
+
+.PHONY: build-html-troff
+build-html-troff: build-html-troff-man build-html-troff-mdoc;
+
+
+endif # include guard
diff --git a/share/mk/build/pdf.mk b/share/mk/build/pdf.mk
deleted file mode 100644
index 380c6c6..0000000
--- a/share/mk/build/pdf.mk
+++ /dev/null
@@ -1,68 +0,0 @@
-########################################################################
-# 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/pdf/_.mk b/share/mk/build/pdf/_.mk
new file mode 100644
index 0000000..f6660aa
--- /dev/null
+++ b/share/mk/build/pdf/_.mk
@@ -0,0 +1,13 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_PDF_INCLUDED
+MAKEFILE_BUILD_PDF_INCLUDED := 1
+
+
+.PHONY: build-pdf
+build-pdf: build-pdf-gropdf;
+
+
+endif # include guard
diff --git a/share/mk/build/pdf/eqn.mk b/share/mk/build/pdf/eqn.mk
new file mode 100644
index 0000000..bb0598b
--- /dev/null
+++ b/share/mk/build/pdf/eqn.mk
@@ -0,0 +1,27 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_PDF_EQN_INCLUDED
+MAKEFILE_BUILD_PDF_EQN_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/pre/tbl.mk
+include $(MAKEFILEDIR)/configure/build-depends/grep.mk
+include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk
+
+
+_PDFMAN_troff := $(patsubst %.eqn,%.pdf.troff,$(_MAN_eqn))
+
+
+$(_PDFMAN_troff): %.pdf.troff: %.eqn $(MK) | $$(@D)/
+ $(info $(INFO_)EQN $@)
+ ! ($(EQN) -Tpdf $(EQNFLAGS) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+
+.PHONY: build-pdf-eqn
+build-pdf-eqn: $(_PDFMAN_troff);
+
+
+endif # include guard
diff --git a/share/mk/build/pdf/gropdf.mk b/share/mk/build/pdf/gropdf.mk
new file mode 100644
index 0000000..0913122
--- /dev/null
+++ b/share/mk/build/pdf/gropdf.mk
@@ -0,0 +1,25 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_PDF_GROPDF_INCLUDED
+MAKEFILE_BUILD_PDF_GROPDF_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/pdf/troff.mk
+include $(MAKEFILEDIR)/configure/build-depends/groff.mk
+
+
+_PDFMAN := $(patsubst %.pdf.set,%.pdf,$(_PDFMAN_MAN_set) $(_PDFMAN_MDOC_set))
+
+
+$(_PDFMAN): %.pdf: %.pdf.set $(MK) | $$(@D)/
+ $(info $(INFO_)GROPDF $@)
+ $(GROPDF) $(GROPDFFLAGS) <$< >$@
+
+
+.PHONY: build-pdf-gropdf
+build-pdf-gropdf: $(_PDFMAN);
+
+
+endif # include guard
diff --git a/share/mk/build/pdf/troff.mk b/share/mk/build/pdf/troff.mk
new file mode 100644
index 0000000..5254d5d
--- /dev/null
+++ b/share/mk/build/pdf/troff.mk
@@ -0,0 +1,75 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_PDF_TROFF_INCLUDED
+MAKEFILE_BUILD_PDF_TROFF_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/configure/build-depends/grep.mk
+include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk
+include $(MAKEFILEDIR)/configure/src.mk
+include $(MAKEFILEDIR)/configure/xfail.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+_XFAIL_PDFMAN_MAN_set := \
+ $(_MANDIR)/man1/iconv.1.pdf.set \
+ $(_MANDIR)/man2/fanotify_init.2.pdf.set \
+ $(_MANDIR)/man2/syscall.2.pdf.set \
+ $(_MANDIR)/man3/newlocale.3.pdf.set \
+ $(_MANDIR)/man7/address_families.7.pdf.set \
+ $(_MANDIR)/man7/armscii-8.7.pdf.set \
+ $(_MANDIR)/man7/ascii.7.pdf.set \
+ $(_MANDIR)/man7/bpf-helpers.7.pdf.set \
+ $(_MANDIR)/man7/charsets.7.pdf.set \
+ $(_MANDIR)/man7/cp1251.7.pdf.set \
+ $(_MANDIR)/man7/iso_8859-2.7.pdf.set \
+ $(_MANDIR)/man7/iso_8859-3.7.pdf.set \
+ $(_MANDIR)/man7/iso_8859-4.7.pdf.set \
+ $(_MANDIR)/man7/iso_8859-5.7.pdf.set \
+ $(_MANDIR)/man7/iso_8859-6.7.pdf.set \
+ $(_MANDIR)/man7/iso_8859-7.7.pdf.set \
+ $(_MANDIR)/man7/iso_8859-8.7.pdf.set \
+ $(_MANDIR)/man7/iso_8859-10.7.pdf.set \
+ $(_MANDIR)/man7/iso_8859-11.7.pdf.set \
+ $(_MANDIR)/man7/iso_8859-13.7.pdf.set \
+ $(_MANDIR)/man7/iso_8859-14.7.pdf.set \
+ $(_MANDIR)/man7/iso_8859-16.7.pdf.set \
+ $(_MANDIR)/man7/koi8-r.7.pdf.set \
+ $(_MANDIR)/man7/koi8-u.7.pdf.set \
+ $(_MANDIR)/man7/vdso.7.pdf.set
+
+
+_PDFMAN_MAN_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.pdf.set,$(NONSO_MAN))
+_PDFMAN_MDOC_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.pdf.set,$(NONSO_MDOC))
+
+
+ifeq ($(SKIP_XFAIL),yes)
+_PDFMAN_MAN_set := $(filter-out $(_XFAIL_PDFMAN_MAN_set), $(_PDFMAN_MAN_set))
+endif
+
+
+$(_PDFMAN_MAN_set): %.pdf.set: %.pdf.troff $(MK) | $$(@D)/
+ $(info $(INFO_)TROFF $@)
+ ! ($(TROFF) -man -Tpdf $(TROFFFLAGS) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+$(_PDFMAN_MDOC_set): %.pdf.set: %.pdf.troff $(MK) | $$(@D)/
+ $(info $(INFO_)TROFF $@)
+ ! ($(TROFF) -mdoc -Tpdf $(TROFFFLAGS) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+
+.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;
+
+
+endif # include guard
diff --git a/share/mk/build/pre.mk b/share/mk/build/pre.mk
deleted file mode 100644
index 4c458fa..0000000
--- a/share/mk/build/pre.mk
+++ /dev/null
@@ -1,47 +0,0 @@
-########################################################################
-# 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/pre/_.mk b/share/mk/build/pre/_.mk
new file mode 100644
index 0000000..f0e86f4
--- /dev/null
+++ b/share/mk/build/pre/_.mk
@@ -0,0 +1,13 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_PRE_INCLUDED
+MAKEFILE_BUILD_PRE_INCLUDED := 1
+
+
+.PHONY: build-pre
+build-pre: build-pre-tbl;
+
+
+endif # include guard
diff --git a/share/mk/build/pre/preconv.mk b/share/mk/build/pre/preconv.mk
new file mode 100644
index 0000000..73aa1da
--- /dev/null
+++ b/share/mk/build/pre/preconv.mk
@@ -0,0 +1,27 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_PRE_PRECONV_INCLUDED
+MAKEFILE_BUILD_PRE_PRECONV_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk
+include $(MAKEFILEDIR)/configure/src.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+_MAN_tbl := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.tbl,$(NONSO_MAN) $(NONSO_MDOC))
+
+
+$(_MAN_tbl): $(_MANDIR)/%.tbl: $(MANDIR)/% $(MK) | $$(@D)/
+ $(info $(INFO_)PRECONV $@)
+ $(PRECONV) $(PRECONVFLAGS) $< >$@
+
+
+.PHONY: build-pre-preconv
+build-pre-preconv: $(_MAN_tbl);
+
+
+endif # include guard
diff --git a/share/mk/build/pre/tbl.mk b/share/mk/build/pre/tbl.mk
new file mode 100644
index 0000000..24486f8
--- /dev/null
+++ b/share/mk/build/pre/tbl.mk
@@ -0,0 +1,25 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_PRE_TBL_INCLUDED
+MAKEFILE_BUILD_PRE_TBL_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/pre/preconv.mk
+include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk
+
+
+_MAN_eqn := $(patsubst %.tbl,%.eqn,$(_MAN_tbl))
+
+
+$(_MAN_eqn): %.eqn: %.tbl $(MK) | $$(@D)/
+ $(info $(INFO_)TBL $@)
+ $(TBL) <$< >$@
+
+
+.PHONY: build-pre-tbl
+build-pre-tbl: $(_MAN_eqn);
+
+
+endif # include guard
diff --git a/share/mk/build/ps.mk b/share/mk/build/ps.mk
deleted file mode 100644
index 5b29dc1..0000000
--- a/share/mk/build/ps.mk
+++ /dev/null
@@ -1,68 +0,0 @@
-########################################################################
-# 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/ps/_.mk b/share/mk/build/ps/_.mk
new file mode 100644
index 0000000..b92ebfc
--- /dev/null
+++ b/share/mk/build/ps/_.mk
@@ -0,0 +1,13 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_PS_INCLUDED
+MAKEFILE_BUILD_PS_INCLUDED := 1
+
+
+.PHONY: build-ps
+build-ps: build-ps-grops;
+
+
+endif # include guard
diff --git a/share/mk/build/ps/eqn.mk b/share/mk/build/ps/eqn.mk
new file mode 100644
index 0000000..a4c921e
--- /dev/null
+++ b/share/mk/build/ps/eqn.mk
@@ -0,0 +1,27 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_PS_EQN_INCLUDED
+MAKEFILE_BUILD_PS_EQN_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/pre/tbl.mk
+include $(MAKEFILEDIR)/configure/build-depends/grep.mk
+include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk
+
+
+_PSMAN_troff := $(patsubst %.eqn,%.ps.troff,$(_MAN_eqn))
+
+
+$(_PSMAN_troff): %.ps.troff: %.eqn $(MK) | $$(@D)/
+ $(info $(INFO_)EQN $@)
+ ! ($(EQN) -Tps $(EQNFLAGS) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+
+.PHONY: build-ps-eqn
+build-ps-eqn: $(_PSMAN_troff);
+
+
+endif # include guard
diff --git a/share/mk/build/ps/grops.mk b/share/mk/build/ps/grops.mk
new file mode 100644
index 0000000..cca9b44
--- /dev/null
+++ b/share/mk/build/ps/grops.mk
@@ -0,0 +1,25 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_PS_GROPS_INCLUDED
+MAKEFILE_BUILD_PS_GROPS_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/ps/troff.mk
+include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk
+
+
+_PSMAN := $(patsubst %.ps.set,%.ps,$(_PSMAN_MAN_set) $(_PSMAN_MDOC_set))
+
+
+$(_PSMAN): %.ps: %.ps.set $(MK) | $$(@D)/
+ $(info $(INFO_)GROPS $@)
+ $(GROPS) $(GROPSFLAGS) <$< >$@
+
+
+.PHONY: build-ps-grops
+build-ps-grops: $(_PSMAN);
+
+
+endif # include guard
diff --git a/share/mk/build/ps/troff.mk b/share/mk/build/ps/troff.mk
new file mode 100644
index 0000000..1492821
--- /dev/null
+++ b/share/mk/build/ps/troff.mk
@@ -0,0 +1,75 @@
+# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org>
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_BUILD_PS_TROFF_INCLUDED
+MAKEFILE_BUILD_PS_TROFF_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/_.mk
+include $(MAKEFILEDIR)/configure/build-depends/grep.mk
+include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk
+include $(MAKEFILEDIR)/configure/src.mk
+include $(MAKEFILEDIR)/configure/xfail.mk
+include $(MAKEFILEDIR)/src.mk
+
+
+_XFAIL_PSMAN_MAN_set := \
+ $(_MANDIR)/man1/iconv.1.ps.set \
+ $(_MANDIR)/man2/fanotify_init.2.ps.set \
+ $(_MANDIR)/man2/syscall.2.ps.set \
+ $(_MANDIR)/man3/newlocale.3.ps.set \
+ $(_MANDIR)/man7/address_families.7.ps.set \
+ $(_MANDIR)/man7/armscii-8.7.ps.set \
+ $(_MANDIR)/man7/ascii.7.ps.set \
+ $(_MANDIR)/man7/bpf-helpers.7.ps.set \
+ $(_MANDIR)/man7/charsets.7.ps.set \
+ $(_MANDIR)/man7/cp1251.7.ps.set \
+ $(_MANDIR)/man7/iso_8859-2.7.ps.set \
+ $(_MANDIR)/man7/iso_8859-3.7.ps.set \
+ $(_MANDIR)/man7/iso_8859-4.7.ps.set \
+ $(_MANDIR)/man7/iso_8859-5.7.ps.set \
+ $(_MANDIR)/man7/iso_8859-6.7.ps.set \
+ $(_MANDIR)/man7/iso_8859-7.7.ps.set \
+ $(_MANDIR)/man7/iso_8859-8.7.ps.set \
+ $(_MANDIR)/man7/iso_8859-10.7.ps.set \
+ $(_MANDIR)/man7/iso_8859-11.7.ps.set \
+ $(_MANDIR)/man7/iso_8859-13.7.ps.set \
+ $(_MANDIR)/man7/iso_8859-14.7.ps.set \
+ $(_MANDIR)/man7/iso_8859-16.7.ps.set \
+ $(_MANDIR)/man7/koi8-r.7.ps.set \
+ $(_MANDIR)/man7/koi8-u.7.ps.set \
+ $(_MANDIR)/man7/vdso.7.ps.set
+
+
+_PSMAN_MAN_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.ps.set,$(NONSO_MAN))
+_PSMAN_MDOC_set:= $(patsubst $(MANDIR)/%,$(_MANDIR)/%.ps.set,$(NONSO_MDOC))
+
+
+ifeq ($(SKIP_XFAIL),yes)
+_PSMAN_MAN_set := $(filter-out $(_XFAIL_PSMAN_MAN_set), $(_PSMAN_MAN_set))
+endif
+
+
+$(_PSMAN_MAN_set): %.ps.set: %.ps.troff $(MK) | $$(@D)/
+ $(info $(INFO_)TROFF $@)
+ ! ($(TROFF) -man -Tps $(TROFFFLAGS) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+$(_PSMAN_MDOC_set): %.ps.set: %.ps.troff $(MK) | $$(@D)/
+ $(info $(INFO_)TROFF $@)
+ ! ($(TROFF) -mdoc -Tps $(TROFFFLAGS) <$< 2>&1 >$@) \
+ | $(GREP) ^ >&2
+
+
+.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;
+
+
+endif # include guard
diff --git a/share/mk/build/src.mk b/share/mk/build/src.mk
deleted file mode 100644
index 365c256..0000000
--- a/share/mk/build/src.mk
+++ /dev/null
@@ -1,117 +0,0 @@
-########################################################################
-# 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