source: trunk/m4/xerces.m4 @ 704

Revision 673, 2.6 KB checked in by dcarter, 3 years ago (diff)

see #125: Improved xerces test

Line 
1# Copyright (C) 2005-2008 David Carter <arm4@arm4.org>
2
3# This file is free software; as a special exception the author gives
4# unlimited permission to copy and/or distribute it, with or without
5# modifications, as long as this notice is preserved.
6#
7# This program is distributed in the hope that it will be useful, but
8# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
9# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
11# Macros to check the version for the Xerces library, and to set whatever link flags are appropriate
12
13AC_DEFUN([__ARM4_XERCES_COMPILE],
14[
15  AC_LANG_PUSH([C++])
16  XERCES_INCLUDES="$1"
17  ac_save_CXXFLAGS="$CXXFLAGS"
18  CXXFLAGS="$CXXFLAGS $XERCES_INCLUDES"
19  AC_COMPILE_IFELSE([
20#include <xercesc/util/PlatformUtils.hpp>
21XERCES_CPP_NAMESPACE_USE
22 
23int main(int argc, char** argv)
24{
25  XMLPlatformUtils::Initialize();
26
27  XMLPlatformUtils::Terminate();
28
29  return 0;
30}
31], ,[XERCES_INCLUDES="fail"])
32  CXXFLAGS="$ac_save_CXXFLAGS"
33  AC_SUBST(XERCES_INCLUDES)
34  AC_LANG_POP([C++])
35])
36
37AC_DEFUN([__ARM4_XERCES_CHECKLINK],
38[
39  AC_LANG_PUSH([C++])
40  XERCES_LIBS="$1"
41  ac_save_CXXFLAGS="$CXXFLAGS"
42  CXXFLAGS="$CXXFLAGS $XERCES_INCLUDES"
43  ac_save_LIBS="$LIBS"
44  LIBS="$LIBS $XERCES_LIBS"
45  AC_LINK_IFELSE([
46#include <xercesc/util/PlatformUtils.hpp>
47XERCES_CPP_NAMESPACE_USE
48 
49int main(int argc, char** argv)
50{
51  XMLPlatformUtils::Initialize();
52
53  XMLPlatformUtils::Terminate();
54
55  return 0;
56}
57], ,[XERCES_LIBS="fail"])
58  LIBS="$ac_save_libs"
59  CXXFLAGS="$ac_save_CXXFLAGS"
60  AC_SUBST(XERCES_LIBS)
61  AC_LANG_POP([C++])
62])
63
64AC_DEFUN([ARM4_CHECK_XERCES],
65[
66  AC_MSG_CHECKING(for xerces)
67  xerces_prefix="/usr"
68  AC_ARG_WITH(xerces,
69  [  --with-xerces=PATH      prefix for installed Xerces C++ library],
70  [
71    if test "$withval" = "no" || test "$withval" = "yes"; then
72      AC_MSG_ERROR([--with-xerces requires the full path to the xerces install root])
73    fi
74
75    xerces_prefix="$withval"
76  ],xerces_prefix="/usr")
77  __ARM4_XERCES_COMPILE([])
78  if test "x$XERCES_INCLUDES" = "xfail" ; then
79    __ARM4_XERCES_COMPILE([-I$xerces_prefix/include])
80  fi
81  if test "x$XERCES_INCLUDES" != "xfail" ; then
82    __ARM4_XERCES_CHECKLINK([-lxerces-c])
83    if test "x$XERCES_LIBS" = xfail ; then
84      __ARM4_XERCES_CHECKLINK([-L$xerces_prefix/lib -lxerces-c])
85    fi
86  fi
87  if test "x$XERCES_LIBS" = "xfail" || test "x$XERCES_INCLUDES" = "xfail" ; then
88    AC_MSG_RESULT(no)
89    AC_MSG_ERROR(require xerces libraries)
90  else
91    AC_DEFINE(HAVE_XERCES, 1,
92      [Define wether the xerces libraries are implemented on this platform])
93    AC_MSG_RESULT(yes)
94  fi
95])
Note: See TracBrowser for help on using the repository browser.