图解aclocal、autoconf、automake、autoheader、configure

本文介绍如何使用autoscan、aclocal、autoheader、automake及autoconf等工具来自动化配置源代码,实现从扫描源代码、生成宏定义文件、创建Makefile.in到最终生成configure脚本的整个过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.autoscan (autoconf): 扫描源代码以搜寻普通的可移植性问题,比如检查编译器,库,头文件等,生成文件configure.scan,它是configure.ac的一个雏形。

2.aclocal (automake):根据已经安装的宏,用户定义宏和acinclude.m4文件中的宏将configure.ac文件所需要的宏集中定义到文件 aclocal.m4中。aclocal是一个perl 脚本程序,它的定义是:“aclocal - create aclocal.m4 by scanning configure.ac”

user input files   optional input     process          output files

================   ==============     =======          ============

                    acinclude.m4 - - - - -.

                                          V

                                      .-------,

configure.ac ------------------------>|aclocal|

                 {user macro files} ->|       |------> aclocal.m4

                                      `-------'

3.autoheader(autoconf): 根据configure.ac中的某些宏,比如cpp宏定义,运行m4,声称config.h.in

user input files    optional input     process          output files

================    ==============     =======          ============

                    aclocal.m4 - - - - - - - .

                                             |

                                             V

                                     .----------,

configure.ac ----------------------->|autoheader|----> autoconfig.h.in

                                     `----------'

4.automake: automake将Makefile.am中定义的结构建立Makefile.in,然后configure脚本将生成的Makefile.in文件转换为Makefile。如果在configure.ac中定义了一些特殊的宏,比如AC_PROG_LIBTOOL,它会调用libtoolize,否则它会自己产生config.guess和config.sub

user input files   optional input   processes          output files

================   ==============   =========          ============

                                     .--------,

                                     |        | - - -> COPYING

                                     |        | - - -> INSTALL

                                     |        |------> install-sh

                                     |        |------> missing

                                     |automake|------> mkinstalldirs

configure.ac ----------------------->|        |

Makefile.am  ----------------------->|        |------> Makefile.in

                                     |        |------> stamp-h.in

                                 .---+        | - - -> config.guess

                                 |   |        | - - -> config.sub

                                 |   `------+-'

                                 |          | - - - -> config.guess

                                 |libtoolize| - - - -> config.sub

                                 |          |--------> ltmain.sh

                                 |          |--------> ltconfig

                                 `----------'

5.autoconf:将configure.ac中的宏展开,生成configure脚本。这个过程可能要用到aclocal.m4中定义的宏。

user input files   optional input   processes          output files

================   ==============   =========          ============

                   aclocal.m4 - - - - - -.

                                         V

                                     .--------,

configure.ac ----------------------->|autoconf|------> configure ----->autoconfig.h,M

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值