Building Emacs.App From Source on OS X Lion

1 minute read

As always, I like building Emacs for my Mac from source. It lets me live on the cutting edge and have tigher control of the version I’m running. If building software from source isn’t your thing then skip the rest of this article and consider installing Emacs using Homebrew, MacPorts, or Fink

I’ve written about building Emacs in the past, but OS X Lion brings a few complexities to the process. Before you begin you’ll need to have Xcode installed (free in the App Store).

In the past the best way to get the Emacs source was with CVS, but CVS is no longer included with Xcode. Fortunately, you can now use Git instead.

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

At this point you have two choices, you can build the current stable version of Emacs, 23.3, which requires a patch to work with Lion. Or you can build the development version, 24.0, which has support for Lion, but requires a couple of extra tools.

First Emacs 23.3. The master branch of the repository is the 24.0 development branch. The stable 23.3 branch is called emacs-23. Check that out with:

$ git checkout emacs-23

Then use curl apply the patch found in this Gist:

$ curl https://raw.github.com/gist/1271239/adb92fb0d8d94c1e32f7d5ab1f33b438bb8ee379/nsterm.m-patch | patch -p1

Now Emacs 23.3 can be built and installed:

$ ./configure --with-ns
$ make install

Drag nextstep/Emacs.app to you Applications folder and you’re good to go. (The “install” step doen’t install anything, it builds the .app wrapper.)

If you want the future of Emacs today, you can build 24.0 instead. However, 24.0 requires newer versions of Autoconf and Automake than the ones shipped with Xcode 4.1.1. We’ll need to install those versions:

Autoconf:

$ cd /tmp
$ curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-2.68.tar.gz
$ tar xf autoconf-2.68.tar.gz
$ cd autoconf-2.68
$ ./configure
$ make
$ sudo make install

Automake:

$ cd /tmp
$ curl -O http://ftp.gnu.org/gnu/automake/automake-1.11.tar.gz
$ tar xf automake-1.11.tar.gz
$ cd automake-1.11
$ ./configure
$ make
$ sudo make install

These will be installed in /usr/local/bin, so make sure you have that first in your PATH:

$ PATH=/usr/local/bin:$PATH

Now build Emacs as follows:

$ cd emacs
$ git checkout master
$ make configure
$ ./configure --with-ns
$ make install

It’s a bit of work, but anytime there is an update I can simply:

$ cd emacs
$ git pull

then re-config and rebuild to have it on my system.

Comments