Install multiple versions of Emacs into $HOME directory from source

  |   Source

CREATED: <2014-05-31 Sat>

UPDATED: <2016-10-05 Wed>

Here is the script,

[ -z "$EMACS_VERSION" ] && echo "Usage: EMACS_VERSION=24.3" && exit 1
[ -z "$EMACS_URL" ] && EMACS_URL=""
# I've assign 12G memory to /tmp as ramdisk
[ -z "$EMACS_TMP" ] && EMACS_TMP="/tmp"

# configure: WARNING: unrecognized options: --without-gtk3, --without-aqua, --without-alsa, --without-aqua
echo "curl $EMACS_URL/emacs-$EMACS_VERSION.tar.gz"
curl $EMACS_URL/emacs-$EMACS_VERSION.tar.gz | tar xvz -C $EMACS_TMP
# @see
# @see for info on Gentoo Linux
# --without-gtk and --without-gtk3 is optional
if [[ $EUID -ne 0 ]]; then
    echo "Installing Emacs as normal user ..."
    cd $EMACS_TMP/emacs-$EMACS_VERSION;mkdir -p $HOME/myemacs/$EMACS_VERSION;rm -rf $HOME/myemacs/$EMACS_VERSION/*;./configure --prefix=$HOME/myemacs/$EMACS_VERSION --without-x --without-dbus --without-sound && make && make install
    rm -rf $EMACS_TMP/emacs-$EMACS_VERSION
    echo "Emacs $EMACS_VERSION installed!"
    echo "Installing Emacs as sudoer ..."
    cd $EMACS_TMP/emacs-$EMACS_VERSION;./configure --without-x --without-dbus --without-sound && make && make install
    echo "Emacs $EMACS_VERSION installed! Please remove $EMACS_TMP/emacs-$EMACS_VERSION"

Usage of the script is as simple as running EMACS_VERSION=24.3 ./install-emacs

The emacs will be installed into the directory ~/myemacs/24.3.

Comments powered by Disqus