Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

46.3. mandoc-1.14.6

Compact suite of tools for BSD mdoc and man formatting

Version 1.14.6, release 1
Shelf doctools — Documentation toolchains, man pages, markup converters and TeX typesetting
Phase 30_foundation (Build Foundation), 82 of 127 in build order
Licence ISC AND BSD-2-Clause AND BSD-3-Clause
Homepage https://mandoc.bsd.lv
Build time 0.1 SBU
Installed size 3.1 MiB in 23 files
Recipe ports/core/doctools/mandoc/kpkgbuild

About

mandoc is the manual-page system of KDOS: it formats man and mdoc pages and installs the commands people type, man, apropos, whatis and makewhatis, under their usual names. No other port provides those programs, and mandoc formats the pages itself, so reading a manual page on KDOS needs neither man-db, which the tree does not carry, nor groff.

mandoc has no autoconf. Its configure is a hand-written shell script that reads its settings from a file named configure.local in the source directory, and ignores any variable it does not know, so build.sh writes that file and runs ./configure with no arguments. Every variable written there is one the script reads.

apropos and whatis search an index, mandoc.db, in each manual root, and man finds a page by walking the tree when no index is there. The build writes no index while ports install (the chroot phases set KPKG_SKIP_INDEX=man), and 70_image/080_whatis.sh builds it once over the finished tree; see Shared indexes.

Why it is in KDOS

The comment above it in script/phases/30_foundation/packages.txt:

mandoc reads the man pages on the image.

Sources

Dependencies

Depends on: less, zlib.

Required by (5): efivar, groff, lsof, man-pages, openldap.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/30_foundation/phase.env && kpkg install mandoc'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/doctools/mandoc.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/doctools/mandoc
echo '8bf0d570f01e70a6e124884088870cbed7537f36328d512909eb10cd53179d9c  mandoc-1.14.6.tar.gz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/mandoc
SRC=$SRC_ROOT/mandoc-1.14.6
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf mandoc-1.14.6.tar.gz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

cat > configure.local <<EOF
CFLAGS="$CFLAGS"
LDFLAGS="$LDFLAGS"
PREFIX="/usr"
BINDIR="/usr/bin"
SBINDIR="/usr/sbin"
MANDIR="/usr/share/man"
INCLUDEDIR="/usr/include"
LIBDIR="/usr/lib"
UTF8_LOCALE="C.UTF-8"
BINM_MAN="man"
BINM_APROPOS="apropos"
BINM_WHATIS="whatis"
BINM_MAKEWHATIS="makewhatis"
BINM_PAGER="less"
MANPATH_DEFAULT="/usr/share/man:/usr/local/share/man"
EOF

./configure
make
make DESTDIR=$PKG install

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/mandoc, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf mandoc-1.14.6-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/mandoc, and runs the triggers its paths call for.

Contents

Installed programs: apropos, demandoc, makewhatis, man, mandoc, soelim, whatis.

Installed directories: /usr/share/licenses/mandoc.

Short descriptions

apropos search manual page databases
demandoc emit only text of UNIX manuals
makewhatis index UNIX manuals
man display manual pages
mandoc format manual pages
soelim interpret .so requests in manpages
whatis search manual page databases