LinuxSir.cn,穿越时空的Linuxsir!

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

急阿,关于Makefile的一个问题,帮帮忙

[复制链接]
发表于 2004-9-14 23:09:09 | 显示全部楼层 |阅读模式
搞了一天了,还是没有搞明白。我现在急需学会这个功能,我的程序需要阿。多谢了。
关于使用autoconf,automake自动生成makefile的问题
http://www.antpower.org/Folder_A ... 072855174/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-17 22:48:49 | 显示全部楼层
请高手不要沉默
发表于 2004-9-18 10:59:05 | 显示全部楼层
这种照着步骤做的东东,如果出现错误,多半是自己那一步做错了造成的。耐心重做一遍就能出来了。
ps:编辑Makefile.am之后没有执行automake --add-missing。
发表于 2004-9-18 11:00:14 | 显示全部楼层
最初由 jhuangjiahua 发表
请高手不要沉默

不要只在旁边看热闹,自己也动手做做,对于提高自己的水平有好处。
 楼主| 发表于 2004-9-18 11:23:17 | 显示全部楼层
呵呵,我岂止是做了一遍,我都做了n遍,都是不对的。
他的步骤是肯定少了某些方面。
发表于 2004-9-18 13:45:12 | 显示全部楼层
你好像没有加上automake?
发表于 2004-9-18 17:34:20 | 显示全部楼层
config.status: error: cannot find input file: Makefile.in

难道没有看见这个提示吗?这就是在创建Makefile.am之后,没有执行 automake --add-missing造成的。楼主到底执行了automake没有?
 楼主| 发表于 2004-9-18 19:00:45 | 显示全部楼层
automake在我的帖子中我没有执行,但是automake --add-missing命令执行了,后来重做是我执行了automake。执行以后也生成了Makefile文件,但是生成的Makefile 文件不对。
我执行Make的时候,提示根本无法编译,给的提示是这样的:
Makefile:15: *** missing separator.  Stop.
而在生成Makefile的之前执行的./configure就有错误,错误提示是可能缺少aclocal.m4文件,最大的可能就是缺少了aclocal.m4这个文件造成了后面生成错误的Makefile文件。

我做了好多遍,我个人认为这里面出现的问题主要应该是在aclocal命令这个地方:
在原帖子中,执行了aclocal这个命令以后,生成的文件应该是aclocal.m4,而我执行完这个命令后生成的是一个文件夹:autom4te.cache,文件夹下的内容是:output.0 requests traces.0三个文件。我怀疑可能是由于版本不同没有生成aclocal.m4造成的。但该如何解决,因为我是新手,我没有经验。看那个大部头的说明书现在也没有时间。呵呵,麻烦各位了,我们有责任把这个问题搞明白,为了后来的人少走弯路。

(似乎,原帖子流传的也比较广,我在网上查到了很多转载,如果本身有错就实在有点对不起新手了。呵呵,我们力争把它弄明白吧)
发表于 2004-9-19 10:34:31 | 显示全部楼层
这篇文章本论坛也有:http://www.linuxsir.cn/forum.php ... ;highlight=autoconf
我以前也参考过,我不认为它有什么大错。可以是作者的环境和具体使用者不太一样吧,可以有些地方原封不动地执行会有问题。
你的源程序、configure.in、Makefile.am文件是怎么写的?编译的过程是如何做的?还有错误提示,能否把它们都贴出来给我看看。
btw:一般碰到的问题,多半是自己造成的。不要动不动就怀疑是人家写错了(当然,写文章的人不可能面面俱到,有所疏漏是难免的,但对一般人不致于造成太大的麻烦)。我看你还很有热情,不过,一定要加强自己处理问题的能力。否则碰到问题解决不了,心有余而力不足,是不是有点郁闷呀?
 楼主| 发表于 2004-9-19 14:03:11 | 显示全部楼层
我找到原因了!
谢谢各位热心的朋友!!
我怎么也想不到,我换了一下编辑器就可以了!!
浪费了大家不少时间,抱歉。
说什么utf8码不行,很奇怪的原因。

特别感谢kj501斑竹的热心,我刚刚接触这个方面的编程,经验和解决问题的能力都不高,我会慢慢提高自己处理问题的能力。
确实同kj501斑竹说的那样,我现在是心有余而力不足,十分郁闷!
呵呵,我会加倍努力。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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