Chinaunix首页 | 论坛 | 博客
  • 博客访问: 157177
  • 博文数量: 7
  • 博客积分: 1415
  • 博客等级: 上尉
  • 技术积分: 500
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-30 13:00
文章存档

2008年(7)

我的朋友

分类:

2008-03-22 13:01:51

automake 实例hello.c
 
/******************************************
 *  小刀听雨-manual.cublog.cn-  *
 *****************************************/
 
==============================================================================
平台与工具:
[root@mylinux hello]# uname -a
Linux mylinux.xiaodao.com 2.6.9-5.EL #1 Wed Jan 5 19:22:18 EST 2005 i686 athlon i386 GNU/Linux
autoscan (GNU Autoconf) 2.59
autoconf (GNU Autoconf) 2.59
automake (GNU automake) 1.9.2
==============================================================================
[root@mylinux c]# mkdir hello         //新建工程目录hello
[root@mylinux c]# cd hello            //进入工程目录hello
[root@mylinux hello]# vi hello.c      //创建源文件hello.c
#include
#include
int
main(void)
{
    printf("Hello, world\n");
    exit(0);
}
[root@mylinux hello]# autoscan        //生成autoscan.log与configure.scan
autom4te: configure.ac: no such file or directory
autoscan: /usr/bin/autom4te failed with exit status: 1
[root@mylinux hello]# cp configure.scan configure.ac       //生成configure.ac
[root@mylinux hello]# vi configure.ac                      //编辑configure.ac
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(hello, 1.0, abc@abc.com)              //修改
AM_INIT_AUTOMAKE(hello,1.0)                            //增加
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h])
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_CONFIG_FILES([Makefile])                             //增加
AC_OUTPUT
[root@mylinux hello]# aclocal                 //生成aclocal.m4与autom4te.cache文件
[root@mylinux hello]# autoheader              //生成config.h.in文件
[root@mylinux hello]# vi Makefile.am          //创建文件Makefile.am
AUTOMAKE_OPTIONS= foreign
bin_PROGRAMS = hello
hello_SOURCES = hello.c
[root@mylinux hello]# touch README NEWS AUTHORS ChangeLog//创建README NEWS AUTHORS ChangeLog文件
[root@mylinux hello]# automake --add-missing  //生成install-sh, missing, depcomp文件
configure.ac: installing `./install-sh'
configure.ac: installing `./missing'
Makefile.am: installing `./depcomp'
[root@mylinux hello]# autoconf                //生成configure脚本
[root@mylinux hello]# ./configure             //执行configure脚本生成Makefile
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
.....省略
config.status: executing depfiles commands
[root@mylinux hello]# make                     //make编译生成hello可执行文件
make  all-am
make[1]: Entering directory `/root/c/hello'
if gcc -DHAVE_CONFIG_H -I. -I. -I.     -g -O2 -MT hello.o -MD -MP -MF ".deps/hello.Tpo" -c -o hello.o hello.c; \
then mv -f ".deps/hello.Tpo" ".deps/hello.Po"; else rm -f ".deps/hello.Tpo"; exit 1; fi
gcc  -g -O2   -o hello  hello.o 
make[1]: Leaving directory `/root/c/hello'
[root@mylinux hello]# ./hello                   //执行hello程序
Hello, world
[root@mylinux hello]#
 
阅读(1507) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~