#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-gdb
VERSION=7.1
ARCH=alpha
BUILD=2
TARGET=$ARCH-alphaslack-linux

rm -rf $PKG
mkdir -p $PKG
( cd $TMP
rm -rf gdb-$VERSION
tar xjf $CWD/gdb-$VERSION.tar.bz2
cd gdb-$VERSION
chown -R root.root .
./configure \
 --prefix=/usr \
 --mandir=/usr/man \
 --infodir=/usr/info \
 --build=$TARGET
cd readline 
./configure \
 --prefix=/usr \
 --mandir=/usr/man \
 --infodir=/usr/info \
 --build=$TARGET
make || exit 1
cd ..
make || exit 1
make DESTDIR=$PKG install

# None of this stuff has ever been included in this package:
rm -rf $PKG/usr/lib
rm -f $PKG/usr/info/{annotate*,bfd*,configure*,standards*}
rm -rf $PKG/usr/include

# Use the -tui option if you want this.
# Including a whole extra copy of the gdb binary is obnoxious:
rm -f $PKG/usr/bin/gdbtui $PKG/usr/man/man1/gdbtui.1*

rm -rf $PKG/usr/info/dir
gzip -9 $PKG/usr/info/* $PKG/usr/man/man?/*.?
chmod 755 $PKG/usr/bin/*
chown -R root.bin $PKG/usr/bin
# Strip binaries:
( cd $PKG
 find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null
 find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null
)
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/gdb-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/gdb.build.log
