Changed all of the library tests into actual compile/link tests, to

ensure that the compilation environment is what it needs to be.  Also,
added a test to make sure the C++ compiler has some basic features,
since gcc2.95 will not work.
This commit is contained in:
John Wiegley 2005-02-01 00:17:14 +00:00
parent 45091a4918
commit 5ac1f9716f

View file

@ -2,8 +2,8 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(ledger, 2.1, johnw@newartisans.com)
AM_INIT_AUTOMAKE(ledger, 2.1)
AC_INIT(ledger, 2.2, johnw@newartisans.com)
AM_INIT_AUTOMAKE(ledger, 2.2)
AC_CONFIG_SRCDIR([main.cc])
AC_CONFIG_HEADER([acconf.h])
@ -11,12 +11,70 @@ AC_CONFIG_HEADER([acconf.h])
AC_PROG_CXX
AC_PROG_MAKE_SET
AC_PROG_RANLIB
#AC_PROG_LIBTOOL
#AM_PROG_LIBTOOL
# Checks for libraries.
AC_CHECK_LIB([gmp], [__gmpz_add], [],
AC_MSG_FAILURE("Could not find gmp (GNU multi-precision) library"))
AC_CHECK_LIB([pcre], [pcre_compile], [],
AC_MSG_FAILURE("Could not find pcre (Perl regular expression) library"))
# check for C++ compiler compatibility
AC_CACHE_CHECK(
[if C++ compiler is compatible],
[cc_compat],
[AC_LANG_PUSH(C++)
AC_TRY_LINK(
[#include <cctype>
#include <iostream>],
[if (std::isspace(' ') || std::isdigit(' '))
std::cout << std::left << std::right << "Hello";],
[cc_compat=true],
[cc_compat=false])
AC_LANG_POP])
if [test x$cc_compat = xfalse ]; then
AC_MSG_FAILURE("System's C++ compiler is not compatible (need to use gcc3?)")
fi
# check for gmp
AC_CACHE_CHECK(
[if libgmp is available],
[libgmp_avail],
[libgmp_save_libs=$LIBS
LIBS="-lgmp $LIBS"
AC_LANG_PUSH(C++)
AC_TRY_LINK(
[#include <gmp.h>],
[mpz_t bar;
mpz_init(bar);
mpz_clear(bar);],
[libgmp_avail=true],
[libgmp_avail=false])
AC_LANG_POP
LIBS=$libgmp_save_libs])
if [test x$libgmp_avail = xtrue ]; then
AM_CONDITIONAL(HAVE_GMP, true)
else
AC_MSG_FAILURE("Could not find gmp library (set CPPFLAGS and LDFLAGS?)")
fi
# check for pcre
AC_CACHE_CHECK(
[if libpcre is available],
[libpcre_avail],
[libpcre_save_libs=$LIBS
LIBS="-lpcre $LIBS"
AC_LANG_PUSH(C++)
AC_TRY_LINK(
[#include <pcre.h>],
[pcre_free((pcre *)NULL);],
[libpcre_avail=true],
[libpcre_avail=false])
AC_LANG_POP
LIBS=$libpcre_save_libs])
if [test x$libpcre_avail = xtrue ]; then
AM_CONDITIONAL(HAVE_PCRE, true)
else
AC_MSG_FAILURE("Could not find pcre library (set CPPFLAGS and LDFLAGS?)")
fi
# check for xmlparse
AC_ARG_ENABLE(xml,
@ -35,14 +93,14 @@ if [test x$xml = xtrue ]; then
[libxmlparse_save_libs=$LIBS
LIBS="-lxmlparse -lxmltok $LIBS"
AC_LANG_PUSH(C++)
AC_TRY_COMPILE(
[extern "C" {
#include <xmlparse.h> // expat XML parser
}
class foo {};],
[return 0],
[libxmlparse_avail=true],
[libxmlparse_avail=false])
AC_TRY_LINK(
[extern "C" {
#include <xmlparse.h> // expat XML parser
}],
[XML_Parser parser = XML_ParserCreate(NULL);
return parser != NULL;],
[libxmlparse_avail=true],
[libxmlparse_avail=false])
AC_LANG_POP
LIBS=$libxmlparse_save_libs])
AM_CONDITIONAL(HAVE_XMLPARSE, test x$libxmlparse_avail = xtrue)
@ -69,7 +127,7 @@ if [test x$python = xtrue ]; then
[boost_python_save_libs=$LIBS
LIBS="-lboost_python $LIBS"
AC_LANG_PUSH(C++)
AC_TRY_COMPILE(
AC_TRY_LINK(
[#include <boost/python.hpp>
using namespace boost::python;
class foo {};