Ubuntu 22 LTS を使って Emacs-31.0.50 をビルドする。Ubuntu なら 素直にビルドできるハズ。
$ sudo apt install autoconf automake libtool m4 make gettext texinfo gcc g++ m17n-db libm17n-dev libncurses5-dev libgpm-dev xaw3dg-dev libgtk2.0-dev libgtk-3-dev libwebkit2gtk-4.0-dev libxpm-dev libjpeg-dev libgif-dev libtiff-dev librsvg2-dev libmagick++-dev libotf-dev liblcms2-dev libgnutls28-dev libtree-sitter-dev libgccjit-*-dev libselinux1-dev libsystemd-dev libacl1-dev ispell mailutils
$ ./configure --with-modules --with-xwidgets --enable-link-time-optimization --with-tree-sitter --with-native-compilation
$ make
$ sudo make install
UTF-8 / S-JIS 混乱回避努力のパッチ