配置 expect 时,发现源 tcl 目录而不是其安装位置

While configuring expect, found source tcl directories instead of its installation location

我正在从源代码构建 gcc。我的意思是 运行 测试,这需要 dejagnuexpecttcl.

我首先 configured tcl(为简洁起见,使用 dir1 而不是实际目录),然后

$ cd dir1/unix
$ ./configure --prefix="$HOME/usr/local"

并建成。 然后我 configured expect

$ ./configure --prefix="$HOME/usr/local"

此时,tcl 被发现在 dir1,即

$ grep tcl config.log
configure:2650: result: found dir1/unix/tclConfig.sh
configure:2656: checking for existence of dir1/unix/tclConfig.sh
configure:5078: result: dir1/generic
...

我的环境生成(为简洁起见,使用 $HOME

LIBRARY_PATH=$HOME/usr/local/lib:...
LD_LIBRARY_PATH=$HOME/usr/local/lib:...
CPATH=$HOME/usr/local/include:...
PATH=$HOME/usr/local/bin:...

怎么可能找到tcl的源目录? 我预计 tcl 会在 $HOME/usr/local 中找到。 也许 expect 正在以某种方式读取 tcl 的配置,这对我来说看起来很奇怪。

如果未指定 --with-tcl,它将首先尝试查看是否在同一目录级别中也有 Tcl 的构建目录(实际上它还会尝试高 2 个目录级别)。例如,如果您有

/src/dir/of/expect-5.xx

然后看看有没有

/src/dir/of/tcl-8.xx
# and 
/src/dir/of/tcl-8.xx/unix/tclConfig.sh

Expect作者可能认为人们可能会先编译Tcl,然后同时编译Expect。 :)

查看Expect源代码中的文件tclconfig/tcl.m4,第80~105行:

 63
 64  # First check to see if --with-tcl was specified.
 65  if test x"${with_tclconfig}" != x ; then
 66      case "${with_tclconfig}" in
 67          */tclConfig.sh )
 68              if test -f "${with_tclconfig}"; then
 69                  AC_MSG_WARN([--with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself])
 70                  with_tclconfig="`echo "${with_tclconfig}" | sed 's!/tclConfig\.sh$!!'`"
 71              fi ;;
 72      esac
 73      if test -f "${with_tclconfig}/tclConfig.sh" ; then
 74          ac_cv_c_tclconfig="`(cd "${with_tclconfig}"; pwd)`"
 75      else
 76          AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
 77      fi
 78  fi
 79
 80  # then check for a private Tcl installation
 81  if test x"${ac_cv_c_tclconfig}" = x ; then
 82      for i in \
 83              ../tcl \
 84              `ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
 85              `ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \
 86              `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
 87              ../../tcl \
 88              `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
 89              `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
 90              `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
 91              ../../../tcl \
 92              `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
 93              `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
 94              `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
 95          if test "${TEA_PLATFORM}" = "windows" \
 96                  -a -f "$i/win/tclConfig.sh" ; then
 97              ac_cv_c_tclconfig="`(cd $i/win; pwd)`"
 98              break
 99          fi
100          if test -f "$i/unix/tclConfig.sh" ; then
101              ac_cv_c_tclconfig="`(cd $i/unix; pwd)`"
102              break
103          fi
104      done
105  fi
106