GaucheのREPLで履歴参照などを有効にするReadline module for Gauche

を、インストールした。

環境

Readline module for Gauche

これは Shiro Kawai さんの作成した Scheme の実装である Gauche の GNU Readline 拡張モジュールです。 このモジュールを使うとカーソルキーで行編集や履歴の検索をしたり、 またその結果を履歴ファイルに残して後でまた読み込んで参照したり、 入力中に関数名や変数名の補間ができます。 使用法の解説書と、このモジュールを用いてGaucheの対話モードを行なう スクリプトが入っています。

Readline module for Gauche

ログ

まず、libreadline-devをインストールした。

sudo apt-get install libreadline-dev 


Readline module for GaucheからGauche-readline-20100625.tar.gzをダウンロードして解凍。できたフォルダに入って、

$ ./configure 
checking for gosh... /usr/bin/gosh
checking for gauche-config... no
checking for gauche-package... no
checking for gauche-install... no
checking for gauche-cesconv... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
./configure: line 3223: --so-suffix: command not found
./configure: line 3224: --object-suffix: command not found
./configure: line 3225: --executable-suffix: command not found
./configure: line 3230: --prefix: command not found
./configure: line 3232: --pkgincdir: command not found
./configure: line 3234: --pkglibdir: command not found
./configure: line 3235: --pkgarchdir: command not found
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking readline/readline.h usability... yes
checking readline/readline.h presence... yes
checking for readline/readline.h... yes
checking readline/history.h usability... yes
checking readline/history.h presence... yes
checking for readline/history.h... yes
checking for readline in -lreadline... yes
checking for rl_basic_quote_characters... yes
configure: creating Gauche-readline.gpd
./configure: line 3645: make-gpd: command not found
configure: creating ./config.status
config.status: creating Makefile
$ make
compile \
		--verbose \
		--cflags="-g -O2 -DGAUCHE_API_0_9" \
		--cppflags="-DPACKAGE_NAME=\"Gauche-readline\" -DPACKAGE_TARNAME=\"gauche-readline\" -DPACKAGE_VERSION=\"20100625\" -DPACKAGE_STRING=\"Gauche-readline\ 20100625\" -DPACKAGE_BUGREPORT=\"yokota-at-netlab.cs.tsukuba.ac.jp\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_READLINE_READLINE_H=1 -DHAVE_READLINE_HISTORY_H=1 -DHAVE_LIBREADLINE=1 -DHAVE_RL_BASIC_QUOTE_CHARACTERS=1 " \
		--libs="-lreadline " \
		 \
		term--readline readline.c readlinelib.stub
/bin/bash: line 1: compile: コマンドが見つかりません
make: *** [term--readline.] エラー 127

なんかエラー。
configureがうまくいってないみたい。


Ubuntu8.04にGauche-readlineをインストールを参考にして、gauche-devをインストール

$ sudo apt-get install gauche-dev
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下のパッケージが新たにインストールされます:
  gauche-dev
アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 0 個。
224kB のアーカイブを取得する必要があります。
この操作後に追加で 770kB のディスク容量が消費されます。
取得:1 http://jp.archive.ubuntu.com/ubuntu/ lucid/universe gauche-dev 0.8.13-1 [224kB]
224kB を 3秒 で取得しました (65.3kB/s)
未選択パッケージ gauche-dev を選択しています。
(データベースを読み込んでいます ... 現在 187523 個のファイルとディレクトリがインストールされています。)
(.../gauche-dev_0.8.13-1_amd64.deb から) gauche-dev を展開しています...
gauche-dev (0.8.13-1) を設定しています ...
$ ./configure 
checking for gosh... /usr/bin/gosh
checking for gauche-config... /usr/bin/gauche-config
checking for gauche-package... /usr/bin/gauche-package
checking for gauche-install... /usr/bin/gauche-install
checking for gauche-cesconv... /usr/bin/gauche-cesconv
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking readline/readline.h usability... yes
checking readline/readline.h presence... yes
checking for readline/readline.h... yes
checking readline/history.h usability... yes
checking readline/history.h presence... yes
checking for readline/history.h... yes
checking for readline in -lreadline... yes
checking for rl_basic_quote_characters... yes
configure: creating Gauche-readline.gpd
configure: creating ./config.status
config.status: creating Makefile
$ make
/usr/bin/gauche-package compile \
		--verbose \
		--cflags="-g -O2 -DGAUCHE_API_0_9" \
		--cppflags="-DPACKAGE_NAME=\"Gauche-readline\" -DPACKAGE_TARNAME=\"gauche-readline\" -DPACKAGE_VERSION=\"20100625\" -DPACKAGE_STRING=\"Gauche-readline\ 20100625\" -DPACKAGE_BUGREPORT=\"yokota-at-netlab.cs.tsukuba.ac.jp\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_READLINE_READLINE_H=1 -DHAVE_READLINE_HISTORY_H=1 -DHAVE_LIBREADLINE=1 -DHAVE_RL_BASIC_QUOTE_CHARACTERS=1 " \
		--libs="-lreadline " \
		 \
		term--readline readline.c readlinelib.stub
'/usr/lib/gauche/0.8.13/x86_64-pc-linux-gnu/gauche-config' --fixup-extension 'term--readline'
gcc -std=gnu99 -c -DPACKAGE_NAME="Gauche-readline" -DPACKAGE_TARNAME="gauche-readline" -DPACKAGE_VERSION="20100625" -DPACKAGE_STRING="Gauche-readline\ 20100625" -DPACKAGE_BUGREPORT="yokota-at-netlab.cs.tsukuba.ac.jp" -DPACKAGE_URL="" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_READLINE_READLINE_H=1 -DHAVE_READLINE_HISTORY_H=1 -DHAVE_LIBREADLINE=1 -DHAVE_RL_BASIC_QUOTE_CHARACTERS=1  -I/usr/lib/gauche/0.8.13/include -g -O2 -DGAUCHE_API_0_9 -fPIC -o 'term--readline_head.o' 'term--readline_head.c'
gcc -std=gnu99 -c -DPACKAGE_NAME="Gauche-readline" -DPACKAGE_TARNAME="gauche-readline" -DPACKAGE_VERSION="20100625" -DPACKAGE_STRING="Gauche-readline\ 20100625" -DPACKAGE_BUGREPORT="yokota-at-netlab.cs.tsukuba.ac.jp" -DPACKAGE_URL="" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_READLINE_READLINE_H=1 -DHAVE_READLINE_HISTORY_H=1 -DHAVE_LIBREADLINE=1 -DHAVE_RL_BASIC_QUOTE_CHARACTERS=1  -I/usr/lib/gauche/0.8.13/include -g -O2 -DGAUCHE_API_0_9 -fPIC -o 'readline.o' 'readline.c'
'/usr/lib/gauche/0.8.13/x86_64-pc-linux-gnu/gosh' genstub readlinelib.stub
gcc -std=gnu99 -c -DPACKAGE_NAME="Gauche-readline" -DPACKAGE_TARNAME="gauche-readline" -DPACKAGE_VERSION="20100625" -DPACKAGE_STRING="Gauche-readline\ 20100625" -DPACKAGE_BUGREPORT="yokota-at-netlab.cs.tsukuba.ac.jp" -DPACKAGE_URL="" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_READLINE_READLINE_H=1 -DHAVE_READLINE_HISTORY_H=1 -DHAVE_LIBREADLINE=1 -DHAVE_RL_BASIC_QUOTE_CHARACTERS=1  -I/usr/lib/gauche/0.8.13/include -g -O2 -DGAUCHE_API_0_9 -fPIC -o 'readlinelib.o' 'readlinelib.c'
gcc -std=gnu99 -c -DPACKAGE_NAME="Gauche-readline" -DPACKAGE_TARNAME="gauche-readline" -DPACKAGE_VERSION="20100625" -DPACKAGE_STRING="Gauche-readline\ 20100625" -DPACKAGE_BUGREPORT="yokota-at-netlab.cs.tsukuba.ac.jp" -DPACKAGE_URL="" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_READLINE_READLINE_H=1 -DHAVE_READLINE_HISTORY_H=1 -DHAVE_LIBREADLINE=1 -DHAVE_RL_BASIC_QUOTE_CHARACTERS=1  -I/usr/lib/gauche/0.8.13/include -g -O2 -DGAUCHE_API_0_9 -fPIC -o 'term--readline_tail.o' 'term--readline_tail.c'
gcc -std=gnu99  -L/usr/lib/gauche/0.8.13/x86_64-pc-linux-gnu   -shared -o term--readline.so 'term--readline_head.o' 'readline.o' 'readlinelib.o' 'term--readline_tail.o' -lgauche -ldl -lcrypt -lutil -lm  -lpthread -lreadline 
mkdir -p term
ln -sf ../readline.scm term/readline.scm
$ make check
mkdir -p term
ln -sf ../readline.scm term/readline.scm
/usr/bin/gosh -I. test.scm > test.log
Testing readline ...                                             passed.
$ sudo make install
mkdir -p term
ln -sf ../readline.scm term/readline.scm
/usr/bin/gauche-install -m 644 -T /usr/share/gauche/site/lib/term readline.scm 
/usr/bin/gauche-install -m 755 -T /usr/lib/gauche/site/0.8.13/x86_64-pc-linux-gnu term--readline.so
/usr/bin/gauche-install -m 644 -T /usr/share/gauche/site/lib/.packages Gauche-readline.gpd
/usr/bin/gauche-install -m 755 --shebang=/usr/bin/gosh gosh-rl.scm /usr/bin/gosh-rl
$ gosh-rl
gosh> (print "Hello World")
Hello World
#<undef>

これでOK

追記

REPLでconsとか使えないとき

(use srfi-1)

を追加

追記

Readline module for Gaucheじゃなくてrlwrapでもいいかもしれない

大学の講義スライド見返していたら発見した。


Ubuntu 10.04 LTSなら

$ sudo apt-get install rlwrap

でインストールできる。


使うときは

$ rlwrap gosh