Building Emacs from source on Xubuntu 12.04

Emacs is an extensible text editor written mostly in Emacs Lisp (or elisp for short). It’s quite old – the first version was released in 1976. according to Wikipedia article about Emacs. It’s, however, still regularly updated – the last stable version as of this writing is 23.4 released on January 29th, 2012.

One problem with Emacs is exactly its extensibility and customizability. It’s updated very often, so the last stable release is, well, unusable. All the extensions and testing is usually done on the development branch – currently, the preview release is 24.1-rc, released just yesterday, June 1st, 2012. In the current Xubuntu repository, the current version is present:

Version: 23.3+1-1ubuntu9

In order to compensate for this, I (and I suppose many other people) install directly from source. Here’s how to easy do this using the git mirror repository.

Steps for building Emacs

  • Build packages

In order to build emacs, you’ll need some packages installed that don’t come pre-installed on a fresh Xubuntu install. In case you did not, install these:

$ sudo apt-get install autoconf automake build-essential libjpeg-dev libgif-dev libncursesw5-dev libpng-dev libtiff4-dev texinfo
  • Clone the git mirror of Emacs

On this Emacs Wiki page – called Emacs From Git – you have several git repositories listed. Pick one, e.g. the one on gnu.org, and clone it somewhere:

$ git clone git://git.savannah.gnu.org/emacs.git

This is going to take a while, so be patient.

  • Build Emacs

Emacs uses the standard Linux configure scripts and make command. To build it, enter the newly cloned git repository and issue configure / make:

$ cd emacs
$ ./autogen.sh
$ ./configure
$ make

The above assumes that you want to install emacs in /usr/local – change that if you have other preferences here. To do that, run configure like this instead:

$ ./configure --prefix=/my/emacs/path

The build step will likely take even more then git cloning, so grab a few coffees or something.

  • Installing

After compiling Emacs, you can now install it:

$ sudo make install

For for a custom folder setup:

$ sudo make install --prefix=/my/emacs/path
  • Test run

Run emacs to confirm the version:

$ emacs --version
GNU Emacs 24.1.50.1
Copyright (C) 2012 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

All set.