#!/bin/sh
# Heavily based on the Slackware 12.1 SlackBuild
# http://flac-tools.sourceforge.net/
# Packager baldelario ~at~ gmail ~dot~ com
# http://www.slacky.it

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-flac123
rm -rf $PKG
mkdir -p $PKG

NAME=flac123
VERSION=0.0.11
ARCH=${ARCH:-i486}
BUILD=2bj

echo "| Start SlackBuild $NAME-$VERSION |"

cd $TMP
rm -rf $NAME-$VERSION
tar xzvf $CWD/$NAME-$VERSION.tar.gz
cd $NAME-$VERSION
chown -R root:root .

./configure --prefix=/usr
make CFLAGS="-O2 -march=i486 -mtune=i686"
make install DESTDIR=$PKG
strip $PKG/usr/bin/*

mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a \
  AUTHORS ChangeLog COPYING README* BUGS NEWS INSTALL \
  $PKG/usr/doc/$NAME-$VERSION

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/slack-desc > $PKG/usr/doc/$NAME-$VERSION/slack-desc
cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/$NAME.SlackBuild
cd $PKG
requiredbuilder -y -v -s $CWD $PKG
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz

if [ "$1" = "--cleanup" ]; then
  rm -rf $TMP/$NAME-$VERSION
  rm -rf $PKG
fi
