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

23. Readline

GNU readline is the line-editing library behind an interactive shell prompt: cursor movement, the history list, completion. The bootstrap builds it for one consumer, the bash of the next step, which links this copy instead of the one bundled in its own source. 070_readline.sh cross-compiles the shared libraries from the readline port’s source tarball against the ncurses that 040_ncurses.sh installed.

Source: the archive of the readline port, without its patch series
Installs into: build/fs/usr
Approximate build time: 0.1 SBU

Installation of readline

The step unpacks the port’s tarball and builds in a build directory inside it, so the source tree itself is never written:

READLINE_SRC=$(extract_port_source readline)

cd "$READLINE_SRC"
mkdir -p build && cd build

../configure \
    --host=$KDOS_TARGET \
    --prefix=/usr \
    --disable-static

make SHLIB_LIBS="-lncursesw"
make DESTDIR=$SYSROOT install

# kpkg prunes the HTML manuals from the readline port's package, so no
# package adopts these copies and they would outlive every install.
rm -f $SYSROOT/usr/share/doc/readline/{history,readline,rluserman}.html

script/phases/10_bootstrap/070_readline.sh, lines 24–39

extract_port_source unpacks the tarball the recipe names first and nothing else, so the official upstream patch series the port carries beside it (readline<ver>-NNN, numbered from 001) is not applied here.

The meaning of the configure options

--host=$KDOS_TARGET
Build for KDOS with the cross compiler. readline’s configure is given no --build, works out the build machine with its own config.guess, and concludes it is not cross-compiling (see Part III).
--prefix=/usr
The libraries go to /usr/lib, the headers to /usr/include/readline.
--disable-static
Install only libreadline.so and libhistory.so, with no .a archives beside them. Nothing in the bootstrap links readline statically.

The meaning of the make variable

SHLIB_LIBS="-lncursesw"
Link libreadline.so against ncurses’ wide-character library, so the shared library itself records that it needs libncursesw.so. readline calls the terminal functions, and built without this it leaves them for every program that links readline to supply. Given on the make command line, the variable overrides the value configure wrote into the makefile.

Removing the HTML manuals

The rm deletes the HTML manuals the install writes under /usr/share/doc/readline. kpkg prunes HTML manuals from every package (see Size and language policy), so the readline port never installs these files again, and a copy left here would be adopted by no package and outlive every install (see Part III).

The step then removes the source and touches build/mark/bootstrap/readline.

Built again later

20_selfhost installs the readline port as a dependency of gawk, and the package adopts both libraries and the headers. 30_foundation names it again so a changed recipe is rebuilt there. The port build:

See also