8.39. Ncurses-6.5

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

Approximate build time: 0.2 SBU
Required disk space: 46 MB

8.39.1. Installation of Ncurses

Create the PKGBUILD for the Ncurses package with the following commands:

mkdir /sources/ncurses
cd /sources/ncurses
cat > PKGBUILD << "REALEOF"
# Maintainer: Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>

pkgname="ncurses"
pkgver="6.5"
pkgrel="1"
pkgdesc="The Ncurses package contains libraries for terminal-independent handling of character screens."
arch=('x86'
      'x86_64')
url="https://www.gnu.org/software/ncurses/"
license=('custom'
         'MIT')
groups=('core')
depends=('glibc'
         'rootfs')
makedepends=('bash'
             'binutils'
             'coreutils'
             'diffutils'
             'gawk'
             'gcc'
             'grep'
             'make'
             'patch'
             'sed')
source=('https://invisible-mirror.net/archives/ncurses/ncurses-6.5.tar.gz')
md5sums=('ac2d2629296f04c8537ca706b6977687')
    
build(){
  cd ${pkgname}-${pkgver}
  ./configure --prefix=/usr           \
              --mandir=/usr/share/man \
              --with-shared           \
              --without-debug         \
              --without-normal        \
              --with-cxx-shared       \
              --enable-pc-files       \
              --with-pkg-config-libdir=/usr/lib/pkgconfig
  make
}

package(){
  make DESTDIR="${pkgdir}" install

  # Not strictly necessary, but remove static archives
  rm -v  "${pkgdir}"/usr/lib/{libncursesw.so."${pkgver}",libncurses++w.a}

  # Edit curses.h so that the wide curses library is used
  sed -e 's/^#if.*XOPEN.*$/#if 1/' -i "${pkgdir}/usr/include/curses.h"
  # Create compatibility symlinks for non-wide ncurses
  for lib in ncurses form panel menu ; do
      ln -sfv lib${lib}w.so "${pkgdir}/usr/lib/lib${lib}.so"
      ln -sfv ${lib}w.pc    "${pkgdir}/usr/lib/pkgconfig/${lib}.pc"
  done

  # Same thing for curses intead of ncurses
  ln -sfv libncurses.so "${pkgdir}/usr/lib/libcurses.so"

  # install documentation
  mkdir -v       "${pkgdir}/usr/share/doc/ncurses-${pkgver}"
  cp -v -R doc/* "${pkgdir}/usr/share/doc/ncurses-${pkgver}"
}
REALEOF

The meaning of the new configure options:

--with-shared

This makes Ncurses build and install shared C libraries.

--without-normal

This prevents Ncurses building and installing static C libraries.

--without-debug

This prevents Ncurses 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.

--enable-pc-files

This switch generates and installs .pc files for pkg-config.

Prepare the build directory for the pacman user and build the package:

chown -R root:pacman .
chmod 2775 .
chmod 664 PKGBUILD
su pacman -c 'makepkg -L --nodeps'

Add the newly created package to the central package repository:

cp ncurses-6.5-1-$(uname -m).pkg.tar.xz \
   /srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
         /srv/pacman/repos/LFS/ncurses-6.5-1-$(uname -m).pkg.tar.xz

Update the local cache and install the Ncurses package:

pacman -Syu
pacman -S ncurses --overwrite \* -dd --noconfirm

Finally, copy the source files into the source repository and clean up the build directory:

mkdir /srv/pacman/source/LFS/ncurses
cp PKGBUILD /srv/pacman/source/LFS/ncurses
cd /sources
rm -rf ncurses
[Note]

Note

The instructions above don't create non-wide-character Ncurses libraries since no package installed by compiling from sources would link against them at runtime. However, the only known binary-only applications that link against non-wide-character Ncurses libraries require version 5. If you must have such libraries because of some binary-only application or to be compliant with LSB, build the package again with the following commands:

make distclean
./configure --prefix=/usr    \
            --with-shared    \
            --without-normal \
            --without-debug  \
            --without-cxx-binding \
            --with-abi-version=5
make sources libs
cp -av lib/lib*.so.5* /usr/lib

8.39.2. Contents of Ncurses

Installed programs: captoinfo (link to tic), clear, infocmp, infotocap (link to tic), ncursesw6-config, reset (link to tset), tabs, tic, toe, tput, and tset
Installed libraries: libcurses.so (symlink), libform.so (symlink), libformw.so, libmenu.so (symlink), libmenuw.so, libncurses.so (symlink), libncursesw.so, libncurses++w.so, libpanel.so (symlink), and libpanelw.so,
Installed directories: /usr/share/tabset, /usr/share/terminfo, and /usr/share/doc/ncurses-6.5

Short Descriptions

captoinfo

Converts a termcap description into a terminfo description

clear

Clears the screen, if possible

infocmp

Compares or prints out terminfo descriptions

infotocap

Converts a terminfo description into a termcap description

ncursesw6-config

Provides configuration information for ncurses

reset

Reinitializes a terminal to its default values

tabs

Clears and sets tab stops on a terminal

tic

The terminfo entry-description compiler that translates a terminfo file from source format into the binary format needed for the ncurses library routines [A terminfo file contains information on the capabilities of a certain terminal.]

toe

Lists all available terminal types, giving the primary name and description for each

tput

Makes the values of terminal-dependent capabilities available to the shell; it can also be used to reset or initialize a terminal or report its long name

tset

Can be used to initialize terminals

libncursesw

Contains functions to display text in many complex ways on a terminal screen; a good example of the use of these functions is the menu displayed during the kernel's make menuconfig

libncurses++w

Contains C++ binding for other libraries in this package

libformw

Contains functions to implement forms

libmenuw

Contains functions to implement menus

libpanelw

Contains functions to implement panels