build-emacs.sh
Brut
#!/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 <<EOF
Build finished successfully.
Next step:
cd ${PWD}
sudo make install
Optional verification before install:
./src/emacs --version
EOF
| 1 | #!/usr/bin/env bash |
| 2 | set -euo pipefail |
| 3 | |
| 4 | EMACS_VER="${EMACS_VER:-30.2}" |
| 5 | |
| 6 | TARBALL="emacs-${EMACS_VER}.tar.gz" |
| 7 | URL="https://ftp.gnu.org/gnu/emacs/${TARBALL}" |
| 8 | SRC_DIR="emacs-${EMACS_VER}" |
| 9 | |
| 10 | install_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 | |
| 29 | echo "==> Building Emacs ${EMACS_VER} (nox-style) under /usr/local" |
| 30 | |
| 31 | install_deps |
| 32 | |
| 33 | if [[ -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 |
| 37 | fi |
| 38 | |
| 39 | if [[ ! -f "${TARBALL}" ]]; then |
| 40 | echo "==> Downloading ${URL}" |
| 41 | curl -fLO "${URL}" |
| 42 | else |
| 43 | echo "==> Reusing existing tarball ${TARBALL}" |
| 44 | fi |
| 45 | |
| 46 | echo "==> Extracting ${TARBALL}" |
| 47 | tar xf "${TARBALL}" |
| 48 | |
| 49 | cd "${SRC_DIR}" |
| 50 | |
| 51 | echo "==> 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 | |
| 66 | echo "==> Building Emacs ${EMACS_VER}" |
| 67 | make -j"$(nproc)" |
| 68 | |
| 69 | cat <<EOF |
| 70 | |
| 71 | Build finished successfully. |
| 72 | |
| 73 | Next step: |
| 74 | cd ${PWD} |
| 75 | sudo make install |
| 76 | |
| 77 | Optional verification before install: |
| 78 | ./src/emacs --version |
| 79 | |
| 80 | EOF |