#!/usr/bin/env bash set -euox pipefail # Build Emacs 28 with GTK and native compilation. # The pure GTK implementation enable native support in Wayland. # Apt dependencies are for Ubuntu 20.04. march=${1:-native} mtune=${1:-native} emacs_git_dir=emacs-pgtk-nativecomp ccache_dir=/usr/lib/ccache echo "Compiling with march=$march and mtune=$mtune" sudo apt install --no-install-recommends -y \ make \ autoconf \ gcc-10 \ g++-10 \ texinfo \ pkg-config \ libjansson-dev \ zlib1g-dev \ libgccjit-10-dev \ libgnutls28-dev \ libncurses5-dev \ libx11-dev \ libgtk-3-dev \ libjpeg-dev \ libgif-dev \ libtiff-dev \ libxpm-dev \ libwebkit2gtk-4.0-dev ( export CC="gcc-10" export CXX="gcc-10" export CFLAGS="-O3 -march=${march} -mtune=${mtune} -pipe -fomit-frame-pointer" export CXXFLAGS="${CFLAGS}" if [[ -d $ccache_dir ]]; then export PATH="$ccache_dir:$PATH" fi echo "CFLAGS options: $CFLAGS" [[ -d $emacs_git_dir ]] || git clone https://github.com/flatwhatson/emacs.git $emacs_git_dir -b pgtk-nativecomp pushd $emacs_git_dir git fetch origin --prune git pull ./autogen.sh ./configure --with-dbus \ --with-cairo \ --with-json \ --with-harfbuzz \ --with-xwidgets \ --with-modules \ --with-native-compilation \ --with-pgtk make bootstrap make -j "$(nproc)" popd echo "Finish installation with 'sudo make install'" )