OS X El Capitanにbrew経由でccacheのHEADを導入する


ccacheを使うとC++などのコードのコンパイルにcacheを使って2回め以降のbuildを高速化することが期待できます。

GCCなどでは brew install ccache してinstallしたccacheを使うだけで問題ありませんが Clangで使う場合は HEADを installする必要があります。
XCodeなどで利用する場合は HEADを導入しましょう。

HEADを導入する場合は --HEAD オプションを付けます。

brew install --HEAD ccache

が、このようなエラーが出てしまいました。


[]:~/ brew install --HEAD ccache      
==> Installing dependencies for ccache: automake
==> Installing ccache dependency: automake
==> Downloading https://homebrew.bintray.com/bottles/automake-1.15.el_capitan.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring automake-1.15.el_capitan.bottle.2.tar.gz
🍺  /usr/local/Cellar/automake/1.15: 130 files, 2.9M
==> Installing ccache
==> Cloning https://github.com/jrosdahl/ccache.git
Cloning into '/Library/Caches/Homebrew/ccache--git'...
remote: Counting objects: 109, done.
remote: Compressing objects: 100% (109/109), done.
remote: Total 109 (delta 6), reused 11 (delta 0), pack-reused 0
Receiving objects: 100% (109/109), 359.51 KiB | 245.00 KiB/s, done.
Resolving deltas: 100% (6/6), done.
Checking connectivity... done.
==> Checking out branch master
==> ./autogen.sh
==> ./configure --prefix=/usr/local/Cellar/ccache/HEAD --mandir=/usr/local/Cellar/ccache/HEAD/share/man --with-bundled-zlib
==> make
==> make install
Last 15 lines from /Users/m00217/Library/Logs/Homebrew/ccache/04.make:
2016-04-28 11:57:56 +0900

make
install

asciidoc -a revnumber=unknown -d manpage -b docbook MANUAL.txt
make: asciidoc: No such file or directory
make: *** [MANUAL.xml] Error 1

READ THIS: https://git.io/brew-troubleshooting
If reporting this issue please do so at (not Homebrew/brew):
  https://github.com/Homebrew/homebrew-core/issues

どうやらasciidocが入ってないようなので、これもbrewでinstallします。

brew install asciidoc


[]:~/ brew install asciidoc         
==> Installing dependencies for asciidoc: docbook
==> Installing asciidoc dependency: docbook
==> Downloading https://homebrew.bintray.com/bottles/docbook-5.0.el_capitan.bottle.3.tar.gz
######################################################################## 100.0%
==> Pouring docbook-5.0.el_capitan.bottle.3.tar.gz
==> xmlcatalog --noout --create /usr/local/etc/xml/catalog
==> xmlcatalog --noout --del file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.2/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --add nextCatalog  file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.2/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --del file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.1.2/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --add nextCatalog  file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.1.2/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --del file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.3/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --add nextCatalog  file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.3/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --del file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.4/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --add nextCatalog  file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.4/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --del file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.5/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --add nextCatalog  file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.5/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --del file:///usr/local/Cellar/docbook/5.0/docbook/xml/5.0/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --add nextCatalog  file:///usr/local/Cellar/docbook/5.0/docbook/xml/5.0/catalog.xml /usr/local/etc/xml/catalog
==> Caveats
To use the DocBook package in your XML toolchain,
you need to add the following to your ~/.bashrc:

export XML_CATALOG_FILES="/usr/local/etc/xml/catalog"
==> Summary
🍺  /usr/local/Cellar/docbook/5.0: 181 files, 4.6M
==> Installing asciidoc
==> Downloading https://homebrew.bintray.com/bottles/asciidoc-8.6.9.el_capitan.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring asciidoc-8.6.9.el_capitan.bottle.1.tar.gz
==> Caveats
If you intend to process AsciiDoc files through an XML stage
(such as a2x for manpage generation) you need to add something
like:

  export XML_CATALOG_FILES=/usr/local/etc/xml/catalog

to your shell rc file so that xmllint can find AsciiDoc's
catalog files.

See `man 1 xmllint' for more.
==> Summary
🍺  /usr/local/Cellar/asciidoc/8.6.9: 94 files, 1M

再度HEADをinstall


[]:~/ brew install --HEAD ccache
Updating /Library/Caches/Homebrew/ccache--git
==> Checking out branch master
==> ./autogen.sh
==> ./configure --prefix=/usr/local/Cellar/ccache/HEAD --mandir=/usr/local/Cellar/ccache/HEAD/share/man --with-bundled-zlib
==> make
==> make install
Last 15 lines from /Users/m00217/Library/Logs/Homebrew/ccache/04.make:
2016-04-28 12:02:24 +0900

make
install

asciidoc -a revnumber=unknown -d manpage -b docbook MANUAL.txt
make: asciidoc: No such file or directory
make: *** [MANUAL.xml] Error 1

READ THIS: https://git.io/brew-troubleshooting
If reporting this issue please do so at (not Homebrew/brew):
  https://github.com/Homebrew/homebrew-core/issues


同様のエラーです。
一度手動でmakeしてみます。

/Library/Caches/Homebrew/ccache--git/ 配下にcloneされているので移動します。

下記のコマンドを実行することで手動でinstall作業が行われます。


./autogen.sh

./configure --prefix=/usr/local/Cellar/ccache/HEAD --mandir=/usr/local/Cellar/ccache/HEAD/share/man --with-bundled-zlib
make && make install

下記の通り make install 時にエラーが出てしまっているのがわかります。


$ make install                                                                                                        
asciidoc -a revnumber=unknown -d manpage -b docbook MANUAL.txt
xsltproc --nonet /usr/local/etc/asciidoc/docbook-xsl/manpage.xsl MANUAL.xml
I/O error : Attempt to load network entity http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
warning: failed to load external entity "http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
compilation error: file /usr/local/etc/asciidoc/docbook-xsl/manpage.xsl line 12 element import
xsl:import : unable to load http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
make: *** [ccache.1] Error 5

どうやらasciidocでxslファイルが読めていないようです。
brew に docbook-xsl というFormulaがあるので導入します。

brew install docbook-xsl

ここで再度 make install すると 問題なくinstall作業が完了します。


[git][* master]:/Library/Caches/Homebrew/ccache--git/ make install
xsltproc --nonet /usr/local/etc/asciidoc/docbook-xsl/manpage.xsl MANUAL.xml
Note: Writing ccache.1
/usr/local/bin/ginstall -c -d /usr/local/Cellar/ccache/HEAD/bin
/usr/local/bin/ginstall -c -m 755 ccache /usr/local/Cellar/ccache/HEAD/bin
/usr/local/bin/ginstall -c -d /usr/local/Cellar/ccache/HEAD/share/man/man1
/usr/local/bin/ginstall -c -m 644 ./ccache.1 /usr/local/Cellar/ccache/HEAD/share/man/man1/

brew link ccache するとbrewのFormulaとしてlinkしてくれます。
気になるようなら再度 brew install --HEAD ccache でinstallし直してもいいと思います。

これでccacheのHEADを導入することが出来ました。

環境
- OS X El Capitan 10.11.4
- Homebrew 0.9.9
- Homebrew/homebrew-core git revision 07d77