#!/bin/sh
# Set initial variables:
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-tcsh
VERSION=6.13.00
ARCH=alpha
BUILD=2
TARGET=$ARCH-alphaslack-linux

mkdir -p $PKG
( cd $TMP
tar xjf $CWD/tcsh-$VERSION.tar.bz2
cd tcsh-$VERSION
chown -R root.root .
mkdir -p $PKG/usr/doc/tcsh-$VERSION
cp -a FAQ Fixes NewThings Ported README README.imake WishList Y2K $PKG/usr/doc/tcsh-$VERSION
chmod 644 $PKG/usr/doc/tcsh-$VERSION/*
./configure --prefix=  $TARGET
make
mkdir -p $PKG/etc
mkdir -p $PKG/bin
cat tcsh > $PKG/bin/tcsh
chmod 755 $PKG/bin/tcsh
chown -R root.bin $PKG/bin
mkdir -p $PKG/usr/man/man1
cat tcsh.man | gzip -9c > $PKG/usr/man/man1/tcsh.1.gz
echo '.so man1/tcsh.1' | gzip -9c > $PKG/usr/man/man1/csh.1.gz
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
( cd $PKG
  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded
)
cd $PKG
makepkg -l y -c n $TMP/tcsh-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/tcsh.build.log
