#!/bin/sh

VERSION=$1

cd $TMP
rm -rf gpm-*

tar xjvf $ORIGPATH/source/gpm-$VERSION.tar.bz2
cd gpm-*

zcat $ORIGPATH/source/gpm_$VERSION-10.diff.gz | patch -p1 --backup --suffix=.orig -E
# This adds #include <time.h> in addition to #include <sys/time.h> per
# recent glibc requirements.
zcat $ORIGPATH/source/gpm-1.19.6.time.diff.gz | patch -p1 --backup --suffix=.orig -E
find . -perm 600 -exec chmod 644 {} \;
find . -perm 700 -exec chmod 755 {} \;
# Nico says the proper way to compile for gpm/ncurses support is:
#   compile ncurses without gpm
#   compile gpm --with-curses
#   compile ncurses --with-gpm
# BTW, I did try gpm-1.20.0, but it produces spurious output on stderr
# totally breaking dialog.  Even after patching that, I noticed more
# quirks using it for a couple of days than I've seen with 1.19.6 with
# all of the patches we apply.  I think it's best to wait until these
# issues are ironed out before upgrading gpm.
CFLAGS="${ARMCFLAGS}" ${ARMCONFIGURE} --prefix=/usr \
            --with-curses \
            --sysconfdir=/etc \


# There are bugs in the docs, so -i work around them :)
make -ei
make install
( cd conf
  install -m644 gpm-root.conf /etc/
  install -m644 gpm-syn.conf /etc/
  install -m644 pm-twiddler.conf /etc/
)
( cd contrib/emacs
  install -m644 t-mouse.el /usr/share/emacs/site-lisp/
)
# This is no longer there, but no big deal.  Emacs'll use the .el.
#cat t-mouse.elc > $PKG/usr/share/emacs/site-lisp/t-mouse.elc
mkdir /usr/doc/gpm-$VERSION
cp -a \
  BUGS COPYING ChangeLog Changes MANIFEST README TODO \
  /usr/doc/gpm-$VERSION

( cd doc
  cp -a \
    Announce FAQ README* gpmdoc.txt \
    /usr/doc/gpm-$VERSION
)

rm -rf ${SLACKTRACKFAKEROOT}/root 

mkdir /install
install -m644 $ORIGPATH/slack-desc /install/

#EOF
