Autotools 工具集使用
1,autoscan
2, aclocal
3, autoconf
4, [autoheader]
5, automake
官方帮助文档
http://www.gnu.org/software/autoconf/manual/autoconf.html#Automake
automake 流程图
Files used in preparing a software package for distribution, when usingjust Autoconf:
your source files --> [autoscan*] --> [configure.scan] --> configure.ac
configure.ac --.
| .------> autoconf* -----> configure
[aclocal.m4] --+---+
| `-----> [autoheader*] --> [config.h.in]
[acsite.m4] ---'
Makefile.in
Additionally, if you use Automake, the following additional productionscome into play:
[acinclude.m4] --.
|
[local macros] --+--> aclocal* --> aclocal.m4
|
configure.ac ----'
configure.ac --.
+--> automake* --> Makefile.in
Makefile.am ---'
Files used in configuring a software package:
.-------------> [config.cache]
configure* ------------+-------------> config.log
|
[config.h.in] -. v .-> [config.h] -.
+--> config.status* -+ +--> make*
Makefile.in ---' `-> Makefile ---'
第一步:
建立hello.c 源文件
#include<stdio.h>
int main ()
{
printf("hello automake");
return 0;
}
在当前目录执行autoscan生成autoscan.log 和configure.scan两个文件,编辑configure.scan文件,将configure.scan 改名configure.ac
编辑该文件修改文件如下:
AC_PREREQ([2.68])
AC_INIT(hello,1.0,zlz2010@yahoo.cn)
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE(hello,1.0)
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_OUTPUT(Makefile)
AM_INIT_AUTOMAKE参数必须添加不然接下来会报错。
第二步
执行aclocal 生成 aclocal.m4 文件
执行 autoheader 生成 config.h.in
第三步
新建文件 Makefile.am 填入
bin_PROGRAMS = hello
hello_SOURCES = hello.c
在文档可以找到详细解释
执行 automake --add-missing 生成 Makefile.in
执行 autoconf 生成 configure
执行 ./configure 生成 Makefile
接下来执行make install 安装你但程序。
执行 make dist 生成hello-1.0.tar.gz 发布包 完成。
2679

被折叠的 条评论
为什么被折叠?



