#!/bin/sh

CWD=`pwd`

TMP=/tmp

PKGNAME=gtkglext

PKG=$TMP/$PKGNAME

VERSION=1.0.6
ARCH=i486
BUILD=1chr

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


if ! [ -a $PKGNAME-$VERSION.tar.bz2 ] ; then 
wget "http://umn.dl.sourceforge.net/sourceforge/gtkglext/gtkglext-1.0.6.tar.bz2"
fi


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

if [ -a $TMP/$PKGNAME-$VERSION.tar.bz2 ] ; then
   rm -r $TMP/$PKGNAME-$VERSION.tar.bz2
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 $PKGNAME-$VERSION.tar.bz2 $TMP

cd $TMP

tar jxvf $PKGNAME-$VERSION.tar.bz2

cd $PKGNAME-$VERSION

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

make   

make install prefix=$PKG/usr


strip -s $PKG/usr/bin/*

chgrp -R bin $PKG/usr/bin

gzip $PKG/usr/man/man6/*

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

cd $TMP/$PKGNAME-$VERSION

cp \
 AUTHORS COPYING* ChangeLog* INSTALL NEWS 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------------------------------------------------------|
gtkglext: gtkglext-1-0-6 (an OpenGL extension to GTK+ 2.0 or later)
gtkglext:
gtkglext:  Gtkglext provides additional GDK objects which support OpenGL
gtkglext: rendering in GTK+, and GtkWidget API add-ons to make GTK+ widgets
gtkglext: OpenGL-capable.
gtkglext:
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/$PKGNAME-$VERSION
rm -rf $TMP/$PKGNAME-$VERSION.tar.bz2
rm -rf $PKG
