<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  <!ENTITY % general-entities SYSTEM "../general.ent">
  %general-entities;
]>

<sect1 id="ch-tools-expect" role="wrap">
  <?dbhtml filename="expect.html"?>

  <sect1info condition="script">
    <productname>expect</productname>
    <productnumber>&expect-version;</productnumber>
    <address>&expect-url;</address>
  </sect1info>

  <title>Expect-&expect-version;</title>

  <indexterm zone="ch-tools-expect">
    <primary sortas="a-Expect">Expect</primary>
  </indexterm>

  <sect2 role="package">
    <title/>

    <!--para>The Expect package contains a program for carrying out scripted
    dialogues with other interactive programs.</para-->
    <para>Expect 软件包包含一个根据脚本，与其他交互程序进行对话的程序。
	</para>

    <segmentedlist>
      <segtitle>&buildtime;</segtitle>
      <segtitle>&diskspace;</segtitle>

      <seglistitem>
        <seg>&expect-ch5-sbu;</seg>
        <seg>&expect-ch5-du;</seg>
      </seglistitem>
    </segmentedlist>

  </sect2>

  <sect2 role="installation">
    <title>安装 Expect</title>

    <!--para>First, force Expect's configure script to use <filename>/bin/stty</filename>
    instead of a <filename>/usr/local/bin/stty</filename> it may find on the host system.
    This will ensure that our test suite tools remain sane for the final builds of our
    toolchain:</para-->
    <para>首先强制 Expect 的配置脚本使用 <filename>/bin/stty</filename>，
		而不是宿主系统上可能存在的
		<filename>/usr/local/bin/stty</filename>，
		以保证测试套件工具在最终构建工具链时仍然完整：</para>

<screen><userinput remap="pre">cp -v configure{,.orig}
sed 's:/usr/local/bin:/bin:' configure.orig &gt; configure</userinput></screen>

    <para>现在准备编译 Expect：</para>

<screen><userinput remap="configure">./configure --prefix=/tools       \
            --with-tcl=/tools/lib \
            --with-tclinclude=/tools/include</userinput></screen>

    <variablelist>
      <title>配置选项的含义：</title>

      <varlistentry>
        <term><parameter>--with-tcl=/tools/lib</parameter></term>
        <listitem>
          <!--para>This ensures that the configure script finds the Tcl
          installation in the temporary tools location instead of possibly
          locating an existing one on the host system.</para-->
	      <para>这保证配置脚本找到临时工具中的 Tcl 安装，
			  而不是宿主系统中可能存在的 Tcl 安装。</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><parameter>--with-tclinclude=/tools/include</parameter></term>
        <listitem>
          <!--para>This explicitly tells Expect where to find Tcl's internal
          headers. Using this option avoids conditions where
          <command>configure</command> fails because it cannot automatically
          discover the location of Tcl's headers.</para-->
          <para>该选项明确告诉 Expect 去哪里寻找 Tcl 的内部头文件。
			  使用该选项可以避免某些情况下 <command>configure</command>
			  由于找不到 Tcl 头文件的位置而失败。</para>
        </listitem>
      </varlistentry>

    </variablelist>

    <para>构建该软件包：</para>

<screen><userinput remap="make">make</userinput></screen>

    <!--para>Compilation is now complete. As discussed earlier, running the test
    suite is not mandatory for the temporary tools here in this chapter. To run
    the Expect test suite anyway, issue the following command:</para-->
    <para>现在编译已经完成，正如之前所述，
		并不需要运行本章中临时工具的测试套件。如果一定要运行 Expect
		的测试套件，输入以下命令：</para>

<screen><userinput remap="test">make test</userinput></screen>

    <!--para>Note that the Expect test suite is known to experience failures under
    certain host conditions that are not within our control. Therefore,
    test suite failures here are not surprising and are not considered
    critical.</para-->
    <para>注意，已经知道在特定宿主环境下 Expect 测试套件会失败。
		我们无法控制宿主环境，因此这里的测试失败并不令人吃惊，
		也不会造成严重问题。</para>

    <para>安装该软件包：</para>

<screen><userinput remap="install">make SCRIPTS="" install</userinput></screen>

    <variablelist>
      <title>make 命令参数的含义：</title>

      <varlistentry>
        <term><parameter>SCRIPTS=""</parameter></term>
        <listitem>
          <!--para>This prevents installation of the supplementary Expect
          scripts, which are not needed.</para-->
	      <para>该选项使得一些不需要的 Expect 辅助脚本不被安装。</para>
        </listitem>
      </varlistentry>

    </variablelist>

  </sect2>

  <sect2 id="contents-expect" role="content">
    <title>Expect 的内容</title>

    <segmentedlist>
      <segtitle>安装的程序</segtitle>
      <segtitle>安装的库</segtitle>

      <seglistitem>
        <seg>expect</seg>
        <seg>libexpect-&expect-lib-version;.so</seg>
      </seglistitem>
    </segmentedlist>

    <variablelist>
      <bridgehead renderas="sect3">简要描述</bridgehead>
      <?dbfo list-presentation="list"?>
      <?dbhtml list-presentation="table"?>

      <varlistentry id="expect">
        <term><command>expect</command></term>
        <listitem>
          <para>根据一个脚本与其他交互程序交流</para>
          <indexterm zone="ch-tools-expect expect">
            <primary sortas="b-expect">expect</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libexpect">
        <term><filename class="libraryfile">libexpect-&expect-lib-version;.so</filename></term>
        <listitem>
		  <para>包含一些函数，使得 Expect 可以作为 Tcl 扩展使用，
				也可以直接在 C 或 C++ 中使用（不使用 Tcl）</para>
          <indexterm zone="ch-tools-expect libexpect">
            <primary sortas="c-libexpect-&expect-lib-version;">libexpect-&expect-lib-version;</primary>
          </indexterm>
        </listitem>
      </varlistentry>

    </variablelist>

  </sect2>

</sect1>
