autoconf和automake的使用

经常遇到自动生成makefile失败的情况,总结一下以供以后参考.

一、configure,makefile.am,makefile.in,makefile之间的关系如下图:

二、自动生成makefile步骤:

1.autoscan  -------> configure.scan      autoscan.log

2.编辑configure.scan

mv configure.scan configure.in
vi configure.in

     主要增加AM_INIT_AUTOMAKE(程序名, 版本号)

          修改AC_OUTPUT(Makefile)

一个configure.in文件模板如下:

#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT(Test, 0.1, test@example.com)
AC_CONFIG_SRCDIR([DBAgent.cpp])
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(Test, 0.1)

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_OUTPUT(Makefile)

 

3.aclocal  ---------> aclocal.m4  autom4te.cache

4.autoconf   ------->

5.新建Makefile.am

一个Makefile.am模板如下:

 

AUTOMAKE_OPTIONS=foreign

bin_PROGRAMS=Test

Test_SOURCES= *.h *.c *.cpp

Test_LDADD = –lpthread

AM_CXXFLAGS = -Wall -Wno-deprecated –g

 

6.automake –-add-missing  ------>

7.执行 ./configure ---> makefile

8.make

三、有可能遇到的问题

1.提示缺少config.h.in文件

用autoheader生成

posted on 2012-02-13 21:30  comeby  阅读(302)  评论(0编辑  收藏  举报