WSLでよくない?という話なんですが、よくよく考えるとRを使うには依存ライブラリとかいろいろ入れないとだめでめんどくさいなあと。ということでやってみた時のメモ。
MSYS2をインストール
以下に従う。
Emacsに必要なパッケージをインストール
pacman -S --needed base-devel \ mingw-w64-x86_64-toolchain \ mingw-w64-x86_64-xpm-nox \ mingw-w64-x86_64-libtiff \ mingw-w64-x86_64-giflib \ mingw-w64-x86_64-libpng \ mingw-w64-x86_64-libjpeg-turbo \ mingw-w64-x86_64-librsvg \ mingw-w64-x86_64-lcms2 \ mingw-w64-x86_64-jansson \ mingw-w64-x86_64-libxml2 \ mingw-w64-x86_64-gnutls \ mingw-w64-x86_64-zlib
レポジトリをclone
pacman -S git mkdir /c/emacs cd /c/emacs wget http://ftp.jaist.ac.jp/pub/GNU/emacs/emacs-25.3.tar.xz tar xJf emacs-25.3.tar.xz
ビルド
注意するのは、ビルドはmsys2.exeじゃなくてmingw64.exeからじゃないとだめだということ。
echo $PATH
の結果を見て、一番上に/bin/mingw64がきていれば正解。そうでなければ以下のようなエラーになる。
configure: error: Emacs does not support 'x86_64-pc-msys' systems.
ちゃんとできていれば、ビルドも成功するはず。
cd /c/emacs/emacs-25.3 ./configure --prefix=/c/emacs/emacs-25.3 --without-imagemagick --without-dbus make -j$(nproc) make install
ちなみに、Clangでもビルドできるかな?と思ったけどなんかエラーでむりだった(深くは追っていない)
In file included from getopt.c:24:
In file included from ./getopt.h:52:
In file included from .\unistd.h:40:
In file included from C:\msys64\mingw64\x86_64-w64-mingw32\include\unistd.h:11:
In file included from ../src\process.h:29:
In file included from ../src/gnutls.h:31:
../src/lisp.h:790:10: fatal error: 'globals.h' file not found
#include "globals.h"
^~~~~~~~~~~
1 error generated.
make[1]: *** [Makefile:89: getopt.o] エラー 1
make[1]: ディレクトリ '/c/emacs/lib' から出ます
make: *** [Makefile:405: lib] エラー 2
あと、26系もビルドしてみようと思ったけどこっちはこっちで別のエラーでだめだった。
Emacsを起動
./bin/runemacs.exe -Q
とやるとEmacsが立ち上がるはず。(-Qってなんのオプションなんでしょう...)
ただし、C:\emacs\emacs25.3\bin\runemacs.exeをクリックして立ち上がるEmacsはGnuTLSを見つけられなくてHTTPSのウェブページにアクセスできない。
とりあえず以下のようにmingw64.exeからrunemacs.exeすればいける。たぶん、C:\emacs\emacs-25.3からC:\msys64\mingw64\libあたりにリンクを貼るのが正しい気がするし、./configure時に指定できそうな気もするけど、とりあえず動くのでこれでいいか...
C:\msys64\mingw64.exe /c/emacs/emacs-25.3/bin/runemacs.exe