前言:关于make和makefile在在管理大型项目中的重要性在这里就不多说了,这篇文章主要讲的是如何自动化的生成Makefile,而不是人工手动的编写符合GNU惯例的Makefile。当然这种方法也是可行的,只是要耗费很大的人力,下面说的是利用GNU的自动化工具,来实现在不同平台上自动化生成Makefile的工具。
工具:autoconf/automake/aclocal/m4
下图为自动化工具原理图
- automake:Generate Makefile.in for configure from Makefile.am.
- autoconf:Generate a configuration script from a TEMPLATE-FILE if given, or`configure.ac' if present, or else `configure.in'. Output is sent to the standard output if TEMPLATE-FILE is given, else into `configure'.
- aclocal:Generate `aclocal.m4' by scanning `configure.ac' or `configure.in'
其中aclocal会调用m4工具,还有就是上图中的aclocal.m4的生成有点问题,应该是依赖configure.in而生成。
至于具体的实现原理及使用方法,请参考下面的链接文章,已经说的很清楚了。
reference:
http://hi.baidu.com/wang282739699/blog/item/f79af6faadced0d7b58f3150.html
http://blog.csdn.net/fpmystar/archive/2009/05/07/4158149.aspx
http://blog.sina.com.cn/s/blog_5f70c7060100gbgy.html