#!/bin/bash

# imlib is needed by slaxsetroot

NAME=imlib2-1.4.4
PKG=$NAME.tar.gz
BUILD=1

# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) export ARCH=i486 ;;
    arm*) export ARCH=arm ;;
    # Unless $ARCH is already set, use uname -m for all other archs:
       *) export ARCH=$( uname -m ) ;;
  esac
fi

LIB=
if [ "$ARCH" = "x86_64" ]; then
   LIB=64
fi

rm -Rf /tmp/package-$NAME
rm -Rf /tmp/$NAME
tar -C /tmp/ -xf $PKG
cd /tmp/$NAME

./configure \
  --enable-static=no \
  --enable-mmx=no \
  --enable-amd64=no \
  --without-gif \
  --without-id3 \
  --build=$ARCH-slackware-linux \
  --prefix=/usr \
  --libdir=/usr/lib$LIB

make
make install DESTDIR=/tmp/package-$NAME
cd /tmp/package-$NAME
find | xargs strip --strip-unneeded
rm -Rf usr/share/imlib2/data/images
/sbin/makepkg -l y -c n /tmp/$NAME-$ARCH-$BUILD.txz