#!/bin/sh
### written by Mario Stabrey <mstabrey@alphaslack.de>
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-mplayer
VERSION=20070112
ARCH=alpha
BUILD=2

rm -rf $PKG
mkdir -p $PKG
( cd $TMP
rm -rf mplayer
tar xjf $CWD/mplayer-$VERSION.tar.bz2
cd mplayer
mkdir -p $PKG/usr/doc/MPlayer-$VERSION
cp -a AUTHORS ChangeLog Copyright LICENSE README $PKG/usr/doc/MPlayer-$VERSION
chown -R root.root $PKG/usr/doc/MPlayer-$VERSION
./configure \
 --prefix=/usr \
 --enable-dynamic-plugins \
 --enable-menu \
 --enable-xmms \
 --enable-gui \
 --enable-gtk1 \
 --disable-smb \
 --codecsdir=/usr/lib/mplayer \
 --realcodecsdir=/usr/lib/mplayer \
 --xanimcodecsdir=/usr/lib/mplayer
make || exit
make DESTDIR=$PKG install
cp -a etc/codecs.conf etc/example.conf etc/input.conf etc/menu.conf $PKG/usr/etc/mplayer
gzip -9 $PKG/usr/man/man?/*.?
rm -rf $PKG/usr/man/man1/*.1
#( cd $PKG ; mv usr/share/doc/* usr/doc ; rm -rf usr/share/doc )
( cd $PKG/usr/man/man1 ; ln -sf mplayer.1.gz mencoder.1.gz )
( cd $PKG
 find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded
 find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded
)
chmod 755 $PKG/usr/lib/mplayer/vidix/*
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/mplayer-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/mplayer.build.log
