Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7347381
  • 博文数量: 1763
  • 博客积分: 18684
  • 博客等级: 上将
  • 技术积分: 16217
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-02 10:28
个人简介

啥也没写

文章分类

全部博文(1763)

文章存档

2023年(44)

2022年(39)

2021年(46)

2020年(43)

2019年(27)

2018年(44)

2017年(50)

2016年(47)

2015年(15)

2014年(21)

2013年(43)

2012年(143)

2011年(228)

2010年(263)

2009年(384)

2008年(246)

2007年(30)

2006年(38)

2005年(2)

2004年(1)

分类: 项目管理

2013-01-23 16:06:29

原文地址:automake快速搭建工程 作者:ckelsel

Automake简介

GNU AutomakeLinux环境下常用的开发工具,可以产生供make使用的Makefile,省却了开发人员编写Makefile的繁琐事情。

搭建流程

Automake搭建工程的一般流程,如下图所示:椭圆或圆形代表动作,长方形代表数据


上图的流程比较繁琐,GNU提供了一个工具Autoreconf,将automakeautoconf等调用顺序隐藏起来,可以更便利的生成工程。流程图如下所示




流程图解析:

1.       $autoscan,对源码进行扫描,生成configure.scan,并修改为configure.ac

2.       准备Makefile.am

3.       $autoreconf –install生成config.h,Makefile

4.       $make编译工程

实例

这个例子是生成一个动态库libmymath.so,供主程序test调用。

3.1 源码目录结构


总共是1个目录,9个文件。

3.2 步骤

1. $autoscan

2.  $mv   configure.scan       configure.ac

3.  $vi    configure.ac

        修改AC_INIT([test], [1.0], BUG-REPORT-ADDRESS)

  增加AM_INIT_AUTOMAKE,初始化automake

  增加AC_PROG_LIBTOOL,支持库文件

4.   $autoreconf      --install

5.   $./configure

6.   $make

附录

4.1 顶层Makefile.am

SUBDIRS=src

 

4.2   srcMakefile.am

#指定生成的二进制的名字

bin_PROGRAMS=test

#test依赖的C文件

test_SOURCES=main.c \

             usage.c

#test依赖的库文件

test_LDADD=libmymath.la

include_HEADERS=del.h \

                add.h


#生成的共享库libmymath.so

lib_LTLIBRARIES=libmymath.la

#共享库的依赖文件

libmymath_la_SOURCES=add.c \

                     del.c

4.3 main.c

#include

#include "add.h"

#include "del.h"


#include "usage.h"

int main(char *argv[], int argc)

{

    if (argc > 1)

    {

        usage();

        return -1;

    }

    int a = 1;

    int b = -1;

    int c;

    c = add(a, b);

    printf("c = %d\n", c);


    c = del(a, b);

    printf("c = %d\n", c);

    return 0;

}

 

4.4 add.c

int add(int a, int b)

{

    return a+b;

}

4.5 add.h

int add(int a, int b);

4.6   del.c

int del(int a, int b)

{

    return a-b;

}

4.7  del.h

int del(int a, int b);

4.8  usage.c

void usage(void)

{

    printf("usage: ./bin");

}

4.9 usage.h

void usage(void);

阅读(981) | 评论(0) | 转发(0) |
0

上一篇:host

下一篇:eeplat PAAS

给主人留下些什么吧!~~