Autoconf/Automake使用备忘

Autoconf/Automake使用备忘
步骤:
 
1,进入代码目录
 
2,运行autoscan,出错不管,只要有configure.scan就好
 
3,mv configure.scan configure.in
 
4,编辑 configure.in
 
以DHTClient程序为例,原始configure.in为
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([CRDHTProtocol.h])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h sys/socket.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_MODE_T
AC_TYPE_SIZE_T
# Checks for library functions.
AC_CHECK_FUNCS([inet_ntoa memset socket strchr strstr strtol])
AC_OUTPUT
 
编辑后的configure.in应该为:
 
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(DHTClient, 0.1,
wuchehai@uestc.edu.cn )
AC_CONFIG_SRCDIR([CRDHTProtocol.h])
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(DHTClient, 0.1)
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h sys/socket.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_MODE_T
AC_TYPE_SIZE_T
# Checks for library functions.
AC_CHECK_FUNCS([inet_ntoa memset socket strchr strstr strtol])
AC_CONFIG_FILES([Makefile])
AC_OUTPU
 
5,生成Makefile.am文件,需要手动输入一个,如下
 
bin_PROGRAMS = DHTClient
DHTClient_SOURCES = DHTClient.cpp CRDHTProtocol.h Error.cpp Error.h FileManager.cpp FileManager.h FunctionReturnValue.h Hash.cpp Hash.h IPAddress.cpp IPAddress.h MetaDataDefinition Socket.cpp TCPSocket.cpp Socket.h TCPSocket.h XMLManager.h XMLManager.cpp
CXXFLAGS = -Wall -Wno-deprecated -g
 
如果有库的话,可以自己添加 INCLUDES 或者DHTClient _LDADD=-LXXX
 
6,运行aclocal
7,运行autoheader
8,运行automake -a -c --foreign
9,运行autoconf
10,运行./configure
11,运行make
 




http://hi.baidu.com/nkhzj/blog/item/e21d52604f25e1da8db10ddb.html

autoconf/automake工具用于自动创建功能完善的makefile文件。当前大多数的 软件包都是用这一工具生成makefile文件的。正是因为有了它们的帮助,我们在linux下安装软件才会变得这么简单:只要照着“三步走”就行了。(1) ./configure,自动检查配置,无误的话生成Makefile   (2) make, 编译链接 (3) make install, 安装!

在这里我们主要介绍如何使用autoconf和automake工具组,来自动生成我们项目的 Makefile文件。

Autoconf/Automake工具组主要包括autoconf、automake、 autoscan、autoheader、aclocal等一组命令。所以首先需要用类似于“rpm -qa | grep autoconf”的命令来检查这些工具是否已经安装。当然也可以用whereis命令来检查。

后面的步骤,可以按照下面图中的指示来执行:

 

 

主要是需要 我们 手动编辑configure.ac的内容,进行配 置。
Makefile.am文件需要我们手动提供,其编写格式可以参考网上的资料。

 

 

 

 

http://www.gnu.org/software/autoconf/manual/index.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值