Last active
December 18, 2015 23:19
-
-
Save doubleotoo/5860928 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 | |
#------------------------------------------------------------------------------- | |
: ${AUTOMAKE_VERSION:=$1} | |
echo "[INFO] Automake '$AUTOMAKE_VERSION'" | |
: ${GCC_HOME:=} | |
if [ -z "${GCC_HOME}" ]; then | |
echo "[FATAL] \$GCC_HOME is not set" | |
exit 1 | |
fi | |
GCC_VERSION="$(gcc -dumpversion)" | |
: ${AUTOCONF_HOME:=} | |
if [ -z "${AUTOCONF_HOME}" ]; then | |
echo "[FATAL] \$AUTOCONF_HOME is not set" | |
exit 1 | |
fi | |
: ${DESTDIR:=$(pwd)} | |
: ${PREFIX:=${DESTDIR}/${AUTOMAKE_VERSION}/gcc/${GCC_VERSION}} | |
: ${WORKSPACE:=${PREFIX}/workspace} | |
#------------------------------------------------------------------------------- | |
# Sanity Checks | |
#------------------------------------------------------------------------------- | |
if [ -z "${AUTOMAKE_VERSION}" ]; then | |
echo "Usage: $0 <version: x.x.x.x>" | |
exit 1 | |
fi | |
#------------------------------------------------------------------------------- | |
# Meta Information | |
#------------------------------------------------------------------------------- | |
AUTOMAKE_SRCDIR="${WORKSPACE}/automake-${AUTOMAKE_VERSION}" | |
AUTOMAKE_TARBALL="automake-${AUTOMAKE_VERSION}.tar.xz" | |
AUTOMAKE_DOWNLOAD_URL="http://ftp.gnu.org/gnu/automake/${AUTOMAKE_TARBALL}" | |
#------------------------------------------------------------------------------- | |
# Workspace | |
#------------------------------------------------------------------------------- | |
mkdir -p "${WORKSPACE}" || exit 1 | |
pushd "${WORKSPACE}" || exit 1 | |
#------------------------------------------------------------------------------- | |
# [LLVM] Download and unpack | |
#------------------------------------------------------------------------------- | |
if [ ! -f "$AUTOMAKE_TARBALL" ]; then | |
echo "[INFO] Downloading AUTOMAKE '$AUTOMAKE_DOWNLOAD_URL'" | |
wget --no-check-certificate "$AUTOMAKE_DOWNLOAD_URL" || exit 1 | |
else | |
echo "[INFO] [SKIP] Automake tarball already exists: '$AUTOMAKE_TARBALL'" | |
fi | |
if [ ! -d "$AUTOMAKE_SRCDIR" ]; then | |
echo "[INFO] Unpacking Automake tarball: '$AUTOMAKE_TARBALL'" | |
unxz "$AUTOMAKE_TARBALL" || exit 1 | |
tar xvf "${AUTOMAKE_TARBALL%.xz}" || exit 1 | |
else | |
echo "[INFO] [SKIP] Automake source code already exists: '$AUTOMAKE_SRCDIR'" | |
fi | |
#------------------------------------------------------------------------------- | |
# Build and install | |
#------------------------------------------------------------------------------- | |
cd "${AUTOMAKE_SRCDIR}" | |
if [ ! -e "${PREFIX}/bin" ]; then | |
echo "[INFO] Configuring Automake" | |
echo "[INFO] Installing to '$PREFIX'" | |
echo "[INFO] \$GCC_HOME='${GCC_HOME}'" | |
"${AUTOMAKE_SRCDIR}/configure" --prefix="$PREFIX" || exit 1 | |
make -j all || exit 1 | |
make -j install || exit 1 | |
echo "[INFO] Creating Automake environment setup file" | |
cat > "${PREFIX}/setup.sh" <<-EOF | |
#!/bin/bash | |
# | |
# Automatically generated by $0 on $(date) | |
export AUTOMAKE_HOME="${PREFIX}" | |
export PATH="\${AUTOMAKE_HOME}/bin:\${PATH}" | |
export AUTOMAKE_GCC_HOME="${GCC_HOME}" | |
export AUTOCONF_HOME="${AUTOCONF_HOME}" | |
export PATH="\${AUTOCONF_HOME}/bin:\${PATH}" | |
export AUTOCONF_GCC_HOME="${AUTOCONF_GCC_HOME}" | |
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