Autoconf/Automake使用备忘
# Process this file with autoconf to produce a configure script.
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([CRDHTProtocol.h])
AC_CONFIG_HEADER([config.h])
AC_PROG_CXX
AC_PROG_CC
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h sys/socket.h unistd.h])
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_MODE_T
AC_TYPE_SIZE_T
AC_CHECK_FUNCS([inet_ntoa memset socket strchr strstr strtol])
AC_OUTPUT
# Process this file with autoconf to produce a configure script.
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)
AC_PROG_CXX
AC_PROG_CC
AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdlib.h string.h sys/socket.h unistd.h])
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_MODE_T
AC_TYPE_SIZE_T
AC_CHECK_FUNCS([inet_ntoa memset socket strchr strstr strtol])
AC_CONFIG_FILES([Makefile])
AC_OUTPU
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
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