⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autoconf.htm

📁 Makefile编程及相关资料的介绍与入门。很适合初学者的学习与借鉴
💻 HTM
📖 第 1 页 / 共 5 页
字号:
    name=TOC73>与外部软件一起工作</A> 
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC74" 
    name=TOC74>选择包选项</A> 
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC75" 
    name=TOC75>配置站点细节</A> 
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC76" 
    name=TOC76>在安装的时候改变程序的名称</A> 
    <UL>
      <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC77" 
      name=TOC77>转换选项</A> 
      <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC78" 
      name=TOC78>转换的例子</A> 
      <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC79" 
      name=TOC79>转换的规则</A> </LI></UL>
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC80" 
    name=TOC80>设定站点缺省值</A> </LI></UL>
  <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC81" 
  name=TOC81>运行<CODE>configure</CODE>脚本</A> 
  <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC82" 
  name=TOC82>重新创建一个配置</A> 
  <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC83" 
  name=TOC83>关于Autoconf的问题</A> 
  <UL>
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC84" 
    name=TOC84>发布<CODE>configure</CODE>脚本</A> 
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC85" 
    name=TOC85>为什么需要使用GNU <CODE>m4</CODE>?</A> 
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC86" 
    name=TOC86>我如何解开死结?</A> 
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC87" 
    name=TOC87>为什么不使用Imake?</A> </LI></UL>
  <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC88" 
  name=TOC88>从版本1中升级</A> 
  <UL>
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC89" 
    name=TOC89>改变了的文件名</A> 
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC90" 
    name=TOC90>改变了的Makefile</A> 
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC91" 
    name=TOC91>改变了的宏</A> 
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC92" 
    name=TOC92>用<CODE>autoupdate</CODE>更新<CODE>configure</CODE></A> 
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC93" 
    name=TOC93>改变了的结果</A> 
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC94" 
    name=TOC94>改变了的宏的编写</A> </LI></UL>
  <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC95" 
  name=TOC95>Autoconf的历史</A> 
  <UL>
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC96" 
    name=TOC96>起源(Genesis)</A> 
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC97" 
    name=TOC97>出发(Exodus)</A> 
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC98" 
    name=TOC98>上路(Leviticus)</A> 
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC99" 
    name=TOC99>发展(Numbers)</A> 
    <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC100" 
    name=TOC100>现状(Deuteronomy)</A> </LI></UL>
  <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC101" 
  name=TOC101>陈旧的宏名</A> 
  <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC102" 
  name=TOC102>环境变量索引</A> 
  <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC103" 
  name=TOC103>输出变量索引</A> 
  <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC104" 
  name=TOC104>预处理器符号索引</A> 
  <LI><A href="http://www.linuxforum.net/books/autoconf.html#SEC105" 
  name=TOC105>宏索引</A> </LI></UL>
<P>
<HR>

<P>
<P>Permission is granted to make and distribute verbatim copies of this manual 
provided the copyright notice and this permission notice are preserved on all 
copies. </P>
<P>Permission is granted to copy and distribute modified versions of this manual 
under the conditions for verbatim copying, provided that the entire resulting 
derived work is distributed under the terms of a permission notice identical to 
this one. </P>
<P>Permission is granted to copy and distribute translations of this manual into 
another language, under the above conditions for modified versions, except that 
this permission notice may be stated in a translation approved by the Free 
Software Foundation. </P>
<P>只要版权声明和本许可声明保留在所有副本中,您就被授权制作和发行本手册的原文副本。 </P>
<P>只要整个最终派生工作按照与本手册相同的许可声明发行,您就被授权按照与发行原文相同的条件复制和发行本手册的修改版本。 </P>
<P>除了本许可声明应该使用由基金会批准的译文之外,您被授权按照与上述修改版本相同的条件复制和发行本手册的其它语言的译文。 </P>
<HR>

<P>本文档由王立翻译。 1999.12.16</P>
<P>译者在此声明:不对任何由译文错误或者对译文的误解承担任何责任。</P>
<HR>

<H1><A href="http://www.linuxforum.net/books/autoconf.html#TOC1" 
name=SEC1>介绍</A></H1><PRE>A physicist, an engineer, and a computer scientist were
discussing the nature of God.  Surely a Physicist, said the
physicist, because early in the Creation, God made Light; and you
know, Maxwell's equations, the dual nature of electro-magnetic
waves, the relativist consequences... An Engineer!, said the
engineer, because before making Light, God split the Chaos into
Land and Water; it takes a hell of an engineer to handle that big
amount of mud, and orderly separation of solids from
liquids... The computer scientist shouted: And the Chaos,
where do you think it was coming from, hmm?

---Anonymous
</PRE>
<P>Autoconf是一个用于生成可以自动地配置软件源代码包以适应多种Unix类系统的 
shell脚本的工具。由Autoconf生成的配置脚本在运行的时候与Autoconf是无关的,就是说配置脚本的用户并不需要拥有Autoconf。 </P>
<P>由Autoconf生成的配置脚本在运行的时候不需要用户的手工干预;通常它们甚至不需要通过给出参数以确定系统的类型。相反,它们对软件包可能需要的各种特征进行独立的测试。(在每个测试之前,它们打印一个单行的消息以说明它们正在进行的检测,以使得用户不会因为等待脚本执行完毕而焦躁。)因此,它们在混合系统或者从各种常见Unix变种定制而成的系统中工作的很好。没有必要维护文件以储存由各个Unix变种、各个发行版本所支持的特征的列表。 
</P>
<P>对于每个使用了Autoconf的软件包,Autoconf从一个列举了该软件包需要的,或者可以使用的系统特征的列表的模板文件中生成配置脚本。在shell代码识别并响应了一个被列出的系统特征之后,Autoconf允许多个可能使用(或者需要)该特征的软件包共享该特征。如果后来因为某些原因需要调整shell代码,就只要在一个地方进行修改;所有的配置脚本都将被自动地重新生成以使用更新了的代码。 
</P>
<P>Metaconfig包在目的上与Autoconf很相似,但它生成的脚本需要用户的手工干预,在配置一个大的源代码树的时候这是十分不方便的。不象Metaconfig脚本,如果在编写脚本时小心谨慎, 
Autoconf可以支持交叉编译(cross-compiling)。 </P>
<P>Autoconf目前还不能完成几项使软件包可移植的工作。其中包括为所有标准的目标自动创建<TT>`Makefile'</TT>文件,包括在缺少标准库函数和头文件的系统上提供替代品。目前正在为在将来添加这些特征而工作。 
</P>
<P>对于在C程序中的<CODE>#ifdef</CODE>中使用的宏的名字,Autoconf施加了一些限制(参见<A 
href="http://www.linuxforum.net/books/autoconf.html#SEC104">预处理器符号索引</A>)。 </P>
<P>Autoconf需要GNU <CODE>m4</CODE>以便于生成脚本。它使用了某些UNIX版本的<CODE>m4</CODE> 
所不支持的特征。它还会超出包括GNU <CODE>m4</CODE> 1.0在内的某些<CODE>m4</CODE>版本的内部限制。你必须使用GNU 
<CODE>m4</CODE>的1.1版或者更新的版本。使用1.3版或者更新的版本将比1.1 或1.2版快许多。 </P>
<P>关于从版本1中升级的详情,参见<A 
href="http://www.linuxforum.net/books/autoconf.html#SEC88">从版本1中升级</A>。关于Autoconf的开发历史,参见<A 
href="http://www.linuxforum.net/books/autoconf.html#SEC95">Autoconf的历史</A>。对与Autoconf有关的常见问题的回答,参见<A 
href="http://www.linuxforum.net/books/autoconf.html#SEC83">关于Autoconf的问题</A>。 
</P>
<P>把关于Autoconf的建议和bug报告发送到<CODE>bug-gnu-utils@prep.ai.mit.edu</CODE>。请把你通过运行<SAMP>`autoconf 
--version'</SAMP>而获得的Autoconf的版本号包括在内。 </P>
<H1><A href="http://www.linuxforum.net/books/autoconf.html#TOC2" 
name=SEC2>创建<CODE>configure</CODE>脚本</A></H1>
<P>由Autoconf生成的配置脚本通常被称为<CODE>configure</CODE>。在运行的时候,<CODE>configure</CODE> 
创建一些文件,在这些文件中以适当的值替换配置参数。由<CODE>configure</CODE>创建的文件有: </P>
<UL>
  <LI>一个或者多个<TT>`Makefile'</TT>文件,在包的每个子目录中都有一个(参见 <A 
  href="http://www.linuxforum.net/books/autoconf.html#SEC11">Makefile中的替换</A>); 
  <LI>有时创建一个C头文件,它的名字可以被配置,该头文件包含一些<CODE>#define</CODE>命令(参见<A 
  href="http://www.linuxforum.net/books/autoconf.html#SEC15">配置头文件</A>); 
  <LI>一个名为<TT>`config.status'</TT>的shell脚本,在运行时,它将重新创建上述文件。(参见<A 
  href="http://www.linuxforum.net/books/autoconf.html#SEC82">重新创建一个配置</A>); 
  <LI>一个名为<TT>`config.cache'</TT>的shell脚本,它储存了许多测试的运行结果(参见<A 
  href="http://www.linuxforum.net/books/autoconf.html#SEC57">缓存文件</A>); 
  <LI>一个名为<TT>`config.log'</TT>的文件,它包含了由编译器生成的许多消息,以便于在<CODE>configure</CODE>出现错误时进行调试。 
  </LI></UL>
<P>为了使用Autoconf创建一个<CODE>configure</CODE>脚本,你需要编写一个Autoconf的输入文件 
<TT>`configure.in'</TT>并且对它运行<CODE>autoconf</CODE>。如果你自行编写了特征测试以补充 
Autoconf所提供的测试,你可能还要编写一个名为<TT>`aclocal.m4'</TT>的文件和一个名为 
<TT>`acsite.m4'</TT>的文件。如果你使用了包含<CODE>#define</CODE>指令的C头文件,你可能还要编写<TT>`acconfig.h'</TT>,并且你需要与软件包一同发布由Autoconf生成的文件 
<TT>`config.h.in'</TT>。 </P>
<P>下面是一个说明了在配置中使用的文件是如何生成的图。运行的程序都标以后缀<SAMP>`*'</SAMP>。可能出现的文件被方括号(<SAMP>`[]'</SAMP>)括起来。<CODE>autoconf</CODE>和<CODE>autoheader</CODE> 
还读取安装了的Autoconf宏文件(通过读取<TT>`autoconf.m4'</TT>)。 </P>
<P>在准备发布软件包的过程中使用的文件: <PRE>你的源文件 --&gt; [autoscan*] --&gt; [configure.scan] --&gt; configure.in

configure.in --.   .------&gt; autoconf* -----&gt; configure
               +---+
[aclocal.m4] --+   `---.
[acsite.m4] ---'       |
                       +--&gt; [autoheader*] -&gt; [config.h.in]
[acconfig.h] ----.     |
                 +-----'
[config.h.top] --+
[config.h.bot] --'

Makefile.in -------------------------------&gt; Makefile.in
</PRE>
<P>在配置软件包的过程中使用的文件: <PRE>                       .-------------&gt; config.cache
configure* ------------+-------------&gt; config.log
                       |
[config.h.in] -.       v            .-&gt; [config.h] -.
               +--&gt; config.status* -+               +--&gt; make*
Makefile.in ---'                    `-&gt; Makefile ---'
</PRE>
<H2><A href="http://www.linuxforum.net/books/autoconf.html#TOC3" 
name=SEC3>编写<TT>`configure.in'</TT></A></H2>
<P>为了为软件包创建<CODE>configure</CODE>脚本,需要编写一个名为<TT>`configure.in'</TT> 
的文件,该文件包含了对那些你的软件包需要或者可以使用的系统特征进行测试的Autoconf宏的调用。现有的Autoconf宏可以检测许多特征; 
对于它们的描述可以参见<A 
href="http://www.linuxforum.net/books/autoconf.html#SEC21">现有的测试</A>。对于大部分其他特征,你可以使用Autconf模板宏以创建定制的测试;关于它们的详情,参见 
<A 
href="http://www.linuxforum.net/books/autoconf.html#SEC40">编写测试</A>。对于特别古怪或者特殊的特征,<TT>`configure.in'</TT> 
可能需要包含一些手工编写的shell命令。程序<CODE>autoscan</CODE>可以为你编写<TT>`configure.in'</TT> 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -