#!/bin/sh

CWD=`pwd`

TMP=/tmp

PKGNAME=sdl_sound

PKG=$TMP/$PKGNAME

VERSION=1.0.1
ARCH=i486
BUILD=1chr

export CFLAGS="-O2 -march=i486 -mcpu=i686"
export CXXFLAGS="-O2 -march=i486 -mcpu=i686"


if ! [ -a SDL_sound-$VERSION.tar.gz ] ; then 
wget "http://www.icculus.org/SDL_sound/downloads/SDL_sound-1.0.1.tar.gz"
fi


if [ -a $TMP/SDL_sound-$VERSION ] ; then
   rm -r $TMP/SDL_sound-$VERSION
fi

if [ -a $TMP/SDL_sound-$VERSION.tar.gz ] ; then
   rm -r $TMP/SDL_sound-$VERSION.tar.gz
fi

if [ -a $TMP/$PKGNAME-$VERSION-$ARCH-$BUILD.tgz ] ; then
   rm -r $TMP/$PKGNAME-$VERSION-$ARCH-$BUILD.tgz
fi

if [ -a $PKG  ] ; then
   rm -r $PKG
fi

mkdir -p $PKG

cp SDL_sound-$VERSION.tar.gz $TMP

cd $TMP

tar zxvf SDL_sound-$VERSION.tar.gz

cd SDL_sound-$VERSION

./configure --prefix=/usr --enable-static=no  --disable-smpegtest

make   

make install prefix=$PKG/usr


strip -s $PKG/usr/bin/*

strip --strip-debug $PKG/usr/lib/*

chgrp -R bin $PKG/usr/bin

mkdir -p $PKG/usr/doc/$PKGNAME-$VERSION

cd $TMP/SDL_sound-$VERSION

cp \
 CHANGELOG COPYING CREDITS INSTALL README TODO \
   $PKG/usr/doc/$PKGNAME-$VERSION

chmod 644 $PKG/usr/doc/$PKGNAME-$VERSION/*


mkdir $PKG/install

{ cat  > $PKG/install/slack-desc << END
        |-----handy-ruler------------------------------------------------------|
sdl_sound: SDL_sound-1.0.1 (a library for soundfile decoding)
sdl_sound:
sdl_sound:  SDL_sound is a library that handles the decoding of several popular
sdl_sound: sound file formats, such as .WAV and .MP3. It is meant to make the
sdl_sound: programmer's sound playback tasks simpler. The programmer gives
sdl_sound: SDL_sound a filename, or feeds it data directly from one of many
sdl_sound: sources, and then reads the decoded waveform data back at her 
sdl_sound: leisure.
sdl_sound:  
sdl_sound: smpeg-0.4.4-ixxx-xxxx.tgz is required  
sdl_sound:
END
}


mkdir -p $PKG/usr/src/slackbuilds/$PKGNAME

cat $CWD/SlackBuild > $PKG/usr/src/slackbuilds/$PKGNAME/SlackBuild

chmod 755 $PKG/usr/src/slackbuilds/$PKGNAME/SlackBuild

cd $PKG
 
makepkg -l y -c n $TMP/$PKGNAME-$VERSION-$ARCH-$BUILD.tgz

rm -rf $TMP/SDL_sound-$VERSION
rm -rf $TMP/SDL_sound-$VERSION.tar.gz
rm -rf $PKG
