GNU Autotools [一]
文章目录
Autotools
系列工具包:Autoconf、Automake、Libtool
工具安装
检测系统是否已经安装:which autoconf
自动安装:apt install autoconf automake libtool
需要依赖的包:m4\perl\autotools-dev\autoconf-archive\gnu-standards\ autobook …
手动安装:
»下载对应.tar.gz源码包;解压tar xvf *.tar.gz
»编译:./configure;make;make install
Autotools自动创建Makefile流程
•生成Makefile的通用规则文件Makefile.in
•(1)手工编写Makefile.am文件
•(2)#automake:将Makefile.am->Makefile.in
•生成配置脚本configure
•(1)#autoscan:生成configure.scan ->configure.ac
•(2)修改、配置configure.ac
•(3)#aclocal:生成aclocal.m4,存放autoconf运行需要的宏
•(4)#autoconf:将configure.acàconfigure
•通过configure生成Makefile
•(1)#./configure:Makefile.inàMakefile
•(2)#make;make install
示例:
-
在autotools下创建hello.c
-
用autoscan生成configure.scan
-
mv configure.scan configure.ac

-
修改configure.ac
1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ([2.69])
5 AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS]) //FULL-PACKAGE-NAME 为软件包名,
6 AC_CONFIG_SRCDIR([hello.c])
7 AC_CONFIG_HEADERS([config.h])
8
9 # Checks for programs.
10 AC_PROG_CC
11
12 # Checks for libraries.
13
14 # Checks for header files.
15
16 # Checks for typedefs, structures, and compiler characteristics.
17
18 # Checks for library functions.
19
20 AC_OUTPUT

1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ([2.69])
5 AC_INIT(hello, 1.0, mail.original.com)
6 AC_CONFIG_SRCDIR([hello.c])
7 AC_CONFIG_HEADERS([config.h])
8 AM_INIT_AUTOMAKE //使用Automake编译
9
10 # Checks for programs.
11 AC_PROG_CC
12
13 # Checks for libraries.
14
15 # Checks for header files.
16
17 # Checks for typedefs, structures, and compiler characteristics.
18
19 # Checks for library functions.
20
21 AC_OUTPUT(Makefile) //指定输出文件 Makefiel
22
23

-
aclocal:生成aclocal.m4,存放autoconf运行需要的宏

-
autoconf:将configure.ac->configure

-
创建 Makefile.am

-
autoheader 生成配置文件

-
automake --add-missing(-a) 生成隐式配置

-
编译
./configure
make
make install
make uninstall
工具的发展史

linux发行版

本文详细介绍了Autotools工具包(Autoconf, Automake, Libtool)的安装流程,从手动到自动配置,以及它们在创建Makefile和自动生成配置脚本中的作用。涵盖了历史发展和在Linux发行版中的应用。
459

被折叠的 条评论
为什么被折叠?



