本文主要是介绍Linux下autoTools工具集使用介绍,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Author : iStone
E-mail : liul.stone@gmail.com
Date : 2015-09-19 15:16:38
一 使用autoTools工具集
1.1 什么是autoTools
我们都了解make工程管理器的强大功能。但编写makefile 确实不是一件轻松的事,尤其对于一个较大的项目而言更是如此。那么,有没有一种轻松的手段生成makefile而同时又能让用户享受make 的优越性呢?本节要讲的autoTools系列工具正是为此而设的,它只需用户输入简单的目标文件、依赖文件、文件目录等就可以轻松地生成makefile了。另外,这些工具还可以完成系统配置信息的收集,从而可以方便地处理各种移植性的问题。也正是基于此,现在Linux上的软件开发一般都用autoTools 来生成makefile。
1.2 autoTools
使用流程
正如上文所言,autoTools
是系列工具,它包含了aclocal、autoscan、autoconf、autoheader、和automake
这些工具,使用autoTools主要就是利用各个工具的脚本文件来生成最后的makefile
文件。其总体流程如下:
图 1-1 autoTools
生成makefile
流程图
接下来用/*sayHello.c*/
来做为实例:
0、安装autoTools
安装autoTools
工具集,Centos下可以使用 yum install autoconf automake
在线安装。
1、创建目录
建立一个TestautoTools
的目录,这个目录将作为存放sayHello
程序及其相关档案的地方。
2、创建源码文件
用编辑器在TestautoTools
目录下创建sayHello.c
源文件和sayHello.h
头文件,内容如下:
[root@localhost TestautoTools]# cat sayHello.c
#include <stdio.h>#include "sayHello.h"int main()
{printf("Program say : %s\n" ,STR);return 0;
}[root@localhost TestautoTools]# cat sayHello.h
#ifndef SAYHELLO_H
#define SAYHELLO_H#define STR "hello AutoTools"#endif[root@localhost TestautoTools]# ls
sayHello.c sayHello.h
接下来就要用autoTools为我们生成makefile文档:
3、autoscan
[root@localhost TestautoTools]# autoscan
[root@localhost TestautoTools]# ls
autoscan.log configure.scan sayHello.c sayHello.h
[root@localhost TestautoTools]#
它会在给定目录及其子目录树中检查源文件,默认是在当前目录及其子目录树中进行检查。执行autoscan后会产生一个configure.scan的档案,我们可以用它做为configure.in文档的蓝本。但由上述结果可知autoscan会首先去读入configure.ac文件,但此时还没有创建该配置文件,于是它就自动生成了一个configure.scan文件。
[root@localhost TestautoTools]# ls
autoscan.log configure.scan sayHello.c
这篇关于Linux下autoTools工具集使用介绍的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!