6.3. Ncurses-6.5

The Ncurses package contains libraries for terminal-independent handling of character screens.

Approximate build time: 0.4 SBU
Required disk space: 53 MB

6.3.1. Installation of Ncurses

First, run the following commands to build the tic program on the build host:

mkdir build
pushd build
  ../configure AWK=gawk
  make -C include
  make -C progs tic
popd

Prepare Ncurses for compilation:

./configure --prefix=/usr                \
            --host=$LFS_TGT              \
            --build=$(./config.guess)    \
            --mandir=/usr/share/man      \
            --with-manpage-format=normal \
            --with-shared                \
            --without-normal             \
            --with-cxx-shared            \
            --without-debug              \
            --without-ada                \
            --disable-stripping          \
            AWK=gawk

The meaning of the new configure options:

--with-manpage-format=normal

This prevents Ncurses from installing compressed manual pages, which may happen if the host distribution itself has compressed manual pages.

--with-shared

This makes Ncurses build and install shared C libraries.

--without-normal

This prevents Ncurses from building and installing static C libraries.

--without-debug

This prevents Ncurses from building and installing debug libraries.

--with-cxx-shared

This makes Ncurses build and install shared C++ bindings. It also prevents it building and installing static C++ bindings.

--without-ada

This ensures that Ncurses does not build support for the Ada compiler, which may be present on the host but will not be available once we enter the chroot environment.

--disable-stripping

This switch prevents the building system from using the strip program from the host. Using host tools on cross-compiled programs can cause failure.

AWK=gawk

This switch prevents the building system from using the mawk program from the host. Some versions of mawk can cause this package to fail to build.

Compile the package:

make

Install the package:

make DESTDIR=$LFS TIC_PATH=$(pwd)/build/progs/tic install
ln -sv libncursesw.so $LFS/usr/lib/libncurses.so
sed -e 's/^#if.*XOPEN.*$/#if 1/' \
    -i $LFS/usr/include/curses.h

The meaning of the install options:

TIC_PATH=$(pwd)/build/progs/tic

We need to pass the path of the newly built tic program that runs on the building machine, so the terminal database can be created without errors.

ln -sv libncursesw.so $LFS/usr/lib/libncurses.so

The libncurses.so library is needed by a few packages we will build soon. We create this symlink to use libncursesw.so as a replacement.

sed -e 's/^#if.*XOPEN.*$/#if 1/' ...

The header file curses.h contains the definition of various Ncurses data structures. With different preprocessor macro definitions two different sets of the data structure definition may be used: the 8-bit definition is compatible with libncurses.so and the wide-character definition is compatible with libncursesw.so. Since we are using libncursesw.so as a replacement of libncurses.so, edit the header file so it will always use the wide-character data structure definition compatible with libncursesw.so.

6.3.2. Building Ncurses - 32bit

Clean previous build:

make distclean

Prepare Ncurses for compilation:

CC="$LFS_TGT-gcc -m32"              \
CXX="$LFS_TGT-g++ -m32"             \
./configure --prefix=/usr           \
            --host=$LFS_TGT32       \
            --build=$(./config.guess)    \
            --libdir=/usr/lib32     \
            --mandir=/usr/share/man \
            --with-shared           \
            --without-normal        \
            --with-cxx-shared       \
            --without-debug         \
            --without-ada           \
            --disable-stripping

Compile the package:

make

Install the package:

make DESTDIR=$PWD/DESTDIR TIC_PATH=$(pwd)/build/progs/tic install
ln -sv libncursesw.so DESTDIR/usr/lib32/libncurses.so
cp -Rv DESTDIR/usr/lib32/* $LFS/usr/lib32
rm -rf DESTDIR

Details on this package are located in Section 8.31.3, “Contents of Ncurses.”