zoukankan      html  css  js  c++  java
  • 使用automake

         多余的话不多说,结合一个简单的例子学习automake的用法。首先创建目录hello然后进入目录:

    mkdir hello

    cd hello

    接下来用自己喜欢的编辑器写一个hello.c文件

    #include<stdio.h>

    int main()

    {

       printf("hello world!\n");

       return 0;

    }

    现在在hello目录下应该有一个自己写的hello.c了,下来生成configure,这里使用autoscan命令来根据目录下的源代码生成一个configure.in的模板文件:

    autoscan

    将会产生一个文件:configure.scan,可以拿他作为configure.in的蓝本,现在将configure.scan改名为configure.in,并编辑它,按如下内容修改,去掉无关语句:

    #-*- Autoconf -*-

    #Process this file with autoconf to produce a configure script.

    AC_INIT(hello.c)

    AM_INIT_AUTOMAKE(hello,1.0)

    #check for programs.

    AC_PROG_CC

    #check for libraries.

    #check for header files.

    #check for typedefs, structures, and compiler characteristics.

    #check for library functions.

    AC_UOTPUT(Makefile)

    然后执行aclocal和autoconf分别产生aclocal.m4和configure两个文件:

    aclocal

    autoconf

    可以看到configure.in的内容是一些宏定义,这些宏经autoconf处理后会变成检查系统特性、环境变量、软件必须的shell脚本。autoconf是用来生成自动配置软件源代码脚本的工具。要生成configure文件,必须告诉autoconf如何找到所用的宏。方式是使用aclocal程序来生成你的aclocal.m4。下面建立一个Makefile.am文件:

    vim Makefile.am

    文件内容为:

    AUTOMAKE——OPTIONS=foreign

    bin_PROGRAMS=hello

    hello_SUORCES=hello.c

    automake会根据所写的Makefile.am来自从生成Makefile.in。下一步将运行automake,命令如下:

    automake --add-missing

    automake会根据Makefile.am文件产生一些文件,包含最重要的Makefile.in。执行configure生成Makefile,命令如下:

    ./configure

    此时Makefile已经产生了,现在就可以使用Makefile编译代码了,命令为:

    make

    运行hello:

    ./hello

    这样hello就编译出来了。

  • 相关阅读:
    xml学习笔记2
    用SVN下载sourceforge上的源代码
    析构函数的浅谈《原创》
    论程序员与妓女
    简单的动画
    突然收到Steve Harmon的短消息,真意外啊。
    从长春到北京--“一个人的旅行”
    动画停止和延时
    。NET :遍历某个权限集中的权限列表
    如何让Silverlight程序可以在浏览器外运行
  • 原文地址:https://www.cnblogs.com/276815076/p/1839589.html
Copyright © 2011-2022 走看看