Windows 上でのコンパイル
Emacs 23.1 が 2009/7/29 にリリースされたので Windows でのコンパイルをしてみた。
- Emacs のソースファイルを Index of /gnu/emacs からダウンロードする
- MinGW (Automated MinGW Installer) を MinGW - Minimalist GNU for Windows - Browse Files at SourceForge.net からダウンロードする
- MinGW のインストーラを実行しパッケージをフルインストールする
- MSYS Base System を MinGW - Minimalist GNU for Windows - Browse Files at SourceForge.net からダウンロードする
- MSYS のインストーラを実行する
- GnuWin32 Packages から必要となるライブラリをダウンロード・インストールする。それぞれ Setup パッケージをインストールすればライブラリ、ヘッダファイルがインストールできる。
必要となるライブラリは以下のもの。
- Xpm
- LibPng
- Zlib
- LibUnGif
- LibJpeg
- LibTiff
Xpm のインストール確認で simx.h が必要となる。これは Xpm のソースファイルに含まれているので、ソースファイルをダウンロードし、インストールした MinGW\src\xpm\3.5.1\libXpm-3.5.1-src\lib にある simx.h を MinGW\include にコピーする必要がある。
- Cygwin など他の実行ファイルが呼び出されないように MinGW, MSYS のみの PATH にしておく
> set PATH=C:\usr\MinGW\bin;c:\usr\msys\bin
- ダウンロードした Emacs のソースファイルを展開する
- 展開した Emacs ディレクトリ下にある nt ディレクトリに移動し、configure.bat を実行する
> cd nt
> configure.bat
Checking for 'cp'...
Checking for 'rm'...
Checking whether 'gcc' is available...
Checking whether gcc requires '-mno-cygwin'...
(中略)
config.settings
gmake.defs
..\leim\makefile.w32-in
1 個のファイルをコピーしました。
1 個のファイルをコピーしました。
Emacs successfully configured.
Run `make' to build, then run `make install' to install.
- mingw32-make.exe を実行する
> mingw32-make.exe
[Please ignore a syntax error on the next line - it is intentional]
/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file
Using C:/usr/msys/bin/sh.exe as shell.
(中略)
mingw32-make.exe[1]: Entering directory `C:/home/emacs-23.1/leim'
mingw32-make.exe[1]: Nothing to be done for `all'.
mingw32-make.exe[1]: Leaving directory `C:/home/emacs-23.1/leim'
- mingw32-make.exe install を実行すると bin ディレクトリが生成され、そこに runemacs.exe が作成される
- runemacs.exe を実行してバージョンを確認する
備考
22.2.1 で使用していた .emacs にある以下のものが使用できなくなっていたが、まずは起動できた
(require 'fixed-width-fontset)
(require 'ntemacs-font)
fixed-width-fonset を 23.1.1 では使用しないように .emacs の fixed-width-fonset をロードする箇所を以下のように変更
; fixed-width-fontset
; Emacs 23.1.1 の場合は使用できない
(defun load-fixed-width-fontset ()
(message "This emacs version can support fixed-width-fontset")
(require 'fixed-width-fontset)
(require 'ntemacs-font))
(message "emacs-version %s" emacs-version)
(message "emacs-version %d" (string-to-number emacs-version))
(if (< 22 (string-to-number emacs-version))
(message "This emacs version CANNOT support fixed-width-fontset")
(load-fixed-width-fontset))
sile-lisp ディレクトリに fixed-width-fontset のディレクトリがあるとロードしにいってしまうので、ディレクトリも削除しておく
Emacs 23.1 の IME patch を当てる
- NTEmacs JP Project プロジェクト日本語トップページ - SourceForge.JP から Emacs-23.1-IME.patch.gz をダウンロードする
- emacs-23.1 を解凍したディレクトリのルート (INSTALL, COPYING, README などがあるディレクトリ) に Emacs-23.1-IME.patch を置く
- patch を当てる
> patch -p3 < Emacs-23.1-IME.patch
patching file lib-src/makefile.w32-in
patching file lisp/loadup.el
patching file nt/configure.bat
patching file src/keyboard.c
patching file src/w32.c
patching file src/w32fns.c
patching file src/w32term.c
patching file src/w32term.h
patching file src/window.c
patching file lisp/international/w32-ime.el
patch コマンドのオプションにある -p は patch ファイルで指定されているディレクトリ階層のレベルを指定する。
この patch ファイルには以下のように記載されており、Emacs-23.1 のディレクトリから見ると 3 階層目からの lib-src からが指定したいファイルとなる。そこで -p3 で 3 階層目から使用することを明示する。
--- ~/src/emacs-23.1/lib-src/makefile.w32-in 2009-07-30 00:09:40.000000000 +0900
+++ /tmp/emacs-23.1/lib-src/makefile.w32-in 2009-08-03 16:54:16.990792800 +0900
patch コマンド中に nt/configure.bat で下記のエラーが出てくる。これは configure.bat の改行コードが CR+LF であるが、patch の方は LF となっているために一致箇所がないと判定されてしまう。その場合は元の configure.bat をエディタで開いて改行コードを LF にして保存すればエラーが解消される。
patching file nt/configure.bat
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file nt/configure.bat.rej
- nt ディレクトリで configure.bat を実行する
> configure.bat --with-gcc --enable-w32-ime --no-cygwin --cflags -D_UNICODE --cflags -DRECONVERSION --prefix=c:/install
RECONVERSION フラグを付けてコンパイルすると入力済み文字列に対して "変換" ボタンを押した時に再変換が可能となる
"_UNICODE" フラグを付けてコンパイルすると Unicode 版を使用可能となる。
"--prefix" でインストール先ディレクトリを指定する
- mingw32-make.exe を実行する
mingw32-make.exe bootstrap をしたところで elc ファイルが一旦削除され、その後再度作成される。
> mingw32-make.exe bootstrap
> mingw32-make.exe info
> mingw32-make.exe
> mingw32-make.exe install
- .emacs の編集
.emacs ロード時に以下のように表示される。これは php-mode のロードで問題が発生してるようだ。
.emacs の該当箇所を requrire から autoload に変更すれば Warning はでなくなる
;;; ====== php =====
;(require 'php-mode)
(autoload 'php-mode "php-mode" "Major mode for editing php code." t)