# Get the tarball
cd
test -f installed/gmp-6.3.0.tar.lz && mv installed/gmp-6.3.0.tar.lz .
test ! -f gmp-6.3.0.tar.lz &&
wget https://gmplib.org/download/gmp/gmp-6.3.0.tar.lz
# Verify tarball w/ sha256sum:
# (this came from my gpg-verified tarball)
echo "be5c908a7a836c3a9bd9d62aa58563c5e9e7fef94c43a7f42dbc35bb6d0273\
3c gmp-6.3.0.tar.lz" | sha256sum -c
# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "gmp-*" -exec rm -r {} \;
tar xv --lzip -f ~/gmp-6.3.0.tar.lz
cd gmp-6.3.0
test $UID = 0 && chown -R root:root .
# Configure the build
test $(uname -m) = 'x86_64' &&
./configure --prefix=/usr --infodir=/usr/info --libdir=/usr/lib64 \
--with-gnu-ld --enable-cxx
# Configure the build for anything else
test $(uname -m) != 'x86_64' &&
./configure --prefix=/usr --infodir=/usr/info --with-gnu-ld --enable-cxx
# Build it
make
# Check the build, takes a while
make check
# Become root to install it
su
# Remove old files, install the new version
# This will leave behind libgmp, libgmpxx because they are also in the
# 'aaa_elflibs' package
test -x /sbin/removepkg && /sbin/removepkg gmp
# Remove this if you have an older version installed that included it
# (if you used --enable-mpbsd) prior to 5.1.1
rm -f /usr/include/mp.h /usr/lib*/libmp.*
# Remove old version library files if nothing else is using them
# Or, the safe option, don't
( cd /usr/lib ; rm -f libgmp.* libgmpxx.* )
test -d /usr/lib64 &&
( cd /usr/lib64 ; rm -f libgmp.* libgmpxx.* )
# Install it
make install
ldconfig
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .
# Become your non-root user again
exit
# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/gmp-*.tar.*
mv gmp-6.3.0.tar.lz installed/
# If you ever want to uninstall GMP, this should do it:
cd
su
test -d src/gmp-* && ( cd src/gmp-* ; make uninstall )
( cd /usr/include ; rm -f gmp.h mp.h gmpxx.h )
for libdir in /usr/lib /usr/lib64;
do
test -d $libdir &&
( cd /usr/lib ; rm -f libgmp.* libgmpxx.* libmp.* )
done
rm -f /usr/info/gmp.info
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "gmp-*" -exec rm -r {} \;
rm -f ~/installed/gmp-*.tar.*