Compiling Emacs 27.0.90 on Ubuntu 18.04

#emacs

Here’s a summary of how I compiled and installed Emacs 27.0.90 in a custom directory on my system running Ubuntu 18.04. Before this, I was using Emacs 26.3, which I got from a Ubuntu PPA. Version 27.0.90 is the first pretest of what will become Emacs 27.1. It’s called a “pretest” version, but they tend to be stable in my experience.

The generic instructions for compiling installing Emacs are:

./autogen.sh
./configure
make bootstrap
make install

However, I wanted Emacs 27 to have the same set of features (at least) that my old Emacs 26.3 had, and I also wanted to install it in my $HOME directory. This meant I had to tweak the ./configure command, and install extra packages with sudo apt install.

Installing Emacs in a custom directory, e.g. /home/thomas/prg/emacs-27, was as easy as

./configure --prefix=/home/thomas/prg/emacs-27

I got my old Emacs 26.3 from a Ubuntu PPA, prebuilt and ready to go. Since it was prebuilt I didn’t know how ./configure was invoked or what features was activated. There are two built-in variables in Emacs that can help with that: system-configuration-features and system-configuration-options. I evaluated them in the *scratch* buffer:

system-configuration-options
"--build=x86_64-linux-gnu --prefix=/usr '--includedir=${prefix}/include'
'--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' --sysconfdir=/etc
--localstatedir=/var --disable-silent-rules
'--libdir=${prefix}/lib/x86_64-linux-gnu'
'--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode
--disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib
--program-suffix=26 --with-modules --with-file-notification=inotify
--with-mailutils --with-x=yes --with-x-toolkit=gtk3 --with-xwidgets
--with-lcms2 'CFLAGS=-g -O2
-fdebug-prefix-map=/build/emacs26-TP6iDo/emacs26-26.3~1.git96dd019=.
-fstack-protector-strong -Wformat -Werror=format-security -no-pie'
'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-Bsymbolic-functions
-Wl,-z,relro -no-pie'"

system-configuration-features
"XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB NOTIFY
LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS
GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS LIBSYSTEMD LCMS2"

system-configuration-options showed the parameters that were passed to ./configure, and system-configuration-features showed enabled features. I wanted the same features to be enabled in my new Emacs 27.

I downloaded emacs-27.0.90.tar.xz, installed package for extracting .xz-files with sudo apt install xz-utils, extracted the file with tar -xf emacs-27.0.90.tar.xz, stepped into the extracted directory with cd, and executed ./autogen.sh.

Next began an iterative process of me running ./configure, installing missing packages, compiling with make bootstrap, starting the new Emacs 27 with src/emacs, and checking to see if all the features I wanted had been enabled yet.

Here’s the final ./configure command I ended up using:

./configure --prefix=/home/thomas/prg/emacs-27\
  --disable-silent-rules\
  --with-modules\
  --with-file-notification=inotify\
  --with-mailutils\
  --with-x=yes\
  --with-x-toolkit=gtk3\
  --with-xwidgets\
  --with-lcms2\
  --with-imagemagick

The relevant output from the ./configure command:

Configured for 'x86_64-pc-linux-gnu'.

  Where should the build process find the source code?    .
  What compiler should emacs be built with?               gcc -g3 -O2
  Should Emacs use the GNU version of malloc?             no
    (The GNU allocators don't work with this system configuration.)
  Should Emacs use a relocating allocator for buffers?    no
  Should Emacs use mmap(2) for buffer allocation?         no
  What window system should Emacs use?                    x11
  What toolkit should Emacs use?                          GTK3
  Where do we find X Windows header files?                Standard dirs
  Where do we find X Windows libraries?                   Standard dirs
  Does Emacs use -lXaw3d?                                 no
  Does Emacs use -lXpm?                                   yes
  Does Emacs use -ljpeg?                                  yes
  Does Emacs use -ltiff?                                  yes
  Does Emacs use a gif library?                           yes -lgif
  Does Emacs use a png library?                           yes -lpng16 -lz
  Does Emacs use -lrsvg-2?                                yes
  Does Emacs use cairo?                                   no
  Does Emacs use -llcms2?                                 yes
  Does Emacs use imagemagick?                             yes
  Does Emacs support sound?                               yes
  Does Emacs use -lgpm?                                   yes
  Does Emacs use -ldbus?                                  yes
  Does Emacs use -lgconf?                                 no
  Does Emacs use GSettings?                               yes
  Does Emacs use a file notification library?             yes -lglibc (inotify)
  Does Emacs use access control lists?                    yes -lacl
  Does Emacs use -lselinux?                               yes
  Does Emacs use -lgnutls?                                yes
  Does Emacs use -lxml2?                                  yes
  Does Emacs use -lfreetype?                              yes
  Does Emacs use HarfBuzz?                                yes
  Does Emacs use -lm17n-flt?                              yes
  Does Emacs use -lotf?                                   yes
  Does Emacs use -lxft?                                   yes
  Does Emacs use -lsystemd?                               yes
  Does Emacs use -ljansson?                               no
  Does Emacs use -lgmp?                                   yes
  Does Emacs directly use zlib?                           yes
  Does Emacs have dynamic modules support?                yes
  Does Emacs use toolkit scroll bars?                     yes
  Does Emacs support Xwidgets (requires gtk3)?            yes
  Does Emacs have threading support in lisp?              yes
  Does Emacs support the portable dumper?                 yes
  Does Emacs support legacy unexec dumping?               no
  Which dumping strategy does Emacs use?                  pdumper

Here are all the extra packages I had to install with sudo apt install:

  • libxpm-dev
  • libjpeg-dev
  • libgnutls28-dev
  • libgif-dev
  • libtiff-dev
  • libacl1-dev
  • libgtk-3-dev
  • libwebkit2gtk-4.0-dev
  • librsvg2-dev
  • libmagickcore-dev
  • libmagick++-dev
  • libgpm-dev
  • libselinux1-dev
  • libm17n-dev
  • libotf-dev
  • libsystemd-dev

You may need to install more or fewer depending on what packages you have installed already and what features you want. The ./configure command is pretty good at telling you what’s missing.

After a successful ./configure run, I compiled and installed it with:

make bootstrap
make install

I started my new Emacs with the command /home/thomas/prg/emacs-27/bin/emacs and evaluated the two system-variables:

system-configuration-options
"--prefix=/home/thomas/prg/emacs-27 --disable-silent-rules --with-modules
--with-file-notification=inotify --with-mailutils --with-x=yes --with-x-toolkit=gtk3
--with-xwidgets --with-lcms2 --with-imagemagick"

system-configuration-features
"XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF XFT
ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS
LIBSYSTEMD PDUMPER LCMS2 GMP"

Those are all the features my old Emacs 26.3 had, and then some. I didn’t bother to investigate these “extra” features (INOTIFY ACL HARFBUZZ PDUMPER GMP), hopefully it’ll be fine.