Clean up defines, and add dlfunc check.
[shibboleth/cpp-xmltooling.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([xmltooling], [1.0], [mace-opensaml-users@internet2.edu], [xmltooling])
3 AM_CONFIG_HEADER(config.h)
4 AM_CONFIG_HEADER(xmltooling/config_pub.h)
5 AM_INIT_AUTOMAKE([xmltooling], [1.0])
6
7 sinclude(acx_pthread.m4)
8 sinclude(doxygen.m4)
9
10 # Docygen features
11 DX_HTML_FEATURE(ON)
12 DX_CHM_FEATURE(OFF)
13 DX_CHI_FEATURE(OFF)
14 DX_MAN_FEATURE(OFF)
15 DX_RTF_FEATURE(OFF)
16 DX_XML_FEATURE(OFF)
17 DX_PDF_FEATURE(OFF)
18 DX_PS_FEATURE(OFF)
19 DX_INIT_DOXYGEN(xmltooling, doxygen.cfg, doc/api)
20
21 AC_ARG_ENABLE(debug,
22     AC_HELP_STRING(--enable-debug, [Have GCC compile with symbols (Default = no)]),
23     enable_debug=$enableval, enable_debug=no)
24
25 if test "$enable_debug" = "yes" ; then
26     GCC_CFLAGS="$CFLAGS -Wall -g -D_DEBUG"
27     GCC_CXXFLAGS="$CXXFLAGS -Wall -g -D_DEBUG"
28 else
29     GCC_CFLAGS="$CFLAGS -Wall -O2 -DNDEBUG"
30     GCC_CXXFLAGS="$CXXFLAGS -Wall -O2 -DNDEBUG"
31 fi
32
33 AC_PROG_CC([gcc gcc3 cc])
34 AC_PROG_CXX([g++ g++3 c++ CC])
35
36 if test "$GCC" = "yes" ; then
37     CFLAGS="$GCC_CFLAGS"
38     CXXFLAGS="$GCC_CXXFLAGS"
39 fi
40
41 AC_DISABLE_STATIC
42 AC_PROG_LIBTOOL
43
44 AC_LANG(C++)
45
46 # C++ requirements
47 AC_CXX_REQUIRE_STL
48 AC_CXX_NAMESPACES
49
50 AC_LANG(C)
51
52 # Checks for typedefs, structures, and compiler characteristics.
53 AC_C_CONST
54 AC_TYPE_SIZE_T
55
56 # Checks for library functions.
57 AC_CHECK_FUNCS([strchr strdup strstr])
58 AC_CHECK_HEADERS([dlfcn.h])
59 AC_CHECK_FUNC(dlclose, , [ AC_CHECK_LIB(dl, dlopen) ])
60
61 AC_LANG(C++)
62
63 # log4cpp settings
64 AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
65 AC_ARG_WITH(log4cpp,
66             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp is installed]),
67             [LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"])
68 if test -f "${LOG4CPP_CONFIG}"; then
69     LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
70     CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
71 else
72     AC_MSG_WARN([log4cpp-config not found, guessing at log4cpp build settings])
73     LIBS="-llog4cpp $LIBS"
74 fi
75 AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
76 AC_CHECK_HEADER([log4cpp/PropertyConfigurator.hh],,AC_MSG_ERROR([you need at least log4cpp 0.3.x]))
77 AC_TRY_LINK(
78         [#include <log4cpp/Category.hh>],
79         [log4cpp::Category::getInstance("foo")],
80         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
81         [AC_MSG_ERROR([unable to link with log4cpp])])
82
83 # Xerces settings
84 AC_ARG_WITH(xerces, 
85             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
86             [if test x_$with_xerces != x_/usr; then
87                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
88                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
89             fi])
90 LIBS="-lxerces-c $LIBS"
91 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
92 AC_MSG_CHECKING([Xerces version])
93 AC_PREPROC_IFELSE(
94     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
95 [#if  _XERCES_VERSION != 20600
96 int i = 0;
97 #else
98 #error cannot use version 2.6.0
99 #endif])],
100     [AC_MSG_RESULT(OK)],
101     [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use special 2.6.1 tarball provided by Shibboleth Project])])
102 AC_TRY_LINK(
103         [#include <xercesc/util/PlatformUtils.hpp>],
104         [xercesc::XMLPlatformUtils::Initialize()],
105         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
106         [AC_MSG_ERROR([unable to link with Xerces])])
107
108
109 # XML-Security settings
110 AC_ARG_WITH(xmlsec,
111             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
112             [with_xmlsec=/usr])
113
114 if test x_$with_xmlsec != x_no; then
115     if test x_$with_xmlsec != x_/usr; then
116         LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
117         CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
118     fi        
119     LIBS="-lxml-security-c $LIBS"
120     AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
121     AC_MSG_CHECKING([XML-Security version])
122     AC_PREPROC_IFELSE(
123             [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
124         [#if XSEC_VERSION_MAJOR > 1 || XSEC_VERSION_MEDIUM >2 
125 int i = 0;
126 #else
127 #error need version 1.3 or later
128 #endif])],
129         [AC_MSG_RESULT(OK)],
130         [AC_MSG_FAILURE([XML-Security version 1.3 or greater is required.])])
131     AC_TRY_LINK(
132             [#include <xsec/utils/XSECPlatformUtils.hpp>],
133             [XSECPlatformUtils::Initialise()],,
134             [AC_MSG_ERROR([unable to link with XML-Sec])])
135 else
136     AC_MSG_WARN([xmlsec disabled, building without signature/encryption support])
137     AC_DEFINE(XMLTOOLING_NO_XMLSEC,1,
138         [Define if you wish to disable XML-Security-dependent features.])
139 fi
140 AM_CONDITIONAL(BUILD_XMLSEC,test x_$with_xmlsec != x_no)
141
142 # Does the STL in use help or screw us?
143 AC_TRY_LINK(
144         [#include <string>],
145         [std::basic_string<unsigned short> foo; foo=foo+(unsigned short)65],
146         [AC_DEFINE(HAVE_GOOD_STL,1,
147             [Define if you have an STL implementation that supports useful string specialization.])],
148         )
149
150 # Check for unit test support
151 CXXTEST="/usr/bin/cxxtestgen.pl"
152 CXXTESTFLAGS=""
153 AC_ARG_WITH(cxxtest,
154             AC_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
155             [if test x_$with_cxxtest != x_/usr; then
156                 CXXTEST="${with_cxxtest}/cxxtestgen.pl"
157                 CXXTESTFLAGS="-I${with_cxxtest}"
158             fi])
159 if ! test -f "${CXXTEST}"; then
160     AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
161 fi
162
163 AC_SUBST(CXXTEST)
164 AC_SUBST(CXXTESTFLAGS)
165 AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
166
167 LIBTOOL="$LIBTOOL --silent"
168
169 # output makefiles
170 AC_OUTPUT(Makefile xmltooling/Makefile xmltoolingtest/Makefile schemas/Makefile)