Building Emacs from source
A reference page for building Emacs from the git source.
git
This is the remote I prefere to use:
$ git remote -v origin git://git.sv.gnu.org/emacs.git (fetch) origin git://git.sv.gnu.org/emacs.git (push)
In order to build from a clean slate do:
git reset --hard git clean -xdf
build
Get all the build dependancies. For debian and the likes uncomment the necessary
deb-src
from /etc/apt/sources.list
and run this:
sudo apt build-dep emacs
The process is:
git clone git://git.sv.gnu.org/emacs.git && cd emacs ./autogen.sh # Optional build dir mkdir build && cd build ./configure # or `../configure` if in build dir # for full native compilation make NATIVE_FULL_AOT=1 -j$(nproc)
In arch figuring the dependancies is easy for each library, in ubuntu not that much. Both libjansson, libgccjit and libtree-sitter required manual intervation because they are not availiable in apt.
Here is a configure command for emacs 29+
./configure --with-json --with-native-compilation=aot --with-tree-sitter
Regarding configure
options I like the following:
--with-json
- requires
libjansson-dev
--with-native-compilation=aot
- reqiures
libgccjit-9-dev
--with-tree-sitter
- reqiures
libtree-sitter-dev
Also some more dependanices:
libsqlite3-dev
- for editing sqlite files
libwebp-dev
- for viewing webp files
I wonder what enables the native image api..
In the end this is what I strive for:
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 dont 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 -lwebp? yes
Does Emacs use -lsqlite3? yes
Does Emacs use cairo? yes
Does Emacs use -llcms2? yes
Does Emacs use imagemagick? no
Does Emacs use native APIs for images? no
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? no
Does Emacs use -lsystemd? yes
Does Emacs use -ljansson? yes
Does Emacs use -ltree-sitter? yes
Does Emacs use the GMP library? 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? no
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
Does Emacs have native lisp compiler? yes
Does Emacs use version 2 of the X Input Extension? yes
Does Emacs generate a smaller-size Japanese dictionary? no