#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-gmp
VERSION=5.0.1
ARCH=alpha
BUILD=1
TARGET=$ARCH-alphaslack-linux

rm -rf $PKG
mkdir -p $PKG/usr
( cd $TMP
rm -rf gmp-$VERSION
tar xjf $CWD/gmp-$VERSION.tar.bz2
cd gmp-$VERSION
chown -R root:root .
find . -perm 664 -exec chmod 644 {} \;
find . -perm 600 -exec chmod 644 {} \;
find . -perm 444 -exec chmod 644 {} \;
find . -perm 400 -exec chmod 644 {} \;
find . -perm 440 -exec chmod 644 {} \;
find . -perm 777 -exec chmod 755 {} \;
find . -perm 775 -exec chmod 755 {} \;
find . -perm 511 -exec chmod 755 {} \;
find . -perm 711 -exec chmod 755 {} \;
find . -perm 555 -exec chmod 755 {} \;
./configure \
 --prefix=/usr \
 --infodir=/usr/info \
 --with-gnu-ld \
 --enable-cxx \
 --enable-mpbsd \
 --build=$TARGET
make || exit 1
make install DESTDIR=$PKG
rm $PKG/usr/info/dir
gzip -9 $PKG/usr/info/*
strip --strip-unneeded $PKG/usr/lib/lib*.so 2> /dev/null
mkdir -p $PKG/usr/doc/gmp-$VERSION
cp -a AUTHORS COPYING COPYING.LIB NEWS README $PKG/usr/doc/gmp-$VERSION
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/gmp-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/gmp.build.log
