Skip to content

Instantly share code, notes, and snippets.

@egnha
Last active August 25, 2023 06:53
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egnha/289fe60e26708ece2480d4bcc08bea7e to your computer and use it in GitHub Desktop.
Save egnha/289fe60e26708ece2480d4bcc08bea7e to your computer and use it in GitHub Desktop.
Build Emacs on the Mac

Build Emacs on the Mac

emacs-mac by Mitsuharu Yamamoto enhances vanilla GNU Emacs by enabling various Safari-like conveniences, such as tabs and tab overview and back/forward swiping between buffers. It also enables various Mac-specific Elisp commands, such as (mac-auto-operator-composition-mode) to enable font ligatures.

You can install a pre-built binary with the Homebrew formula provided by railwaycat. But be aware that you can't launch it from Spotlight, because it doesn't install Emacs.app in /Applications (you'd have to do that manually).

Install dependencies

brew install autoconf gnutls pkg-config texinfo

Enabling makeinfo

Since texinfo is keg-only (cf. brew info texinfo), you'll need to (temporarily) add the makeinfo path to PATH in order to build the Emacs manuals (info files):

export PATH="/usr/local/opt/texinfo/bin:$PATH"

Configure, build, install

Clone the emacs-mac repo:

git clone https://bitbucket.org/mituharu/emacs-mac.git

Configure it:

cd emacs-mac
./autogen.sh
./configure CC="clang -fobjc-arc" --with-mac --enable-mac-app --with-modules --with-gnutls

Build and install:

make
sudo make install

The app will be installed to /Applications/Emacs.app.

Optional: Install additional headers

On macOS 10.14 (Mojave), make may stop with the following error:

... fatal error: 'libxml/tree.h' file not found
#include <libxml/tree.h>
         ^~~~~~~~~~~~~~~
1 error generated.

If so, you need to install additional header files:

sudo installer \
  -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg \
  -target /

Alternatively, you can drop XML parsing support with the configure switch --without-xml2 (see above).

Optional: Install Info files

You may need to install the info files manually, if you find that the entries listed by C-h i don't match those in the file info/dir (e.g., no entry for the Emacs Lisp Reference Manual).

sudo make install-info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment