LinuxSir.cn,穿越时空的Linuxsir!

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

学用automake 生成Makefile失败了:(

[复制链接]
发表于 2005-12-28 15:31:03 | 显示全部楼层 |阅读模式
我按照网上的这篇http://fanqiang.chinaunix.net/system/linux/2005-12-14/3926.shtml 试着用automake生成Makefile.可以一直没有成功:
先写了一个简单的c程序 hello.c

  1. int main(int argc,char **argv)
  2. {
  3.         printf("hello,the world\n");
  4.         return 0;
  5. }
复制代码


然后执行autoscan,显示如下
[huting@MagicLinux hello]$ autoscan
autom4te: configure.ac: no such file or directory
autoscan: /usr/bin/autom4te failed with exit status: 1

但是ls显示已经有一个configure.scan文件了.我将这个文件改为configure.in并且修改成
[huting@MagicLinux hello]$ cat configure.in
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

##AC_PREREQ(2.59)
AC_INIT(hello.c)
AC_INIT(hello, 0.1)
#AC_CONFIG_SRCDIR([hello.c])
#AC_CONFIG_HEADER([config.h])

# 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)
[huting@MagicLinux hello]$            

再运行 aclocal ,显示如下
[huting@MagicLinux hello]$ aclocal
/usr/share/aclocal/smpeg.m4:13: warning: underquoted definition of AM_PATH_SMPEG
  run info '(automake)Extending aclocal'
  or see http://sources.redhat.com/automa ... l#Extending-aclocal
/usr/share/aclocal/libfame.m4:6: warning: underquoted definition of AM_PATH_LIBFAME
/usr/share/aclocal/gtk.m4:7: warning: underquoted definition of AM_PATH_GTK
/usr/share/aclocal/gpg-error.m4:7: warning: underquoted definition of AM_PATH_GPG_ERROR
/usr/share/aclocal/ao.m4:9: warning: underquoted definition of XIPH_PATH_AO
/usr/share/aclocal/aalib.m4:12: warning: underquoted definition of AM_PATH_AALIB
NONE:0: error: m4_init: unbalanced m4_divert_push:
configure.in:5: m4_divert_push: BODY
configure.in:5: m4_divert_push: KILL
NONE:0: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
aclocal: autom4te failed with exit status: 1
[huting@MagicLinux hello]$   

运行 autoconf
[huting@MagicLinux hello]$ autoconf
NONE:0: error: m4_init: unbalanced m4_divert_push:
configure.in:5: m4_divert_push: BODY
configure.in:5: m4_divert_push: KILL
NONE:0: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
[huting@MagicLinux hello]$

这时ls一下,发现并没有生成aclocal.m4 和configure.
能告诉我问题出在什么地方吗?
谢谢!
 楼主| 发表于 2005-12-28 16:07:31 | 显示全部楼层
看了他人的一个包,然后仔细对照看了一个自己的文件 ,原来是写错了:beat
configure.in改成这样
[huting@MagicLinux hello]$ cat configure.in
AC_INIT(hello.c)
AM_INIT_AUTOMAKE(hello,0.1)
AC_PROG_CC
AC_OUTPUT(Makefile)
[huting@MagicLinux hello]$   

哈哈,弄了一天时间呀
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-12-28 19:50:45 | 显示全部楼层
再请教一个问题:如果把代码都移到src目录下,这时confiugre.in,Makefile.in如何写??
回复 支持 反对

使用道具 举报

发表于 2005-12-28 20:32:59 | 显示全部楼层
[matt@localhost ttt]$ cat configure.in
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT(hello, 0.1)
AC_CONFIG_SRCDIR([src/hello.c])
AM_INIT_AUTOMAKE

# 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 src/Makefile])

[matt@localhost ttt]$ cat Makefile.am
SUBDIRS = src

[matt@localhost ttt]$ cat src/Makefile.am

noinst_PROGRAMS=hello

hello_SOURCES = hello.c
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-12-28 20:44:34 | 显示全部楼层
我接楼上所写的配置,执行如下命令:aclocal ;autoconf;automake --add-missing ;但是在程序的根目录下没有生成Makefile.in,但是在src目录里是有的
运行./configure 出错提出没有Makefile.in文件
回复 支持 反对

使用道具 举报

发表于 2005-12-28 23:48:05 | 显示全部楼层
Post by tingxx
我接楼上所写的配置,执行如下命令:aclocal ;autoconf;automake --add-missing ;但是在程序的根目录下没有生成Makefile.in,但是在src目录里是有的
运行./configure 出错提出没有Makefile.in文件


你执行 automake 后没有警告吗?
如果有提示 `NEWS' not found 之类,要么创建这些文件,要么给 automake 加上 --foreign。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-12-29 08:37:11 | 显示全部楼层
谢谢楼上, 上--foreign后成功了
回复 支持 反对

使用道具 举报

发表于 2005-12-29 09:08:04 | 显示全部楼层
楼主怎么也不看看提示呀,给出的提示应该告诉你发生了什么问题。如果你不能理解给出的提示,可以把它在论坛上贴出来。
不管有什么问题就先把问题解决了再说,然后再进行下一步。
回复 支持 反对

使用道具 举报

发表于 2005-12-30 14:05:35 | 显示全部楼层
If my project are consist of not only file, for instance, xxx.c/cpp, a_x.h,b_x.h,c_x.h etc
how can I to do?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-12-30 14:07:58 | 显示全部楼层
多个文件也是一样的
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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