#!/bin/sh
# Build "links" for AlphaSlack by <masta@alphaslack.de>
# Set initial variables:
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-links
VERSION=2.1pre15
ARCH=alpha
BUILD=2
TARGET=$ARCH-alphaslack-linux

mkdir -p $PKG
( cd $TMP
rm -rf links-$VERSION
tar xjf $CWD/links-$VERSION.tar.bz2
cd links-$VERSION
chown -R root.root .
# We are configuring this without X as there are MANY browser choices for
# X already.  If you need a browser for X, either use something else or
# recompile.
./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --enable-javascript \
    --enable-graphics \
    --without-x \
    $TARGET
make
( 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/bin
cat links > $PKG/usr/bin/links
chmod 755 $PKG/usr/bin/links
chown -R root.bin $PKG/usr/bin
mkdir -p $PKG/usr/man/man1
cat links.1 | gzip -9c > $PKG/usr/man/man1/links.1.gz
mkdir -p $PKG/usr/doc/links-$VERSION
cp -a AUTHORS BUGS COPYING INSTALL NEWS README SITES TODO doc/links_cal $PKG/usr/doc/links-$VERSION
chmod 644 $PKG/usr/doc/links-$VERSION/*
cp -a mailcap.pl $PKG/usr/doc/links-$VERSION
chmod 755 $PKG/usr/doc/links-$VERSION/mailcap.pl
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/links-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/links.build.log
