#!/bin/sh
CWD=`pwd`
cd /tmp

VERSION=2.4.4

rm -rf gcl-$VERSION
tar xjvf $CWD/gcl-$VERSION.tar.bz2
cd gcl-$VERSION
chown -R root.root .
CFLAGS=-O ./configure --prefix=/usr \
           --enable-tkconfig=/usr/lib \
           --enable-tclconfig=/usr/lib \
           --enable-infodir=/usr/info

## GCL needs to be static, or it crashes.  There was an attempt to fix this
## in the new sources, but it's not working for me.  I'll keep an eye on any
## new developments.
#for makefile in ./makefile */makefile ; do
#  ( cd `dirname $makefile` ; zcat $CWD/gcl-static.diff.gz | patch -p0 )
#done

make EMACS_SITE_LISP=/usr/share/emacs/site-lisp \
     EMACS_DEFAULT_EL=/usr/share/emacs/site-lisp/default.el

make EMACS_SITE_LISP=/usr/share/emacs/site-lisp \
     EMACS_DEFAULT_EL=/usr/share/emacs/site-lisp/default.el \
     install

#( cd /usr/lib/gcl-$VERSION/info
( cd /usr/lib/gcl-2*/info
  rm texinfo.tex
  gzip -9 --force *.info
  gzip -9 --force *.info-?
  chmod 644 *
  mv * /usr/info 
  cd ..
  rm -r info
  ln -sf /usr/info . )

mkdir -p /install
cat $CWD/slack-desc > /install/slack-desc
# install docs:
mkdir -p /usr/doc/gcl-$VERSION
cp -a \
  COPYING.LIB-2.0 ChangeLog faq machines readme doc \
  /usr/doc/gcl-$VERSION
find /usr/doc/gcl-$VERSION -type f -exec chmod 644 {} \;
echo
echo 'Do not strip the binaries in this package!'
echo
echo 'See inst script example:'
## Add this to doinst.sh before running makepkg:
## patcode(tm):
#if fgrep "GCL TK Doc" usr/info/dir 1> /dev/null 2> /dev/null ; then
#  true
#else
#  cat << EOF >> usr/info/dir
#* GCL Doc: (gcl-si.info).       GNU Common Lisp specific Documentation.
#* GCL TK Doc: (gcl-tk.info).    TK window GCL interface.
#* GCL Ansi Doc: (gcl.info).  Ansi Common Lisp Specification.
#EOF
#fi
## Autogenerated portion begins:

