Add autoconf function check for strcasecmp for macro referenced in TemplateEngine...
[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(doxygen.m4)
8 sinclude(acx_pthread.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 #    AC_HAVE_GCC_VERSION(4,0,0,0,
38 #        [
39 #        AC_DEFINE(GCC_HASCLASSVISIBILITY,1,
40 #            [Define to enable class visibility control in gcc.])
41 #        GCC_CFLAGS="$GCC_CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
42 #        GCC_CXXFLAGS="$GCC_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
43 #        ])
44     CFLAGS="$GCC_CFLAGS"
45     CXXFLAGS="$GCC_CXXFLAGS"
46 fi
47
48 AC_DISABLE_STATIC
49 AC_PROG_LIBTOOL
50
51 # Checks for typedefs, structures, and compiler characteristics.
52 AC_C_CONST
53 AC_TYPE_SIZE_T
54
55 # Checks for library functions.
56 AC_CHECK_FUNCS([strchr strdup strstr timegm strcasecmp])
57 AC_CHECK_HEADERS([dlfcn.h])
58 AC_CHECK_FUNC(dlclose, , [ AC_CHECK_LIB(dl, dlopen) ])
59
60 # checks for pthreads
61 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
62 if test $enable_threads != "pthread"; then
63     AC_MSG_ERROR([unable to find pthreads, currently this is required])
64 else
65     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
66         AM_CONDITIONAL(BUILD_PTHREAD,test "$enable_threads" = "pthread")
67     LIBS="$PTHREAD_LIBS $LIBS"
68     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
69     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
70 fi
71
72 # OpenSSL settings
73 AC_ARG_WITH(openssl,
74     AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
75     [if test x_$with_openssl != x_/usr; then
76         SSLLIBS="-L${with_openssl}/lib -lcrypto -lssl"
77         SSLFLAGS="-I${with_openssl}/include"
78     fi])
79
80 if test "x$SSLLIBS" = "x" ; then
81     AC_PATH_PROG(PKG_CONFIG, pkg-config)
82     if test "x$PKG_CONFIG" != x && test "x$PKG_CONFIG" != "xno" ; then
83         if pkg-config openssl ; then
84             SSLLIBS="`$PKG_CONFIG --libs openssl`"
85             SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
86         else
87             AC_MSG_ERROR([OpenSSL not supported by pkg-config, try --with-openssl instead])
88         fi
89     fi
90 fi
91
92 if test "x$SSLLIBS" = "x" ; then
93     SSLLIBS="-lcrypto -lssl"
94 fi
95
96 AC_MSG_CHECKING(for OpenSSL libraries)
97 AC_MSG_RESULT($SSLLIBS)
98 LIBS="$LIBS $SSLLIBS"
99 AC_MSG_CHECKING(for OpenSSL cflags)
100 AC_MSG_RESULT($SSLFLAGS)
101 CPPFLAGS="$SSLFLAGS $CPPFLAGS"
102
103 AC_CHECK_HEADER([openssl/pem.h],,
104                 AC_MSG_ERROR([unable to find openssl header files]))
105 AC_MSG_CHECKING(for ERR_load_CRYPTO_string)
106 AC_TRY_LINK_FUNC([ERR_load_CRYPTO_strings],,
107              AC_MSG_ERROR([unable to link with openssl libraries]))
108 AC_MSG_RESULT(yes)
109
110 AC_LANG(C++)
111
112 # C++ requirements
113 AC_CXX_REQUIRE_STL
114 AC_CXX_NAMESPACES
115
116 # log4cpp settings
117 AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
118 AC_ARG_WITH(log4cpp,
119     AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
120     [
121     LOG4CPP_CONFIG="${with_log4cpp}"
122     if ! test -f "${LOG4CPP_CONFIG}" ; then
123         LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
124     fi
125     ])
126 if test -f "${LOG4CPP_CONFIG}"; then
127     LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
128     CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
129 else
130     AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
131     LIBS="-llog4cpp $LIBS"
132 fi
133 AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
134 AC_CHECK_HEADER([log4cpp/PropertyConfigurator.hh],,AC_MSG_ERROR([you need at least log4cpp 0.3.x]))
135 AC_TRY_LINK(
136         [#include <log4cpp/Category.hh>],
137         [log4cpp::Category::getInstance("foo")],
138         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
139         [AC_MSG_ERROR([unable to link with log4cpp])])
140
141 # Xerces settings
142 AC_ARG_WITH(xerces, 
143             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
144             [if test x_$with_xerces != x_/usr; then
145                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
146                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
147             fi])
148 LIBS="-lxerces-c $LIBS"
149 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
150 AC_MSG_CHECKING([Xerces version])
151 AC_PREPROC_IFELSE(
152     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
153 [#if  _XERCES_VERSION != 20600
154 int i = 0;
155 #else
156 #error cannot use version 2.6.0
157 #endif])],
158     [AC_MSG_RESULT(OK)],
159     [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])])
160 AC_TRY_LINK(
161         [#include <xercesc/util/PlatformUtils.hpp>],
162         [xercesc::XMLPlatformUtils::Initialize()],
163         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
164         [AC_MSG_ERROR([unable to link with Xerces])])
165
166
167 # XML-Security settings
168 AC_ARG_WITH(xmlsec,
169             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
170             [with_xmlsec=/usr])
171
172 if test x_$with_xmlsec != x_no; then
173     if test x_$with_xmlsec != x_/usr; then
174         LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
175         CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
176     fi        
177     LIBS="-lxml-security-c $LIBS"
178     AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
179     AC_MSG_CHECKING([XML-Security version])
180     AC_PREPROC_IFELSE(
181             [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
182         [#if XSEC_VERSION_MAJOR > 1 || XSEC_VERSION_MEDIUM >2 
183 int i = 0;
184 #else
185 #error need version 1.3 or later
186 #endif])],
187         [AC_MSG_RESULT(OK)],
188         [AC_MSG_FAILURE([XML-Security version 1.3 or greater is required.])])
189     AC_TRY_LINK(
190             [#include <xsec/utils/XSECPlatformUtils.hpp>],
191             [XSECPlatformUtils::Initialise()],,
192             [AC_MSG_ERROR([unable to link with XML-Sec])])
193 else
194     AC_MSG_WARN([xmlsec disabled, building without signature/encryption support])
195     AC_DEFINE(XMLTOOLING_NO_XMLSEC,1,
196         [Define if you wish to disable XML-Security-dependent features.])
197 fi
198 AM_CONDITIONAL(BUILD_XMLSEC,test x_$with_xmlsec != x_no)
199
200 # Does the STL in use help or screw us?
201 AC_TRY_LINK(
202         [#include <string>],
203         [std::basic_string<unsigned short> foo; foo=foo+(unsigned short)65],
204         [AC_DEFINE(HAVE_GOOD_STL,1,
205             [Define if you have an STL implementation that supports useful string specialization.])],
206         )
207
208 # Check for unit test support
209 CXXTEST="/usr/bin/cxxtestgen.pl"
210 CXXTESTFLAGS=""
211 AC_ARG_WITH(cxxtest,
212             AC_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
213             [if test x_$with_cxxtest != x_/usr; then
214                 CXXTEST="${with_cxxtest}/cxxtestgen.pl"
215                 CXXTESTFLAGS="-I${with_cxxtest}"
216             fi])
217 if ! test -f "${CXXTEST}"; then
218     AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
219 fi
220
221 AC_SUBST(CXXTEST)
222 AC_SUBST(CXXTESTFLAGS)
223 AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
224
225 LIBTOOL="$LIBTOOL --silent"
226
227 # output makefiles
228 AC_OUTPUT(Makefile xmltooling/Makefile xmltoolingtest/Makefile schemas/Makefile)