WiLiKiソース解読:configure.in

WiLiKiソース解読:configure.in

 dnl
 dnl configuring wiliki
 dnl
 dnl $Id: configure.in,v 1.2 2002/12/27 01:05:44 shirok Exp $
 AC_INIT(src/wiliki.scm)

dnlはコメント行。

AC_INITには、ソースファイルのどれかを指定しておけば良い。

 dnl Determine if we're configuring inside of Gauche main source tree or not.
 if test -f ../../src/gauche.h; then
   GAUCHE_CONFIG="sh ../../src/gauche-config"
   GAUCHE_TOP='../../'
   GAUCHE_INC="-I../../src -I../../gc/include `$GAUCHE_CONFIG --local-incdir`"
   GOSH="../../src/gosh -I../../src -I../../lib"
 else
   GAUCHE_CONFIG=gauche-config
   GAUCHE_TOP=
   GAUCHE_INC=`gauche-config -I`
   GOSH=gosh
 fi
 AC_SUBST(GAUCHE_CONFIG)
 AC_SUBST(GAUCHE_TOP)
 AC_SUBST(GAUCHE_INC)
 AC_SUBST(GOSH)

AC_SUBSTは、シェル変数を外部変数にする。AC_OUTPUTで指定された ファイルを処理するときに、@で囲まれた変数を置換する。

最後のAC_OUTPUTで、src/Makefileとtest/Makefileを指定している。これらを 作る元となるそれぞれのMakefile.inで@GAUCHE_CONFIG@があれば、それが上の内容で 置換される。

ここでは、Gaucheのソースツリーの中にいるかどうかをチェックしている。大抵の場合、 else節の内容がセットされるだろう。

gauche-configは、Gauche用configツール。オプションIは、

 -I   include paths required to compile programs using gauche

であり、私の環境では以下のとおり。

 bash-2.05$ gauche-config -I
 -I/usr/local/lib/gauche/0.6.7.1/include
 dnl A user has a choice to install the module into Gauche system directory
 dnl or site local directory, by setting environment variable INSTALL_TYPE
 dnl to either 'sys' or 'site'.   The variable can be overridden at make time.
 : ${INSTALL_TYPE=site}  dnl This sets the default.
 AC_SUBST(INSTALL_TYPE) 

コロンで始まる行の意味は分からない。変数の宣言、定義かな?

 dnl Get compiler parameters which Gauche has been compiled with.
 CC="`$GAUCHE_CONFIG --cc`"
 AC_SUBST(CC)

gauche-config --ccは、

 --cc name of the compiler

であり、私の環境では、

 bash-2.05$ gauche-config --cc
 gcc
 CFLAGS="$CFLAGS $GAUCHE_INC `$GAUCHE_CONFIG --so-cflags`"
 AC_SUBST(CFLAGS)
 CPPFLAGS="$GAUCHE_INC"       # some test requires this
 LDFLAGS="$LDFLAGS `$GAUCHE_CONFIG --local-libdir`" 

gauche-config --so-cflagsは、

 --so-cflags     flags required to compile shared object

で、私の環境では、

 bash-2.05$ gauche-config --so-cflags
 -fPIC

また、gauche-config --local-libdirは、gauche-configのヘルプには出てこない。 私の環境では空(未定義?)だった。

 dnl Check for other programs.
 AC_PROG_INSTALL

install-shスクリプトを要求する。以下の外部変数を定義する。

INSTALL installプログラムがあればそれを設定する。
INSTALL_PROGRAM 通常は、${INSTALL}。
INSTALL_SCRIPT 通常は、${INSTALL}。
INSTALL_DATA 通常は、{INSTALL} -m 644。
 dnl Add more test
 
 dnl Set LDFLAGS to generate shared library.
 dnl This has to come after all the tests that requre linking, or those test
 dnl will fail because they can't generate stand-alone executable.
 LDFLAGS="$LDFLAGS `$GAUCHE_CONFIG --so-ldflags`"
 AC_SUBST(LDFLAGS)

gauche-config --so-ldflagsは、

 --so-ldflags    flags required to link a gauche extension

で、私の環境では、

 bash-2.05$ gauche-config --so-ldflags
 -shared -o
 dnl Output
 AC_OUTPUT(src/Makefile test/Makefile)

AC_OUTPUTには、configureスクリプトを実行したときに作成されるファイル、 実行するコマンドなどを指定する。通常は、Makefile。

More ...