#!/usr/tgcware/bin/bash

export CONFIG_SHELL=/usr/tgcware/bin/bash
export PATH=/usr/local/gnu/bin:/usr/tgcware/bin:/usr/sbin:/usr/bsd:/sbin:/usr/bin:/etc:/usr/etc:/usr/bin/X11
export CC=gcc
# export CFLAGS=-O2

gzip -dc gmp-4.2.4.tar.gz | tar xf -
(cd gmp-4.2.4 && patch -s -p0 < ../mpf_eq.diff)
(cd gmp-4.2.4 && patch -s -p0 < ../mpf_set_str.c.4.diff)
(cd gmp-4.2.4 && patch -s -p0 < ../perfpow.c.diff)

mkdir gmp-4.2.4/obj
cd gmp-4.2.4/obj

../configure --prefix=/usr/local/gnu --disable-shared
make -j2
make -k check > ../../gmp-4.2.4.mips-sgi-irix5.3-check.txt 2>&1
make install DESTDIR=`pwd`/root

# Tidy up

# Strip debug info from libs
(cd root && find  `pwd` -type f -name "*.a" -print | xargs -n1 objcopy --strip-debug --preserve-dates)


(cd root && /sbin/tar cf - usr/ | gzip -9 > ../../../gmp-4.2.4.mips-sgi-irix5.3.tar.gz)
cd ../..

# Clean up
rm -rf gmp-4.2.4

