Try to patch around Sun compiler bug.
[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 else
47 # Fix for Sun Workshop compiler in debug mode, may be Sun case #6360993
48         case "${host_cpu}-${host_os}" in
49                 *solaris*)
50                         if test "$CXX" = "CC" ; then
51                                 CXXFLAGS="$CXXFLAGS -Qoption ccfe -stabs=no%dfltlit+no%dflthlp"
52                         fi
53                 ;;
54         esac
55 fi
56
57 AC_DISABLE_STATIC
58 AC_PROG_LIBTOOL
59
60 # Checks for typedefs, structures, and compiler characteristics.
61 AC_C_CONST
62 AC_TYPE_SIZE_T
63
64 # Checks for library functions.
65 AC_CHECK_FUNCS([strchr strdup strstr timegm strcasecmp])
66 AC_CHECK_HEADERS([dlfcn.h])
67 AC_CHECK_FUNC(dlclose, , [ AC_CHECK_LIB(dl, dlopen) ])
68
69 # checks for pthreads
70 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
71 if test $enable_threads != "pthread"; then
72     AC_MSG_ERROR([unable to find pthreads, currently this is required])
73 else
74     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
75         AM_CONDITIONAL(BUILD_PTHREAD,test "$enable_threads" = "pthread")
76     LIBS="$PTHREAD_LIBS $LIBS"
77     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
78     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
79 fi
80
81 # OpenSSL settings
82 AC_ARG_WITH(openssl,
83     AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
84     [if test x_$with_openssl != x_/usr; then
85         SSLLIBS="-L${with_openssl}/lib -lcrypto -lssl"
86         SSLFLAGS="-I${with_openssl}/include"
87     fi])
88
89 if test "x$SSLLIBS" = "x" ; then
90     AC_PATH_PROG(PKG_CONFIG, pkg-config)
91     if test "x$PKG_CONFIG" != x && test "x$PKG_CONFIG" != "xno" ; then
92         if pkg-config openssl ; then
93             SSLLIBS="`$PKG_CONFIG --libs openssl`"
94             SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
95         else
96             AC_MSG_ERROR([OpenSSL not supported by pkg-config, try --with-openssl instead])
97         fi
98     fi
99 fi
100
101 if test "x$SSLLIBS" = "x" ; then
102     SSLLIBS="-lcrypto -lssl"
103 fi
104
105 AC_MSG_CHECKING(for OpenSSL libraries)
106 AC_MSG_RESULT($SSLLIBS)
107 LIBS="$LIBS $SSLLIBS"
108 AC_MSG_CHECKING(for OpenSSL cflags)
109 AC_MSG_RESULT($SSLFLAGS)
110 CPPFLAGS="$SSLFLAGS $CPPFLAGS"
111
112 AC_CHECK_HEADER([openssl/pem.h],,
113                 AC_MSG_ERROR([unable to find openssl header files]))
114 AC_MSG_CHECKING(for ERR_load_CRYPTO_string)
115 AC_TRY_LINK_FUNC([ERR_load_CRYPTO_strings],,
116              AC_MSG_ERROR([unable to link with openssl libraries]))
117 AC_MSG_RESULT(yes)
118
119 # libcurl settings
120 AC_PATH_PROG(CURL_CONFIG,curl-config)
121 AC_ARG_WITH(curl,
122     AC_HELP_STRING([--with-curl=PATH], [where curl-config is installed]),
123     [
124     CURL_CONFIG="${with_curl}"
125     if ! test -f "${CURL_CONFIG}" ; then
126         CURL_CONFIG="${with_curl}/bin/curl-config"
127     fi
128     ])
129 if test -f "${CURL_CONFIG}" ; then
130     LDFLAGS="`${CURL_CONFIG} --libs` $LDFLAGS"
131     CPPFLAGS="`${CURL_CONFIG} --cflags` $CPPFLAGS"
132 else
133     AC_MSG_ERROR([curl-config not found, may need to use --with-curl option])
134 fi
135 AC_CHECK_HEADER([curl/curl.h],,AC_MSG_ERROR([unable to find libcurl header files]))
136 AC_CHECK_LIB([curl],[curl_global_init],,AC_MSG_ERROR([unable to link with libcurl]))
137 AC_MSG_CHECKING([for CURLOPT_SSL_CTX_FUNCTION in curl.h])
138 AC_EGREP_HEADER([CURLOPT_SSL_CTX_FUNCTION], [curl/curl.h],
139                 [AC_MSG_RESULT(yes)],
140                 [AC_MSG_ERROR([need libcurl that supports CURLOPT_SSL_CTX_FUNCTION])])
141
142
143 AC_LANG(C++)
144
145 # C++ requirements
146 AC_CXX_REQUIRE_STL
147 AC_CXX_NAMESPACES
148
149 # are covariant methods allowed?
150 AC_TRY_LINK(
151      [ class base { public: virtual base *GetPtr( void ) { return this; } }; ],
152      [ class derived: virtual public base { public: virtual derived *GetPtr( void ) { return this; } }; ],
153      [AC_DEFINE(HAVE_COVARIANT_RETURNS,1,[Define if C++ compiler supports covariant virtual methods.])])
154
155 # log4cpp settings
156 AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
157 AC_ARG_WITH(log4cpp,
158     AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
159     [
160     LOG4CPP_CONFIG="${with_log4cpp}"
161     if ! test -f "${LOG4CPP_CONFIG}" ; then
162         LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
163     fi
164     ])
165 if test -f "${LOG4CPP_CONFIG}"; then
166     LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
167     CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
168 else
169     AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
170     LIBS="-llog4cpp $LIBS"
171 fi
172 AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
173 AC_CHECK_HEADER([log4cpp/PropertyConfigurator.hh],,AC_MSG_ERROR([you need at least log4cpp 0.3.x]))
174 AC_TRY_LINK(
175         [#include <log4cpp/Category.hh>],
176         [log4cpp::Category::getInstance("foo")],
177         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
178         [AC_MSG_ERROR([unable to link with log4cpp])])
179
180 # Xerces settings
181 AC_ARG_WITH(xerces, 
182             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
183             [if test x_$with_xerces != x_/usr; then
184                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
185                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
186             fi])
187 LIBS="-lxerces-c $LIBS"
188 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
189 AC_MSG_CHECKING([Xerces version])
190 AC_PREPROC_IFELSE(
191     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
192 [#if  _XERCES_VERSION != 20600
193 int i = 0;
194 #else
195 #error cannot use version 2.6.0
196 #endif])],
197     [AC_MSG_RESULT(OK)],
198     [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use a newer version])])
199 AC_TRY_LINK(
200         [#include <xercesc/util/PlatformUtils.hpp>],
201         [xercesc::XMLPlatformUtils::Initialize()],
202         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
203         [AC_MSG_ERROR([unable to link with Xerces])])
204
205
206 # XML-Security settings
207 AC_ARG_WITH(xmlsec,
208             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
209             [with_xmlsec=/usr])
210
211 if test x_$with_xmlsec != x_no; then
212     if test x_$with_xmlsec != x_/usr; then
213         LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
214         CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
215     fi        
216     LIBS="-lxml-security-c $LIBS"
217     AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
218     AC_MSG_CHECKING([XML-Security version])
219     AC_PREPROC_IFELSE(
220             [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
221         [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3) || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM == 3 && XSEC_VERSION_MINOR > 0)
222 int i = 0;
223 #else
224 #error need version 1.3.1 or later
225 #endif])],
226         [AC_MSG_RESULT(OK)],
227         [AC_MSG_FAILURE([XML-Security version 1.3.1 or greater is required.])])
228     AC_TRY_LINK(
229             [#include <xsec/utils/XSECPlatformUtils.hpp>],
230             [XSECPlatformUtils::Initialise()],,
231             [AC_MSG_ERROR([unable to link with XML-Sec])])
232 else
233     AC_MSG_WARN([xmlsec disabled, building without signature/encryption support])
234     AC_DEFINE(XMLTOOLING_NO_XMLSEC,1,
235         [Define if you wish to disable XML-Security-dependent features.])
236 fi
237 AM_CONDITIONAL(BUILD_XMLSEC,test x_$with_xmlsec != x_no)
238
239 # Does the STL in use help or screw us?
240 AC_TRY_LINK(
241         [#include <string>],
242         [std::basic_string<unsigned short> foo; foo=foo+(unsigned short)65],
243         [AC_DEFINE(HAVE_GOOD_STL,1,
244             [Define if you have an STL implementation that supports useful string specialization.])],
245         )
246
247 # Check for unit test support
248 CXXTEST="/usr/bin/cxxtestgen.pl"
249 CXXTESTFLAGS=""
250 AC_ARG_WITH(cxxtest,
251             AC_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
252             [if test x_$with_cxxtest != x_/usr; then
253                 CXXTEST="${with_cxxtest}/cxxtestgen.pl"
254                 CXXTESTFLAGS="-I${with_cxxtest}"
255             fi])
256 if ! test -f "${CXXTEST}"; then
257     AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
258 fi
259
260 AC_SUBST(CXXTEST)
261 AC_SUBST(CXXTESTFLAGS)
262 AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
263
264 LIBTOOL="$LIBTOOL --silent"
265
266 # output makefiles
267 AC_OUTPUT(Makefile xmltooling/Makefile xmltoolingtest/Makefile schemas/Makefile)