Skip to content

Instantly share code, notes, and snippets.

@JBreit
Forked from nodekid/update-node.sh
Last active August 29, 2015 14:06
Show Gist options
  • Save JBreit/456dd996c28e0bc2ea05 to your computer and use it in GitHub Desktop.
Save JBreit/456dd996c28e0bc2ea05 to your computer and use it in GitHub Desktop.
#!/bin/sh
[ $# -eq 0 ] && { echo "Usage: ${0} version-string" ; exit 1; }
VERSION=${1}
PREFIX="/usr/local"
SRC_CWD="${PREFIX}/src"
SRC_DIR="${SRC_CWD}/node"
SRC_GIT="git://github.com/joyent/node.git"
CPUS=$( grep processor /proc/cpuinfo | wc -l ) # non-portable :/
JOBS=$(( $CPUS + 1 ))
cd "${SRC_CWD}"
if [ ! -d "${SRC_DIR}" ] ; then
git clone "${SRC_GIT}"
fi
cd "${SRC_DIR}"
echo "[Checking for updates...]"
git checkout master && git pull
git checkout "v${VERSION}"
./configure --prefix="${PREFIX}"
echo "[Compiling using ${JOBS} jobs...]"
make install \
V=1 \
-j $JOBS #\
#CFLAGS+="-mtune=native -march=native" \
#CXXFLAGS+="-mtune=native -march=native"
echo "[Cleaning up...]"
make distclean > /dev/null 2>&1
echo "[Build complete]" && exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment