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

34.1. ncurses-6.6

System V Release 4.0 curses emulation library

Version 6.6, release 2
Shelf base-libs — Low-level C libraries that the base system links
Phase 20_selfhost (Self-Hosting Bootstrap), 11 of 15 in build order
Licence X11-distribute-modifications-variant
Homepage https://invisible-island.net/ncurses/
Build time 0.8 SBU
Installed size 7.0 MiB in 3901 files
Recipe ports/core/base-libs/ncurses/kpkgbuild

About

ncurses is the terminal-handling library behind full-screen text programs: it reads the terminfo database to learn what a terminal can do and draws windows, colours and menus through it. It also installs the terminfo database itself and the tools that compile and query it, tic, infocmp and tput. readline, bash and the text-mode programs of the tree build against it, and 20_selfhost builds it because gawk needs readline.

KDOS builds one ncurses, the wide-character one, and makes every other name a build may ask for point at it. Its headers go flat into /usr/include, with no ncursesw/ directory; what that means for a port that includes <ncursesw/ncurses.h> or wants the wide API is in The wide curses API.

Sources

Dependencies

Depends on: nothing a recipe names.

Required by (79): aalib, alsa-utils, aspell, bash, bc, bitwise, bladerf, brltty, bsd-games, calcurse, clamav, cmake, cmus, frotz, gdb, gdbm, gettext, ghc, gnugo, gpsd, gptfdisk, guile, htop, hunspell, hwloc, iftop, iotop, kalgebra, kdos-bb, lagrange, lame, less, libcdio, libcec, libedit, lldb, lnav, lynx, minicom, moon-buggy, mosh, mtr, nano, ncdu, nethack, newsboat, ngspice, nvtop, octave, partclone, parted, pinentry, pipewire, powertop, predict, procps-ng, profanity, psmisc, pv, python3, qemu, readline, samba, samtools, sc-im, sdcc, sfeed, sqlite, stfl, testdisk, texinfo, tig, tlf, tmux, util-linux, vlc, w3m, weechat, zsh.

Differs from the bootstrap build. Ncurses builds this source too, in script/phases/10_bootstrap/040_ncurses.sh, before kpkg exists.

Only in the bootstrap build: --build=$(../config.guess), --disable-stripping, --host=$KDOS_TARGET, --prefix=$CROSS_SYSROOT, --with-manpage-format=normal, --without-ada, --without-normal.

Only in this build: --disable-pkg-ldflags, --enable-pc-files, --with-pkg-config-libdir=/usr/lib/pkgconfig.

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/20_selfhost/phase.env && kpkg install ncurses'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/base-libs/ncurses.

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/base-libs/ncurses
echo '355b4cbbed880b0381a04c46617b7656e362585d52e9cf84a67e2009b749ff11  ncurses-6.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/ncurses
SRC=$SRC_ROOT/ncurses-6.6
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf ncurses-6.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:

./configure --prefix=/usr \
            --mandir=/usr/share/man \
            --with-shared \
            --without-debug \
            --with-cxx-shared \
            --enable-pc-files \
            --disable-pkg-ldflags \
            --enable-widec \
            --with-pkg-config-libdir=/usr/lib/pkgconfig
make
make DESTDIR=$PKG install

for lib in ncurses form panel menu; do
	ln -sf lib${lib}w.so $PKG/usr/lib/lib${lib}.so
	ln -sf ${lib}w.pc $PKG/usr/lib/pkgconfig/${lib}.pc
done
ln -sf libncurses.so $PKG/usr/lib/libcurses.so

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/ncurses, 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 ncurses-6.6-2.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/ncurses, and runs the triggers its paths call for.

Contents

Installed programs: captoinfo, clear, infocmp, infotocap, ncursesw6-config, reset, tabs, tic, toe, tput, tset.

Installed libraries: libcurses.so, libform.so, libformw.a, libformw.so, libmenu.so, libmenuw.a, libmenuw.so, libncurses++w.a, libncurses++w.so, libncurses.so, libncursesw.a, libncursesw.so, libpanel.so, libpanelw.a, libpanelw.so.

Installed directories: /usr/share/licenses/ncurses, /usr/share/tabset, /usr/share/terminfo.

Short descriptions

captoinfo convert a termcap description into a terminfo description
clear clear the terminal screen
infocmp compare or print out terminfo descriptions
infotocap convert a terminfo description into a termcap description
ncursesw6-config configuration helper for ncurses libraries
tabs set terminal tab stops
tic compile terminal descriptions for terminfo or termcap
toe list table of entries of terminfo terminal types
tput initialize a terminal, exercise its capabilities, or query terminfo database
tset initialize or reset terminal state
formw.pc ncurses 6.6 add-on library
menuw.pc ncurses 6.6 add-on library
ncurses++w.pc ncurses 6.6 add-on library
ncursesw.pc ncurses 6.6 library
panelw.pc ncurses 6.6 add-on library

Notes

The for loop after the install links the names without the w to the wide libraries: libncurses.so, libform.so, libmenu.so and libpanel.so, and the .pc files of the same names. libcurses.so then links to libncurses.so. A build that asks for -lncurses, -lcurses or pkg-config ncurses gets the wide library, and nothing in the tree links a narrow one, because there is none.

Those links are also what readline’s configure finds first when it searches for the library holding tgetent, which is why that port names libncursesw outright.