Executive Orc House

HOMO HOMINI LUPUS

How I Build Emacs Now

So a while ago I posted a hideous shell script that I use to build Emacs on OSX. It was hideous and awful and didn’t in fact solve the problems that I wanted it to.

My requirements:

  • don’t build what you don’t have to;
  • personal configuration should live in ~/Library
  • shared configuration should live in /Library
  • the warning about the missing arch-dependent data dir makes me mad enough to punch a nun.

So I’ve hacked together the following, which:

  • updates my bzr checkout;
  • builds a non self-contained Emacs;
  • points the various directories that would live in /usr/local to where I want them;
  • is doubtless full of bugs.

But I figure, share and enjoy. There are probably, what, four people in the world who might find this elucidating?

Build my idosyncratic Emacs (build_emacs.zsh) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/zsh

# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004

# Copyright (C) 2004 Sam Hocevar
# 14 rue de Plaisance, 75014 Paris, France
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.

# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

# 0. You just DO WHAT THE FUCK YOU WANT TO.

set -e

export PATH=$HOME/gnu/bin:/usr/bin:/usr/sbin:/bin:/sbin

PREFIX=/Library/Emacs
SRC_DIR=$HOME/src/emacs/trunk

LIBEXEC_DIR=$PREFIX/libexec
SITE_LISP=$HOME/Library/Emacs/site-lisp

NS_SRC_DIR=$SRC_DIR/nextstep

SRC_APP=$NS_SRC_DIR/Emacs.app

rm -rf $SRC_APP

cd $SRC_DIR

THREAD_COUNT=$(( $(sysctl machdep.cpu.thread_count | cut -c27-) + 1 ))

echo "Building @`date`"
(/usr/local/bin/bzr revert && /usr/local/bin/bzr update) || exit 4

export CFLAGS="-pipe -march=nocona"

make distclean > /dev/null 2>&1 || true

[[ -f "configure" ]] || ./autogen.sh

chmod 0755 ./configure # yikes.
./configure --without-x \
            --with-ns \
            --without-dbus \
            --disable-ns-self-contained \
            --without-gpm \
            --without-selinux \
            --without-pop \
            --with-gameuser=$USER \
            --without-gconf \
            --prefix=$PREFIX \
            --datarootdir=$PREFIX \
            --docdir=$PREFIX/doc \
            --exec_prefix=$PREFIX \
            --enable-locallisppath=$SITE_LISP || exit 1

# Make the actual binary.
(make bootstrap libexecdir=$LIBEXEC_DIR archlibdir=$LIBEXEC_DIR && \
 make -j$THREAD_COUNT archlibdir=$LIBEXEC_DIR libexecdir=$LIBEXEC_DIR &&  make install archlibdir=$LIBEXEC_DIR libexecdir=$LIBEXEC_DIR && \
 echo "OK") || (echo "UH OH"; exit 2)

rm -rf $PREFIX/* || true
open $NS_SRC_DIR