Building Emacs on OS X El Capitan

2 minute read

Last week I wrote about my issue with Emacs’ visible-bell on OS X El Capitan. I figured it was about the most esoteric thing I’ve written, but it may have gotten more comments then any other post. I’m not sure if that’s good or bad…

In any case, before coming up with my work-around, I first tried rebuilding Emacs, in case the issues had been already fixed or simply re-compiling/re-linking would take care of it. That didn’t help, but this is fine time to revisit building Emacs from source on OS X.

First, you will need Xcode installed (free in the Mac App Store) to build. If you don’t have Xcode installed you’re not reading my blog anyway. However, if you just installed El Capitan, you may need to re-install the Xcode command line tools to build Emacs (or really compile anything).

xcode-select --install

You will also need Autoconf and Automake. These once shipped with Xcode, but haven’t in quite some time. I used to build these from source, but I’ve switched to using Homebrew for this:

brew install autoconf automake

Yes, it’s possibly ironic that I use Homebrew and yet build Emacs from source. However, Emacs is my #1 tool, and I want fine control over it. Think of it as building your own lightsaber.

If you do want to build from source, it’s easy:

Autoconf:

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

Automake:

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

Once you have the tools in place, you need the source:

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

At this point you have two choices, you can build the current production release, 24.5, from the emacs-24 branch, or you can build the development version 25.0 in master. I ran 25.0 for a bit, but experienced random crashing, so let’s start with production:

git checkout emacs-24
make configure
./configure --with-ns
make install

The make install it builds the Emacs.app bundle, no actual installing happens.

If you’d like to try Emacs 25.0, simple skip the checkout step.

To take shiny new Emacs for a spin:

open nextstep/Emacs.app

to install it:

open -R nextstep/Emacs.app

then drag Emacs to the Applications folder.

If you want to get fancy you might setup EmacsClient like I do. Or at least create an alias for launching from the command line:

# BASH
alias emacs=/Applications/Emacs.app/Contents/MacOS/Emacs
# TCSH
alias emacs /Applications/Emacs.app/Contents/MacOS/Emacs

Or if you like command line, you can put some command line in your command line so you can command line while you command line by adding the -nw flag to your alais:

# BASH
alias emacs='/Applications/Emacs.app/Contents/MacOS/Emacs -nw'

which will open Emacs in text only mode.

Finally, if you built emacs-24 and want to switch to master or vice versa run:

git clean -f -d -x

Then checkout the branch you want. That removes all untracked and ignored files from the directory. In theory one of the make *clean invocations should do that as well, but I’ve never been able get that to clear everything.

Tags: ,

Updated:

Comments