开始目录结构:
. `-- src `-- main.cStep 1:
在工程目录 touch Makefile.am 并敲入: SUBDIRS = src 新建src目录,进入src并新建Makefile.am AUTOMAKE_OPTIONS = foreign bin_PROGRAMS = hello hello_SOURCES = main.c目录结构:
. |-- Makefile.am `-- src |-- main.c `-- Makefile.amStep 2. autoscan
Step 3.
mv configure.scan configure.in 修改AC_INIT为 AC_INIT(CB, 0.1, emacs@vimer.org) 添加:AM_INIT_AUTOMAKE()目录结构:
. |-- autoscan.log |-- configure.in |-- Makefile.am `-- src |-- main.c `-- Makefile.amStep 4.aclocal
目录结构:
. |-- aclocal.m4 |-- autom4te.cache | |-- output.0 | |-- requests | `-- traces.0 |-- autoscan.log |-- configure.in |-- Makefile.am `-- src |-- main.c `-- Makefile.amStep 5.autoconf
目录结构:
|-- aclocal.m4 |-- autom4te.cache | |-- output.0 | |-- output.1 | |-- requests | |-- traces.0 | `-- traces.1 |-- autoscan.log |-- configure |-- configure.in |-- Makefile.am `-- src |-- main.c `-- Makefile.amStep 6.touch NEWS README AUTHORS ChangeLog
Step 7.autoheader
Step 8.automake --add-missing
Step 9. ./configure
Step 10.make
...........................一连串的Step只是个Autoamke Tools的简单使用.............................
各个步骤的分析如下:
Step 1:
Makefile.am是为了生成Makefile准备的. 可以说是Makefile的高层次的规则格式.
AUTOMAKE_OPTIONS 是Automake的选项,Automake是帮助开发GNU软件的人员维护软件,所以在执行Atuomake时,会先检查目录下是否存在标准GNU软件中应该具备的文件,例如'NEWS', 'AUTHOR' , 'ChangeLog'等文件, 设置foreign时,Automake会改用一般软件的标准来检查也就是可以不需要建立 NEWS 等这些文件..
bin_PROGRAMS = hello //生成的可执行程序的名称
hello_SOURCE //源文件
Step 2:
autoscan检查源文件和一些依赖关系
Step 3:
修改configure.scan为configure.in
configure.in文件的内容为一系列的GNU m4的宏,M4的宏是为了产生configure的 .需要一定的了解.
Step 4:
根据configure.in的内容生成aclocal.m4 和 auto4te.cache供automake使用
Step 5:
autoconf 根据configure.in和aclocal.m4生成configure
Step 7:
生成config.h.in
Step 8:
生成一些Makefile.in depcpmp install-sh 等等
Step 9:
生成Makefile