Rubyのconfigure.in読んでみる(1)
以前はRubyのメソッド呼び出しについて調べましたが、 ふとRubyのビルドの仕組みが気になったので追っていきたいと思います。
Rubyのビルド
Ruby(MRI)のビルドには以下のコマンドを実行しています。
% autoconf #=> configure.inを元にconfigureを作成する % ./configure #=> Makefile.inを元にMakefileを作成する % make #=> Makefileを実行してビルドする
リポジトリにあるのはconfigure.in
とMakefile.in
の2つで、
configure
とMakefile
はそれぞれビルドの過程で作成されています。
configure.in
今回は、まずconfigureを作成する過程から追っていきます。
autoconf
autoconf自体ほぼ初見ですが…、GNUのツールで公式サイトにドキュメントがあります。 http://www.gnu.org/software/autoconf/manual/autoconf.html
AC_(autoconfの略と思われる)のprefixがつくマクロはドキュメントを参照する必要がありそうです。 まずconfigure.inに下記2つは必須らしい。
- AC_INIT (package, version, [bug-report], [tarname], [url])
- 最初に書く
- AC_OUTPUT
- 最後に書く
configure.in全体の概要
configure.in全体は4.7KStepくらいありますが、 下のような作りになっているらしい
2AC_INIT() 3{ このあたりで初期処理 #=> ① 38{ # environment section #=> ② 735} 736{ # compiler section #=> ③ 1020} 1021{ # header and library section #=> ④ 3232} 3233{ # runtime section #=> ⑤ 4039} 4040{ # build section #=> ⑥ 4668AC_OUTPUT 4669} 4670} 以降は最後の結果出力など #=> ⑦
上記のように、ざっくり7つのセクションに分かれていそうです。 次回から順番に見ていきたいと思います。
その他
ところで現在はconfigure.inは曖昧だからconfigure.acが推奨らしい。
Previous versions of Autoconf promoted the name configure.in, which is somewhat ambiguous (the tool needed to process this file is not described by its extension), and introduces a slight confusion with config.h.in and so on (for which ‘.in’ means “to be processed by configure”). Using configure.ac is now preferred.
rubyはconfigure.inのままでいいのかな?