Back off libtool macro for compatibility.
[shibboleth/cpp-xmltooling.git] / configure.ac
1 # Process this file with autoreconf
2 AC_PREREQ([2.50])
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 AC_PROG_LIBTOOL
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_NAMESPACES
91 AC_CXX_REQUIRE_STL
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 # is nullptr supported?
103 AC_COMPILE_IFELSE(
104     [AC_LANG_PROGRAM([[]],[[const char* ptr = nullptr;]])],
105     [AC_DEFINE([HAVE_NULLPTR],[1],[Define to 1 if C++ compiler supports nullptr keyword.])])
106
107 # log4shib settings (favor this version over the log4cpp code)
108 AC_PATH_PROG(LOG4SHIB_CONFIG,log4shib-config)
109 AC_ARG_WITH(log4shib,
110     AS_HELP_STRING([--with-log4shib=PATH],[where log4shib-config is installed]),
111     [
112     LOG4SHIB_CONFIG="${with_log4shib}"
113     if ! test -f "${LOG4SHIB_CONFIG}" ; then
114         LOG4SHIB_CONFIG="${with_log4shib}/bin/log4shib-config"
115     fi
116     ])
117 if test -f "${LOG4SHIB_CONFIG}" ; then
118     LIBS="`${LOG4SHIB_CONFIG} --libs` $LIBS"
119     CPPFLAGS="`${LOG4SHIB_CONFIG} --cflags` $CPPFLAGS"
120     AC_CHECK_HEADER([log4shib/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4shib header files]))
121     AC_LINK_IFELSE(
122         [AC_LANG_PROGRAM([[#include <log4shib/Category.hh>
123 #include <log4shib/CategoryStream.hh>]],
124             [[log4shib::Category::getInstance("foo").errorStream() << log4shib::eol]])],
125         [AC_DEFINE([XMLTOOLING_LOG4SHIB],[1],[Define to 1 if log4shib library is used.])],
126         [AC_MSG_ERROR([unable to link with log4shib])])
127 else
128     AC_MSG_WARN([log4shib-config not found, may need to use --with-log4shib option])
129     AC_MSG_WARN([will look for original log4cpp library])
130     
131     # log4cpp settings
132     AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
133     AC_ARG_WITH(log4cpp,
134         AS_HELP_STRING([--with-log4cpp=PATH],[where log4cpp-config is installed]),
135         [
136         LOG4CPP_CONFIG="${with_log4cpp}"
137         if ! test -f "${LOG4CPP_CONFIG}" ; then
138                 LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
139         fi
140         ])
141     if test -f "${LOG4CPP_CONFIG}"; then
142         AC_MSG_WARN([will try to use log4cpp, note that most non-Internet2 supplied versions are not thread-safe])
143         LIBS="`${LOG4CPP_CONFIG} --libs` $LIBS"
144         CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
145         AC_CHECK_HEADER([log4cpp/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
146         AC_LINK_IFELSE(
147             [AC_LANG_PROGRAM([[#include <log4cpp/Category.hh>
148 #include <log4cpp/CategoryStream.hh>]],
149                 [[log4cpp::Category::getInstance("foo").errorStream() << log4cpp::eol]])],
150             [AC_DEFINE([XMLTOOLING_LOG4CPP],[1],[Define to 1 if log4cpp library is used.])],
151             [AC_MSG_ERROR([unable to link with log4cpp, need version 1.0 or later])])
152         else
153             AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
154         fi
155 fi
156
157 # Xerces settings
158 AC_ARG_WITH(xerces, 
159     AS_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
160     [if test x_$with_xerces != x_/usr; then
161         LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
162         CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
163     fi])
164 LIBS="-lxerces-c $LIBS"
165 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
166 AC_MSG_CHECKING([Xerces version])
167 AC_PREPROC_IFELSE(
168     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
169 [#if  _XERCES_VERSION != 20600
170 int i = 0;
171 #else
172 #error cannot use version 2.6.0
173 #endif])],
174     [AC_MSG_RESULT(OK)],
175     [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use a newer version])])
176 AC_LINK_IFELSE(
177     [AC_LANG_PROGRAM([[#include <xercesc/util/PlatformUtils.hpp>]],
178         [[xercesc::XMLPlatformUtils::Initialize()]])],
179     ,[AC_MSG_ERROR([unable to link with Xerces])])
180
181 AC_MSG_CHECKING([whether Xerces is 64-bit clean])
182 AC_COMPILE_IFELSE(
183     [AC_LANG_PROGRAM([[#include <xercesc/framework/MemBufInputSource.hpp>]],
184         [[using namespace XERCES_CPP_NAMESPACE; XMLFilePos testvar;]])],
185     [AC_MSG_RESULT([yes])AC_DEFINE([XMLTOOLING_XERCESC_64BITSAFE],[1],[Define to 1 if Xerces has a 64-bit-safe API.])],
186     [AC_MSG_RESULT([no])])
187
188 AC_MSG_CHECKING([whether Xerces BinInputStream requires getContentType])
189 AC_COMPILE_IFELSE(
190     [AC_LANG_PROGRAM([[#include <xercesc/util/BinMemInputStream.hpp>]],
191         [[using namespace XERCES_CPP_NAMESPACE; XMLByte buf[1024]; BinMemInputStream in(buf,1024); in.getContentType();]])],
192     [AC_MSG_RESULT([yes])AC_DEFINE([XMLTOOLING_XERCESC_INPUTSTREAM_HAS_CONTENTTYPE],[1],[Define to 1 if Xerces InputStream class requires getContentType.])],
193     [AC_MSG_RESULT([no])])
194
195 AC_MSG_CHECKING([whether Xerces DOMLS API is compliant])
196 AC_COMPILE_IFELSE(
197     [AC_LANG_PROGRAM([[#include <xercesc/dom/DOM.hpp>]],
198         [[using namespace XERCES_CPP_NAMESPACE;
199         DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(NULL);
200         DOMLSSerializer *ls = ((DOMImplementationLS*)impl)->createLSSerializer();]])],
201     [AC_MSG_RESULT([yes])AC_DEFINE([XMLTOOLING_XERCESC_COMPLIANT_DOMLS],[1],[Define to 1 if Xerces supports a compliant DOMLS API.])],
202     [AC_MSG_RESULT([no])])
203
204 AC_MSG_CHECKING([whether Xerces has setIdAttribute(XMLCh*, bool)])
205 AC_COMPILE_IFELSE(
206     [AC_LANG_PROGRAM([[#include <xercesc/dom/DOM.hpp>]],
207         [[using namespace XERCES_CPP_NAMESPACE; DOMElement * elt; elt->setIdAttribute(NULL, false);]])],
208     [AC_MSG_RESULT([yes])AC_DEFINE([XMLTOOLING_XERCESC_BOOLSETIDATTRIBUTE],[1],[Define to 1 if Xerces DOM ID methods take extra parameter.])],
209     [AC_MSG_RESULT([no])])
210
211 AC_MSG_CHECKING([whether Xerces XMLString::release(XMLByte**) exists])
212 AC_COMPILE_IFELSE(
213     [AC_LANG_PROGRAM([[#include <xercesc/util/XMLString.hpp>]],
214     [[using namespace XERCES_CPP_NAMESPACE; XMLByte* buf=NULL; XMLString::release(&buf);]])],
215     [AC_MSG_RESULT([yes])AC_DEFINE([XMLTOOLING_XERCESC_HAS_XMLBYTE_RELEASE],[1],[Define to 1 if Xerces XMLString includes XMLByte release.])],
216     [AC_MSG_RESULT([no])])
217
218 # XML-Security settings
219 AC_ARG_WITH(xmlsec,
220     AS_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
221     [with_xmlsec=/usr])
222
223 if test x_$with_xmlsec != x_no; then
224
225     # OpenSSL settings (need to do this first in case it's in a different spot from xmlsec)
226     AC_ARG_WITH(openssl,
227         AS_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
228         [if test x_$with_openssl != x_/usr; then
229             SSLFLAGS="-I${with_openssl}/include"
230             SSLLIBS="-L${with_openssl}/lib -lcrypto -lssl"
231         else
232             SSLLIBS="-lcrypto -lssl"
233         fi])
234     
235     if test "x$SSLLIBS" = "x" ; then
236         AC_PATH_PROG(PKG_CONFIG, pkg-config)
237         if test "x$PKG_CONFIG" != x && test "x$PKG_CONFIG" != "xno" ; then
238             if pkg-config openssl ; then
239                 SSLLIBS="`$PKG_CONFIG --libs openssl`"
240                 SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
241             else
242                 AC_MSG_WARN([OpenSSL not supported by pkg-config, try --with-openssl instead])
243             fi
244         fi
245     fi
246     
247     if test "x$SSLLIBS" = "x" ; then
248         SSLLIBS="-lcrypto -lssl"
249     fi
250     
251     AC_MSG_CHECKING(for OpenSSL cflags)
252     AC_MSG_RESULT($SSLFLAGS)
253     CPPFLAGS="$CPPFLAGS $SSLFLAGS"
254     AC_MSG_CHECKING(for OpenSSL libraries)
255     AC_MSG_RESULT($SSLLIBS)
256     XMLSEC_LIBS="$XMLSEC_LIBS $SSLLIBS"
257
258     # save and append master libs
259     save_LIBS="$LIBS"
260     LIBS="$XMLSEC_LIBS $LIBS"
261     
262     AC_CHECK_HEADER([openssl/pem.h],,AC_MSG_ERROR([unable to find openssl header files]))
263     AC_MSG_CHECKING(for ERR_load_CRYPTO_string)
264     AC_TRY_LINK_FUNC([ERR_load_CRYPTO_strings],,AC_MSG_ERROR([unable to link with openssl libraries]))
265     AC_MSG_RESULT(yes)
266
267     AC_CHECK_DECL(EVP_sha512,
268         [AC_DEFINE([XMLTOOLING_OPENSSL_HAVE_SHA2],[1],[Define to 1 if OpenSSL supports the SHA-2 hash family.])],
269                 ,[#include <openssl/evp.h>])
270
271     # restore master libs
272     LIBS="$save_LIBS"
273
274     if test x_$with_xmlsec != x_/usr; then
275         CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
276         LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
277     fi        
278     XMLSEC_LIBS="$XMLSEC_LIBS -lxml-security-c"
279     
280     # save and append master libs
281     save_LIBS="$LIBS"
282     LIBS="$XMLSEC_LIBS $LIBS"
283     
284     AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
285     AC_MSG_CHECKING([XML-Security version])
286     AC_PREPROC_IFELSE(
287             [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
288         [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3)
289 int i = 0;
290 #else
291 #error need version 1.4.0 or later
292 #endif])],
293         [AC_MSG_RESULT(OK)],
294         [AC_MSG_FAILURE([XML-Security version 1.4.0 or greater is required.])])
295         
296     AC_LINK_IFELSE(
297         [AC_LANG_PROGRAM([[#include <xsec/utils/XSECPlatformUtils.hpp>]],
298             [[XSECPlatformUtils::Initialise()]])],,
299         [AC_MSG_ERROR([unable to link with XML-Security])])
300     AC_CHECK_TYPE([xsecsize_t],[AC_DEFINE([HAVE_XSECSIZE_T],[1],[Define to 1 if you have the 'xsecsize_t' type.])])
301
302     AC_MSG_CHECKING([whether XML-Security-C has multiple CRL support])
303     AC_COMPILE_IFELSE(
304         [AC_LANG_PROGRAM([[#include <xsec/dsig/DSIGKeyInfoList.hpp>]],
305             [[DSIGKeyInfoList* klist; klist->getX509CRLListSize();]])],
306         [AC_MSG_RESULT([yes])AC_DEFINE([XMLTOOLING_XMLSEC_MULTIPLECRL],[1],[Define to 1 if XML-Security-C handles multiple CRLs.])],
307         [AC_MSG_RESULT([no])])
308
309     AC_MSG_CHECKING([whether XML-Security-C exposes the signature algorithm URI])
310     AC_COMPILE_IFELSE(
311         [AC_LANG_PROGRAM([[#include <xsec/dsig/DSIGSignature.hpp>]],
312             [[DSIGSignature* sig; sig->getAlgorithmURI();]])],
313         [AC_MSG_RESULT([yes])AC_DEFINE([XMLTOOLING_XMLSEC_SIGALGORITHM],[1],[Define to 1 if XML-Security-C exposes the signature algorithm URI.])],
314         [AC_MSG_RESULT([no])])
315
316     AC_MSG_CHECKING([whether XML-Security-C includes ECC support])
317     AC_COMPILE_IFELSE(
318         [AC_LANG_PROGRAM([[#include <xsec/dsig/DSIGKeyInfoValue.hpp>]],
319             [[DSIGKeyInfoValue* info; info->getECNamedCurve();]])],
320         [AC_MSG_RESULT([yes])AC_DEFINE([XMLTOOLING_XMLSEC_ECC],[1],[Define to 1 if XML-Security-C includes ECC support.])],
321         [AC_MSG_RESULT([no])])
322
323     AC_MSG_CHECKING([whether XML-Security-C includes debug logging support])
324     AC_COMPILE_IFELSE(
325         [AC_LANG_PROGRAM([[#include <xsec/utils/XSECPlatformUtils.hpp>]],
326             [[XSECPlatformUtils::SetReferenceLoggingSink(NULL)]])],
327         [AC_MSG_RESULT([yes])AC_DEFINE([XMLTOOLING_XMLSEC_DEBUGLOGGING],[1],[Define to 1 if XML-Security-C includes debug logging support.])],
328         [AC_MSG_RESULT([no])])
329
330     # restore master libs
331     LIBS="$save_LIBS"
332
333     # libcurl settings
334     AC_PATH_PROG(CURL_CONFIG,curl-config)
335     AC_ARG_WITH(curl,
336         AS_HELP_STRING([--with-curl=PATH], [where curl-config is installed]),
337         [
338         CURL_CONFIG="${with_curl}"
339         if ! test -f "${CURL_CONFIG}" ; then
340             CURL_CONFIG="${with_curl}/bin/curl-config"
341         fi
342         ])
343     if test -f "${CURL_CONFIG}" ; then
344         CPPFLAGS="`${CURL_CONFIG} --cflags` $CPPFLAGS"
345         XMLSEC_LIBS="`${CURL_CONFIG} --libs` $XMLSEC_LIBS"
346     else
347         AC_MSG_ERROR([curl-config not found, may need to use --with-curl option])
348     fi
349
350     # save and append master libs
351     save_LIBS="$LIBS"
352     LIBS="$XMLSEC_LIBS $LIBS"
353         
354     AC_CHECK_HEADER([curl/curl.h],,AC_MSG_ERROR([unable to find libcurl header files]))
355     AC_CHECK_LIB([curl],[curl_global_init],,AC_MSG_ERROR([unable to link with libcurl]))
356     AC_MSG_CHECKING([for CURLOPT_SSL_CTX_FUNCTION in curl.h])
357     AC_EGREP_HEADER([CURLOPT_SSL_CTX_FUNCTION], [curl/curl.h],
358         [AC_MSG_RESULT(yes)],
359         [AC_MSG_ERROR([need libcurl that supports CURLOPT_SSL_CTX_FUNCTION])])
360     AC_CHECK_TYPE([curl_off_t],[AC_DEFINE([HAVE_CURL_OFF_T],[1],[Define to 1 if you have the 'curl_off_t' type.])])
361     
362     # restore master libs
363     LIBS="$save_LIBS"
364     
365     AC_SUBST(XMLSEC_LIBS)
366 else
367     AC_MSG_WARN([xmlsec disabled, building without signature/encryption support])
368     AC_DEFINE([XMLTOOLING_NO_XMLSEC],[1],[Define to 1 if you wish to disable XML-Security-dependent features.])
369 fi
370 AM_CONDITIONAL(BUILD_XMLSEC,test x_$with_xmlsec != x_no)
371
372 # Does the STL in use help or screw us?
373 AC_LINK_IFELSE(
374     [AC_LANG_PROGRAM([[#include <string>]],[[std::basic_string<unsigned short> foo; foo=foo+(unsigned short)65]])],
375     [AC_DEFINE([HAVE_GOOD_STL],[1],[Define to 1 if you have an STL implementation that supports useful string specialization.])],[])
376 AC_LINK_IFELSE(
377     [AC_LANG_PROGRAM([[#include <vector>]],[[std::iterator_traits<std::vector<int>::iterator>::value_type foo=0]])],
378     [AC_DEFINE([HAVE_ITERATOR_TRAITS],[1],[Define to 1 if you have an STL implementation that supports std::iterator_traits.])],[])
379
380 # Check for unit test support
381 CXXTEST="/usr/bin/cxxtestgen.pl"
382 CXXTESTFLAGS=""
383 AC_ARG_WITH(cxxtest,
384     AS_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
385     [if test x_$with_cxxtest != x_/usr; then
386         CXXTEST="${with_cxxtest}/cxxtestgen.pl"
387         CXXTESTFLAGS="-I${with_cxxtest}"
388     fi])
389 if ! test -f "${CXXTEST}"; then
390     AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
391 fi
392
393 AC_SUBST(CXXTEST)
394 AC_SUBST(CXXTESTFLAGS)
395 AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
396
397 AX_CREATE_PKGCONFIG_INFO(,,[$XMLSEC_LIBS -lxmltooling],[OpenSAML XMLTooling-C library])
398
399 LIBTOOL="$LIBTOOL --silent"
400
401 # output packaging and makefiles
402 AC_OUTPUT