Auto Tools使用流程
http://vaqeteart.iteye.com/blog/900666
图解autoscan、aclocal、autoheader、automake、autoconf、configure、make
http://baigoogledu.blog.51cto.com/738227/153552
http://hi.baidu.com/yzkuang/blog/item/557e4f24423d8136c9955908.html
Auto Tools使用流程
本文内容:
一、简介
二、AutoTools相关说明
三、实际例子
一、简介
=============
本文简单介绍最简单的auto tools工具的使用流程。
对于一个UNIX/Linux下C程序员来说,一个比较麻烦的工作就是写自己的Makefile。
可能你有如下经验:写一个简单的C程序,自己多写几行gcc命令就把程序变成可执行的了;写一个稍微复杂点的程序,源文件个数可能在30个左右,还是写一 行行的gcc命令就麻烦了,你可能想到写个makefile,你可能也在这样做着;但你某一天会发现你写的这个Makefile可能不是一个所有 UNIX/Linux类操作系统下通用的Makefile,比如某人下载了你的程序去他自己电脑上可能make不了。这样,你就有必要了解并学会运用 autoconf和automake了。
本节要讲的autotools系列工具正是为此而设的,它只需用户输入简单的目标文件、依赖文件、文件目录等就可以轻松地生成Makefile了,这无疑 是广大用户的所希望的。另外,这些工具还可以完成系统配置信息的收集,从而可以方便地处理各种移植性的问题。也正是基于此,现在Linux上的软件开发一 般都用autotools来制作Makefile。
二、AutoTools相关说明
============= =============
autotools 是系列工具 , 它含有 :
• aclocal
• autoscan
• autoconf
• autoheader
• automake
============= =============
在开始使用autoconf和automake之前,首先确认你的系统安装有GNU的如下软件:
1. automake
2. autoconf
3. m4
4. perl
5. 如果你需要产生共享库(shared library)则还需要GNU Libtool
autoconf和automake工作的几个步骤:
步骤解释如下:
1、由你的源文件通过autoscan命令生成configure.scan文件,然后修改configure.scan文件并重命名为configure.in
2、由aclocal命令生成aclocal.m4
3、由autoconf命令生成configure
4、编辑一个Makefile.am文件并由automake命令生成Makefile.in文件
5、运行configure命令生成Makefile
automake支持三种目录层次:flat、shallow和deep。
一个flat包指的是所有文件都在一个目录中的包。为这类包提供的Makefile.am不需要SUBDIRS这个宏。这类包的一个例子是termutils。对应咱们程序员来说:就是所有源文件及自己写的头文件都位于当前目录里面,且没有子目录。
一个deep包指的是所有的源代码都被储存在子目录中的包;顶层目录主要包含配置信息。GNU cpio是这类包的一个很好的例子,GNU tar也是。deep包的顶层Makefile.am将包括宏SUBDIRS,但没有其它定义需要创建的对象的宏。对应咱们程序员来说:就是所有源文件及 自己写的头文件都位于当前目录的一个子目录里面,而当前目录里没有任何源文件。
一个shallow包指的是主要的源代码储存在顶层目录中,而各个部分(典型的是库)则储存在子目录中的包。automake本身就是这类包(GNU make也是如此,它现在已经不使用automake)。对应咱们程序员来说:就是主要源文件在当前目录里,而其它一些实现各部分功能的源文件各自位于不 同目录。
前两个层次的程序编辑方法非常简单,按照上述步骤一步步即可。而第三种层次shallow稍微复杂一点,但这是我们经常写程序用到的结构。下面以一个例子说明shallow层次结构的源文件如何自动生成Makefile文件。
本文只是用一个非常简单的例子,记录了一个使用autotools的实践步骤:
更高级的用法,需要仔细学习这个系列工具的用户手册。
1.autoscan (autoconf): 扫描源代码以搜寻普通的可移植性问题,比如检查编译器,库,头文件等,生成文件configure.scan,它是configure.ac的一个雏形。
your source files --> [autoscan*] --> [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 ,autoconfig.h.in - - - - - - -. V .--------, configure.ac ----------------------->|autoconf|------> configure
6. ./configure的过程
.-------------> [config.cache] configure* --------------------------+-------------> config.log | [config.h.in] -. v .--> [autoconfig.h] +-------> config.status* -+ Makefile.in ---' `--> Makefile
7. make过程
[autoconfig.h] -. +--> make* ---> 程序 Makefile ---'
.---------,
config.site - - ->| |
config.cache - - ->|configure
| - - -> config.cache
| +-,
`-+-------' |
| |----> config.status
config.h.in ------->|config- |----> config.h
Makefile.in ------->| .status|----> Makefile
| |----> stamp-h
| +--,
.-+ | |
| `------+--' |
ltmain.sh ------->|ltconfig|-------> libtool
| | |
`-+------' |
|config.guess|
| config.sub |
`------------'
.--------,
Makefile ------>| |
config.h ------>| make
|
{project sources} ---------------->| |--------> {project targets}
.-+ +--,
| `--------' |
| libtool |
| missing |
| install-sh |
|mkinstalldirs|
`-------------'
These critical programs are missing or too old: as ld
http://blog.csdn.net/testcs_dn/article/details/45437903
onfigure 时出现以下错误:
checking for autoconf... no
configure: error:
*** These critical programs are missing or too old: as ld
*** Check the INSTALL file for required versions.
问题原因:
缺少autoconf或版本太低
下载安装新版本
# wget ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.68.tar.gz
# tar zxvf autoconf-2.68.tar.gz
# cd autoconf-2.68
# ./configure --prefix=/usr/
# make && make install
查看当前版本:
# autoconf -V
autoconf (GNU Autoconf) 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+/Autoconf: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>, <http://gnu.org/licenses/exceptions.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by David J. MacKenzie and Akim Demaille.
注意是大写的V。
end
相关推荐
根据给出的文件信息,文件标题提及了OS和Linux RedHat系列,包括Red Hat Enterprise Linux(RHEL)的多个版本(包括redhat7、redhat 7、redhat 6和redhat 5)。描述部分未提供实际信息,但给出了一个博文链接,而...
gcc: error trying to exec 'cc1': execvp: No such file or directory
### Red Hat Linux 9.0 系统下载与安装指南 #### 一、Red Hat Linux 9.0 简介 Red Hat Linux 9.0(也称为 Red Hat 9)是 Red Hat 公司在2003年发布的一款流行的操作系统,基于 GNU/Linux。它提供了一个强大的平台...
registry.access.redhat.com/rhel7/pod-infrastructure: 解决创建pod失败,创建pods,一直处于ContainerCreating
linux下tomcat+JDK+redhat配置文档+安装软件linux下tomcat+JDK+redhat配置文档+安装软件linux下tomcat+JDK+redhat配置文档+安装软件linux下tomcat+JDK+redhat配置文档+安装软件linux下tomcat+JDK+redhat配置文档+...
RedHat Linux 服务开启方法详解 RedHat Linux 作为开源操作系统,提供了多种服务来满足不同用户的需求,包括 Telnet、FTP 和 VNC 服务。本文将详细介绍如何在 RedHat Linux 中开启这些服务。 开启 FTP 服务 在 ...
gpgkey=http://ftp.no.sohu.com/pub/os/Linux/RedHat/enterprise/$basearch/7ASU1/dvd/RPM-GPG-KEY-redhat-beta http://ftp.no.sohu.com/pub/os/Linux/RedHat/enterprise/$basearch/7ASU1/dvd/RPM-GPG-KEY-redhat-...
包含Redhat 6.4 6.5/6.6/6.7/7.1的百度盘分享 ,X86_64_DVD
`rpm -ivh ftp://216.254.0.38/linux/redhat/7.3/en/os/i386/RedHat/RPMS/glibc-kernheaders-2.4-7.14.i386.rpm` - glibc-common `rpm -ivh ftp://216.254.0.38/linux/redhat/7.3/en/os/i386/RedHat/RPMS/glibc-...
Oracle10gIAS Install For RedHat Linux9.0/AS3.0 安装报告
- **自动化构建工具**:如`autoconf`和`automake`,帮助自动配置和构建项目。 - **测试工具**:如`check`和`gtest`,用于编写和运行测试用例。 #### 三、安装步骤 1. **下载必要的rpm包**:首先需要从可靠的源站点...
前不久在卸载oracle时不小心把/etc/inittab这个文件删了,找了半天没找到,最终不得不翻出安装盘把这个文件找出来,现在把文件提供给大家。
ansible-zabbix-agent, 为 RedHat/Debian/Ubuntu 安装和维护zabbix代理 目录概述升级插件1.0.00.8.0要求操作系统Zabbix版本Zabbix 3.4Zabbix 3.2:Zabbix 3.0:Zabbix 2.4:Zabbix 2.2:Zabbix AP