Skip to content

Instantly share code, notes, and snippets.

@antonymerle
Forked from abidanBrito/build-emacs.sh
Last active October 18, 2024 20:21
Show Gist options
  • Save antonymerle/b6eab47dc101869208c9e82b9d8dcf24 to your computer and use it in GitHub Desktop.
Save antonymerle/b6eab47dc101869208c9e82b9d8dcf24 to your computer and use it in GitHub Desktop.
Build GNU Emacs from source.
#!/usr/bin/env bash
## Author: Abidán Brito
## Adapted by Antony Merle for Arch Linux with KDE 6 and Wayland
## This script builds GNU Emacs 29.1 with support for native elisp compilation,
## tree-sitter, libjansson (C JSON library), Wayland, and mailutils.
# Exit on error and print out commands before executing them.
set -euxo pipefail
# Let's set the number of jobs to something reasonable; keep 2 cores
# free to avoid choking the computer during compilation.
JOBS=$(nproc --ignore=2)
# Clone repo locally and get into it.
git clone --depth 1 --branch emacs-29 git://git.savannah.gnu.org/emacs.git
pushd emacs
# Get essential dependencies.
sudo pacman -S --needed base-devel \
texinfo \
gnutls \
libjpeg-turbo \
libpng \
libtiff \
giflib \
libxpm \
ncurses \
gtk3 \
tree-sitter \
imagemagick \
libwebp \
jansson \
gcc \
libgccjit \
autoconf \
mailutils \
cairo \
harfbuzz \
glib2 \
libxml2 \
wayland \
wayland-protocols \
gtk-layer-shell
# Needed for compiling libgccjit
export CC=/usr/bin/gcc CXX=/usr/bin/g++
# Configure and run.
./autogen.sh \
&& ./configure \
--with-native-compilation \
--with-pgtk \
--with-wayland \
--with-tree-sitter \
--with-wide-int \
--with-json \
--with-modules \
--without-dbus \
--with-gnutls \
--with-mailutils \
--without-pop \
--with-cairo \
--with-imagemagick \
CFLAGS="-O2 -pipe -mtune=native -march=native -fomit-frame-pointer"
# Build.
make -j${JOBS} NATIVE_FULL_AOT=1 \
&& sudo make install
# Return to the original path.
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment