#!/bin/sh
#
# source: http://ftp.gnome.org/pub/gnome/sources/libart_lgpl/2.3/libart_lgpl-2.3.21.tar.bz2
#
# maintainer: gmg (monpontet.gerard@neuf.fr)
#

#------------------Set Some Variables

soft='libart_lgpl'
softversion='2.3.21'
packageversion='66.1'

arch='i486'
cpu='i686'

buildir=$(pwd)
srcpkg="$buildir/$soft-$softversion.tar.bz2"
src="$buildir/$soft-$softversion"
package="$soft-$softversion-$arch-$packageversion"
dest="$buildir/$package"

cd $buildir
rm -rf $src
tar -xvjf $srcpkg
rm -f $dest.tgz
rm -rf $dest

cd $src

chown -R root:root .
find . \
 \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
 -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
 -exec chmod 644 {} \;
./configure \
  --prefix=/usr

make -j4
make install DESTDIR=$dest

find $dest | xargs file | grep -e "shared object" -e "executable" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

#-------------------Prepare the documentation

mkdir -p $dest/usr/doc/$soft-$softversion 
cp -a AUTHORS ChangeLog COPYING NEWS README $dest/usr/doc/$soft-$softversion

mkdir -p $dest/install
cat << EODESC > $dest/install/slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.  Line
# up the first '|' above the ':' following the base package name, and the '|'
# on the right side marks the last column you can put a character in.  You must
# make exactly 11 lines for the formatting to be correct.  It's also
# customary to leave one space after the ':'.

           |-----handy-ruler------------------------------------------------------|
libart_lgpl: libart_lgpl -is graphics library
libart_lgpl:
libart_lgpl: Libart is a library for high-performance 2D graphics.  It is used by
libart_lgpl: both KDE and GNOME.  This is the LGPL'd component of the library.
libart_lgpl:
libart_lgpl: Raph Levien <raph@acm.org> is the author of libart.
libart_lgpl:
libart_lgpl:
libart_lgpl:
libart_lgpl:
libart_lgpl:

EODESC

mkdir -p $dest/usr/src/$soft-$softversion
cp -a $buildir/build-$soft.sh $dest/usr/src/$soft-$softversion

#-------------------Make the packages and the md5sum

cd $dest
makepkg -l y -c n $dest.txz
cd $buildir
md5sum $package.txz > $package.md5