[PATCH liburing 2/3] man: Introduce rules to convert Markdown to groff

Gabriel Krisman Bertazi <[email protected]> Mon, 6 Jul 2026 17:41:24 -0400
Newsgroups org.kernel.vger.io-uring
Message-ID <[email protected]>
Introduce infrastructure to convert back from Markdown to Groff during
the compilation step.

This is split from the patch actually doing the convertion to facilitate
review.

The conversion is not lossless, mostly due to groff being painful.
You'll notice the conversion is not byte-per-byte accurate, but most of
the differences are whitespace, which is not relevant.  Other more
tricky changes are in bold/italics, which I tried to preserve as much as
possible.

This obviously adds a build dependency on pandoc, which is already
packaged by any sane distro out there.  The configure file is updated to
check for that.

Groff comments need to be preserved because of copyrights notices. This
is done by a pre-processor python script.

Signed-off-by: Gabriel Krisman Bertazi <[email protected]>
---
 configure      |  8 ++++++++
 man/.gitignore |  8 ++++++++
 man/Makefile   | 13 +++++++++++--
 3 files changed, 27 insertions(+), 2 deletions(-)
 create mode 100644 man/.gitignore

diff --git a/configure b/configure
index 39c377c9..98761b49 100755
--- a/configure
+++ b/configure
@@ -530,6 +530,14 @@ if test "$has_clang" = "yes" && test "$has_bpftool" = "yes" && test "$has_bpf_cl
   output_mak "bpf_toolchain" "y"
 fi
 
+#############################################################################
+# check for pandoc
+
+if ! has pandoc ; then
+	fatal "pandoc is needed for manpages generation"
+fi
+print_config "pandoc" "yes"
+
 #############################################################################
 liburing_nolibc="no"
 if test "$use_libc" != "yes"; then
diff --git a/man/.gitignore b/man/.gitignore
new file mode 100644
index 00000000..5fba7856
--- /dev/null
+++ b/man/.gitignore
@@ -0,0 +1,8 @@
+*.1
+*.2
+*.3
+*.4
+*.5
+*.6
+*.7
+*.8
diff --git a/man/Makefile b/man/Makefile
index 0c68d9db..8b54f523 100644
--- a/man/Makefile
+++ b/man/Makefile
@@ -1,6 +1,15 @@
-.PHONY all clean
+MDS := $(wildcard *.md)
+PAGES := $(patsubst %.md,%,$(MDS))
+VPATH = $(root)/man
 
-all: gen_aliases
+mandir ?= $(prefix)/share/man
+
+.PHONY: all clean
+
+all: $(PAGES) gen_aliases
+
+%: %.md
+	sed -E '/\.\\/d' $<| pandoc --standalone --to man -o $@
 
 gen_aliases:
 	while IFS=$$'\t' read -r link tgt ; do ln -f -s $$tgt $$link; done < ALIASES
-- 
2.54.0