Compiling Emacs 29.2 from the source on Debian
Compile Emacs 29.2 from source with a recent bug-fix release highlighted by Eli Zaretskii. This Debian 12-focused tutorial simplifies the process, covering downloading, signature verification, and configuration. With an emphasis on ease, Debian's build dependencies are leveraged, allowing users to quickly build, install, and even uninstall Emacs for a seamless experience.
Compiling Emacs 29.2 from the source
Some days ago the Emacs community received a really nice message from Eli Zaretskii, which currently is a co-maintainer of GNU Emacs.
You can read it here: https://lists.gnu.org/archive/html/emacs-devel/2024-01/msg00666.html.
This is a bug-fix release, that means no new features were added.
That said, this gives us the opportunity of building Emacs from the source (which I usually prefer, since I like to toggle some switches).
The next steps in this short tutorial will take in consideration you have the latest Debian release, in my case:
(Linux debian 6.1.0-17-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.69-1 (2023-12-30) x86_64 GNU/Linux).
Downloading Emacs Source-Code
Create a new directory of your liking and cd into it:
mkdir ~/emacs_build
cd emacs_build
Download the Emacs source code and the signature file. You can do this from https://ftp.gnu.org/gnu/emacs/, by accessing it from your web-browser, or:
wget -c https://ftpmirror.gnu.org/emacs/emacs-29.2.tar.gz
wget -c https://ftpmirror.gnu.org/emacs/emacs-29.2.tar.gz.sig
Verifying the tarball Authenticity
Now verify the tarball (.tar.gz compressed file) authenticity by running:
gpg --verify emacs-29.2.tar.gz.sig
If you have some error message, it is possible you haven't yet imported Eli Zaretskii public key. You can do So by issuing:
gpg --keyserver keyserver.ubuntu.com --recv-keys \
17E90D521672C04631B1183EE78DAE0F3115E06B
That will return:
gpg: key E78DAE0F3115E06B: public key "Eli Zaretskii <eliz@gnu.org>" imported
gpg: Total number processed: 1
gpg: imported: 1
Now running gpg --verify emacs-29.2.tar.gz.sig
will return something like:
gpg: assuming signed data in 'emacs-29.2.tar.gz'
gpg: Signature made Thu 18 Jan 2024 07:55:42 AM -03
gpg: using RSA key 17E90D521672C04631B1183EE78DAE0F3115E06B
gpg: Good signature from "Eli Zaretskii <eliz@gnu.org>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 17E9 0D52 1672 C046 31B1 183E E78D AE0F 3115 E06B
And you can verify the signature of the package. If something is strange, stop here, check the sources and make sure you have an authentic copy of Emacs source code.
Unpacking the tarball
You can now unpack the tarball by running:
tar xvfz emacs-29.2.tar.gz
After that enter the created folder with:
cd emacs-29.2
Configuring for the build
Usually, building something from source means going trough config and make, several times, resolving dependencies and so on.
Here we're gonna cheat a little bit. Since Debian already ships some sort (normally older) of Emacs. We can ask to install the build dependencies for Emacs and save us some configure-make loop time.
Do this with:
sudo apt-get build-dep emacs
After this, it is time to configure things.
You can check all Emacs flags running ./configure --help
.
I usually go with these options:
./configure --with-native-compilation=aot\
--with-tree-sitter\
--with-gif\
--with-png\
--with-jpeg\
--with-rsvg\
--with-tiff\
--with-imagemagick\
--with-x-toolkit=lucid\
--with-json\
--with-mailutils
Customize it to your will.
Making and Installing
In this step we're actually building the software and installing.
Start by cleaning any older building with:
make clean
If you had some problem during a previous make, or had to stop it for some reason, this will ensure you new "build" is clean and starting from the beginning.
Now we actually run make with:
make -j8
This will compile Emacs by allowing 8 jobs at once. You can leave make with no -j
flag for infinite
jobs or customize at will.
If everything runs ok and make exits successfully you can test Emacs with ./src/emacs
, I recommend just doing a version check with:
./src/emacs --version
That may return:
GNU Emacs 29.2
Copyright (C) 2024 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
To have your built Emacs readily available, install it to your system with:
make install
Verify if you have the compiled version to your path by issuing:
emacs --version
You may have again:
GNU Emacs 29.2
...
And that's it!
Uninstalling Emacs
If things go wrong or you need to uninstall a version of Emacs
before compiling a new one, it is a "necessity practice" to keep the
folder from where you built your software, so you can run: make uninstall
and remove it completely from your system.