Fixes for disabling xmlsec
[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
9 AC_ARG_ENABLE(debug,
10     AC_HELP_STRING(--enable-debug, [Have GCC compile with symbols (Default = no)]),
11     enable_debug=$enableval, enable_debug=no)
12
13 if test "$enable_debug" = "yes" ; then
14     GCC_CFLAGS="$CFLAGS -g -D_DEBUG"
15     GCC_CXXFLAGS="$CXXFLAGS -g -D_DEBUG"
16 else
17     GCC_CFLAGS="$CFLAGS -O2 -DNDEBUG"
18     GCC_CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG"
19 fi
20
21 AC_PROG_CC([gcc gcc3 cc])
22 AC_PROG_CXX([g++ g++3 c++ CC])
23
24 if test "$GCC" = "yes" ; then
25     CFLAGS="$GCC_CFLAGS"
26     CXXFLAGS="$GCC_CXXFLAGS"
27 fi
28
29 AC_DISABLE_STATIC
30 AC_PROG_LIBTOOL
31
32 AC_LANG(C++)
33
34 # C++ requirements
35 AC_CXX_REQUIRE_STL
36 AC_CXX_NAMESPACES
37
38 AC_LANG(C)
39
40 # checks for pthreads
41 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
42 if test $enable_threads != "pthread"; then
43     AC_MSG_ERROR([unable to find pthreads, currently this is required])
44 else
45     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
46     LIBS="$PTHREAD_LIBS $LIBS"
47     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
48     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
49 fi
50
51 # Checks for typedefs, structures, and compiler characteristics.
52 AC_C_CONST
53 AC_TYPE_SIZE_T
54 AC_STRUCT_TM
55 AC_STRUCT_TIMEZONE
56
57 # Checks for library functions.
58 AC_FUNC_STRFTIME
59 AC_CHECK_FUNCS([strchr strdup strstr gmtime_r timegm])
60 AC_CHECK_HEADERS([dlfcn.h])
61
62 # OpenSSL settings
63 AC_PATH_PROG(PKG_CONFIG, pkg-config)
64 if test "x$PKG_CONFIG" = x || test "x$PKG_CONFIG" = "xno" ; then
65     AC_ARG_WITH(openssl, 
66             AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
67             [if test x_$with_openssl != x_/usr; then
68                 SSLLIBS="-L${with_openssl}/lib"
69                 SSLFLAGS="-I${with_openssl}/include"
70             fi])
71     SSLLIBS="$SSLLIBS -lssl -lcrypto"
72 else
73     SSLLIBS="`$PKG_CONFIG --libs openssl`"
74     SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
75 fi
76 AC_MSG_CHECKING(for OpenSSL libraries)
77 AC_MSG_RESULT($SSLLIBS)
78 LIBS="$LIBS $SSLLIBS"
79 AC_MSG_CHECKING(for OpenSSL cflags)
80 AC_MSG_RESULT($SSLFLAGS)
81 CPPFLAGS="$SSLFLAGS $CPPFLAGS"
82
83 AC_CHECK_HEADER([openssl/ssl.h],,
84                 AC_MSG_ERROR([unable to find openssl header files]))
85 AC_MSG_CHECKING(for ERR_load_CRYPTO_string)
86 AC_TRY_LINK_FUNC([ERR_load_CRYPTO_strings],,
87              AC_MSG_ERROR([unable to link with openssl libraries]))
88 AC_MSG_RESULT(yes)
89 AC_MSG_CHECKING(for SSL_library_init)
90 AC_TRY_LINK_FUNC([SSL_library_init],, 
91              AC_MSG_ERROR([unable to link with openssl libraries]))
92 AC_MSG_RESULT(yes)
93
94 # libcurl settings
95 AC_PATH_PROG(CURL_CONFIG,curl-config)
96 AC_ARG_WITH(curl,
97             AC_HELP_STRING([--with-curl=PATH], [where libcurl is installed]),
98             [CURL_CONFIG="${with_curl}/bin/curl-config"])
99 if test -f "${CURL_CONFIG}"; then
100     LDFLAGS="`${CURL_CONFIG} --libs` $LDFLAGS"
101     CPPFLAGS="`${CURL_CONFIG} --cflags` $CPPFLAGS"
102 else
103     AC_MSG_WARN([curl-config not found, guessing at libcurl build settings])
104 fi
105 AC_CHECK_HEADER([curl/curl.h],,AC_MSG_ERROR([unable to find libcurl header files]))
106 AC_CHECK_LIB([curl],[curl_global_init],,AC_MSG_ERROR([unable to link with libcurl]))
107 AC_MSG_CHECKING([for CURLOPT_SSL_CTX_FUNCTION in curl.h])
108 AC_EGREP_HEADER([CURLOPT_SSL_CTX_FUNCTION], [curl/curl.h],
109                 [AC_MSG_RESULT(yes)],
110                 [AC_MSG_ERROR([need libcurl that supports CURLOPT_SSL_CTX_FUNCTION])])
111
112 AC_LANG(C++)
113
114 # log4cpp settings
115 AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
116 AC_ARG_WITH(log4cpp,
117             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp is installed]),
118             [LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"])
119 if test -f "${LOG4CPP_CONFIG}"; then
120     LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
121     CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
122 else
123     AC_MSG_WARN([log4cpp-config not found, guessing at log4cpp build settings])
124     LIBS="-llog4cpp $LIBS"
125 fi
126 AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
127 AC_CHECK_HEADER([log4cpp/PropertyConfigurator.hh],,AC_MSG_ERROR([you need at least log4cpp 0.3.x]))
128 AC_TRY_LINK(
129         [#include <log4cpp/Category.hh>],
130         [log4cpp::Category::getInstance("foo")],
131         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
132         [AC_MSG_ERROR([unable to link with log4cpp])])
133
134 # Xerces settings
135 AC_ARG_WITH(xerces, 
136             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
137             [if test x_$with_xerces != x_/usr; then
138                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
139                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
140             fi])
141 LIBS="-lxerces-c $LIBS"
142 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
143 AC_MSG_CHECKING([Xerces version])
144 AC_PREPROC_IFELSE(
145     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
146 [#if  _XERCES_VERSION != 20600
147 int i = 0;
148 #else
149 #error cannot use version 2.6.0
150 #endif])],
151     [AC_MSG_RESULT(OK)],
152     [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])])
153 AC_TRY_LINK(
154         [#include <xercesc/util/PlatformUtils.hpp>],
155         [xercesc::XMLPlatformUtils::Initialize()],
156         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
157         [AC_MSG_ERROR([unable to link with Xerces])])
158
159
160 # XML-Security settings
161 AC_ARG_WITH(xmlsec,
162             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
163             [with_xmlsec=/usr])
164
165 if test x_$with_xmlsec != x_no; then
166     if test x_$with_xmlsec != x_/usr; then
167         LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
168         CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
169     fi        
170     LIBS="-lxml-security-c $LIBS"
171     AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
172     AC_MSG_CHECKING([XML-Security version])
173     AC_PREPROC_IFELSE(
174             [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
175         [#if XSEC_VERSION_MAJOR > 1 || XSEC_VERSION_MEDIUM >2 
176 int i = 0;
177 #else
178 #error need version 1.3 or later
179 #endif])],
180         [AC_MSG_RESULT(OK)],
181         [AC_MSG_FAILURE([XML-Security version 1.3 or greater is required.])])
182     AC_TRY_LINK(
183             [#include <xsec/utils/XSECPlatformUtils.hpp>],
184             [XSECPlatformUtils::Initialise()],,
185             [AC_MSG_ERROR([unable to link with XML-Sec])])
186 else
187     AC_MSG_WARN([xmlsec disabled, building without signature/encryption support])
188     AC_DEFINE(XMLTOOLING_NO_XMLSEC,1,
189         [Define if you wish to disable XML-Security-dependent features.])
190 fi
191 AM_CONDITIONAL(BUILD_XMLSEC,test x_$with_xmlsec != x_no)
192
193 # Does the STL in use help or screw us?
194 AC_TRY_LINK(
195         [#include <string>],
196         [std::basic_string<unsigned short> foo; foo=foo+(unsigned short)65],
197         [AC_DEFINE(HAVE_GOOD_STL,1,
198             [Define if you have an STL implementation that supports useful string specialization.])],
199         )
200
201 # Check for unit test support
202 CXXTEST="/usr/bin/cxxtestgen.pl"
203 CXXTESTFLAGS=""
204 AC_ARG_WITH(cxxtest,
205             AC_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
206             [if test x_$with_cxxtest != x_/usr; then
207                 CXXTEST="${with_cxxtest}/cxxtestgen.pl"
208                 CXXTESTFLAGS="-I${with_cxxtest}"
209             fi])
210 if ! test -f "${CXXTEST}"; then
211     AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
212 fi
213
214 AC_SUBST(CXXTEST)
215 AC_SUBST(CXXTESTFLAGS)
216 AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
217
218 # output makefiles
219 AC_OUTPUT(Makefile xmltooling/Makefile xmltoolingtest/Makefile schemas/Makefile)