0
点赞
收藏
分享

微信扫一扫

GNU Autotools [一]

爱读书的歌者 2022-04-20 阅读 132
linux

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发行版

在这里插入图片描述

举报

相关推荐

0 条评论