Last active
October 13, 2015 02:48
-
-
Save doubleotoo/4127892 to your computer and use it in GitHub Desktop.
Quick and dirty script to automate the installation of MPFR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
#------------------------------------------------------------------------------- | |
# Set defaults | |
#------------------------------------------------------------------------------- | |
: ${MPFR_VERSION:=$1} | |
: ${GMP_HOME:=} | |
: ${DESTDIR:=$(pwd)} | |
: ${PREFIX:=${DESTDIR}/${MPFR_VERSION}} | |
: ${SRCDIR:=} | |
: ${WORKSPACE:=${PREFIX}/workspace} | |
: ${BUILDDIR:=${WORKSPACE}/build} | |
if [ -z "${MPFR_VERSION}" ]; then | |
echo "[FATAL] Please specify the \$MPFR_VERSION to install" | |
echo "[INFO] Usage: GMP_VERSION=<version> $0" | |
exit 1 | |
fi | |
if [ -z "$GMP_HOME" -o ! -d "${GMP_HOME}" ]; then | |
echo "[FATAL] \$GMP_HOME not set or does not exist" | |
echo "[INFO] Usage: GMP_HOME=</path/to/gmp/installation> $0" | |
exit 1 | |
fi | |
#------------------------------------------------------------------------------- | |
# Use separate workspace | |
#------------------------------------------------------------------------------- | |
mkdir -p "${WORKSPACE}" || exit 1 | |
pushd "${WORKSPACE}" || exit 1 | |
#------------------------------------------------------------------------------- | |
# Download and unpack software | |
#------------------------------------------------------------------------------- | |
TARBALL="mpfr-${MPFR_VERSION}.tar.gz" | |
if ! test -e "${TARBALL}"; then | |
wget "http://www.mpfr.org/mpfr-${MPFR_VERSION}/${TARBALL}" || exit 1 | |
fi | |
if ! test -e "mpfr-${MPFR_VERSION}"; then | |
tar xvzf "${TARBALL}" || exit 1 | |
fi | |
#------------------------------------------------------------------------------- | |
# Setup build tree | |
#------------------------------------------------------------------------------- | |
pushd "mpfr-${MPFR_VERSION}" || exit 1 | |
SRCDIR="$(pwd)" | |
mkdir -p "$BUILDDIR" || exit 1 | |
cd "$BUILDDIR" || exit 1 | |
#------------------------------------------------------------------------------- | |
# Install | |
#------------------------------------------------------------------------------- | |
"${SRCDIR}/configure" --prefix="${PREFIX}" --with-gmp="${GMP_HOME}" || exit 1 | |
make install -j || exit 1 | |
#------------------------------------------------------------------------------- | |
# Create environment-setup file | |
#------------------------------------------------------------------------------- | |
cat > "${PREFIX}/setup.sh" <<-EOF | |
export MPFR_HOME="${PREFIX}" | |
export LD_LIBRARY_PATH="\${MPFR_HOME}/lib:\${LD_LIBRARY_PATH}" | |
export GMP_HOME="${GMP_HOME}" | |
export LD_LIBRARY_PATH="\${GMP_HOME}/lib:\${LD_LIBRARY_PATH}" | |
EOF | |
#------------------------------------------------------------------------------- | |
# Setup permissions | |
#------------------------------------------------------------------------------- | |
chmod -R g+r "${PREFIX}" || exit 1 | |
find "${PREFIX}" -type d -exec chmod g+x {} \; || exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment