#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-gaim
VERSION=1.5.0
GAIMENC=2.39
ARCH=alpha
BUILD=2
TARGET=$ARCH-alphaslack-linux

rm -rf $PKG
mkdir -p $PKG
( cd $TMP
rm -rf gaim-$VERSION
tar xjf $CWD/gaim-$VERSION.tar.bz2
cd gaim-$VERSION
chown -R root.root .
./configure \
 --prefix=/usr \
 --with-nspr-includes=/usr/include/seamonkey-1.1/nspr \
 --with-nspr-libs=/usr/lib/seamonkey-1.1 \
 --with-nss-includes=/usr/include/seamonkey-1.1/nss \
 --with-nss-libs=/usr/lib/seamonkey-1.1 \
 --program-prefix="" \
 --program-suffix="" \
 $TARGET
make -s || exit
make install DESTDIR=$PKG
#make install #needed by gaim-encryption

### add gaim-encryption
( cd $TMP
rm -rf gaim-encryption-$GAIMENC
tar xzf $CWD/gaim-encryption-$GAIMENC.tar.gz
cd gaim-encryption-$GAIMENC
./configure \
 --prefix=/usr \
 --disable-static \
 --with-nspr-includes=/usr/include/seamonkey-1.1/nspr \
 --with-nspr-libs=/usr/lib/seamonkey-1.1 \
 --with-nss-includes=/usr/include/seamonkey-1.1/nss \
 --with-nss-libs=/usr/lib/seamonkey-1.1 \
 --program-prefix="" \
 --program-suffix="" \
 $TARGET
make -s || exit
make install DESTDIR=$PKG )

### end add gaim-encryption
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
)
mkdir -p $PKG/usr/lib/perl5/5.8.8/alpha-alphaslack-linux $PKG/usr/man/man3
( cd $PKG
  find . -name perllocal.pod | xargs rm -f
  mv auto Gaim.pm $PKG/usr/lib/perl5/5.8.8/alpha-alphaslack-linux
  mv Gaim.3 $PKG/usr/man/man3
)
mkdir -p $PKG/usr/doc/gaim-$VERSION
cp -a ABOUT-NLS AUTHORS COPYING ChangeLog HACKING NEWS README doc/FAQ doc/CREDITS $PKG/usr/doc/gaim-$VERSION
chmod 644 $PKG/usr/doc/gaim-$VERSION/*
gzip -9 $PKG/usr/man/man?/*.?
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n ../gaim-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee /tmp/gaim.build.log
