使用autoconf automake制作make文件

9 views
Skip to first unread message

sevenever

unread,
Mar 17, 2007, 10:33:02 AM3/17/07
to sevenever的学习笔记
先留个大概的记录在此,详细的以后来补充。

先autoscan然后aclocle,然后autohead生成config.in然后修改configure.in,以下是例子:
其中AC_CHECK_LIB宏用来检查library条件是否满足,如果满足就自动在连接参数中加上-llib***

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

AC_PREREQ(2.61)
AC_INIT(example, 1.0, BUG-REPORT-ADDRESS)
AM_INIT_AUTOMAKE(example, 1.0)
AC_CONFIG_SRCDIR([wavefile.cpp])
AC_CONFIG_HEADER([config.h])

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC

# Checks for libraries.

# Check for curl library
AC_CHECK_LIB(curl, curl_global_init, , AC_MSG_ERROR([*** Unable to
find curl libary ]))

# Check for ofa library
AC_CHECK_LIB(ofa, ofa_get_version, , AC_MSG_ERROR([*** Unable to find
ofa libary ]))

# Check for expat library
AC_CHECK_LIB(expat, XML_ParserCreate, , AC_MSG_ERROR([*** Unable to
find expat libary ]))

# Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([fcntl.h stdlib.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_PID_T
AC_TYPE_SIZE_T

# Checks for library functions.
AC_FUNC_FORK
AC_CHECK_FUNCS([strrchr strstr])

AC_OUTPUT(Makefile)


然后修改Makefile.am下面是例子:

AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=example
example_SOURCES=example.cpp protocol.cpp uselame.cpp wavefile.cpp
protocol.h

然后automake就生成Makefile了。

Reply all
Reply to author
Forward
0 new messages