<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Liu Zhongshu &#187; make</title>
	<atom:link href="http://www.liuzhongshu.com/tag/make/feed" rel="self" type="application/rss+xml" />
	<link>http://www.liuzhongshu.com</link>
	<description>人生重要的不是所站的位置，而是所朝的方向。</description>
	<lastBuildDate>Sat, 31 Jul 2010 02:47:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>makefile for asciidoc</title>
		<link>http://www.liuzhongshu.com/code/makefile-for-asciidoc.html</link>
		<comments>http://www.liuzhongshu.com/code/makefile-for-asciidoc.html#comments</comments>
		<pubDate>Mon, 17 Dec 2007 12:17:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[code|编程]]></category>
		<category><![CDATA[asciidoc]]></category>
		<category><![CDATA[make]]></category>

		<guid isPermaLink="false">http://www.liuzhongshu.com/archives/521</guid>
		<description><![CDATA[不愿意每次键入长长的命令来执行asciidoc的编译，那么下面这个makefile正是为此准备的，自动检查是否需要编译，如果需要则自动调用asciidoc:
HTMLS := $(patsubst %.txt,%.html,$(wildcard *.txt))
all: $(HTMLS)
%.html: %.txt&#160;&#160;&#160;&#160;&#160;&#160;&#160; asciidoc -a toc -a numbered $&#60; 
]]></description>
			<content:encoded><![CDATA[<p>不愿意每次键入长长的命令来执行asciidoc的编译，那么下面这个makefile正是为此准备的，自动检查是否需要编译，如果需要则自动调用asciidoc:</p>
<p>HTMLS := $(patsubst %.txt,%.html,$(wildcard *.txt))</p>
<p>all: $(HTMLS)</p>
<p>%.html: %.txt<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; asciidoc -a toc -a numbered $&lt; </p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuzhongshu.com/code/makefile-for-asciidoc.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Docbook 编译</title>
		<link>http://www.liuzhongshu.com/code/docbook-compiler.html</link>
		<comments>http://www.liuzhongshu.com/code/docbook-compiler.html#comments</comments>
		<pubDate>Tue, 13 Nov 2007 12:57:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[code|编程]]></category>
		<category><![CDATA[make]]></category>

		<guid isPermaLink="false">http://www.liuzhongshu.com/archives/459</guid>
		<description><![CDATA[Docbook很好，我喜欢。所以了解它的&#8221;编译&#8221;过程是挺有意思的事，典型的两个方法是：1）以Svnbook为例，它使用gmake来写makefile，基本上这个makefile还是很简单的，有几个关键的target和rule，分别用于生成各种目标文件类型，比如HTML，PDF等（为了生成pdf，需要先生成fo文件），还有几个公共的make target，比如version用于每次make时更新版本号，这个版本号会记录在一个xml文件中（ 比如version.xml），这个xml文件将被包含在最终的book中。用于格式转换的工具，是最基本的xsltproc（c实现的）和fop（用于将fo文件转换到pdf），可惜fop在中文处理上有些瑕疵（中文，哎），需要不小的调整。
2）Diveintopython则走了Java的路线，编译使用ant，格式转换使用Saxon，Java的东东我不太熟悉，也无意往下看了，不过它不用.fo格式，而是直接通过html生成pdf，转换工具是html2doc，无比遗憾的是，html2doc也不支持中文（中文真是永远的痛啊），也许将html转换为pdf不是很困难，但要比较完美的转换则不太容易（保持目录，链接等信息），再加上中文，那是相当的不简单啊。 
看起来还是有些复杂，不过这些东东都只用写一次的，倒是蛮符合Docbook的精髓： Write Once, Read Anywhere!
]]></description>
			<content:encoded><![CDATA[<p>Docbook很好，我喜欢。所以了解它的&#8221;编译&#8221;过程是挺有意思的事，典型的两个方法是：<br />1）以Svnbook为例，它使用gmake来写makefile，基本上这个makefile还是很简单的，有几个关键的target和rule，分别用于生成各种目标文件类型，比如HTML，PDF等（为了生成pdf，需要先生成fo文件），还有几个公共的make target，比如version用于每次make时更新版本号，这个版本号会记录在一个xml文件中（ 比如version.xml），这个xml文件将被包含在最终的book中。用于格式转换的工具，是最基本的xsltproc（c实现的）和fop（用于将fo文件转换到pdf），可惜fop在中文处理上有些瑕疵（中文，哎），需要不小的调整。</p>
<p>2）Diveintopython则走了Java的路线，编译使用ant，格式转换使用Saxon，Java的东东我不太熟悉，也无意往下看了，不过它不用.fo格式，而是直接通过html生成pdf，转换工具是html2doc，无比遗憾的是，html2doc也不支持中文（中文真是永远的痛啊），也许将html转换为pdf不是很困难，但要比较完美的转换则不太容易（保持目录，链接等信息），再加上中文，那是相当的不简单啊。 </p>
<p>看起来还是有些复杂，不过这些东东都只用写一次的，倒是蛮符合Docbook的精髓： Write Once, Read Anywhere!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuzhongshu.com/code/docbook-compiler.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>makefile 的 $(wildcard)</title>
		<link>http://www.liuzhongshu.com/code/makefile-wildcard.html</link>
		<comments>http://www.liuzhongshu.com/code/makefile-wildcard.html#comments</comments>
		<pubDate>Thu, 11 Oct 2007 11:52:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[code|编程]]></category>
		<category><![CDATA[make]]></category>

		<guid isPermaLink="false">http://www.liuzhongshu.com/archives/522</guid>
		<description><![CDATA[gmake的$wildcard函数可以列举一个目录下的文件，通常的用法是$(wildcard *.cpp)之类的，但实际上gmake可以支持这类语法：&#160;$(wildcard */Makefile)也就是说用wildcard来匹配所有的含makefile文件的子目录，甚至象这样的语法：&#160;$(wildcard */*/Makefile)匹配二级子目录下的Makefile也能工作。
所以一些老的工具虽然看上去有些土，或不太容易上手，但由于经年的积累，它们可能非常的强大，一旦掌握，威力很大啊。 
 
]]></description>
			<content:encoded><![CDATA[<p>gmake的$wildcard函数可以列举一个目录下的文件，通常的用法是$(wildcard *.cpp)之类的，但实际上gmake可以支持这类语法：<br />&nbsp;$(wildcard */Makefile)<br />也就是说用wildcard来匹配所有的含makefile文件的子目录，甚至象这样的语法：<br />&nbsp;$(wildcard */*/Makefile)<br />匹配二级子目录下的Makefile也能工作。</p>
<p>所以一些老的工具虽然看上去有些土，或不太容易上手，但由于经年的积累，它们可能非常的强大，一旦掌握，威力很大啊。 </p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuzhongshu.com/code/makefile-wildcard.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>从源文件中提取版本号</title>
		<link>http://www.liuzhongshu.com/code/extracted-from-the-source-files-version.html</link>
		<comments>http://www.liuzhongshu.com/code/extracted-from-the-source-files-version.html#comments</comments>
		<pubDate>Tue, 21 Aug 2007 13:29:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[code|编程]]></category>
		<category><![CDATA[make]]></category>

		<guid isPermaLink="false">http://www.liuzhongshu.com/archives/467</guid>
		<description><![CDATA[在build软件的过程中，经常需要版本号（比如打标签，压缩包的时候），从代码中获取是最好的方法，shell命令就可以做到，比如代码中有这样的语句：version = &#8220;1.0.2&#8243;
可以用这样的命令截取下来：grep &#34;versions*=&#34; sourcefile &#124; cut -d &#34;&#160; -f 2
如果是在makefile中，就可以赋值给变量了：VERSION := $(shell grep &#34;versions*=&#34; sourcefile &#124; cut -d &#34;&#160; -f 2)  
]]></description>
			<content:encoded><![CDATA[<p>在build软件的过程中，经常需要版本号（比如打标签，压缩包的时候），从代码中获取是最好的方法，shell命令就可以做到，比如代码中有这样的语句：<br />version = &#8220;1.0.2&#8243;</p>
<p>可以用这样的命令截取下来：<br />grep &quot;versions*=&quot; sourcefile | cut -d &quot;&nbsp; -f 2</p>
<p>如果是在makefile中，就可以赋值给变量了：<br />VERSION := $(shell grep &quot;versions*=&quot; sourcefile | cut -d &quot;&nbsp; -f 2)  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuzhongshu.com/code/extracted-from-the-source-files-version.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pyGtk程序如何写？</title>
		<link>http://www.liuzhongshu.com/code/pygtk-procedures-how-to-write.html</link>
		<comments>http://www.liuzhongshu.com/code/pygtk-procedures-how-to-write.html#comments</comments>
		<pubDate>Tue, 29 May 2007 14:14:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[code|编程]]></category>
		<category><![CDATA[make]]></category>

		<guid isPermaLink="false">http://www.liuzhongshu.com/archives/507</guid>
		<description><![CDATA[我收集了很多Linux下的pyGtk程序，并做了一个有趣的比较，目前比较关注三个地方- 使用galde还是不使用？- 使用何种方法安装到系统？- 如何做i18n？
下面是统计出的一个列表：                      glade   install        i18ngmail-notify    √        &#215;       [...]]]></description>
			<content:encoded><![CDATA[<p>我收集了很多Linux下的pyGtk程序，并做了一个有趣的比较，目前比较关注三个地方<br />- 使用galde还是不使用？<br />- 使用何种方法安装到系统？<br />- 如何做i18n？
<p>下面是统计出的一个列表：<br />                      glade   install        i18n<br />gmail-notify    √        &#215;               xml<br />gjosts             &#215;        ？             gettext<br />disksearch      √        makefile    gettext<br />comix             &#215;        setup.py    gettext<br />christine         √        autotool     gettext<br />emesene        &#215;        &#215;              gettext<br />meld               √        makefile    gettext<br />quod libet       &#215;        makefile    gettext<br />revelation       &#215;        autotool    gettext<br />scribes           &#215;        autotool    gettext<br />gourmet         √        setup.py    gettext<br />penguintv      √        setup.py    gettext<br />mirage           &#215;        setup.py    gettext<br />deluge           √        setup.py    gettext<br />straw             √        setup.py    gettext<br />gpodder         √        makefile    gettext<br />jbrout             √        &#215;               gettext
<p>（？表示没有搞清楚，makefile表示手工写makefile，autotool表示使用GNU的autoconf和automake，setup.py表示使用python提供的distutils）
<p>这样的统计可以得出一些有意义的结论：<br />- 如果要做i18n的话，不要犹豫，使用gettext不会错。<br />- 是否使用glade，可能要根据应用考虑一下，但似乎使用glade的应用稍多一些。<br />- 使用python的distutils/setup是个不错的选择。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuzhongshu.com/code/pygtk-procedures-how-to-write.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GNU build系统 I</title>
		<link>http://www.liuzhongshu.com/code/i-gnu-build-system.html</link>
		<comments>http://www.liuzhongshu.com/code/i-gnu-build-system.html#comments</comments>
		<pubDate>Wed, 23 May 2007 14:20:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[code|编程]]></category>
		<category><![CDATA[make]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.liuzhongshu.com/archives/472</guid>
		<description><![CDATA[提到automake，autoconf我就头大，但还是需要还是要理解这些东东的，否则永远也不能理解GNU developer world。
GNU build系统是一组工具的集合，用于简化开发人员的build工作，将开发人员的精力集中在代码实现上，而不是花费在烦人的build script上（比如makefile，install script。。。），这一组工具主要是autoconf和automake，使用他们除了简化build script外，还额外得到了更好的跨平台特性，因为GNU build系统会生成一个cofngure脚本，这个脚本会根据平台特性生成相应的makefile，而且这个makefile可以很好的兼容各种 make版本。
例子，例子。。。。，建立三个文件：`hello.c&#8217; #include &#60;stdio.h&#62;main(){printf(&#8221;Hello, world!
&#8220;);}
`Makefile.am&#8217; bin_PROGRAMS = hellohello_SOURCES = hello.c
`configure.in&#8217; AC_INIT(hello.c)AM_INIT_AUTOMAKE(hello,0.1)AC_PROG_CCAC_PROG_INSTALLAC_OUTPUT(Makefile)
然后，演出开始，依次执行$ aclocal$ autoconf$ touch NEWS README AUTHORS ChangeLog$ automake -a$ ./configure$ make$ make distcheck
如 果这些工具都已经安装的话，一阵滚屏之后，hello程序生成了，甚至连第一个发布的版本hello-0.1.tar.gz也准备好了。如果我们修改了 hello.c，要再发一个版本，也很简单，先用make distcheck检测一遍，保证没有问题。然后修改configure.in中的版本号，修改说明文档NEWS，ChangeLog，再调用make dist，新的gz生成了，一切搞定（命令行有时真是爽啊）。
爽过之后，来理性的分析一下过程，大致的过程是这样的*.m4, configure.in &#8212;&#8212;&#8212;&#8212;-&#62;{aclocal}&#8212;&#8211;&#62; aclocal.m4aclocal.m4, configure.in  &#8212;&#8211;&#62; {autoconf} &#8212;&#8212;&#8211;&#62; configureMakefile.am &#8212;&#8212;&#8211;&#62; {automake} &#8212;&#8212;&#8212;&#8211;&#62; Makefile.inMakefile.in  &#8212;&#8212;&#8212;-&#62; {configure} &#8212;&#8212;&#8212;&#8212;&#62; Makfile
m4 是macro的缩写（因为m后面有4个字符），这里定义的是autoconf需要看到的宏，aclocal可以自动生成这些宏，并写入到 aclocal.m4中，后面的三个步骤比较明显。其中漏掉的那个touch命令，是用来建立GNU规范所需要的几个文档文件，否则automake会失 [...]]]></description>
			<content:encoded><![CDATA[<p>提到automake，autoconf我就头大，但还是需要还是要理解这些东东的，否则永远也不能理解GNU developer world。</p>
<p>GNU build系统是一组工具的集合，用于简化开发人员的build工作，将开发人员的精力集中在代码实现上，而不是花费在烦人的build script上（比如makefile，install script。。。），这一组工具主要是autoconf和automake，使用他们除了简化build script外，还额外得到了更好的跨平台特性，因为GNU build系统会生成一个cofngure脚本，这个脚本会根据平台特性生成相应的makefile，而且这个makefile可以很好的兼容各种 make版本。</p>
<p>例子，例子。。。。，建立三个文件：<br />`hello.c&#8217; <br />#include &lt;stdio.h&gt;<br />main()<br />{<br />printf(&#8221;Hello, world!<br />
&#8220;);<br />}</p>
<p>`Makefile.am&#8217; <br />bin_PROGRAMS = hello<br />hello_SOURCES = hello.c</p>
<p>`configure.in&#8217; <br />AC_INIT(hello.c)<br />AM_INIT_AUTOMAKE(hello,0.1)<br />AC_PROG_CC<br />AC_PROG_INSTALL<br />AC_OUTPUT(Makefile)</p>
<p>然后，演出开始，依次执行<br />$ aclocal<br />$ autoconf<br />$ touch NEWS README AUTHORS ChangeLog<br />$ automake -a<br />$ ./configure<br />$ make<br />$ make distcheck</p>
<p>如 果这些工具都已经安装的话，一阵滚屏之后，hello程序生成了，甚至连第一个发布的版本hello-0.1.tar.gz也准备好了。如果我们修改了 hello.c，要再发一个版本，也很简单，先用make distcheck检测一遍，保证没有问题。然后修改configure.in中的版本号，修改说明文档NEWS，ChangeLog，再调用make dist，新的gz生成了，一切搞定（命令行有时真是爽啊）。</p>
<p>爽过之后，来理性的分析一下过程，大致的过程是这样的<br />*.m4, configure.in &#8212;&#8212;&#8212;&#8212;-&gt;{aclocal}&#8212;&#8211;&gt; aclocal.m4<br />aclocal.m4, configure.in  &#8212;&#8211;&gt; {autoconf} &#8212;&#8212;&#8211;&gt; configure<br />Makefile.am &#8212;&#8212;&#8211;&gt; {automake} &#8212;&#8212;&#8212;&#8211;&gt; Makefile.in<br />Makefile.in<a href="http://makefile.in/"> </a> &#8212;&#8212;&#8212;-&gt; {configure} &#8212;&#8212;&#8212;&#8212;&gt; Makfile</p>
<p>m4 是macro的缩写（因为m后面有4个字符），这里定义的是autoconf需要看到的宏，aclocal可以自动生成这些宏，并写入到 aclocal.m4中，后面的三个步骤比较明显。其中漏掉的那个touch命令，是用来建立GNU规范所需要的几个文档文件，否则automake会失 败。</p>
<p>这样生成的makefile在调用编译器时会加上很多-D参数（来自于configure），过多的参数可能会导致make失败，可 以统一将这些参数放在一个头文件中（config.h)，为了使用和产生config.h，需要改动几个地方，首先需要改动configure.in，在 AC_INIT下面加上AM_CONFIG_HEADER(config.h)，然后所有的源文件前要加上：<br />#ifdef HAVE_CONFIG_H<br />#include &lt;config.h&gt;<br />#endif<br />并在执行autoconf之后，执行autoheader，这一步相当于：
<div id="mb_0"> configure.in &#8212;&#8211;> {autoheader} &#8212;&#8212;&#8211;> config.h.in<br />这样就可以了，后面的configure将生成两个文件<br />config.h.in，Makefile.in &#8212;&#8212;> {configure} &#8212;&#8212;-> config.h，Makfile</p>
<p>如果觉得这样的hello，world太麻烦（我也是这么想的）<wbr>，可以下载<a href="http://autotoolset.sourceforge.net/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">autotoolset</a>这个工具来做自动化生成，（这个工具是rpm格式<wbr>，在debian/ubuntu下需要用alien -i安装)，安装完后，执行acmkdir dirname就可以按照向导生成一个目录框架了。</div>
]]></content:encoded>
			<wfw:commentRss>http://www.liuzhongshu.com/code/i-gnu-build-system.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
