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

VERSION=5.3
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

compile() {
   tar -zxvf $CWD/ncurses-$VERSION.tar.gz
   cd ncurses-$VERSION
   chown -R root.root .

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

install() {
   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
     for file in curses eti form menu ncurses ncurses_dll panel term termcap unctrl ; do
       mv $file.h ncurses
     done
     for file in curses eti form menu ncurses ncurses_dll panel term unctrl ; do
      ln -sf ncurses/$file.h .
    done
   )

   mkdir /package-ncurses/lib
   ( cd /package-ncurses/usr/lib
     mv libncurses.so.5* /package-ncurses/lib
     rm -rf libcurses.so  ; ln -sf libncurses.so libcurses.so
     rm -rf libncurses.so ; ln -sf /lib/libncurses.so.5 libncurses.so
   )

   # Thomas Dickey wrote to ask Pat why we do 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
}

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
   find $PKG/package-ncurses/usr/doc -type f | xargs chmod 444
}

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
}

