Chinaunix首页 | 论坛 | 博客
  • 博客访问: 60578
  • 博文数量: 16
  • 博客积分: 1090
  • 博客等级: 少尉
  • 技术积分: 220
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-21 00:40
文章分类

全部博文(16)

文章存档

2011年(3)

2010年(1)

2009年(10)

2008年(2)

我的朋友

分类: 嵌入式

2011-06-08 20:17:22

软件环境:VMworkstation 6.0.3-build80004

                Ubuntu 8.04

先写一下如何生成一个helloworld文件

首先建立一个路径,如/home/helloworld

#mkdir /home/helloworld

vi编辑器编辑hello.c程序

#vi hello.c

程序内容如下

Int main(int argc, char** argv)

{

       Printf(“hello world\n”);

       Return 0;

}

在编辑器界面下输入:wq保存并退出。

#autoscan

此时目录下会生成configure.scan文件

#mv configure.scan configure.in

configure.scan文件名改为configure.in

#vi configure.in

使用vi编辑器编辑configure.in文件,去掉无关语句,修改configure.in内容为

============================configure.in内容开始=========================================
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_INIT(helloworld.c)
AM_INIT_AUTOMAKE(helloworld, 1.0)

# 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(Makefile)
============================configure.in
内容结束=========================================

:wq保存并退出

#aclocal

目录下会生成aclocal.m4文件

#autoconf

这一步生成了一个文件名为configure的脚本文件

Autoconf用来生成自动配置软件源代码脚本(configure)的工具,configure脚本可以独立于autoconf运行,在运行过程中,不需要用户干预。

建立Makefile.am文件

#vi Makefile.am

编辑如下内容:

----------------------------------------

AUTOMAKE_OPTIONS=foreign

bin_PROGRAMS=hello

hello_SOURCES=hello.c

---------------------------------------

:wq保存并退出

#automake –add-missing

 

configure.in: installing `./install-sh'

configure.in: installing `./missing'

Makefile.am: installing `./depcomp'

 

#./configure

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

checking for gawk... no

checking for mawk... mawk

……

……

configure: creating ./config.status

config.status: creating Makefile

config.status: executing depfiles commands

# make

if gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"helloworld\" -DVERSION=\"1.0\" -I. -I.     -g -O2 -MT helloworld.o -MD -MP -MF ".deps/helloworld.Tpo" -c -o helloworld.o helloworld.c; \

       then mv -f ".deps/helloworld.Tpo" ".deps/he

helloworld.c:3: warning: incompatible implicit declaration of built-in function ‘printf’

gcc  -g -O2   -o hello  hello.o 

#./hello

helloworld!

屏幕上显示helloworld!就表示已经成功

下一步,就可以按照自己的想法,为需要的软件项目编写makefile文件了

整个过程命令如下:

autoscan

mv configure.scan configure.in

aclocal

autoconf

vi Makefile.am

automake --add-missing

./configure

make

 

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