2023/07/28

Compiling emacs for Crostini/chromeos

0. Introduction

I read an excellent article called Using Emacs 81 Elfeed Webkit by Mike Zamansky.  The ability to see more content whilst staying within Emacs is a good idea. Spoiler alert: It turned out to be even better than I thought, in fact, it is my favourite way to consume RSS/Atom.

I also wanted to get a newer version of Emacs than is readily available from standard sources, plus I also wanted to try tree-sitter. Note the is a much fuller explanation of compiling emacs with tree-sitter here; more importantly it gives extensive insight into why you will want it!

In summary, it worked, it wasn't too difficult and I found it fun!
I have highlighted what seemed to be Chromeos specifics in red.

1. Setting up the environment

I did the following
  • setup deb-src entries in /etc/apt/sources.lst. This can easily be done in the UI of a normal Linux distribution - and it can be done on Chromeos but it seemed more trouble than it was worth!
  • sudo apt update
  • sudo apt build-dep emacs ; this should install the required dependencies

2. Get extras

In addition to tree-sitter and widgets (for reading RSS) I also wanted to have native compilation
  • tree-sitter (many full distributions have easier ways of getting this)
    • git clone git@github.com:tree-sitter/tree-sitter.git
    • make
    • sudo make install
  • get xwidgets
    • sudo apt-get install libwebkit2gtk-4.0-dev
  • sudo apt install libgccjit-13-dev
  • sudo ldconfig

3. Build emacs

This is standard stuff, with the augmented configure line, which you may wish to vary.
  • git clone -b master git://git.sv.gnu.org/emacs.git
  • OR
    git clone --single-branch --branch=emacs-29 http://git.savannah.gnu.org/r/emacs.git emacs-29
  • checkout required version ( I just went with master and so I am on version 30! It works fine for me but you could be more prudent
  • export CC="gcc-13"
  • sh autogen.sh
  • ./configure --without-compress-install --with-native-compilation --with-json --with-mailutils --with-tree-sitter --with-xwidgets

  • make (may need to make bootstrap if there are errors)
  • sudo make install
If there is a config.h error try 'git clean -fdx' then make

4. Conclusion

The above list of commands is quite straightforward and you end up with a nice modern emacs which seemed a bit quicker to me.  In reality, the above list was obtained by a lot of trial and error, hence why I am documenting it!

Let me know if you have any questions or comments.

No comments: