Created
June 28, 2013 17:29
-
-
Save doubleotoo/5886467 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 -e | |
#------------------------------------------------------------------------------- | |
# Default values | |
#------------------------------------------------------------------------------- | |
: ${GRAPHVIZ_VERSION:=$1} | |
echo "[INFO] Graphviz '$GRAPHVIZ_VERSION'" | |
GCC_VERSION="$(gcc -dumpversion)" | |
: ${DESTDIR:=$(pwd)} | |
: ${PREFIX:=${DESTDIR}/${GRAPHVIZ_VERSION}/gcc/${GCC_VERSION}} | |
: ${WORKSPACE:=${PREFIX}/workspace} | |
#------------------------------------------------------------------------------- | |
# Sanity Checks | |
#------------------------------------------------------------------------------- | |
if [ -z "${GRAPHVIZ_VERSION}" ]; then | |
echo "Usage: $0 <version: x.xx.x>" | |
exit 1 | |
fi | |
#------------------------------------------------------------------------------- | |
# Meta Information | |
#------------------------------------------------------------------------------- | |
GRAPHVIZ_SRCDIR="${WORKSPACE}/graphviz-${GRAPHVIZ_VERSION}" | |
GRAPHVIZ_TARBALL="graphviz-${GRAPHVIZ_VERSION}.tar.gz" | |
GRAPHVIZ_DOWNLOAD_URL="http://www.graphviz.org/pub/graphviz/stable/SOURCES/${GRAPHVIZ_TARBALL}" | |
#------------------------------------------------------------------------------- | |
# Workspace | |
#------------------------------------------------------------------------------- | |
mkdir -p "${WORKSPACE}" || exit 1 | |
pushd "${WORKSPACE}" || exit 1 | |
#------------------------------------------------------------------------------- | |
# [LLVM] Download and unpack | |
#------------------------------------------------------------------------------- | |
if [ ! -f "$GRAPHVIZ_TARBALL" ]; then | |
echo "[INFO] Downloading GRAPHVIZ '$GRAPHVIZ_DOWNLOAD_URL'" | |
wget --no-check-certificate "$GRAPHVIZ_DOWNLOAD_URL" || exit 1 | |
else | |
echo "[INFO] [SKIP] Graphviz tarball already exists: '$GRAPHVIZ_TARBALL'" | |
fi | |
if [ ! -d "$GRAPHVIZ_SRCDIR" ]; then | |
echo "[INFO] Unpacking Graphviz tarball: '$GRAPHVIZ_TARBALL'" | |
tar xvzf "${GRAPHVIZ_TARBALL}" | |
else | |
echo "[INFO] [SKIP] Graphviz source code already exists: '$GRAPHVIZ_SRCDIR'" | |
fi | |
#------------------------------------------------------------------------------- | |
# Build and install | |
#------------------------------------------------------------------------------- | |
cd "${GRAPHVIZ_SRCDIR}" | |
if [ ! -e "${PREFIX}/bin" ]; then | |
echo "[INFO] Configuring Graphviz" | |
echo "[INFO] Installing to '$PREFIX'" | |
"${GRAPHVIZ_SRCDIR}/configure" --prefix="$PREFIX" || exit 1 | |
make -j || exit 1 | |
make -j install || exit 1 | |
echo "[INFO] Creating Graphviz environment setup file" | |
cat > "${PREFIX}/setup.sh" <<-EOF | |
#!/bin/bash | |
# | |
# Automatically generated by $0 on $(date) | |
export GRAPHVIZ_VERSION="${GRAPHVIZ_VERSION}" | |
export GRAPHVIZ_HOME="${PREFIX}" | |
export PATH="\${GRAPHVIZ_HOME}/bin:\${PATH}" | |
export GRAPHVIZ_GCC_VERSION="${GCC_VERSION}" | |
EOF | |
#----------------------------------------------- | |
# Set Permissions | |
#----------------------------------------------- | |
echo "[INFO] Setting group permissions of '${PREFIX}'" | |
chmod -R g+r "${PREFIX}" | |
find "${PREFIX}" -type d -exec chmod g+x {} \; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment