Skip to content

Instantly share code, notes, and snippets.

@briang
Last active May 31, 2022 10:41
Show Gist options
  • Save briang/6ee9463305bb87be365a1661c87bee55 to your computer and use it in GitHub Desktop.
Save briang/6ee9463305bb87be365a1661c87bee55 to your computer and use it in GitHub Desktop.
Emacs 28 compilation script for debian 11
#!/bin/bash
set -o errexit # exit on error
set -o pipefail # trap pipe fails
set -o nounset # trap unset vars
DEST="/usr/local"
SOURCE="$HOME/emacs-28.1"
NATIVE_FULL_AOT='' # 'NATIVE_FULL_AOT=1' # removed in emacs 28.1
JOBS='-j 3'
function prereqs {
cd $HOME
sudo apt install \
autoconf build-essential checkinstall git libgccjit-11-dev libgif-dev \
libgnutls28-dev libgtk-3-dev libjansson-dev libjpeg-dev \
libncurses5-dev libtiff-dev libxpm-dev texinfo
export PKG_CONFIG_PATH=$(find /usr /lib -name pkgconfig | paste -s -d':')
# [[ ! -e ~/emacs.git ]] && \
# git clone --depth=1 https://github.com/emacs-mirror/emacs ~/emacs.git -b emacs-28
# cd ~/emacs.git
# git clean -dxf
if [[ ! -e $SOURCE ]] ; then
for f in emacs-28.1.tar.gz ; do
[[ ! -e $f ]] && wget https://ftp.gnu.org/gnu/emacs/$f
tar xf $f
done
fi
}
function build {
cd $SOURCE
unset confopts
confopts+="--prefix $DEST "
confopts+="--with-cairo "
confopts+="--with-gnutls "
confopts+="--with-json "
confopts+="--with-mailutils "
confopts+="--with-native-compilation "
confopts+="--with-rsvg "
confopts+="--with-x-toolkit=gtk "
confopts+="--without-toolkit-scroll-bars "
confopts+="--without-xaw3d "
confopts+="--without-xwidgets "
# --with-pgtk --with-sqlite3 # cut from emacs-28.1
./autogen.sh
./configure $confopts CFLAGS="-O2 -pipe"
make html
# AOT = Ahead Of Time aka native compile everything in advance
make $JOBS $NATIVE_FULL_AOT
}
function package {
cd $SOURCE
cat <<"EOD" > description-pak
GNU Emacs editor
GNU Emacs is the extensible self-documenting text editor. This package is
compiled with GTK+ GUI support and native-compilation of Elisp files.
EOD
sudo checkinstall \
--backup=no \
--pkgname=emacs28 \
--maintainer='"Brian Greenfield <[email protected]>"' \
sudo make $JOBS install install-html
echo ""
echo "install: dpkg -i *.deb"
echo "uninstall: dpkg -r emacs28"
}
function doit {
prereqs
build
package
}
time doit
echo ""
cd $SOURCE
for t in elc eln ; do
echo "$t: $(find . -name \*.$t | wc -l)"
done
@HarmtH
Copy link

HarmtH commented May 30, 2022

Thanks for the script. Btw, you forgot the bang in the shebang :-)

@briang
Copy link
Author

briang commented May 30, 2022

Fixed the missing shebang.

Thanks!

@briang
Copy link
Author

briang commented May 30, 2022 via email

@HarmtH
Copy link

HarmtH commented May 31, 2022

I got notified :-) I just tested the build, but pgtk doesn't seem to be available:

configure:39980: WARNING: unrecognized options: --with-pgtk, --with-sqlite3

Seems that it's not merged into the emacs-28 branch.

@briang
Copy link
Author

briang commented May 31, 2022

Yeah, sorry. This is an old script. I have a newer script that I've uploaded. This one creates a .deb in the root of the emacs28 source directory. You have to press Enter a couple of times towards the end of the build.

I'm not using this script any more. Now I build emacs.deb packages using https://github.com/kelleyk/ppa-emacs. This works for both Debian and Ubuntu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment