#!/bin/sh
# Set initial variables:
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-gimp-print
VERSION=4.2.7
ARCH=alpha
BUILD=2
TARGET=$ARCH-alphaslack-linux

# Let GIMP use the plug-in it comes with or it's a messy dependancy.
# This comes with some ghostscript patches that already seem to be
# built into ghostscript now :-)

rm -rf $PKG
mkdir -p $PKG
( cd $TMP
rm -rf gimp-print-$VERSION
tar xjf $CWD/gimp-print-$VERSION.tar.bz2
cd gimp-print-$VERSION
chown -R root.root .
find . -perm 777 -exec chmod 755 {} \;
./configure --prefix=/usr \
 --infodir=/usr/info \
 --with-ijs \
 --with-cups \
 --without-gimp \
 --without-samples \
 --without-user-guide \
 --enable-escputil \
 --disable-nls \
 $TARGET
make || exit
make install DESTDIR=$PKG
chown -R root.bin $PKG/usr/bin
( cd $PKG
 find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
 find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
)
rm -rf $PKG/usr/lib/gimp
rm -rf $PKG/usr/info/dir
gzip -9 $PKG/usr/info/*
gzip -9 $PKG/usr/man/man?/*
mkdir -p $PKG/usr/doc/gimp-print-$VERSION
cp -a ABOUT-NLS AUTHORS COPYING NEWS README $PKG/usr/doc/gimp-print-$VERSION
cp -a src/ghost/README $PKG/usr/doc/gimp-print-$VERSION/README.ghostscript
rm -rf $PKG/usr/share/gimp-print/
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n ../gimp-print-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/gimp-print.build.log
