Last active 1773473428

Revision 08960a36aadf21006211b5c50471e328d8702636

build-emacs.sh Raw
1#!/usr/bin/env bash
2set -euo pipefail
3
4EMACS_VER="${EMACS_VER:-30.2}"
5
6TARBALL="emacs-${EMACS_VER}.tar.gz"
7URL="https://ftp.gnu.org/gnu/emacs/${TARBALL}"
8SRC_DIR="emacs-${EMACS_VER}"
9
10install_deps() {
11 echo "==> Installing build dependencies (Debian/Ubuntu)"
12 sudo apt update
13 sudo apt install -y \
14 build-essential \
15 autoconf \
16 texinfo \
17 curl \
18 libsystemd-dev \
19 libmailutils-dev \
20 libtree-sitter-dev \
21 libxml2-dev \
22 libjansson-dev \
23 libsqlite3-dev \
24 libgnutls28-dev \
25 libncurses-dev \
26 pkg-config
27}
28
29echo "==> Building Emacs ${EMACS_VER} (nox-style) under /usr/local"
30
31install_deps
32
33if [[ -e "${SRC_DIR}" ]]; then
34 echo "Error: source directory '${SRC_DIR}' already exists."
35 echo "Please remove it first, or build a different version."
36 exit 1
37fi
38
39if [[ ! -f "${TARBALL}" ]]; then
40 echo "==> Downloading ${URL}"
41 curl -fLO "${URL}"
42else
43 echo "==> Reusing existing tarball ${TARBALL}"
44fi
45
46echo "==> Extracting ${TARBALL}"
47tar xf "${TARBALL}"
48
49cd "${SRC_DIR}"
50
51echo "==> Configuring Emacs ${EMACS_VER}"
52./configure \
53 --prefix=/usr/local \
54 --with-libsystemd \
55 --with-pop=yes \
56 --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" \
57 --without-sound \
58 --without-gconf \
59 --with-mailutils \
60 --with-native-compilation=no \
61 --with-x=no \
62 --without-gsettings \
63 --with-tree-sitter \
64 --with-xml2
65
66echo "==> Building Emacs ${EMACS_VER}"
67make -j"$(nproc)"
68
69cat <<EOF
70
71Build finished successfully.
72
73Next step:
74 cd ${PWD}
75 sudo make install
76
77Optional verification before install:
78 ./src/emacs --version
79
80EOF