Mac OS X El Capitanにrlwrapをソースからインストールする

つまづいたところのメモ。

rlwrapをbrewからインストールしようとしたら、パッケージのダウンロードで失敗していた。

% brew install rlwrap                                                                          [master]
==> Downloading http://utopia.knoware.nl/~hlub/rlwrap/rlwrap-0.42.tar.gz

curl: (7) Failed to connect to utopia.knoware.nl port 80: Operation timed out
Error: Failed to download resource "rlwrap"
Download failed: http://utopia.knoware.nl/~hlub/rlwrap/rlwrap-0.42.tar.gz

utopia.knoware.nlの名前解決もできない残念な状況。

仕方ないのでソースから入れることにする。

git clone https://github.com/hanslub42/rlwrap
cd rlwrap
autoreconf --install
./configure

しかしmakeに失敗する。

% make                                                                                        [994/1376]
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in doc
sed -e 's#@DATADIR@#/usr/local/share#'  rlwrap.man > rlwrap.1
Making all in src
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
main.c:813:15: error: use of undeclared identifier 'rl_basic_quote_characters'
    case 'q': rl_basic_quote_characters = mysavestring(optarg); break;
              ^
1 error generated.
make[2]: *** [main.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

readlineライブラリにあるはずの関数がないと言っている。調べてみると、Mac OS Xに入っているreadlineライブラリはeditlineというライブラリへのリンクになっているらしい。一方で、rlwrapはGNU readline(が定義している関数)を必要としている。

そういうわけで、GNU readlineをインストールして、そのパスをconfigure時に教えてあげる必要がある。

brew install readline
./configure LDFLAGS="-L/usr/local/opt/readline/lib" CPPFLAGS="-I/usr/local/opt/readline/include"
make
make install

通った。

参考にしたページ