なんだこれは

はてなダイアリーから移転しました。

Emacs 25.1/Mac でAppKit usability noを回避

TL;DR

Emacs 25.1.1 をMac にインストールするときのAppkit/Appkit.h が存在するが利用できない(usability...no & presence...yes)というエラーがでる場合、clangを使う

発生条件

CC=gcc つまり gccがデフォルトのコンパイラMac OS X環境でEmacs 25.1のビルド準備(configure)するとき (XサポートなしでCocoaサポートのはず)

cd somewhere
curl -OL http://ftp.jaist.ac.jp/pub/GNU/emacs/emacs-25.1.tar.xz
tar Jxvf emacs-25.1.tar.xz
cd emacs-25.1
./configure --without-x

configureスクリプトはこのようなエラーをだすことがある。

checking AppKit/AppKit.h usability... no
checking AppKit/AppKit.h presence... yes
configure: WARNING: AppKit/AppKit.h: present but cannot be compiled
configure: WARNING: AppKit/AppKit.h: check for missing prerequisite headers?
configure: WARNING: AppKit/AppKit.h: see the Autoconf documentation
configure: WARNING: AppKit/AppKit.h: section "Present But Cannot Be Compiled"
configure: WARNING: AppKit/AppKit.h: proceeding with the compiler's result
configure: WARNING: ## ------------------------------------ ##
configure: WARNING: ## Report this to bug-gnu-emacs@gnu.org ##
configure: WARNING: ## ------------------------------------ ##
checking for AppKit/AppKit.h... no
configure: error: The include files (AppKit/AppKit.h etc) that
are required for a Nextstep build are missing or cannot be compiled.
Either fix this, or re-configure with the option '--without-ns'.

通常のMac環境では、AppKit/Appkit.h は例えば以下の場所にあるはずである。

locate AppKit.h | grep -v html

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/AppKit.h
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdk/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/AppKit.h
/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/AppKit.h

このパスをCPPFLAGS=-Iで渡してみたが同じエラーがでることがある。
エラーをよくみると、usability ... no で presence ... yesとあることから、見つけているが使用できないといっている。

AppKit.h といえば MacMacの標準コンパイラ環境といえば、clang/Xcodeである。ということで、コンパイラをclangと交換すればうまくいきそうである。

cd somewhere
curl -OL http://ftp.jaist.ac.jp/pub/GNU/emacs/emacs-25.1.tar.xz
tar Jxvf emacs-25.1.tar.xz
cd emacs-25.1
CC=/usr/bin/clang ./configure --without-x

これでエラーがでずにすすめられる。
このときにmakeがgnu make とbsd makeの両方をいれていた場合、gmake使ってねなどと指示がでることがあるので、従うこと。

あとは、

gmake
gmake install

すると、そのディレクトリ以下の nextstep ディレクトリ以下にEmacs.appができている。
これをどこかにコピーすれば、終了である。