Chinaunix首页 | 论坛 | 博客
  • 博客访问: 582602
  • 博文数量: 109
  • 博客积分: 1463
  • 博客等级: 上尉
  • 技术积分: 859
  • 用 户 组: 普通用户
  • 注册时间: 2011-07-22 13:21
个人简介

希望和广大热爱技术的童鞋一起交流,成长。

文章分类

全部博文(109)

文章存档

2017年(1)

2016年(2)

2015年(18)

2014年(1)

2013年(9)

2012年(15)

2011年(63)

分类: LINUX

2011-11-09 09:49:14

建立一个hello的目录,用编辑器写一个hello.c文件:
  1. #include <stdio.h>

  2. int main(int argc,char** argv)
  3. {
  4.     printf("hello,gnu!\n");
  5.     return 0;
  6. }

1. 利用autoscan工具产生一个configure.in文件的模板文件configure.scan文件:

#autoscan

# ls
autoscan.log  configure.scan  hello.c

2.         configure.scan文件更名为configure.in文件,并编译其内容如下:

# mv configure.scan configure.in

# gedit configure.in

将内容:

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

AC_PREREQ([2.65])
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

改为:

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

AC_PREREQ([2.65])
#AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AC_INIT(hello.c)//括号里主要是存放主程序的文件名

    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_CONFIG_FILES([Makefile])

AC_OUTPUT

 

3.执行aclocal,会产生aclocal.m4文件:

# aclocal

# ls
aclocal.m4  autom4te.cache  autoscan.log  configure.in  hello.c

4.执行autoconf,会产生configure文件:

# autoconf
# ls
aclocal.m4  autom4te.cache  autoscan.log  configure  configure.in  hello.c

5.执行autoheader,会产生config.h.in文件:

# ls
aclocal.m4      autoscan.log  configure     hello.c
autom4te.cache  config.h.in   configure.in

6.创建文件Makefile.am文件,并编辑内容如下:

AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=hello   
MyFirst_EXE_SOURCES=hello.c

: 其中,hello为编译后产生的可执行文件名称,而第三行等号后面为源文件列表,所有的源文件都要写出。

7.接下来执行一系列命令,直到生成可执行文件并执行:

# automake --add-missing
# ls

# ./configure
# make

# ls
aclocal.m4      config.h.in    configure.in  hello.o      Makefile.in
autom4te.cache  config.log     depcomp       install-sh   missing
autoscan.log    config.status  hello         Makefile     stamp-h1
config.h        configure      hello.c       Makefile.am
# ./hello
hello,gnu!

OK,至此所有就结束了。


阅读(708) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~