6.3 Ncurses-6.6

Ncurses 软件包包含用于与终端无关地处理字符屏幕的库。

大致构建时间: 0.4 SBU
所需磁盘空间: 54 MB

6.3.1 安装 Ncurses

首先,运行以下命令在构建宿主上构建 tic 程序。我们将其安装到 $LFS/tools,以便在需要时能在 PATH 中找到它:

mkdir build
pushd build
  ../configure --prefix=$LFS/tools AWK=gawk
  make -C include
  make -C progs tic
  install progs/tic $LFS/tools/bin
popd

准备编译 Ncurses:

./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

新的 configure 选项的含义:

--with-manpage-format=normal

这可以防止 Ncurses 安装压缩的手册页,如果宿主发行版本身带有压缩的手册页,就可能发生这种情况。

--with-shared

这使 Ncurses 构建并安装共享 C 库。

--without-normal

这防止 Ncurses 构建并安装静态 C 库。

--without-debug

这防止 Ncurses 构建并安装调试库。

--with-cxx-shared

这使 Ncurses 构建并安装共享 C++ 绑定。它还防止其构建并安装静态 C++ 绑定。

--without-ada

这确保 Ncurses 不构建对 Ada 编译器的支持,该编译器可能存在于宿主上,但一旦我们进入 chroot 环境后就将不可用。

--disable-stripping

此开关防止构建系统使用宿主上的 strip 程序。在交叉编译的程序上使用宿主工具可能导致失败。

AWK=gawk

此开关防止构建系统使用宿主上的 mawk 程序。某些版本的 mawk 可能导致此软件包构建失败。

编译软件包:

make

安装软件包:

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

安装选项的含义:

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

我们即将构建的几个软件包需要 libncurses.so 库。我们创建此符号链接,以使用 libncursesw.so 作为替代。

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

头文件 curses.h 包含各种 Ncurses 数据结构的定义。 使用不同的预处理器宏定义时,可能会使用两套不同的数据结构定义: 8 位定义与 libncurses.so 兼容,宽字符定义与 libncursesw.so 兼容。由于我们使用 libncursesw.so 替代 libncurses.so,请编辑该头文件, 使其始终使用与 libncursesw.so 兼容的宽字符数据结构定义。

有关此软件包的详细信息位于 第 8.33.2 节,“Ncurses 的内容”。