#
# source: http://ftp.gnome.org/pub/gnome/sources/atk/2.2/atk-2.2.0.tar.xz
#

CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-atk
rm -rf $PKG
mkdir -p $PKG/usr

VERSION=2.2.0
ARCH=i486
BUILD=72.1

SLKCFLAGS="-O2 -march=i486 -mtune=i686"

cd $TMP
rm -rf atk-$VERSION
tar xvf $CWD/atk-$VERSION.tar.xz
cd atk-$VERSION
chown -R root:root .
find . \
 \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
 -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
 -exec chmod 644 {} \;
find . -perm 664 -exec chmod 644 {} \;
CFLAGS="$SLKCFLAGS" \
./configure \
      --prefix=/usr \
      --sysconfdir=/etc
      
make -j6
make install DESTDIR=$PKG

find $PKG | xargs file | grep -e "shared object" -e "executable" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

mkdir -p $PKG/usr/doc/atk-$VERSION
cp -a \
  AUTHORS ChangeLog COPYING NEWS INSTALL README \
  $PKG/usr/doc/atk-$VERSION

mkdir -p $PKG/usr/src/atk-$VERSION
cp $CWD/build-atk.sh $PKG/usr/src/atk-$VERSION

mkdir -p $PKG/install
cat <<"EOF" > $PKG/install/slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.  Line
# up the first '|' above the ':' following the base package name, and the '|' on
# the right side marks the last column you can put a character in.  You must make
# exactly 11 lines for the formatting to be correct.  It's also customary to
# leave one space after the ':'.

   |-----handy-ruler--------------------------------------------------------|
atk: atk - is the Accessibility Toolkit
atk:
atk: atk is a library of accessibility functions that is used by the GTK+-2
atk: toolkit.
atk:
atk:
atk:
atk:
atk:
atk:
atk:
EOF

cd $TMP/package-atk
makepkg -l y -c n ../atk-$VERSION-$ARCH-$BUILD.txz

cd ..
md5sum atk-$VERSION-$ARCH-$BUILD.txz > atk-$VERSION-$ARCH-$BUILD.md5
