通过搜索资料和自身体会总结autotools的一个简单使用方法。
大致包括如下命令:
autoscan
aclocal
autoconf
autoheader
automake
首先创建hello.c文件并编辑
(1)autoscan
在源代码目录中执行 autoscan
生成configure.scan文件。
编辑configure.scan文件,通常添加如下两行
并另存为configure.ac(或configure.in),和autoscan.log。
(2)aclocal
执行aclocal,工具根据configure.ac(或configure.in)生成aclocal.m4文件和autom4te.cache文件夹。
(3)autoconf
执行autoconf,生成configure文件。
(4)autoheader
执行autoheader,生成config.h.in文件。
(5)automake
新建文件Makefile.am并编辑
执行automake,提示:
执行automake --add-missing
再执行automake
后面的过程即为熟知的
./configure
make
make install
补充:
autotools工具还提供 make dist 打包功能
执行 make dist
根据configure.ac中
AC_INIT( [ hello ], [ 1.0 ] )
生成hello-1.0.tar.gz的源码包文件。
总结:
在autotools的使用过程中,除了源代码以外,必须的文件只有两个 configure.ac 和 Makefile.am