box.matto.nl
Enjoying Open Source Software

Compiling Emacs

Quite some time ago I started with a git clone of the Emacs sources and compiled that.

From that time on, on a regular basis I do a git pull and recompile Emacs.

Like all self compiled software, I manage the installation with GNU Stow.

Being Emacs, there is probably more than one way to compile it, and I don't know if the way I compile Emacs is the best way, but it works and has never failed.

Before you start, make sure you have the right dependencies installed. The (not very big) list of packages to install is, of course, for every operating system different.

Lucid toolkit

In the past, I had some problems with the GTK version, can't remember exactly what it was, I guess some problems with the interaction with the window manager (either ratpoison or dwm).

I changed to the Lucid toolkit, and all problems were gone. From than on, I have stayed with Lucid.

Prepare to install with stow

mkdir -p /usr/local/stow/emacs

Initial git clone

As mortal user:

git clone https://git.savannah.gnu.org/git/emacs.git
./autogen.sh
./configure --with-x-toolkit=lucid --prefix=/usr/local/stow/emacs
make bootstrap

As root:

make install
cd /usr/local/stow
stow --ignore=dir emacs

After this, Emacs has been installed, with a number of subdirectories, under /usr/local/stow/emacs:

.
|-- bin
|   |-- ctags
|   |-- ebrowse
|   |-- emacs -> emacs-30.0.50
|   |-- emacs-30.0.50
|   |-- emacsclient
|   `-- etags
|-- include
|   `-- emacs-module.h
|-- lib
|   `-- systemd
|-- libexec
|   `-- emacs
`-- share
    |-- applications
    |-- emacs
    |-- icons
    |-- info
    |-- man
    `-- metainfo

The command stow --ignore=dir emacs creates symlinks in /usr/local/bin, /usr/local/include, and so on, to these subdirectories.

Upgrade and recompile

Recompiling Emacs is not much different.

This is how I do this:

As mortal user:

git pull
git clean -dxf
./autogen.sh
./configure --with-x-toolkit=lucid --prefix=/usr/local/stow/emacs
make bootstrap

As root:

cd /usr/local/stow
stow -D --ignore=dir emacs

rm -rf emacs-old
mv emacs emacs-old

cd [git clone dir]
make install

cd /usr/local/stow
stow --ignore=dir emacs

This moves the current install from /usr/local/stow/emacs to /usr/local/stow/emacs-old, creates a new directory /usr/local/stow/emacs and installs the new version there.

This way, if the new compiled version has any problems, I can always revert to the last compiled version. In practice, however, I have never had to do this.

Also, on several boxes with the same OS (and OS-version), the stow-directory can be shared, so compilation on only one system is needed.

Upgrade packages

After a recompile, I upgrade the packages in Emacs.

Happy Emacsing !

Tags:

⇽ Org-capture template for weeknotes The old Thinkpad X201 has become my daily driver ⇾