Linux HOWTOs

About | Home | Search


HOWTO: ncurses
Description: CRT screen handling and optimization package
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# GNU Ncurses 6.1 (ncurses = new curses)
# ===============
# Slackware 13.37, 14.0, 14.1, 14.2: ncurses 5.9

# Many other pieces of software can be removed before you install a new
# version with little to no ill-effects, 'make uninstall' the old one, 'make
# install' the new one.  ncurses is so widely used that you may not be able
# to get away with that, without breaking a bunch of things.  Below we blow
# away files that may be left over from old source-installed versions of
# ncurses, ass|u|me'ing that you still have libncurses in /lib or /lib64
# from Slackware's aaa_elflibs package to keep things working that use it.
# If you are not comfortable with that, skip the cleanup part before
# 'make install' below, then either leave it all there and hope for the
# best, or manually clean up files after the new version is installed - 
# look for a date that is other than today.
#
# Loads of console programs like dialog, lynx, mc, mutt, ncftp, joe, vim,
# etc. use ncurses and even things like the Dropbox daemon do, so running
# something like:
#   lsof /lib*/libncurses.* /usr/lib*/libncurses.*
# is not a bad idea, to find out what running programs are using it.

# The home page for Ncurses is https://invisible-island.net/ncurses/
# but the GNU page for it is here:
# https://invisible-island.net/ncurses/

# If you have any trouble downloading Ncurses from gnu.org, you can
# also get it here:
# ftp://ftp.invisible-island.net/ncurses/

# Release notes

# Mailing list announcement of 6.1

# Prerequisites:
# pkg-config
# ctags

# Due to the number of patches, create a directory for the ncurses tarball
# and patches, move the tarball and patches into it (if you previously had
# any of them):
mkdir -p -m 0700 ~/installed/ncurses
( cd ~/installed
  mv -f ncurses-6.1.tar.gz ncurses-*.patch.gz \
   ncurses-*-patch.sh.bz2 ncurses/ 2> /dev/null )

# Get it
cd
test -f installed/ncurses/ncurses-6.1.tar.gz &&
 mv installed/ncurses/ncurses-6.1.tar.gz .
test ! -f ncurses-6.1.tar.gz &&
 wget http://ftpmirror.gnu.org/ncurses/ncurses-6.1.tar.gz

# Verify tarball w/ sha1sum:
# (this came from my gpg-verified tarball)
echo "57acf6bc24cacd651d82541929f726f4def780cc  ncurses-6.1.tar.gz" | \
sha1sum -c

# Verify tarball w/ sha256sum:
# (this also came from my gpg-verified tarball)
echo "aa057eeeb4a14d470101eff4597d5833dcef5965331be3528c08d99cebaa0d17  n\
curses-6.1.tar.gz" | sha256sum -c

# Verify tarball w/ gpg:
( gpg --list-keys F7E48EDB > /dev/null 2>&1 || gpg --recv-keys F7E48EDB ) &&
 wget -nc http://ftpmirror.gnu.org/ncurses/ncurses-6.1.tar.gz.sig &&
  gpg --verify ncurses-6.1.tar.gz.sig && rm ncurses-6.1.tar.gz.sig

# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "ncurses-*" -exec rm -r {} \;
tar xzvf ~/ncurses-6.1.tar.gz
cd ncurses-6.1
test $UID = 0 && chown -R root:root .

### [ No roll-up patch this time so far ]
## Patch it with the latest roll-up patch:
#test -f ~/installed/ncurses/ncurses-6.1-2018xxxx-patch.sh.bz2 &&
# mv ~/installed/ncurses/ncurses-6.1-2018xxxx-patch.sh.bz2 .
#test ! -f ncurses-6.1-2018xxxx-patch.sh.bz2 &&
# wget -nc ftp://ftp.invisible-island.net/ncurses/6.1/\
#ncurses-6.1-2018xxxx-patch.sh.bz2
#rm -f ~/installed/ncurses/ncurses-*-patch.sh.*
#bunzip2 -k ./ncurses-6.1-2018xxxx-patch.sh.bz2 &&
# mv ./ncurses-6.1-2018xxxx-patch.sh.bz2 ~/installed/ncurses/
#sh ./ncurses-6.1-2018xxxx-patch.sh &&
# rm ./ncurses-6.1-2018xxxx-patch.sh

# gpg-verify, then apply patches that have come out since the full release
# if there is one, the latest rollout patch:
# [ NOTE: I had to manually apply one rejected hunk (?) in 20180609 ]
gpg --list-keys F7E48EDB > /dev/null 2>&1 || gpg --recv-keys F7E48EDB
mv -f ~/installed/ncurses/ncurses-6.1-*.patch.gz .
rm -f ~/installed/ncurses/ncurses-*.patch.gz
wget -N http://invisible-mirror.net/archives/ncurses/6.1/dev-patches.zip
unzip -n dev-patches.zip
chmod u+w ncurses-6.1-*.patch.gz*
for file in ncurses-6.1-*.patch.gz;
do
  test -f ${file}.asc && gpg --verify ${file}.asc && rm ${file}.asc
  zcat $file | patch -p1 -N && mv -f $file ~/installed/ncurses/
  echo "Hit enter to continue"
  read
done

# Configure build #1 (libncurses.so.*) for 64-bit
test $(uname -m) = 'x86_64' && LIBDIR=lib64 &&
CFLAGS="-O2 -fPIC" ./configure --prefix=/usr --libdir=/usr/${LIBDIR} \
--mandir=/usr/man --without-ada \
--with-pkg-config-libdir=/usr/${LIBDIR}/pkgconfig \
--enable-pc-files --with-shared --without-normal --without-debug \
--disable-overwrite --enable-symlinks --enable-hard-tabs --with-cxx-shared \
--enable-xmc-glitch --enable-colorfgbg --with-ospeed=unsigned \
--with-termlib=tinfo --with-ticlib=tic \
--with-chtype=long --with-mmask-t=long

# Configure build #1 (libncurses.so.*) for anything else
test $(uname -m) != 'x86_64' && LIBDIR=lib &&
CFLAGS="-O2" ./configure --prefix=/usr --libdir=/usr/${LIBDIR} \
--mandir=/usr/man --without-ada \
--with-pkg-config-libdir=/usr/${LIBDIR}/pkgconfig \
--enable-pc-files --with-shared --without-normal --without-debug \
--disable-overwrite --enable-symlinks --enable-hard-tabs --with-cxx-shared \
--enable-xmc-glitch --enable-colorfgbg --with-ospeed=unsigned \
--with-termlib=tinfo --with-ticlib=tic

# Build it
make

# Become root to clean up old files and to install it
su

# Remove Slackware package, if there is one
test -x /sbin/removepkg && /sbin/removepkg ncurses

# Remove files from old source-installed versions.
# We do not mess with Slackware package libncurses or aaa_elflibs /lib*/
# files here.
( cd /usr/bin ; rm -f clear infocmp ncurses5-config ncursesw5-config \
  ncurses6-config ncursesw6-config tabs tic toe tput tset )
find /usr/doc -maxdepth 1 -type d -name "ncurses-*" -exec rm -r {} \;
find /usr/include -type l -ilname "ncurses/*" -exec rm -r {} \;
test -d /usr/include/ncurses && rm -r /usr/include/ncurses
for lib in libform libformw libmenu libmenuw libncurses++ libncurses++w \
libncurses libncursesw libpanel libpanelw;
do
  ( cd /usr/lib ; rm -f "${lib}.*" )
  test -d /usr/lib64 && ( cd /usr/lib64 ; rm -f "${lib}.*" )
done
test -L /usr/include/ncursesw &&
 rm -f /usr/include/ncursesw

# If you have a termcap.h from the libtermcap package and you want to move
# it out of the way for the one from ncurses:
grep -q usr/include/termcap.h /var/adm/packages/libtermcap* &&
 test ! -L /usr/include/termcap.h &&
  mv -f /usr/include/termcap.h /usr/include/termcap.h.orig

# Install the new version
make install

# Create symlinks from the *.h files in /usr/include/ncurses/
# to /usr/include
( cd /usr/include
  for file in ncurses/*.h ; do ln -sf $file . ; done )

# Become yourself again (to rebuild it)
exit

# Clean the previous build files
make clean

# Configure build #2 (libncursesw.so.*) for 64-bit
test $(uname -m) = 'x86_64' && LIBDIR=lib64 &&
CFLAGS="-O2 -fPIC" ./configure --prefix=/usr --libdir=/usr/${LIBDIR} \
--mandir=/usr/man --without-ada \
--with-pkg-config-libdir=/usr/${LIBDIR}/pkgconfig \
--enable-pc-files --with-shared --without-normal --without-debug \
--disable-overwrite --enable-symlinks --enable-hard-tabs --with-cxx-shared \
--enable-xmc-glitch --enable-colorfgbg --with-ospeed=unsigned \
--with-termlib=tinfo --with-ticlib=tic \
--with-chtype=long --with-mmask-t=long --enable-widec

# Configure build #2 (libncursesw.so.*) for anything else
test $(uname -m) != 'x86_64' && LIBDIR=lib &&
CFLAGS="-O2" ./configure --prefix=/usr --libdir=/usr/${LIBDIR} \
--mandir=/usr/man --without-ada \
--with-pkg-config-libdir=/usr/${LIBDIR}/pkgconfig \
--enable-pc-files --with-shared --without-normal --without-debug \
--disable-overwrite --enable-symlinks --enable-hard-tabs --with-cxx-shared \
--enable-xmc-glitch --enable-colorfgbg --with-ospeed=unsigned \
--with-termlib=tinfo --with-ticlib=tic --enable-widec

# Re-build it
make

# Become root to install it
su

# Install the 'w' version of everything
# It will just install the same man pages, /usr/share/terminfo files...
make install

# If you're really low on drive space, I'm pretty sure you could zap
# /usr/include/ncursesw and symlink from /usr/include/ncurses to that

# Move libncurses library files into /lib*/, fix up symlinks to make sure
# all is well
( cd /usr/${LIBDIR}
  rm -f libcurses.so libcursesw.so libncurses.so libncursesw.so
  mv -f libncurses.so.* /${LIBDIR}/
  mv -f libncursesw.so.* /${LIBDIR}/
  ln -sf /${LIBDIR}/libncurses.so.6
  ln -sf /${LIBDIR}/libncurses.so.6 libncurses.so
  ln -sf /${LIBDIR}/libncursesw.so.6
  ln -sf /${LIBDIR}/libncursesw.so.6 libncursesw.so
  test -L /${LIBDIR}/libncurses.so.5 && ln -sf /${LIBDIR}/libncurses.so.5 )

( cd /${LIBDIR}
  rm -f libncurses.so libncurses.so.6 libncursesw.so libncursesw.so.6
  ln -sf libncurses.so.6.1 libncurses.so.6
  ln -sf libncurses.so.6 libncurses.so
  ln -sf libncursesw.so.6.1 libncursesw.so.6
  ln -sf libncursesw.so.6 libncursesw.so
  ln -sf libncurses.so libcurses.so
  ln -sf libncursesw.so libcursesw.so )

# If you want things looking for -lcurses (no "n") to work
echo "INPUT(-lncurses)" > /usr/${LIBDIR}/libcurses.so
echo "INPUT(-lncursesw)" > /usr/${LIBDIR}/libcursesw.so

# Make sure the linker can see the libraries
ldconfig

# Unset the temporary lib or lib64
unset LIBDIR

# ncurses has a 'clear' and the textutils package has a 'clear'.  The latter
# is a shell script that runs 'tput clear'.  textutils, fileutils, and
# sh-utils became coreutils, and there was no clear in Slackware's coreutils
# last time I checked.

# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .

# Become yourself again
exit

# Save the tarball for later
cd
mkdir -p -m 0700 installed
rm -f installed/ncurses-*.tar.* installed/ncurses/ncurses-*.tar.*
mv ncurses-6.1.tar.gz installed/ncurses/

Back to the list


Last updated: Wed, 29 Apr 2020 22:04:50 -0400
Jason Englander <jason at englanders dot us>