#!/bin/sh
# Set initial variables:
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-gimp-print
VERSION=4.2.7
ARCH=alpha
BUILD=1
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 :-)

mkdir -p $PKG
( cd $TMP
tar xzf $CWD/gimp-print-${VERSION}.tar.gz
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-static \
  --disable-nls \
  $TARGET
make
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
rmdir $PKG/usr/share/gimp-print/samples/
rmdir $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
