GNU Autotools [一]

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

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

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 

示例:

  1. 在autotools下创建hello.c

  2. 用autoscan生成configure.scan

  3. mv configure.scan configure.ac
    在这里插入图片描述

  4. 修改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                                  

在这里插入图片描述

  1. aclocal:生成aclocal.m4,存放autoconf运行需要的宏
    在这里插入图片描述

  2. autoconf:将configure.ac->configure
    在这里插入图片描述

  3. 创建 Makefile.am
    在这里插入图片描述

  4. autoheader 生成配置文件
    在这里插入图片描述

  5. automake --add-missing(-a) 生成隐式配置
    在这里插入图片描述

  6. 编译

        ./configure
        make
        make install
        make uninstall

工具的发展史

在这里插入图片描述

linux发行版

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值