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

rm -rf $PKG
mkdir -p $PKG
( cd $TMP
rm -rf supertux-$VERSION
tar xjf $CWD/supertux-$VERSION.tar.bz2
cd supertux-$VERSION
./configure \
 --bindir=/usr/local/games/supertux \
 --datarootdir=/usr/local/games \
 $TARGET
jam || exit
echo 'DESTDIR ?= "/tmp/package-supertux" ;' >> Jamconfig
jam install
( cd $PKG/usr/local/games ; mv applications doc pixmaps supertux )
( 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 -g 2> /dev/null
)
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/supertux-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/supertux.build.log
