8.11. ncurses stage 2 6.6-20260418

Rebuild ncurses in the final target environment so curses libraries, terminfo data, and package metadata match the completed userspace.

Input assumption: ncurses-6.6-20260418.tgz is already present in /sources from the chapter 4 source staging step.

Source URL: https://invisible-mirror.net/archives/ncurses/current/ncurses-6.6-20260418.tgz

Upstream build note: the upstream INSTALL file and ./configure --help document the standard ./configure, make, and make install flow, plus the wide-character, shared-library, C++ binding, manpage-format, stripping, and pkg-config file switches used below.

Licenses:

Dependencies:

ncurses is a terminal handling library and terminfo toolkit. we need it to provide final target curses interfaces, terminal capability data, and pkg-config metadata for later software.

Extract and Enter the Source Tree

Remove any previous extracted ncurses tree before unpacking. ncurses generates build-time table sources such as ncurses/comp_captab.c and include/hashsize.h; stale copies from an earlier failed or cross build can be newer than the unpacked sources and break the final build.

cd /sources
rm -rf ncurses-6.6-20260418
tar -xf ncurses-6.6-20260418.tgz
cd ncurses-6.6-20260418

Configure ncurses

lbi_configure \
    --with-manpage-format=normal \
    --with-shared \
    --without-normal \
    --without-cxx-binding \
    --without-debug \
    --without-ada \
    --enable-widec \
    --disable-stripping \
    --enable-pc-files \
    --with-pkg-config-libdir=/system/libraries/pkgconfig \
    AWK=awk

Pre-generate ncurses capability tables

ncurses generates include/hashsize.h from the capability tables in include/Caps and include/Caps-ncurses. In this target environment, the make frontend can mis-generate that file as a zero-entry table, which then creates an empty ncurses/comp_captab.c and fails with term.h and comp_captab.c disagree.

Replace the hash-size generator with an equivalent awk implementation, then pre-generate the capability tables before the full build. This keeps the main build from compiling a zero-entry comp_captab.c.

cat > include/MKhashsize.sh <<'EOF'
#!/bin/sh
echo "/*"
echo " * hashsize.h -- hash and token table constants"
echo " */"

awk '
    /^[ #]/ { next }
    /^$/ { next }
    /^capalias/ { next }
    /^infoalias/ { next }
    /^userdef/ { next }
    /^used_by/ { next }
    { ++n }
    END {
        print ""
        printf "#define CAPTABSIZE\t%d\n", n
        printf "#define HASHTABSIZE\t(%d * 2)\n", n
    }
' "$@"
EOF
chmod +x include/MKhashsize.sh

sh include/MKhashsize.sh include/Caps include/Caps-ncurses > include/hashsize.h

captabsize=$(sed -n 's/^#define[[:space:]]*CAPTABSIZE[[:space:]]*//p' include/hashsize.h)
test "$captabsize" -gt 0

rm -f ncurses/comp_captab.c ncurses/comp_userdefs.c

make -C include sources
make -C ncurses make_hash

(
    cd ncurses
    sh -e ./tinfo/MKcaptab.sh \
        awk \
        1 \
        ./tinfo/MKcaptab.awk \
        ../include/Caps \
        ../include/Caps-ncurses \
        > comp_captab.c
    sh -e ./tinfo/MKuserdefs.sh \
        awk \
        1 \
        ../include/Caps \
        ../include/Caps-ncurses \
        > comp_userdefs.c
)

Build ncurses

make $LWI_MAKE_FLAGS 

Install ncurses

make install

Post-install Compatibility Adjustments

ln -sf libncursesw.so /system/libraries/libncurses.so
sed -e 's/^#if.*XOPEN.*$/#if 1/' \
    -i '' /system/headers/curses.h
After this step is complete, you can remove the extracted source directory and source tarball from /sources if you do not plan to rebuild ncurses again.

Command Explanations