LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 902|回复: 5

着急阿,关于自动生成Makefile的一个问题

[复制链接]
发表于 2004-9-14 23:10:14 | 显示全部楼层 |阅读模式
搞了一天了,还是没有搞明白。我现在急需学会这个功能,我的程序需要阿。多谢了。
关于使用autoconf,automake自动生成makefile的问题
http://www.antpower.org/Folder_AntF...55174/post_view
上面的网址是一篇关于自动生成Makefile的帖子。(为了方便我把原贴步骤列在下面)
我按它的步骤一步一步走下来,也都按它的规则做了,在执行完
% aclocal
% autoconf
命令后按它的步骤应该产生的文件是:aclocal.m4
在我的系统下产生的是一个目录:autom4te.cache,目录下的内容是:output.0 requests traces.0
按它的步骤编辑完Makefile.am后
接下来我执行
% ./configure
出错信息如下:
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
configure: creating ./config.status
config.status: creating Makefile
config.status: error: cannot find input file: Makefile.in

我猜想是它的步骤错了,还是我的版本比较新造成的。
我现在不知道该怎么办了,大家帮帮忙,给我一点指点。谢了。
我的系统是rh9.0,里面用到的autoconf,automake都是系统自带的。
还需要什么信息,我提供。


原贴:******************************************************
**************************************************
原贴步骤:
1. 一个简单的例子

Automake 所产生的 Makefile 除了可以做到程式的编译和连结,也已经把

如何产生程式文件 (如 manual page, info 档及 dvi 档) 的动作,还有

把原始程式包装起来以供散 的动作都考虑进去了,所以原始程式所存放

的目录架构最好符合 GNU 的标准惯例,接下来我拿 hello.c 来做为例

子。

在工作目录下建立一个新的子目录 ``devel'',再在 devel 下建立一个

``hello'' 的子目录,这个目录将作为我们存放 hello 这个程式及其相关

档案的地方:
% mkdir devel
% cd devel
% mkdir hello
% cd hello
用编辑器写个 hello.c 档,
#include
int main(int argc, char** argv)
{
printf(``Hello, GNU!\n'');
return 0;
}
接下来就要用 Autoconf 及 Automake 来帮我们产生 Makefile 档了,
1. 用 autoscan 产生一个 configure.in 的雏型,执行 autoscan 後会产
生一个configure.scan 的档案,我们可以用它做为 configure.in档的蓝本。
% autoscan
% ls
configure.scan hello.c
1. 编辑 configure.scan 档,如下所示,并且把它的档名改成configure.in
dnl Process this file with autoconf to produce a configure script.
AC_INIT(hello.c)
AM_INIT_AUTOMAKE(hello, 1.0)
dnl Checks for programs.
AC_PROG_CC
dnl Checks for libraries.
dnl Checks for header files.
dnl Checks for typedefs, structures, and compiler characteristics.
dnl Checks for library functions.
AC_OUTPUT(Makefile)
1. 执行 aclocal 和 autoconf ,分别会产生 aclocal.m4 及 configure 两个档案
% aclocal
% autoconf
% ls
aclocal.m4 configure configure.in hello.c
1. 编辑 Makefile.am 档,内容如下
AUTOMAKE_OPTIONS= foreign
bin_PROGRAMS= hello
hello_SOURCES= hello.c
1. 执行 automake --add-missing ,Automake 会根据 Makefile.am 档产生
一些档案,包含最重要的 Makefile.in
% automake --add-missing
automake: configure.in: installing `./install-sh'
automake: configure.in: installing `./mkinstalldirs'
automake: configure.in: installing `./missing'
1. 最後执行 ./configure ,
% ./configure
creating cache ./config.cache
checking for a BSD compatible install... /usr/bin/in
stall -c
checking whether build environment is sane... yes
checking whether make sets ${MAKE}... yes
checking for working aclocal... found
checking for working autoconf... found
checking for working automake... found
checking for working autoheader... found
checking for working makeinfo... found
checking for gcc... gcc
checking whether the C compiler (gcc ) works... yes
checking whether the C compiler (gcc ) is a cross-co mpiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
updating cache ./config.cache
creating ./config.status
creating Makefile
现在你的目录下已经产生了一个 Makefile 档,下个 ``make'' 指令就可
以开始编译 hello.c 成执行档,执行 ./hello 和 GNU 打声招呼吧!
发表于 2004-9-15 08:20:48 | 显示全部楼层
1. 编辑 configure.scan 档
1. 执行 aclocal 和 autoconf
1. 编辑 Makefile.am 档
1. 执行 automake --add-missing
1. 最後执行 ./configure

这是从你提供的资料摘出来的,没发现你少了什么吗?
发表于 2004-9-15 08:55:24 | 显示全部楼层
1. 编辑 configure.scan 档,如下所示,并且把它的档名改成configure.in

注意这句话。
 楼主| 发表于 2004-9-15 09:03:09 | 显示全部楼层
没错,老兄,我一步都没有少,该改的文档内容和文档名字我也都改了,如果不改错误更多的。只是我在提问的时候把没有出错的步骤和完全一样的步骤省略了。
出错的步骤和它不一样的地方我才写出来的。
如果你的系统和我的系统redhat9一样,看看和我的过程是不是一样。
我是刚刚接触这个东西,出错了没有经验的说。
谢了。

我在网上查了关于这方面的东西,查到了10多处都有这个帖子,都是同样的帖子,一个字都不差。如果说它的步骤有问题,那这个步骤对于新手来说无疑是一个沉重的打击。希望能把这个问题讨论清楚也为以后的新手顺利工作提供帮助,修改这个帖子中的某些步骤。
 楼主| 发表于 2004-9-15 09:29:46 | 显示全部楼层
我在水木清华求助,一个大侠说在原贴中
./configure
前少了一步:
automake
这一步骤主要用来生成makefile.in

加上这一步以后,Makefile 是生成了,但是又出现下面一个错误:

config.status: creating config.h
config.status: error: cannot find input file: config.h.in

呵呵,这个是什么原因?
以后大家再见到这个帖子,可以帮助新手解决问题了。
发表于 2004-9-15 10:08:40 | 显示全部楼层

autoheader

之前加上这个
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表