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 ownconfig.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.soandlibhistory.so, with no.aarchives beside them. Nothing in the bootstrap links readline statically.
The meaning of the make variable
SHLIB_LIBS="-lncursesw"-
Link
libreadline.soagainst ncurses’ wide-character library, so the shared library itself records that it needslibncursesw.so. readline calls the terminal functions, and built without this it leaves them for every program that links readline to supply. Given on themakecommand 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:
- applies the upstream patch series in order before configuring;
- reaches the same link to ncurses through configure instead of
make, with--with-curses,--with-shared-termcap-libraryandbash_cv_termcap_lib=libncursesw; - overrides
SHLIB_XLDFLAGSwith the soname alone. readline’s default for Linux, which the bootstrap build keeps, also passes-Wl,-rpath,$(libdir), so the bootstrap libraries carry a run-time search path naming/usr/lib. The port fails its build ifreadelffinds anRPATHorRUNPATHinlibreadline.so; - passes
--disable-install-examples.
See also
- Sed, the step before this one, and Bash, the step after it
- The readline port: its version, source and contents
- What a build verifies: the checks every package passes, which these hand-installed libraries never meet