zoukankan      html  css  js  c++  java
  • autoconf/automake自动化工具

    1. 查看autoconf ,automake,perl,m4是否安装

    [xpan@localhost ~]$ rpm -qa |grep autoconf
    autoconf-2.68-3.fc17.noarch
    [xpan@localhost ~]$ rpm -qa |grep automake
    automake14-1.4p6-22.fc17.noarch
    automake17-1.7.9-15.fc17.1.noarch
    automake-1.11.3-1.fc17.noarch
    [xpan@localhost ~]$ rpm -qa |grep perl
    perl-Digest-1.17-2.fc17.noarch
    perl-TimeDate-1.20-6.fc17.noarch
    ......
    [xpan@localhost ~]$ rpm -qa |grep m4
    m4-1.4.16-3.fc17.i686

    2. 查看autoconfig,automake命令所在的位置

    [xpan@localhost ~]$ whereis aclocal
    aclocal: /bin/aclocal /usr/bin/aclocal /usr/share/aclocal /usr/share/man/man1/aclocal.1.gz
    [xpan@localhost ~]$ whereis autoscan
    autoscan: /bin/autoscan /usr/bin/autoscan /usr/share/man/man1/autoscan.1.gz
    [xpan@localhost ~]$ whereis autoconf
    autoconf: /bin/autoconf /usr/bin/autoconf /usr/share/autoconf /usr/share/man/man1/autoconf.1.gz
    [xpan@localhost ~]$ whereis autoheader
    autoheader: /bin/autoheader /usr/bin/autoheader /usr/share/man/man1/autoheader.1.gz
    [xpan@localhost ~]$ whereis automake
    automake: /bin/automake /usr/bin/automake /usr/share/man/man1/automake.1.gz

    3.Autoscan工具生成configure.ac文件
    [xpan@localhost 2.6]$ mkdir hello
    [xpan@localhost 2.6]$ cd hello/
    [xpan@localhost hello]$ ls
    [xpan@localhost hello]$ vi hello.c
    [xpan@localhost hello]$ ls
    hello.c
    [xpan@localhost hello]$ cat hello.c
    int main( int argc, char** argv)
    {
    printf("hello! GNU\n");
    return 0;
    }
    [xpan@localhost hello]$ autoscan ./
    [xpan@localhost hello]$ ls
    autoscan.log  configure.scan  hello.c
    [xpan@localhost hello]$ cat configure.scan
    #                                               -*- Autoconf -*-
    # Process this file with autoconf to produce a configure script.


    AC_PREREQ([2.68])
    AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
    AC_CONFIG_SRCDIR([hello.c])
    AC_CONFIG_HEADERS([config.h])

    # Checks for programs.
    AC_PROG_CC

    # Checks for libraries.

    # Checks for header files.

    # Checks for typedefs, structures, and compiler characteristics.

    # Checks for library functions.

    AC_OUTPUT


    [xpan@localhost hello]$  cp configure.scan configure.ac

    [xpan@localhost hello]$ ls
    autoscan.log  configure.ac  configure.scan  hello.c

    [xpan@localhost hello]$ cat configure.ac
    #                                               -*- Autoconf -*-
    # Process this file with autoconf to produce a configure script.

    AC_PREREQ([2.68])
    AC_INIT(hello, 1.0,pxh7212@163.com)
    AM_INIT_AUTOMAKE(hello,1.0)
    AC_CONFIG_SRCDIR([hello.c])
    AC_CONFIG_HEADERS([config.h])

    # Checks for programs.
    AC_PROG_CC

    # Checks for libraries.

    # Checks for header files.

    # Checks for typedefs, structures, and compiler characteristics.

    # Checks for library functions.

    AC_OUTPUT(Makefile)
    [xpan@localhost hello]$

    3. 使用aclocal工具生成aclocal.m4

    [xpan@localhost hello]$ aclocal
    [xpan@localhost hello]$ ls
    aclocal.m4  autom4te.cache  autoscan.log  configure.ac  configure.scan  hello.c

    4.使用autoconf 工具生成configure文件

    [xpan@localhost hello]$ autoconf
    [xpan@localhost hello]$ ls
    aclocal.m4      autoscan.log  configure.ac    hello.c
    autom4te.cache  configure     configure.scan

    5.使用autoheader工具生成configure.h.in文件
    [xpan@localhost hello]$ find / -name acconfig.h
    /usr/src/kernels/3.4.0-1.fc17.i686/include/acpi/acconfig.h
    [xpan@localhost hello]$ autoheader
    [xpan@localhost hello]$ ls
    aclocal.m4      autoscan.log  configure     configure.scan
    autom4te.cache  config.h.in   configure.ac  hello.c

    6.创建Makefile.am文件

    [xpan@localhost hello]$ vi Makefile.am
    [xpan@localhost hello]$ cat Makefile.am
    UTOMAKE_OPTIONS=foreign   //软件等级 foreign, gnu, gnits 默认等级gnu
    bin_PROGRAMS=hello              //定义要产生的执行文件名
    hello_SOURCES=hello.c           //源文件名,如果有多个文件,文件名中间用空格分开
    [xpan@localhost hello]$

    7. 使用Automake生成Makefile.in文件

    [xpan@localhost hello]$automake --add-missing

    8.配置

    [xpan@localhost hello]$./configure     //生成Makefile文件

    gcc编译参数:

    -fPIC 生成与位置无关的代码,这样库就可以在任何位置被链接和装载;

    -shared 指定生成共享链接库;

    -static 指定生成静态链接库;

    -l 指定链接的库文件;

    -L 指定库文件所在的位置;

  • 相关阅读:
    毕设问题02-index.jsp跳转html问题
    毕设问题01-html中引入公共部分代码
    毕设开篇
    object和大括号自定义对象
    数组js
    function 方法的使用
    JavaScript01
    CSS属性
    听说不能改日期了
    获取时间
  • 原文地址:https://www.cnblogs.com/panxihua/p/2544500.html
Copyright © 2011-2022 走看看