#!/bin/sh
# Heavily based on the Slackware 12.1 SlackBuild
# http://sourceforge.net/projects/linscope/
# Packager Gohanz ( gohanz@infinito.it )
# http://www.slacky.it

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-linscope
NAME=Linscope
VERSION=0.3.2
ARCH=${ARCH:-i486}
BUILD=2as

if [ ! -d $TMP ]; then
 mkdir -p $TMP
fi
if [ ! -d $PKG ]; then
 mkdir -p $PKG
fi

cd $TMP
tar xvzf $CWD/linscope-$VERSION.tar.gz
cd $NAME/linscope

qmake
sed -i "s|-O2|-O2 -march=i486 -mtune=i686|g" Makefile
make

mkdir -p $PKG/usr/bin
mkdir -p $PKG/usr/share/applications

cd    $TMP/$NAME/linscope/
cp -a linscope lrpcscanip $PKG/usr/bin
cp $CWD/linscope.desktop $PKG/usr/share/applications

strip $PKG/usr/bin/linscope

mkdir -p $PKG/usr/doc/$NAME-$VERSION
cd    $TMP/$NAME
cp -a  *.TXT $PKG/usr/doc/$NAME-$VERSION

cd $CWD
cp -a *.SlackBuild slack-desc $PKG/usr/doc/$NAME-$VERSION

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
chown -R root:root .
requiredbuilder -v -y -s $CWD $PKG
makepkg -l y -c n $CWD/linscope-$VERSION-$ARCH-$BUILD.tgz

if [ "$1" = "--cleanup" ]; then
  rm -rf $TMP
fi
