#!/bin/sh
PKGNAM=gmp
VERSION=4.2.1
BUILD=${BUILD:-2}

. /etc/pkghelpers
pkghelpers_env

cd /tmp
rm -rf gmp-$VERSION
tar xjvf $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 {} \;
CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --libdir=/usr/lib$LIBSUFFIX \
  --with-gnu-ld \
  --enable-cxx \
  --enable-mpbsd \
	--enable-mpfr \
  $ARCH-$DISTRO-linux-gnu
make -j12 || exit 1
make install DESTDIR=$PKG
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
if [ -d usr/lib$LIBSUFFIX/pkgconfig ]; then
	mkdir -p usr/lib
	mv usr/lib$LIBSUFFIX/pkgconfig usr/lib
fi

pkghelpers_fixup
pkghelpers_makepkg
