#!/usr/bin/env bash set -euo pipefail EMACS_VER="${EMACS_VER:-30.2}" TARBALL="emacs-${EMACS_VER}.tar.gz" URL="https://ftp.gnu.org/gnu/emacs/${TARBALL}" SRC_DIR="emacs-${EMACS_VER}" install_deps() { echo "==> Installing build dependencies (Debian/Ubuntu)" sudo apt update sudo apt install -y \ build-essential \ autoconf \ texinfo \ curl \ libsystemd-dev \ libmailutils-dev \ libtree-sitter-dev \ libxml2-dev \ libjansson-dev \ libsqlite3-dev \ libgnutls28-dev \ libncurses-dev \ pkg-config } echo "==> Building Emacs ${EMACS_VER} (nox-style) under /usr/local" install_deps if [[ -e "${SRC_DIR}" ]]; then echo "Error: source directory '${SRC_DIR}' already exists." echo "Please remove it first, or build a different version." exit 1 fi if [[ ! -f "${TARBALL}" ]]; then echo "==> Downloading ${URL}" curl -fLO "${URL}" else echo "==> Reusing existing tarball ${TARBALL}" fi echo "==> Extracting ${TARBALL}" tar xf "${TARBALL}" cd "${SRC_DIR}" echo "==> Configuring Emacs ${EMACS_VER}" ./configure \ --prefix=/usr/local \ --with-libsystemd \ --with-pop=yes \ --enable-locallisppath="/etc/emacs:/usr/local/share/emacs/${EMACS_VER}/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/${EMACS_VER}/site-lisp" \ --without-sound \ --without-gconf \ --with-mailutils \ --with-native-compilation=no \ --with-x=no \ --without-gsettings \ --with-tree-sitter \ --with-xml2 echo "==> Building Emacs ${EMACS_VER}" make -j"$(nproc)" cat <