Created
August 25, 2015 22:25
-
-
Save rosecompiler/815bdf7fbe90ec2dfe8c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
#------------------------------------------------------------------------------- | |
: ${GMP_VERSION:=$1} | |
: ${DESTDIR:=$(pwd)} | |
: ${PREFIX:=${DESTDIR}/${GMP_VERSION}} | |
: ${WORKSPACE:=${PREFIX}/workspace} | |
if [ -z "$GMP_VERSION" ]; then | |
echo "[FATAL] \$GMP_VERSION not set" | |
echo "[INFO] Usage: GMP_VERSION=<version> $0" | |
exit 1 | |
fi | |
#------------------------------------------------------------------------------- | |
# Sanity Checks | |
#------------------------------------------------------------------------------- | |
if [ -z "${GMP_VERSION}" ]; then | |
echo "Usage: $0 <version: x.x.x>" | |
exit 1 | |
fi | |
#------------------------------------------------------------------------------- | |
# Meta Information | |
#------------------------------------------------------------------------------- | |
GMP_SRCDIR="${WORKSPACE}/gmp-${GMP_VERSION}" | |
GMP_TARBALL="gmp-${GMP_VERSION}.tar.bz2" | |
GMP_DOWNLOAD_URL="http://ftp.gnu.org/gnu/gmp/${GMP_TARBALL}" | |
#------------------------------------------------------------------------------- | |
# Use separate workspace | |
#------------------------------------------------------------------------------- | |
mkdir -p "${WORKSPACE}" || exit 1 | |
pushd "${WORKSPACE}" || exit 1 | |
#------------------------------------------------------------------------------- | |
# Download and unpack | |
#------------------------------------------------------------------------------- | |
if [ ! -f "$GMP_TARBALL" ]; then | |
echo "[INFO] Downloading GMP '$GMP_DOWNLOAD_URL'" | |
wget --no-check-certificate "$GMP_DOWNLOAD_URL" || exit 1 | |
else | |
echo "[INFO] [SKIP] GMP tarball already exists: '$GMP_TARBALL'" | |
fi | |
if [ ! -d "$GMP_SRCDIR" ]; then | |
echo "[INFO] Unpacking GMP tarball: '$GMP_TARBALL'" | |
tar xjvf "${GMP_TARBALL}" | |
else | |
echo "[INFO] [SKIP] GMP source code already exists: '$GMP_SRCDIR'" | |
fi | |
#------------------------------------------------------------------------------- | |
# Build and install | |
#------------------------------------------------------------------------------- | |
cd "${GMP_SRCDIR}" || exit 1 | |
if [ ! -e "${PREFIX}/lib" ]; then | |
echo "[INFO] Configuring GMP" | |
echo "[INFO] Installing to '$PREFIX'" | |
"${GMP_SRCDIR}/configure" --prefix="${PREFIX}" || exit 1 | |
make -j || exit 1 | |
make install -j || exit 1 | |
fi | |
#------------------------------------------------------------------------------- | |
# Create environment-setup file | |
#------------------------------------------------------------------------------- | |
cat > "${PREFIX}/setup.sh" <<-EOF | |
# Automatically generated by '$USER'@'$(hostname)' on '$(date)' | |
export GMP_VERSION="${GMP_VERSION}" | |
export GMP_HOME="${PREFIX}" | |
export LD_LIBRARY_PATH="\${GMP_HOME}/lib:\${LD_LIBRARY_PATH}" | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment