#!/bin/sh
# Build "links" for AlphaSlack by <masta@alphaslack.de>
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-links
VERSION=2.2
ARCH=alpha
BUILD=1
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 \
 --without-sdl \
 --build=$TARGET || exit 1
make -j2 || exit 1
make DESTDIR=$PKG install
( 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/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
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 $TMP/links-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/links.build.log
