Result of autoupdate
[shibboleth/cpp-xmltooling.git] / configure.ac
1 # Process this file with autoreconf
2 AC_PREREQ([2.67])
3 AC_INIT([xmltooling],[1.4],[https://bugs.internet2.edu/],[xmltooling])
4 AC_CONFIG_SRCDIR(xmltooling)
5 AC_CONFIG_AUX_DIR(build-aux)
6 AC_CONFIG_MACRO_DIR(m4)
7 AM_INIT_AUTOMAKE
8 LT_INIT
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     AS_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 -g -D_DEBUG"
27     GCC_CXXFLAGS="$CXXFLAGS -g -D_DEBUG"
28 else
29     GCC_CFLAGS="$CFLAGS -O2 -DNDEBUG"
30     GCC_CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG"
31 fi
32
33 AC_CONFIG_HEADERS([config.h xmltooling/config_pub.h])
34 AC_CONFIG_FILES([xmltooling.spec pkginfo Portfile])
35 AC_CONFIG_FILES([Makefile xmltooling/Makefile xmltoolingtest/Makefile schemas/Makefile doc/Makefile])
36
37 AC_PROG_CC([gcc gcc3 cc])
38 AC_PROG_CXX([g++ g++3 c++ CC])
39 AC_DISABLE_STATIC
40 AC_CANONICAL_HOST
41
42 if test "$GCC" = "yes" ; then
43 #    AC_HAVE_GCC_VERSION(4,0,0,0,
44 #        [
45 #        AC_DEFINE(GCC_HASCLASSVISIBILITY,1,
46 #            [Define to enable class visibility control in gcc.])
47 #        GCC_CFLAGS="$GCC_CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
48 #        GCC_CXXFLAGS="$GCC_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
49 #        ])
50     CFLAGS="-Wall $GCC_CFLAGS"
51     CXXFLAGS="-Wall $GCC_CXXFLAGS"
52 else
53 # Fix for Sun Workshop compiler in debug mode, may be Sun case #6360993
54         case "${host_cpu}-${host_os}" in
55                 *solaris*)
56                         if test "$CXX" = "CC" ; then
57                                 CXXFLAGS="$CXXFLAGS -Qoption ccfe -stabs=no%dfltlit+no%dflthlp"
58                         fi
59                 ;;
60         esac
61 fi
62
63 # Checks for typedefs, structures, and compiler characteristics.
64 AC_C_CONST
65 AC_TYPE_SIZE_T
66 AC_CHECK_SIZEOF([long])
67
68 # Checks for library functions.
69 AC_CHECK_FUNCS([strchr strdup strstr timegm strcasecmp])
70 AC_CHECK_HEADERS([dlfcn.h])
71 AC_CHECK_FUNC(dlclose, , [ AC_CHECK_LIB(dl, dlopen) ])
72
73 # checks for pthreads
74 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
75 if test $enable_threads != "pthread"; then
76     AC_MSG_ERROR([unable to find pthreads, currently this is required])
77 else
78     AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])
79         AM_CONDITIONAL(BUILD_PTHREAD,test "$enable_threads" = "pthread")
80     LIBS="$PTHREAD_LIBS $LIBS"
81     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
82     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
83 fi
84
85 AC_CHECK_FUNCS([pthread_rwlock_init])
86
87 AC_LANG(C++)
88
89 # C++ requirements
90 AC_CXX_REQUIRE_STL
91 AC_CXX_NAMESPACES
92
93 # are covariant methods allowed?
94 AC_LINK_IFELSE(
95         [AC_LANG_PROGRAM([[]],
96                 [[
97                 class base { public: virtual base *GetPtr( void ) { return this; } };
98                 class derived: virtual public base { public: virtual derived *GetPtr( void ) { return this; } };
99                 ]])],
100     [AC_DEFINE([HAVE_COVARIANT_RETURNS], [1], [Define to 1 if C++ compiler supports covariant virtual methods.])]
101         )
102
103 # is nullptr supported?
104 AC_COMPILE_IFELSE(
105         [AC_LANG_PROGRAM([[]],
106                 [[
107                 const char* ptr = nullptr;
108                 ]])],
109         [AC_DEFINE([HAVE_NULLPTR], [1], [Define to 1 if C++ compiler supports nullptr keyword.])]
110         )
111
112 # log4shib settings (favor this version over the log4cpp code)
113 AC_PATH_PROG(LOG4SHIB_CONFIG,log4shib-config)
114 AC_ARG_WITH(log4shib,
115     AS_HELP_STRING([--with-log4shib=PATH], [where log4shib-config is installed]),
116     [
117     LOG4SHIB_CONFIG="${with_log4shib}"
118     if ! test -f "${LOG4SHIB_CONFIG}" ; then
119         LOG4SHIB_CONFIG="${with_log4shib}/bin/log4shib-config"
120     fi
121     ])
122 if test -f "${LOG4SHIB_CONFIG}"; then
123     LIBS="`${LOG4SHIB_CONFIG} --libs` $LIBS"
124     CPPFLAGS="`${LOG4SHIB_CONFIG} --cflags` $CPPFLAGS"
125         AC_CHECK_HEADER([log4shib/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4shib header files]))
126         AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <log4shib/Category.hh>
127 #include <log4shib/CategoryStream.hh>]], [[log4shib::Category::getInstance("foo").errorStream() << log4shib::eol]])],[AC_DEFINE([XMLTOOLING_LOG4SHIB], [1], [Define to 1 if log4shib library is used.])],[AC_MSG_ERROR([unable to link with log4shib])])
128 else
129     AC_MSG_WARN([log4shib-config not found, may need to use --with-log4shib option])
130     AC_MSG_WARN([will look for original log4cpp library])
131     
132         # log4cpp settings
133         AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
134         AC_ARG_WITH(log4cpp,
135             AS_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
136             [
137             LOG4CPP_CONFIG="${with_log4cpp}"
138             if ! test -f "${LOG4CPP_CONFIG}" ; then
139                 LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
140             fi
141             ])
142         if test -f "${LOG4CPP_CONFIG}"; then
143                 AC_MSG_WARN([will try to use log4cpp, note that most non-Internet2 supplied versions are not thread-safe])
144             LIBS="`${LOG4CPP_CONFIG} --libs` $LIBS"
145             CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
146                 AC_CHECK_HEADER([log4cpp/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
147                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <log4cpp/Category.hh>
148 #include <log4cpp/CategoryStream.hh>]], [[log4cpp::Category::getInstance("foo").errorStream() << log4cpp::eol]])],[AC_DEFINE([XMLTOOLING_LOG4CPP], [1], [Define to 1 if log4cpp library is used.])],[AC_MSG_ERROR([unable to link with log4cpp, need version 1.0 or later])])
149         else
150             AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
151         fi
152 fi
153
154 # Xerces settings
155 AC_ARG_WITH(xerces, 
156             AS_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
157             [if test x_$with_xerces != x_/usr; then
158                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
159                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
160             fi])
161 LIBS="-lxerces-c $LIBS"
162 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
163 AC_MSG_CHECKING([Xerces version])
164 AC_PREPROC_IFELSE(
165     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
166 [#if  _XERCES_VERSION != 20600
167 int i = 0;
168 #else
169 #error cannot use version 2.6.0
170 #endif])],
171     [AC_MSG_RESULT(OK)],
172     [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use a newer version])])
173 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <xercesc/util/PlatformUtils.hpp>]], [[xercesc::XMLPlatformUtils::Initialize()]])],[AC_DEFINE([HAVE_LIBXERCESC], [1], [Define to 1 if Xerces-C library was found])],[AC_MSG_ERROR([unable to link with Xerces])])
174
175 AC_MSG_CHECKING([whether Xerces is 64-bit clean])
176 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <xercesc/framework/MemBufInputSource.hpp>]], [[using namespace XERCES_CPP_NAMESPACE;
177       XMLFilePos testvar;
178     ]])],[AC_MSG_RESULT([yes])
179     AC_DEFINE([XMLTOOLING_XERCESC_64BITSAFE], [1], [Define to 1 if Xerces has a 64-bit-safe API.])],[AC_MSG_RESULT([no])])
180
181 AC_MSG_CHECKING([whether Xerces BinInputStream requires getContentType])
182 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <xercesc/util/BinMemInputStream.hpp>]], [[using namespace XERCES_CPP_NAMESPACE;
183       XMLByte buf[1024];
184       BinMemInputStream in(buf,1024);
185       in.getContentType();
186     ]])],[AC_MSG_RESULT([yes])
187     AC_DEFINE([XMLTOOLING_XERCESC_INPUTSTREAM_HAS_CONTENTTYPE], [1], [Define to 1 if Xerces InputStream class requires getContentType.])],[AC_MSG_RESULT([no])])
188
189 AC_MSG_CHECKING([whether Xerces DOMLS API is compliant])
190 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <xercesc/dom/DOM.hpp>]], [[using namespace XERCES_CPP_NAMESPACE;
191         DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(NULL);
192         DOMLSSerializer *ls = ((DOMImplementationLS*)impl)->createLSSerializer();
193     ]])],[AC_MSG_RESULT([yes])
194     AC_DEFINE([XMLTOOLING_XERCESC_COMPLIANT_DOMLS], [1], [Define to 1 if Xerces supports a compliant DOMLS API.])],[AC_MSG_RESULT([no])])
195
196 AC_MSG_CHECKING([whether Xerces has setIdAttribute(XMLCh*, bool)])
197 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <xercesc/dom/DOM.hpp>]], [[using namespace XERCES_CPP_NAMESPACE;
198           DOMElement * elt;
199           elt->setIdAttribute(NULL, false);
200       ]])],[AC_MSG_RESULT([yes])
201       AC_DEFINE([XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE], [1], [Define to 1 if Xerces DOM ID methods take extra parameter.])],[AC_MSG_RESULT([no])])
202
203 AC_MSG_CHECKING([whether Xerces XMLString::release(XMLByte**) exists])
204 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <xercesc/util/XMLString.hpp>]], [[using namespace XERCES_CPP_NAMESPACE;
205       XMLByte* buf=NULL;
206       XMLString::release(&buf);
207     ]])],[AC_MSG_RESULT([yes])
208     AC_DEFINE([XMLTOOLING_XERCESC_HAS_XMLBYTE_RELEASE], [1], [Define to 1 if Xerces XMLString includes XMLByte release.])],[AC_MSG_RESULT([no])])
209
210 # XML-Security settings
211 AC_ARG_WITH(xmlsec,
212             AS_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
213             [with_xmlsec=/usr])
214
215 if test x_$with_xmlsec != x_no; then
216
217     # OpenSSL settings (need to do this first in case it's in a different spot from xmlsec)
218     AC_ARG_WITH(openssl,
219         AS_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
220         [if test x_$with_openssl != x_/usr; then
221             SSLFLAGS="-I${with_openssl}/include"
222             SSLLIBS="-L${with_openssl}/lib -lcrypto -lssl"
223         else
224             SSLLIBS="-lcrypto -lssl"
225         fi])
226     
227     if test "x$SSLLIBS" = "x" ; then
228         AC_PATH_PROG(PKG_CONFIG, pkg-config)
229         if test "x$PKG_CONFIG" != x && test "x$PKG_CONFIG" != "xno" ; then
230             if pkg-config openssl ; then
231                 SSLLIBS="`$PKG_CONFIG --libs openssl`"
232                 SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
233             else
234                 AC_MSG_WARN([OpenSSL not supported by pkg-config, try --with-openssl instead])
235             fi
236         fi
237     fi
238     
239     if test "x$SSLLIBS" = "x" ; then
240         SSLLIBS="-lcrypto -lssl"
241     fi
242     
243     AC_MSG_CHECKING(for OpenSSL cflags)
244     AC_MSG_RESULT($SSLFLAGS)
245     CPPFLAGS="$CPPFLAGS $SSLFLAGS"
246     AC_MSG_CHECKING(for OpenSSL libraries)
247     AC_MSG_RESULT($SSLLIBS)
248     XMLSEC_LIBS="$XMLSEC_LIBS $SSLLIBS"
249
250     # save and append master libs
251     save_LIBS="$LIBS"
252     LIBS="$XMLSEC_LIBS $LIBS"
253     
254     AC_CHECK_HEADER([openssl/pem.h],,
255                     AC_MSG_ERROR([unable to find openssl header files]))
256     AC_MSG_CHECKING(for ERR_load_CRYPTO_string)
257     AC_TRY_LINK_FUNC([ERR_load_CRYPTO_strings],,
258                  AC_MSG_ERROR([unable to link with openssl libraries]))
259     AC_MSG_RESULT(yes)
260
261         AC_CHECK_DECL(EVP_sha512,
262                 [AC_DEFINE([XMLTOOLING_OPENSSL_HAVE_SHA2],[],[Define to 1 if OpenSSL supports the SHA-2 hash family.])],
263                 ,[#include <openssl/evp.h>])
264
265     # restore master libs
266     LIBS="$save_LIBS"
267
268     if test x_$with_xmlsec != x_/usr; then
269         CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
270         LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
271     fi        
272     XMLSEC_LIBS="$XMLSEC_LIBS -lxml-security-c"
273     
274     # save and append master libs
275     save_LIBS="$LIBS"
276     LIBS="$XMLSEC_LIBS $LIBS"
277     
278     AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
279     AC_MSG_CHECKING([XML-Security version])
280     AC_PREPROC_IFELSE(
281             [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
282         [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3)
283 int i = 0;
284 #else
285 #error need version 1.4.0 or later
286 #endif])],
287         [AC_MSG_RESULT(OK)],
288         [AC_MSG_FAILURE([XML-Security version 1.4.0 or greater is required.])])
289     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <xsec/utils/XSECPlatformUtils.hpp>]], [[XSECPlatformUtils::Initialise()]])],[],[AC_MSG_ERROR([unable to link with XML-Security])])
290     AC_CHECK_TYPE([xsecsize_t],[AC_DEFINE([HAVE_XSECSIZE_T], [1], [Define to 1 if you have the 'xsecsize_t' type.])])
291
292     AC_MSG_CHECKING([whether XML-Security-C has multiple CRL support])
293     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <xsec/dsig/DSIGKeyInfoList.hpp>]], [[DSIGKeyInfoList* klist; klist->getX509CRLListSize();]])],[AC_MSG_RESULT([yes])
294           AC_DEFINE([XMLTOOLING_XMLSEC_MULTIPLECRL], [1], [Define to 1 if XML-Security-C handles multiple CRLs.])],[AC_MSG_RESULT([no])])
295
296     AC_MSG_CHECKING([whether XML-Security-C exposes the signature algorithm URI])
297     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <xsec/dsig/DSIGSignature.hpp>]], [[DSIGSignature* sig; sig->getAlgorithmURI();]])],[AC_MSG_RESULT([yes])
298           AC_DEFINE([XMLTOOLING_XMLSEC_SIGALGORITHM], [1], [Define to 1 if XML-Security-C exposes the signature algorithm URI.])],[AC_MSG_RESULT([no])])
299
300     AC_MSG_CHECKING([whether XML-Security-C includes ECC support])
301     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <xsec/dsig/DSIGKeyInfoValue.hpp>]], [[DSIGKeyInfoValue* info; info->getECNamedCurve();]])],[AC_MSG_RESULT([yes])
302           AC_DEFINE([XMLTOOLING_XMLSEC_ECC], [1], [Define to 1 if XML-Security-C includes ECC support.])],[AC_MSG_RESULT([no])])
303
304     AC_MSG_CHECKING([whether XML-Security-C includes debug logging support])
305     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <xsec/utils/XSECPlatformUtils.hpp>]], [[XSECPlatformUtils::SetReferenceLoggingSink(NULL)]])],[AC_MSG_RESULT([yes])
306           AC_DEFINE([XMLTOOLING_XMLSEC_DEBUGLOGGING], [1], [Define to 1 if XML-Security-C includes debug logging support.])],[AC_MSG_RESULT([no])])
307
308         # restore master libs
309         LIBS="$save_LIBS"
310
311         # libcurl settings
312         AC_PATH_PROG(CURL_CONFIG,curl-config)
313         AC_ARG_WITH(curl,
314             AS_HELP_STRING([--with-curl=PATH], [where curl-config is installed]),
315             [
316             CURL_CONFIG="${with_curl}"
317             if ! test -f "${CURL_CONFIG}" ; then
318                 CURL_CONFIG="${with_curl}/bin/curl-config"
319             fi
320             ])
321         if test -f "${CURL_CONFIG}" ; then
322             CPPFLAGS="`${CURL_CONFIG} --cflags` $CPPFLAGS"
323             XMLSEC_LIBS="`${CURL_CONFIG} --libs` $XMLSEC_LIBS"
324         else
325             AC_MSG_ERROR([curl-config not found, may need to use --with-curl option])
326         fi
327
328         # save and append master libs
329         save_LIBS="$LIBS"
330         LIBS="$XMLSEC_LIBS $LIBS"
331         
332         AC_CHECK_HEADER([curl/curl.h],,AC_MSG_ERROR([unable to find libcurl header files]))
333         AC_CHECK_LIB([curl],[curl_global_init],,AC_MSG_ERROR([unable to link with libcurl]))
334         AC_MSG_CHECKING([for CURLOPT_SSL_CTX_FUNCTION in curl.h])
335         AC_EGREP_HEADER([CURLOPT_SSL_CTX_FUNCTION], [curl/curl.h],
336                         [AC_MSG_RESULT(yes)],
337                         [AC_MSG_ERROR([need libcurl that supports CURLOPT_SSL_CTX_FUNCTION])])
338     AC_CHECK_TYPE([curl_off_t],[AC_DEFINE([HAVE_CURL_OFF_T], [1], [Define to 1 if you have the 'curl_off_t' type.])])
339
340         # restore master libs
341         LIBS="$save_LIBS"
342
343         AC_SUBST(XMLSEC_LIBS)
344 else
345     AC_MSG_WARN([xmlsec disabled, building without signature/encryption support])
346     AC_DEFINE([XMLTOOLING_NO_XMLSEC], [1], [Define to 1 if you wish to disable XML-Security-dependent features.])
347 fi
348 AM_CONDITIONAL(BUILD_XMLSEC,test x_$with_xmlsec != x_no)
349
350 # Does the STL in use help or screw us?
351 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <string>]], [[std::basic_string<unsigned short> foo; foo=foo+(unsigned short)65]])],[AC_DEFINE([HAVE_GOOD_STL], [1],
352             [Define to 1 if you have an STL implementation that supports useful string specialization.])],[])
353 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <vector>]], [[std::iterator_traits<std::vector<int>::iterator>::value_type foo=0]])],[AC_DEFINE([HAVE_ITERATOR_TRAITS], [1],
354             [Define to 1 if you have an STL implementation that supports std::iterator_traits.])],[])
355
356 # Check for unit test support
357 CXXTEST="/usr/bin/cxxtestgen.pl"
358 CXXTESTFLAGS=""
359 AC_ARG_WITH(cxxtest,
360             AS_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
361             [if test x_$with_cxxtest != x_/usr; then
362                 CXXTEST="${with_cxxtest}/cxxtestgen.pl"
363                 CXXTESTFLAGS="-I${with_cxxtest}"
364             fi])
365 if ! test -f "${CXXTEST}"; then
366     AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
367 fi
368
369 AC_SUBST(CXXTEST)
370 AC_SUBST(CXXTESTFLAGS)
371 AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
372
373 AX_CREATE_PKGCONFIG_INFO(,,[$XMLSEC_LIBS -lxmltooling],[OpenSAML XMLTooling-C library])
374
375 LIBTOOL="$LIBTOOL --silent"
376
377 # output packaging and makefiles
378 AC_OUTPUT