build-emacs.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env bash
  2. set -euo pipefail # bash strict mode
  3. # https://gist.github.com/mberrueta/d2234142c639de1fc6b0f2192228bcc1
  4. # NOTE: If you're using Wayland, you might want to consider compiling Emacs 29 with the '--with-pgtk' option as well.
  5. DATE="$(date +%F)"
  6. VERSION_CALCULATED="$(( $(date +%y) + 5 ))"
  7. VERSION="${1:-$VERSION_CALCULATED}"
  8. BRANCH="emacs-${VERSION}"
  9. BUILD_DIR="/tmp/${BRANCH}_${DATE}"
  10. INSTALL_DIR="${HOME}/.local/${BRANCH}"
  11. JOBS="$(nproc --ignore 4)" # do not flood the cpu
  12. sudo apt-get -y build-dep emacs
  13. sudo apt-get -y install libtree-sitter-dev
  14. # clone if not such dir
  15. [[ ! -d "$BUILD_DIR" ]] && git clone --depth 1 --branch "$BRANCH" git://git.savannah.gnu.org/emacs.git "$BUILD_DIR"
  16. cd "$BUILD_DIR"
  17. ./autogen.sh
  18. # ./configure --prefix="$INSTALL_DIR" --without-compress-install --with-native-compilation --with-json --with-mailutils --with-tree-sitter --with-pgtk CC=gcc-12
  19. ./configure --prefix="$INSTALL_DIR" --without-compress-install --with-native-compilation --with-json --with-mailutils --with-tree-sitter CC=gcc-12
  20. make -j "$JOBS"
  21. make install
  22. ln -fs "${INSTALL_DIR}/bin/emacs"* "/usr/local/bin/"
  23. rsync -ruhvP "${INSTALL_DIR}/share" "/usr/local/share/"
  24. # Uninstallation
  25. # --------------
  26. # Change directory to the folder containing the source and perform the following steps:
  27. # $ sudo make uninstall
  28. # $ make clean
  29. # $ make distclean