#!/bin/sh
# CUPS build script by volkerdi@slackware.com.

PKGNAM=cups32
VERSION=1.3.9
BUILD=${BUILD:-1}

. /etc/pkghelpers
pkghelpers_env
export MULTILIB=false

rm -rf $PKG
mkdir -p $PKG

cd $TMP
rm -rf cups-$VERSION
tar xjvf $CWD/cups-$VERSION-source.tar.bz2 || exit 1
cd cups-$VERSION

pkghelpers_permissions

./configure \
  --prefix=/usr \
	--enable-32bit \
	--enable-64bit=no \
	--without-dbus \
	--without-perl \
	--without-python \
	--without-java \
        --libdir=/usr/lib \
  --enable-ssl \
  --enable-openssl=yes \
  --enable-gnutls=no \
  --enable-cdsassl=no \
  --without-php \
  --disable-pam \
  --build=$ARCH-$DISTRO-linux

make -j5 || exit 1
make BUILDROOT=$PKG install || exit 1

rm -rf $PKG/usr/{bin,etc,include,lib/cups,man,sbin,share,var}
rm -rf $PKG/etc

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

# Strip stuff:
( 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
)

# Build the package:
cd $PKG
pkghelpers_fixup
pkghelpers_makepkg