Chinaunix首页 | 论坛 | 博客
  • 博客访问: 249258
  • 博文数量: 49
  • 博客积分: 1231
  • 博客等级: 少尉
  • 技术积分: 967
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-02 00:04
个人简介

-->软硬件结合的系统级开发工程师,带过团队,爱好心理学,哲学,艺术...偶像:达芬奇

文章存档

2014年(2)

2013年(4)

2012年(15)

2011年(28)

分类: LINUX

2011-12-30 10:36:43

 
Ubuntu系统下autoconf生成Makefile的文件过程

1.安装必要的工具软件
  1. $ sudo apt-get install autoconf automake gettext
 
2.编写样例程序
  1. $ mkdir helloworld
  2. $ cd helloworld
  3. $ vim helloworld.c
  1. #include <stdio.h>

  2. int main(int argc, char **argv)
  3. {
  4.     printf("Hello, Linux World!\n");
  5.     return 0;
  6. }
 
3.生成configure.scan并改名为configure.in
  1. $ autoscan
  2. $ mv configure.scan configure.in
  3. $ vim configure.in
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.

  3. AC_PREREQ(2.61)
  4. AC_INIT(helloworld, 1.1, xxx@sina.cn)
  5. AC_CONFIG_SRCDIR([helloworld.c])
  6. AC_CONFIG_HEADER([config.h])
  7. AM_INIT_AUTOMAKE(helloworld, 1.1)

  8. # Checks for programs.
  9. AC_PROG_CC

  10. # Checks for libraries.

  11. # Checks for header files.

  12. # Checks for typedefs, structures, and compiler characteristics.

  13. # Checks for library functions.

  14. AC_OUTPUT(Makefile)

4.生成aclocal.m4和configure两个文件
  1. $ aclocal
  2. $ autoconf
 
5.新建Makefile.am文件并添加以下内容
  1. $ vim Makefile.am
  1. UTOMAKE_OPTIONS=foreign
  2. bin_PROGRAMS=helloworld
  3. helloworld_SOURCES=helloworld.c
 
6.生成config.h.in文件
  1. $ autoheader
 
7.生成Makefile.in文件
  1. $ touch NEWS README AUTHORS ChangeLog
  2. $ automake --add-missing
 
8.执行configure生成Makefile文件
  1. $ ./configure
 
9.使用Makefile编译代码
  1. $ make
 
10.运行helloworld代码
  1. $ ./helloworld
 
阅读(1951) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~