set -e
TARDIR="$HOME/Downloads"
GMPVER=6.1.2
GMPVERP="$GMPVER"
GMPTAR="$TARDIR/gmp-$GMPVER.tar.lz"
GMPPATCH="$TARDIR/gmp-$GMPVERP-allpatches"
MPFRVER=4.0.0
MPFRVERP="$MPFRVER"
MPFRTAR="$TARDIR/mpfr-$MPFRVER.tar.xz"
MPFRPATCH="$TARDIR/mpfr-$MPFRVERP-allpatches"
MPCVER=1.1.0
MPCVERP="$MPCVER"
MPCTAR="$TARDIR/mpc-$MPCVER.tar.gz"
MPCPATCH="$TARDIR/mpc-$MPCVERP-allpatches"
tar xf "$GMPTAR"
mv gmp-$GMPVER gmp-$GMPVERP-c
cd gmp-$GMPVERP-c
if [ -f "$GMPPATCH" ]; then
patch -N -Z -p1 < "$GMPPATCH" > /dev/null
fi
rm ChangeLog doc/*.info*
sed -i.rm~ '/Configs for demos/,/Create config.m4/{//!d}' configure
sed -i.rm~ '/^ac_config_files=/s/[^ ]*\(doc\|demos\)[^ ]\{1,\}Makefile//g' \
configure
sed -i.rm~ '/^SUBDIRS = /s/doc\|demos//g' Makefile.in
cd ..
tar xf "$MPFRTAR"
mv mpfr-$MPFRVER mpfr-$MPFRVERP-c
cd mpfr-$MPFRVERP-c
if [ -f "$MPFRPATCH" ]; then
patch -N -Z -p1 < "$MPFRPATCH" > /dev/null
fi
rm ChangeLog doc/*.info doc/*.html
sed -i.rm~ '/^ac_config_files=/s/\([^ ]*doc[^ ]\{1,\}Makefile\|mpfr.pc\)//g' configure
sed -i.rm~ '/^SUBDIRS = /s/doc//g' Makefile.in
sed -i.rm~ '/^DATA = /s/\$(pkgconfig_DATA)//g' Makefile.in
cd ..
tar xf "$MPCTAR"
mv mpc-$MPCVER mpc-$MPCVERP-c
cd mpc-$MPCVERP-c
if [ -f "$MPCPATCH" ]; then
patch -N -Z -p1 < "$MPCPATCH" > /dev/null
fi
rm ChangeLog doc/*.info
sed -i.rm~ '/^ac_config_files=/s/[^ ]*doc[^ ]\{1,\}Makefile//g' configure
sed -i.rm~ '/^SUBDIRS = /s/doc//g' Makefile.in
cd ..
for m in $(find *-c -name Makefile.in); do
sed -i.rm~ '/Makefile:/,/esac/d' $m
done
find *-c -name \*.rm~ -delete