#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-time
VERSION=1.7
ARCH=alpha
BUILD=1
TARGET=$ARCH-alphaslack-linux

rm -rf $PKG
mkdir -p $PKG
( cd $TMP
rm -rf time-$VERSION
tar xzf $CWD/time-$VERSION.tar.gz
cd time-$VERSION
cat $CWD/resuse.h.diff | patch -p0 --verbose || exit
./configure \
 --prefix=/usr \
 --build=$TARGET
make -j 2 || exit
mkdir -p $PKG/usr/bin
cat time > $PKG/usr/bin/time
chmod 755 $PKG/usr/bin/time
mkdir -p $PKG/usr/info
cat time.info | gzip -9c > $PKG/usr/info/time.info.gz
mkdir -p $PKG/usr/doc/time-$VERSION
cp -a AUTHORS COPYING NEWS README $PKG/usr/doc/time-$VERSION
( cd $PKG
 find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
 find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
)
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/time-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/time.build.log
