博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
OS + Linux RedHat Autotools aclocal / autoscan / autoconf / autoheader /automake
阅读量:4077 次
发布时间:2019-05-25

本文共 7904 字,大约阅读时间需要 26 分钟。

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的实践步骤:
更高级的用法,需要仔细学习这个系列工具的用户手册。

 

 

 

图解autoscan、aclocal、autoheader、automake、autoconf、configure、make
2008年05月13日 星期二 16:42

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.inuser 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|------> mkinstalldirsconfigure.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

你可能感兴趣的文章
BootLoader
查看>>
好盈电调,乐天和天行者
查看>>
无人机电机我似乎是朗宇听得多
查看>>
F330的动力套装
查看>>
电池3S和4S的区别,无人机原本是3S的电池,换成4S确实是可能造成参数不匹配
查看>>
真正实际弄无人机我感觉很多知识需要恶补
查看>>
现在明白为什么pixhawk光流模块和超声波模块绑在一起
查看>>
无人机的日志分析是真的有用,能真正找出问题所在!
查看>>
找找有没有不需要焊接的分电板
查看>>
插头的类别
查看>>
突然发现湖南优象还和全景相机有点联系
查看>>
US100超声波模块使用说明
查看>>
尽量不要自己焊线接传感器
查看>>
我看到TB上有真正卖这种载人平衡车控制板的
查看>>
无人机出问题更多可能是硬件上的问题而不是软件上的问题。
查看>>
JTAG、JLINK、ULINK、ST-LINK的联系和区别
查看>>
*玩无人机很明显的一点就是理论和实践相差很大(考研,找工作也是的)
查看>>
无人机光流模块的选择
查看>>
不一定超声波测高,还可以激光测高
查看>>
现在发现如果无人机的电机不同,浆可能是不能混用的。
查看>>