Skip to content

Instantly share code, notes, and snippets.

@mahmoudimus
Forked from 3tty0n/build-emacs.sh
Last active March 24, 2024 14:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahmoudimus/10f02bb5c809edf04ae5b6bff8d55f65 to your computer and use it in GitHub Desktop.
Save mahmoudimus/10f02bb5c809edf04ae5b6bff8d55f65 to your computer and use it in GitHub Desktop.
Build emacs on Ubuntu 22.04
#!/bin/sh
# Explore:
# https://github.com/howardabrams/hamacs/blob/main/README-Linux.org
# https://batsov.com/articles/2021/12/19/building-emacs-from-source-with-pgtk/
# https://practical.li/blog/build-emacs-from-source-on-debian-linux/
# https://github.com/konstare/emacs-gcc-pgtk/blob/master/Dockerfile
# First determine your gcc version with gcc --version,
# then modify libgccjit-12-dev below to the major version number you have!
# From: https://codeberg.org/aesdef/spartan-emacs#headline-9
# Modified by Mahmoud Abdelkader (github.com/mahmoudimus)
sudo apt install \
build-essential \
autoconf \
libgtk-3-dev \
libgnutls28-dev \
libtiff5-dev \
libgif-dev \
librsvg2-dev \
libjpeg-dev \
libwebp-dev \
libxml2-dev \
libpng-dev \
libxpm-dev \
libncurses-dev \
texinfo \
libjansson4 \
libjansson-dev \
libgccjit0 \
libgccjit-12-dev \
libtree-sitter-dev
# Clone repo, checkout relevant branch at time of this writing
git clone git://git.sv.gnu.org/emacs.git
git checkout emacs-29
cd emacs
# Generate makefile
./autogen.sh
# set your c compiler to again be the major version of gcc on your system
export CC=/usr/bin/gcc-12 CXX=/usr/bin/gcc-12
# configure with the flags you want to build with
./configure --with-native-compilation \
--with-json \
--with-pgtk \
--with-rsvg \
--with-gnutls \
--without-xwidgets \
--without-xaw3d \
--with-mailutils \
--with-tree-sitter
# compile it
make -j"$(nproc)"
# start emacs (test)
./src/emacs
# From here, one could add a bash alias to the compiled executable in the HOME directory, e.g.
# alias emacs=~/repos/emacs/src/emacs
# OR, one could opt to just install it...
# sudo make install # to clobber it all over your system
# sudo make uninstall # should do a decent enough cleanup job
# to update, it might be necessary to clean it before pulling the repo and running through the entire process again
# make clean
# git clean -fdx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment