8.24. mandoc 1.14.6
Build and install mandoc as the final manual page compiler, viewer, and indexer.
Input assumption: mandoc-1.14.6.tar.gz is already present in /sources from the chapter 4 source staging step.
Source URL: https://mandoc.bsd.lv/snapshots/mandoc-1.14.6.tar.gz
Upstream build note: upstream documents the portable build as ./configure, make, make install, and then makewhatis. The configure script is not generated by GNU autotools; it reads configure.local for installation paths and feature choices, so lbi_configure is not applicable here.
Licenses:
- ISC-style permissive license
- BSD-2-Clause and BSD-3-Clause licenses for imported compatibility files
Dependencies:
- musl (libc)
- make
- zlib-ng
mandoc is a manual page compiler and viewer for mdoc, man, and roff documents. we need it to provide the final target man, apropos, whatis, makewhatis, and soelim commands for reading and indexing installed manual pages.
Extract and Enter the Source Tree
cd /sources
rm -rf mandoc-1.14.6
tar -xf mandoc-1.14.6.tar.gz
cd mandoc-1.14.6
Configure mandoc
cat > configure.local <<EOF
PREFIX=/system
BINDIR=/system/binaries
SBINDIR=/system/systembinaries
MANDIR=/system/documentation/man-pages
MANPATH_DEFAULT="/system/documentation/man-pages"
MANPATH_BASE="/system/documentation/man-pages"
BIN_FROM_SBIN="../binaries"
BINM_PAGER=cat
LN="ln -sf"
CC=cc
CFLAGS="-O2 $LWI_CFLAGS"
LDFLAGS="$LBI_CUSTOM_LDFLAGS"
EOF
./configure
grep '#define BINM_PAGER "cat"' config.h
BINM_PAGER is compiled into mandoc as the fallback pager. The grep check catches stale configure output before installation. At runtime, MANPAGER and PAGER still override this fallback, so set either variable to cat if your shell environment points at a pager that is not installed yet.
Build mandoc
make $LWI_MAKE_FLAGS
Install mandoc
make install
/system/systembinaries/makewhatis /system/documentation/man-pages
MANPAGER=cat man mandoc >/dev/null
man, apropos, and whatis as links to mandoc, installs soelim, and installs makewhatis in /system/systembinaries.
/sources if you do not plan to rebuild mandoc again.
Command Explanations
rm -rf mandoc-...andtar -xf: Recreate a clean mandoc source tree.cat > configure.local: Writes mandoc's supported local configuration file instead of using an autotools-style configure command.PREFIX,BINDIR,SBINDIR, andMANDIR: Set install paths for the book's/systemlayout.MANPATH_DEFAULTandMANPATH_BASE: Point mandoc tools at the book's man-page tree.make $LWI_MAKE_FLAGS: Builds mandoc with shared make parallelism.make install: Installs mandoc tools into the target filesystem.makewhatis /system/documentation/man-pages: Builds the manual-page database.MANPAGER=cat man mandoc >/dev/null: Smoke-tests the installedmancommand without invoking an interactive pager.