📄 蚂蚁公社 - 轻轻松松产生 makefile 利用automake.htm
字号:
<P>要产的目标: </P>
<P>AUTOMAKE_OPTIONS </P>
<P>设定 automake 的选项。Automake 主要是帮助开发 GNU 软体的人员 </P>
<P>维护软体套件,所以在执行 automake 时,会检查目录下是否存在标 </P>
<P>准 GNU 软体套件中应具备的文件档案,例如 'NEWS'、'AUTHOR'、 </P>
<P><CODE>ChangeLog</CODE> 等文件档。设成 foreign 时,automake 会改用一般软 </P>
<P>体套件的标准来检查。 </P>
<P>bin_PROGRAMS </P>
<P>定义我们所要产生的执行档档名。如果要产生多个执行档,每个档名 </P>
<P>用空白字元隔开。 </P>
<P>hello_SOURCES </P>
<P>定义 <CODE>hello</CODE> 这个执行档所需要的原始档。如果 <CODE>hello</CODE> 这个程式
</P>
<P>是由多个原始档所产生,必须把它所用到的原始档都列出来,以空白 </P>
<P>字元隔开。假设 <CODE>hello</CODE> 这个程式需要 'hello.c'、'main.c'、 </P>
<P><CODE>hello.h</CODE> 三个档案的话,则定义 </P>
<P>hello_SOURCES= hello.c main.c hello.h </P>
<P>如果我们定义多个执行档,则对每个执行档都要定义相对的 </P>
<P>filename_SOURCES。 </P>
<P>编辑好 Makefile.am 档,就可以用 automake --add-missing 来产生 </P>
<P>Makefile.in。加上 --add-missing 选项是告诉 automake 顺便帮我们加 </P>
<P>入包装一个软体套件所必备的档案。Automake 产生出来的 Makefile.in </P>
<P>档是完全符合 GNU Makefile 的惯例,我们只要执行 configure 这个 </P>
<P>shell script 便可以产生合适的 Makefile 档了。 </P>
<OL>
<LI>3 使用 Makefile </LI></OL>
<P>利用 configure 所产生的 Makefile 档有几个预设的目标可供使用,我们 </P>
<P>只拿其中几个简述如下: </P>
<P>make all 产生我们设定的目标,即此范例中的执行档。只打 make 也可以,此
时会开始编译原始码,然後连结,并且产生执行档。 make clean 清除之前所编译的执行档及目的档 (object file,
*.o)。 make distclean 除了清除执行档和目的档外,也把 configure 所产生的 Makefile 也清除掉。
make install 将程式安装至系统中。如果原始码编译无误,且执行结果正确,便可
以把程式安装至系统预设的执行档存放路径。如果我们用 bin_PROGRAMS 巨集的话,程式会被安装至 /usr/local/bin
这个目录。 make dist 将程式和相关的档案包装成一个压缩档以供散播 (distribution) 。 执行完在目录下会产生一个以
PACKAGE-VERSION.tar.gz 为名称的档 案。PACKAGE 和 VERSION 这两个变数是根据
configure.in 档中 AM_INIT_AUTOMAKE(PACKAGE, VERSION) 的定义。在此范例中会产生
<CODE>hello-1.0.tar.gz</CODE> 的档案。 make distcheck 和 make dist
类似,但是加入检查包装後的压缩档是否正常。这个 目标除了把程式和相关档案包装成 tar.gz 档外,还会自动把这个压 缩档解开,执行
configure,并且进行 make all 的动作,确认编译 无误後,会显示这个 tar.gz 档已经准备好可供散播了。这个检查非
常有用,检查过关的套件,基本上可以给任何一个具备 GNU 发展环 境的人去重新编译。就 hello-1.tar.gz
这个范例而言,除了在 Red Hat Linux 上,在 FreeBSD 2.2.x 版也可以正确地重新编译。 要注意的是,利用
Autoconf 及 Automake 所产生出来的软体套件是可以 在没有安装 Autoconf 及 Automake
的环境上使用的,因为 configure 是 一个 shell script,它己被设计可以在一般 Unix 的 sh 这个 shell
下 执行。但是如果要修改 configure.in 及 Makefile.am 档再产生新的 configure 及
Makefile.in 档时就一定要有 Autoconf 及 Automake 了。 5. 相关讯息 Autoconf 和
Automake 功能十分强大,你可以从它们所附的 info 档找到 详细的用法。你也可以从许多现存的 GNU 软体或 Open
Source 软体中找 到相关的 configure.in 或 Makefile.am 档,它们是学习 Autoconf 及
Automake 更多技巧的最佳范例。 这篇简介只用到了 Autoconf 及 Automake 的皮毛罢了,如果你有心加入 Open
Source 软体开发的行列,希望这篇文件能帮助你对产生 Makefile 有个简单的依据。其它有关开发 GNU 程式或 C 程式设计及
Makefile 的 详细运用及技巧,我建议你从 GNU Coding Standards3 (GNU 编码标准规 定)
读起,里面包含了 GNU Makefile 惯例,还有发展 GNU 软体套件的标 准程序和惯例。这些 GNU 软体的线上说明文件可以在
http://www.gnu.org/ 这个网站上找到。 6. 结语 经由 Autoconf 及 Automake 的辅助,产生一个
Makefile 似乎不再像以 前那麽困难了,而使用 Autoconf 也使得我们在不同平台上或各家 Unix
之间散播及编译程式变得简单,这对於在 Unix 系统上开发程式的人员来 说减轻了许多负担。妥善运用这些 GNU
的工具软体,可以帮助我们更容易 去发展程式,而且更容易维护原始程式码。 About this document ... 轻轻松松产生
Makefile1 This document was generated using the LaTeX2HTML
translator Version 98.2 beta6 (August 14th, 1998) Copyright (C)
1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit,
University of Leeds. Copyright (C) 1997, 1998, Ross Moore,
Mathematics Department, Macquarie University, Sydney. The command
line arguments were: latex2html -split 0 -show_section_numbers
automake.tex The translation was initiated by on 1999-02-11
Footnotes ...\title1 本文件使用 ChiLaTeX 制作。 ... Standards3 GNU Coding
Standards, Richard Stallman. 1999-02-11 </P></DIV>
<DIV class=spacer></DIV></TD></TR></TBODY></TABLE><BR></SPAN>
<DIV class=comments><SPAN>
<TABLE cellSpacing=0 cellPadding=0 width=620 border=0>
<TBODY>
<TR class=color2 height=25>
<TD align=middle width=50>
<DIV><IMG alt=Post
src="蚂蚁公社 - 轻轻松松产生 Makefile 利用automake.files/icon_post.gif"> <IMG
alt=""
src="蚂蚁公社 - 轻轻松松产生 Makefile 利用automake.files/smiley11.gif">
</DIV></TD>
<TD width=150><SPAN class=label>作者</SPAN> <FONT
color=#3366cc><B>chensy</B> </FONT></TD>
<TD align=right><SPAN class=label>日期</SPAN> <FONT color=#3366cc>Dec
31, 2003 3:20 pm</FONT> </TD></TR>
<TR>
<TD colSpan=5 height=1></TD>
<TR class="content even">
<TD
style="PADDING-RIGHT: 2em; PADDING-LEFT: 2em; PADDING-BOTTOM: 0.5em; PADDING-TOP: 0.5em"
colSpan=4>
<DIV class=message_body>
<P>为什么格式总是不对</P></DIV>
<DIV class=spacer></DIV></TD></TR></TBODY></TABLE><BR></SPAN><SPAN>
<TABLE cellSpacing=0 cellPadding=0 width=620 border=0>
<TBODY>
<TR class=color2 height=25>
<TD align=middle width=50>
<DIV><IMG alt=Post
src="蚂蚁公社 - 轻轻松松产生 Makefile 利用automake.files/icon_post.gif"> <IMG
alt=""
src="蚂蚁公社 - 轻轻松松产生 Makefile 利用automake.files/smiley3.gif">
</DIV></TD>
<TD width=150><SPAN class=label>作者</SPAN> <FONT
color=#3366cc><B>Checky</B> </FONT></TD>
<TD align=right><SPAN class=label>日期</SPAN> <FONT color=#3366cc>Jan
1, 2004 11:58 pm</FONT> </TD></TR>
<TR>
<TD colSpan=5 height=1></TD>
<TR class="content even">
<TD
style="PADDING-RIGHT: 2em; PADDING-LEFT: 2em; PADDING-BOTTOM: 0.5em; PADDING-TOP: 0.5em"
colSpan=4>
<DIV class=message_body>
<P>参见“格式化文本说明”:http://www.antpower.org/Folder_AntGuide/Link.2003-09-27.0627/view</P>
<P>另外在发帖之前可以先用“预览”功能预览后再发布。</P></DIV>
<DIV class=spacer></DIV></TD></TR></TBODY></TABLE><BR></SPAN></DIV><BR>
<DIV>[ <A
href="http://www.antpower.org/Folder_AntForum/Forum_SoftAndFramwork">主题家园</A>
| <A
href="http://www.antpower.org/Folder_AntForum/Forum_SoftAndFramwork/forum_search_form">查询</A>
] </DIV></DIV>
<DIV></DIV></DIV>
<DIV class=spacer></DIV></DIV></TD></TR></TBODY></TABLE>
<HR class=netscape4>
<DIV class=footer><A href="http://www.antpower.org/"><IMG alt="Ant Power"
src="蚂蚁公社 - 轻轻松松产生 Makefile 利用automake.files/logo_small.jpg" border=0> </A>
<P></P>蚂蚁公社 版权所有 © 2003-2004 Powered by Plone <!-- Please keep the Plone Powered button (or a textual link to us) if you use Plone on your site. It's a nice token of gratitude, and we appreciate your help in promoting the Plone name. Plone is powered by the combined forces of Zope and CMF, two absolutely great systems made by Zope Corporation (http://zope.com) and they in turn are based on the best programming language in the world - Python (http://www.python.org). We owe these guys a lot, thanks for making Plone possible! -->
<HR class=netscape4>
<STRONG class=netscape4>If you can read this text, it means you are not
experiencing the Plone design at its best. Plone makes heavy use of CSS, which
means it is accessible to any internet browser, but the design needs a <A
href="http://www.webstandards.org/upgrade/">standards-compliant browser to look
like we intended it</A>. Just so you know ;) </STRONG><!--script language=javascript src="/Folder_AntStats/js/awstats_misc_tracker.js"></script--></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -