#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-mplayer
VERSION=20041217
ARCH=alpha
BUILD=2

mkdir -p $PKG
### real codecs ###
( cd $TMP
tar xjf $CWD/rp8codecs-alpha-20040626.tar.bz2
cd rp8codecs-alpha-20040626
mkdir -p $PKG/usr/lib
cp *.so.* /usr/lib
cp *.so.* $PKG/usr/lib

### XVID ###
cd $TMP
tar xjf $CWD/xvidcore-1.0.2.tar.bz2
cd xvidcore-1.0.2/build/generic
./configure --prefix=/usr $ARCH-alphaslack-linux
make
#make install
cp -a =build/libxvidcore.a =build/libxvidcore.so.4.0 $PKG/usr/lib
mkdir -p $PKG/usr/include
cp ../../src/xvid.h $PKG/usr/include

### DIVXdecore ###
cd $TMP
tar xzf $CWD/libdivxdecore-0.4.7.tar.gz
cd libdivxdecore-0.4.7
./configure --prefix=/usr $ARCH-alphaslack-linux
make
#make install
make install DESTDIR=$PKG

### MPlayer ###
cd $TMP
tar xjf $CWD/MPlayer-current.tar.bz2
cd MPlayer-$VERSION
mkdir -p $PKG/usr/doc/MPlayer-$VERSION
cp -a DOCS/tech/* $PKG/usr/doc/MPlayer-$VERSION
chown -R root.root $PKG/usr/doc/MPlayer-$VERSION
./configure \
    --prefix=/usr \
    --enable-dynamic-plugins \
    --enable-shared-pp \
    --enable-menu \
    --enable-xmms \
    --with-reallibdir=/usr/lib \
    --with-xvidlibdir=/usr/lib \
    --with-xvidincdir=/usr/include
make
make install DESTDIR=$PKG
cp libavcodec/libpostproc/libpostproc.so $PKG/usr/lib/libpostproc.so
cp libavcodec/libpostproc/libpostproc.a $PKG/usr/lib/libpostproc.a
cp -a etc/codecs.conf etc/example.conf etc/input.conf etc/menu.conf $PKG/usr/etc/mplayer
gzip -9 $PKG/usr/man/man1/*
rm -rf $PKG/usr/man/man1/*.1
( cd $PKG/usr/man/man1 ; ln -sf mplayer.1.gz mencoder.1.gz )
( cd $PKG/usr/lib ; ln -sf libpostproc.so libpostproc.so.0 )
( 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
