#!/bin/sh
# Set initial variables:

PKGNAM=gutenprint
VERSION=5.0.0
BUILD=${BUILD:-2}

. /etc/pkghelpers
pkghelpers_env

rm -rf $PKG
mkdir -p $PKG

cd $TMP
rm -rf gutenprint-${VERSION}
tar xjvf $CWD/gutenprint-${VERSION}.tar.bz2
cd gutenprint-${VERSION}

chown -R root:root .
find . -perm 666 -exec chmod 644 {} \;
find . -perm 664 -exec chmod 644 {} \;
find . -perm 600 -exec chmod 644 {} \;
find . -perm 444 -exec chmod 644 {} \;
find . -perm 400 -exec chmod 644 {} \;
find . -perm 440 -exec chmod 644 {} \;
find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 511 -exec chmod 755 {} \;
find . -perm 711 -exec chmod 755 {} \;
find . -perm 555 -exec chmod 755 {} \;
find . -perm 777 -exec chmod 755 {} \;

CFLAGS="-O2 -fPIC" \
./configure --prefix=/usr \
  --libdir=/usr/lib$LIBSUFFIX \
  --infodir=/usr/info \
  --mandir=/usr/man \
  --with-cups \
  --with-gimp2 \
  --with-gimp2-as-gutenprint \
  --enable-escputil \
  --disable-nls \
  $ARCH-$DISTRO-linux
make -j12 || exit 1
make install DESTDIR=$PKG || exit 1

mkdir -p $PKG/usr/doc/gutenprint-${VERSION}
# If you want 1MB of ChangeLog, it's in the source...
cp -a \
  ABOUT-NLS AUTHORS COPYING INSTALL NEWS README \
  $PKG/usr/doc/gutenprint-${VERSION}
  ( cd $PKG/usr/doc/gutenprint-${VERSION}
    ln -sf /usr/share/gutenprint/doc .
    ln -sf /usr/share/gutenprint/samples .
  )

# Big...  again, it's in the source if you want it.
rm -f $PKG/usr/share/gutenprint/doc/*.pdf

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

cd $PKG
pkghelpers_fixup
pkghelpers_makepkg
