IGNOREPATH=/etc:/home:/var:/dev:/boot:/root:/tmp:/usr/local:/usr/lib:/bin:/sbin:/mnt:/usr/src
STRIPLIB=y
STRIPBIN=y

VERSION=5.4
PROGNAME="ncurses library $VERSION"
DESC="\
The ncurses (new curses) library is a free software emulation of        \n\
curses in System V Release 4.0, and more.  It uses the terminfo format, \n\
supports pads and color and multiple highlights and forms characters    \n\
and function-key mapping, and has all the other SYSV-curses             \n\
enhancements over BSD curses."

BUILD=1
MAINTAINER="Mark Post <mark.post@eds.com>"
SOURCE=ftp://ftp.gnu.org/gnu/ncurses
PKGNAME=ncurses-$VERSION-s390-$BUILD
TAG=REC

ncurses_configure() {
./configure \
  --prefix=/usr \
  --without-gpm \
  --disable-termcap \
  --with-normal \
  --with-shared \
  --enable-symlinks \
  --without-debug \
  --without-profile \
  --without-ada \
  --program-prefix="" \
  $WIDEC \
  --build=s390-slackware-linux \
  --host=s390-slackware-linux \
  --target=s390-slackware-linux
}

compile() {
   tar -zxvf $CWD/ncurses-$VERSION.tar.gz
   cd ncurses-$VERSION
   chown -R root.root .
   if [ -f Makefile ]; then
     make clean
   fi
   ncurses_configure
   make
}

install() {
   make install DESTDIR=/package-ncurses
   # Build/install again with wide character support:
   make clean
   WIDEC=--enable-widec
   ncurses_configure
   make
   make install DESTDIR=/package-ncurses

   mkdir -p /package-ncurses/usr/doc/ncurses-$VERSION
   cp -a ANNOUNCE INSTALL MANIFEST NEWS README* TO-DO \
       /package-ncurses/usr/doc/ncurses-$VERSION
   mkdir -p /package-ncurses/usr/doc/ncurses-$VERSION/c++
   cp -a c++/NEWS c++/PROBLEMS c++/README-first \
       /package-ncurses/usr/doc/ncurses-$VERSION/c++/

   ( cd /package-ncurses/usr/man/man1
     gzip -9f tack.1
   )

   ( cd /package-ncurses/usr/include
     rm -rf ncurses
     mkdir ncurses
     mv *.h ncurses
     for file in ncurses/* ; do
      ln -sf $file .
    done
    # This shouldn't clobber the real one:
    rm termcap.h
   )

   mkdir /package-ncurses/lib
   ( cd /package-ncurses/usr/lib
     mv libncurses.so.5* /package-ncurses/lib
     mv libncursesw.so.5* /package-ncurses/lib
     rm -f libncurses.so ; ln -sf /lib/libncurses.so.5 libncurses.so
     rm -f libncursesw.so ; ln -sf /lib/libncursesw.so.5 libncursesw.so
     # Olde obsolete names, just in case
     rm -f libcurses.so ; ln -sf libncurses.so libcurses.so
     rm -f libcursesw.so ; ln -sf libncursesw.so libcursesw.so
   )

   # Thomas Dickey wrote to ask Pat why he does this, since --enable-symlinks already
   # makes symlinks.  This was about a year ago, 1/2001 or so, and at the time Pat
   # couldn't remember. :)  Well, now he does, so he'll document it here.  It's so that the
   # symlinks are all freshly created so his package scanning scripts find all the links.
   # If any of them already existed, they might not be picked up.
#  ( cd / ; sh $CWD/terminfo.link.sh )
   # Note, we don't need to worry about this, since we're installing into the
   # /package-ncurses hierarchy, and all symlinks will be "fresh."

   # Fix the xterm entries:
   if [ -r /usr/X11R6/lib/X11/etc/xterm.terminfo ]; then
     tic -o /package-ncurses/usr/share/terminfo/ /usr/X11R6/lib/X11/etc/xterm.terminfo
   else
     echo "WARNING: /usr/X11R6/lib/X11/etc/xterm.terminfo not found"
     sleep 470
   fi

   # Update screen entries:
   tic -o /package-ncurses/usr/share/terminfo/ $CWD/screeninfo.src

   # Update rxvt entries:
   tic -o /package-ncurses/usr/share/terminfo/ $CWD/rxvt.terminfo

   # Update Eterm entry:
   tic -o /package-ncurses/usr/share/terminfo/ $CWD/Eterm.ti
}

attributes() {
   chown -R root.bin $PKG/package-ncurses/usr/bin/
   chmod 755 $PKG/package-ncurses/lib/libncurses* \
             $PKG/package-ncurses/usr/lib/*.so*
   chmod 644 $PKG/package-ncurses/usr/lib/libncurses++.a \
             $PKG/package-ncurses/usr/lib/libncurses++w.a
}

special() {
   cd $PKG
   mv package-ncurses/* ./
   rmdir package-ncurses

   cd $CTL
   cat $CWD/slack-desc > slack-desc

   sed -e 's%package-ncurses/%%g' doinst.sh > doinst.sh.new
   cat doinst.sh.new > doinst.sh
   rm -rf doinst.sh.new
}

