#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-wget
rm -rf $PKG
mkdir -p $PKG

VERSION=1.9.1
ARCH=i486
BUILD=1

if [ $ARCH = i486 ]; then
  CPUOPT='-march=i486 -mcpu=i686'
elif [ $ARCH = x86_64 ]; then
  CPUOPT='-march=x86_64'
fi

cd $TMP
rm -rf wget-$VERSION
tar xjvf $CWD/wget-$VERSION.tar.bz2
cd wget-$VERSION
chown -R root.root .
CFLAGS="-O2 $CPUOPT" \
./configure --prefix=/usr \
  --sysconfdir=/etc \
  ${ARCH}-slackware-linux
make
# Ordinarily I detest this trick, but wget is simple enough that
# it's easy to verify no inappropriate /tmp paths are getting
# embedded.  Don't expect much more use of this technique.
mkdir -p $PKG/usr $PKG/etc
make install prefix=$PKG/usr sysconfdir=$PKG/etc
strip --strip-unneeded $PKG/usr/bin/*
chown -R root.bin $PKG/usr/bin
gzip -9 $PKG/usr/info/* $PKG/usr/man/man?/*
mkdir -p $PKG/usr/doc/wget-$VERSION
cp -a \
  AUTHORS COPYING MAILING-LIST NEWS PATCHES README README.cvs TODO \
  $PKG/usr/doc/wget-$VERSION
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
makepkg -l y -c n $TMP/wget-$VERSION-$ARCH-$BUILD.tgz

