|
搞了一天了,还是没有搞明白。我现在急需学会这个功能,我的程序需要阿。多谢了。
关于使用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 打声招呼吧! |
|