Last active
December 18, 2015 10:38
-
-
Save doubleotoo/5769430 to your computer and use it in GitHub Desktop.
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 | |
: ${MPC_VERSION:=$1} | |
: ${GMP_HOME:=} | |
: ${MPFR_HOME:=} | |
: ${DESTDIR:=$(pwd)} | |
: ${PREFIX:=${DESTDIR}/${MPC_VERSION}} | |
: ${WORKSPACE:=${PREFIX}/workspace} | |
: ${BUILDDIR:=${WORKSPACE}/build} | |
if [ -z "${MPC_VERSION}" ]; then | |
echo "[FATAL] \$MPC_VERSION not set" | |
echo "[INFO] Usage: MPC_VERSION=<version> $0" | |
exit 1 | |
fi | |
if [ -z "${GMP_HOME}" -o ! -d "${GMP_HOME}" ]; then | |
echo "[FATAL] \$GMP_HOME is not set or does not exist" | |
exit 1 | |
fi | |
if [ -z "${MPFR_HOME}" -o ! -d "${MPFR_HOME}" ]; then | |
echo "[FATAL] \$MPFR_HOME is not set or does not exist" | |
exit 1 | |
fi | |
#------------------------------------------------------------------------------- | |
# Use separate workspace | |
#------------------------------------------------------------------------------- | |
mkdir -p "${WORKSPACE}" || exit 1 | |
pushd "${WORKSPACE}" || exit 1 | |
#------------------------------------------------------------------------------- | |
# Download and unpack software | |
#------------------------------------------------------------------------------- | |
wget --no-check-certificate "http://www.multiprecision.org/mpc/download/mpc-${MPC_VERSION}.tar.gz" || exit 1 | |
tar xvzf "mpc-${MPC_VERSION}.tar.gz" || exit 1 | |
MPC_SOURCE="$(pwd)/mpc-${MPC_VERSION}" | |
#------------------------------------------------------------------------------- | |
# Setup build tree | |
#------------------------------------------------------------------------------- | |
mkdir -p "${BUILDDIR}" || exit 1 | |
pushd "${BUILDDIR}" || exit 1 | |
#------------------------------------------------------------------------------- | |
# Install | |
#------------------------------------------------------------------------------- | |
echo "[INFO] Installing MPC '${MPC_VERSION}' to '${PREFIX}'" | |
echo "[INFO] Using GMP '${GMP_HOME}'" | |
echo "[INFO] Using MPFR '${MPFR_HOME}'" | |
"${MPC_SOURCE}/configure" --prefix="${PREFIX}" --with-gmp="${GMP_HOME}" --with-mpfr="${MPFR_HOME}" || exit 1 | |
make -j || exit 1 | |
make check || exit 1 | |
make install || exit 1 | |
#------------------------------------------------------------------------------- | |
# Create environment-setup file | |
#------------------------------------------------------------------------------- | |
cat > "${PREFIX}/setup.sh" <<-EOF | |
export MPC_HOME="${PREFIX}" | |
export LD_LIBRARY_PATH="\${MPC_HOME}/lib:\${LD_LIBRARY_PATH}" | |
export GMP_HOME="${GMP_HOME}" | |
export LD_LIBRARY_PATH="\${GMP_HOME}/lib:\${LD_LIBRARY_PATH}" | |
export MPFR_HOME="${MPFR_HOME}" | |
export LD_LIBRARY_PATH="\${MPFR_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 | |
echo "[INFO] Successfully installed MPC version '${MPC_VERSION}' to '${PREFIX}'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment