Fix Win lib version strings
[shibboleth/cpp-opensaml.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([opensaml],[2.5.4],[https://issues.shibboleth.net/],[opensaml])
3 AC_CONFIG_SRCDIR(saml)
4 AC_CONFIG_AUX_DIR(build-aux)
5 AC_CONFIG_MACRO_DIR(m4)
6 AM_INIT_AUTOMAKE
7 AC_DISABLE_STATIC
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(opensaml, doxygen.cfg, doc/api)
20 DX_INCLUDE=
21
22 AC_ARG_ENABLE(debug,
23     AS_HELP_STRING([--enable-debug],[Have GCC compile with symbols (Default = no)]),
24     enable_debug=$enableval, enable_debug=no)
25
26 if test "$enable_debug" = "yes" ; then
27     GCC_CFLAGS="$CFLAGS -Wall -g -D_DEBUG"
28     GCC_CXXFLAGS="$CXXFLAGS -Wall -g -D_DEBUG"
29 else
30     GCC_CFLAGS="$CFLAGS -Wall -O2 -DNDEBUG"
31     GCC_CXXFLAGS="$CXXFLAGS -Wall -O2 -DNDEBUG"
32 fi
33
34 AC_CONFIG_HEADERS([config.h])
35 AC_CONFIG_FILES([opensaml.spec])
36 AC_CONFIG_FILES([Makefile saml/Makefile samltest/Makefile samlsign/Makefile schemas/Makefile doc/Makefile])
37
38 AC_PROG_CC([gcc gcc3 cc])
39 AC_PROG_CXX([g++ g++3 c++ CC])
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="$GCC_CFLAGS"
51     CXXFLAGS="$GCC_CXXFLAGS"
52 fi
53
54 # Fix for Sun Workshop compiler in debug mode, may be Sun case #6360993
55 # Also enables POSIX semantics for some functions.
56 case "${host_cpu}-${host_os}" in
57     *solaris*)
58         CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS"
59         CXXFLAGS="$CXXFLAGS -D_POSIX_PTHREAD_SEMANTICS"
60         if test "$CXX" = "CC" ; then
61                 CXXFLAGS="$CXXFLAGS -Qoption ccfe -stabs=no%dfltlit+no%dflthlp"
62         fi
63     ;;
64 esac
65
66 # Checks for typedefs, structures, and compiler characteristics.
67 AC_C_CONST
68 AC_TYPE_SIZE_T
69 AC_HEADER_DIRENT
70
71 # Checks for library functions.
72 AC_CHECK_FUNCS([strchr strdup strstr])
73
74 # checks for pthreads
75 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
76 if test $enable_threads != "pthread"; then
77     AC_MSG_ERROR([unable to find pthreads, currently this is required])
78 else
79     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
80     LIBS="$PTHREAD_LIBS $LIBS"
81     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
82     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
83 fi
84
85 # zlib settings
86 AC_ARG_WITH(zlib,
87     AS_HELP_STRING([--with-zlib=PATH],[where zlib is installed]),
88     [
89         if test -d "$withval" ; then
90             CPPFLAGS="${CPPFLAGS} -I$withval/include"
91             LDFLAGS="${LDFLAGS} -L$withval/lib"
92         fi
93     ]
94 )
95
96 AC_ARG_WITH(zlib,
97     AS_HELP_STRING([--with-zlib=PATH],[where zlib is installed]),,
98     [with_zlib=/usr])
99 if test x_$with_zlib != x_/usr; then
100     CPPFLAGS="-I${with_zlib}/include $CPPFLAGS"
101     LIBS="-L${with_zlib}/lib -lz $LIBS"
102 else
103     LIBS="-lz $LIBS"
104 fi
105
106 AC_CHECK_HEADER([zlib.h],,AC_MSG_ERROR([unable to find zlib header files]))
107 AC_LINK_IFELSE(
108     [AC_LANG_PROGRAM([[#include <zlib.h>]],
109         [[zlibVersion()]])],,
110     [AC_MSG_ERROR([unable to link with zlib])])
111
112
113 # OpenSSL settings
114 AC_ARG_WITH(openssl,
115     AS_HELP_STRING([--with-openssl=PATH],[where openssl is installed]),
116     [if test x_$with_openssl != x_/usr; then
117         SSLFLAGS="-I${with_openssl}/include"
118     fi])
119
120 if test "x$with_openssl" = "x" ; then
121     AC_PATH_PROG(PKG_CONFIG, pkg-config)
122     if test "x$PKG_CONFIG" != x && test "x$PKG_CONFIG" != "xno" ; then
123         if pkg-config openssl ; then
124             SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
125         else
126             AC_MSG_WARN([OpenSSL not supported by pkg-config, try --with-openssl instead])
127         fi
128     fi
129 fi
130
131 AC_MSG_CHECKING(for OpenSSL cflags)
132 AC_MSG_RESULT($SSLFLAGS)
133 CPPFLAGS="$SSLFLAGS $CPPFLAGS"
134
135 AC_CHECK_HEADER([openssl/x509.h],,AC_MSG_ERROR([unable to find openssl header files]))
136
137 AC_LANG([C++])
138
139 # C++ requirements
140 AC_CXX_NAMESPACES
141 AC_CXX_REQUIRE_STL
142
143 # Boost
144 BOOST_REQUIRE
145 BOOST_BIND
146 BOOST_LAMBDA
147 BOOST_PTR_CONTAINER
148 BOOST_SMART_PTR
149 BOOST_STRING_ALGO
150 CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS"
151
152 # log4shib settings (favor this version over the log4cpp code)
153 AC_PATH_PROG(LOG4SHIB_CONFIG,log4shib-config)
154 AC_ARG_WITH(log4shib,
155     AS_HELP_STRING([--with-log4shib=PATH],[where log4shib-config is installed]),
156     [
157     LOG4SHIB_CONFIG="${with_log4shib}"
158     if ! test -f "${LOG4SHIB_CONFIG}"; then
159         LOG4SHIB_CONFIG="${with_log4shib}/bin/log4shib-config"
160     fi
161     ])
162 if test -f "${LOG4SHIB_CONFIG}" ; then
163     LIBS="`${LOG4SHIB_CONFIG} --libs` $LIBS"
164     CPPFLAGS="`${LOG4SHIB_CONFIG} --cflags` $CPPFLAGS"
165         AC_CHECK_HEADER([log4shib/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4shib header files]))
166     AC_LINK_IFELSE(
167         [AC_LANG_PROGRAM([[#include <log4shib/Category.hh>
168 #include <log4shib/CategoryStream.hh>]],
169             [[log4shib::Category::getInstance("foo").errorStream() << log4shib::eol]])],
170         [AC_DEFINE([OPENSAML_LOG4SHIB],[1],[Define to 1 if log4shib library is used.])],
171         [AC_MSG_ERROR([unable to link with log4shib])])
172 else
173     AC_MSG_WARN([log4shib-config not found, may need to use --with-log4shib option])
174     AC_MSG_WARN([will look for original log4cpp library])
175     
176     # log4cpp settings
177     AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
178     AC_ARG_WITH(log4cpp,
179         AS_HELP_STRING([--with-log4cpp=PATH],[where log4cpp-config is installed]),
180         [
181         LOG4CPP_CONFIG="${with_log4cpp}"
182         if ! test -f "${LOG4CPP_CONFIG}"; then
183                 LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
184         fi
185         ])
186     if test -f "${LOG4CPP_CONFIG}"; then
187         AC_MSG_WARN([will try to use log4cpp, note that most non-Internet2 supplied versions are not thread-safe])
188         LIBS="`${LOG4CPP_CONFIG} --libs` $LIBS"
189         CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
190         AC_CHECK_HEADER([log4cpp/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
191         AC_LINK_IFELSE(
192             [AC_LANG_PROGRAM([[#include <log4cpp/Category.hh>
193 #include <log4cpp/CategoryStream.hh>]],
194                 [[log4cpp::Category::getInstance("foo").errorStream() << log4cpp::eol]])],
195             [AC_DEFINE([OPENSAML_LOG4CPP],[1],[Define to 1 if log4cpp library is used.])],
196             [AC_MSG_ERROR([unable to link with log4cpp, need version 1.0 or later])])
197     else
198         AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
199     fi
200 fi
201
202 # Xerces settings
203 AC_ARG_WITH(xerces,
204     AS_HELP_STRING([--with-xerces=PATH],[where xerces-c is installed]),,
205     [with_xerces=/usr])
206 if test x_$with_xerces != x_/usr; then
207     CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
208     LIBS="-L${with_xerces}/lib -lxerces-c $LIBS"
209 else
210     LIBS="-lxerces-c $LIBS"
211 fi
212
213 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
214 AC_MSG_CHECKING([Xerces version])
215 AC_PREPROC_IFELSE(
216     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
217 [#if  _XERCES_VERSION != 20600
218 int i = 0;
219 #else
220 #error cannot use version 2.6.0
221 #endif])],
222     [AC_MSG_RESULT(OK)],
223     [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use a newer version])])
224 AC_LINK_IFELSE(
225     [AC_LANG_PROGRAM([[#include <xercesc/util/PlatformUtils.hpp>]],[[xercesc::XMLPlatformUtils::Initialize()]])],
226     ,[AC_MSG_ERROR([unable to link with Xerces])])
227
228 AC_MSG_CHECKING([whether Xerces XMLString::release(XMLByte**) exists])
229 AC_COMPILE_IFELSE(
230     [AC_LANG_PROGRAM([[#include <xercesc/util/XMLString.hpp>]],
231     [[using namespace XERCES_CPP_NAMESPACE; XMLByte* buf=NULL; XMLString::release(&buf);]])],
232     [AC_MSG_RESULT([yes])AC_DEFINE([OPENSAML_XERCESC_HAS_XMLBYTE_RELEASE],[1],[Define to 1 if Xerces XMLString includes XMLByte release.])],
233     [AC_MSG_RESULT([no])])
234
235 # XML-Security settings
236 AC_ARG_WITH(xmlsec,
237     AS_HELP_STRING([--with-xmlsec=PATH],[where xmlsec is installed]),,
238     [with_xmlsec=/usr])
239 if test x_$with_xmlsec != x_/usr; then
240     CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
241     LIBS="-L${with_xmlsec}/lib -lxml-security-c $LIBS"
242 else
243     LIBS="-lxml-security-c $LIBS"
244 fi
245 AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find xmlsec header files]))
246 AC_MSG_CHECKING([XML-Security version])
247 AC_PREPROC_IFELSE(
248     [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
249     [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3)
250 int i = 0;
251 #else
252 #error need version 1.4.0 or later
253 #endif])],
254     [AC_MSG_RESULT(OK)],
255     [AC_MSG_FAILURE([XML-Security version 1.4.0 or greater is required.])])
256     AC_LINK_IFELSE(
257         [AC_LANG_PROGRAM([[#include <xsec/utils/XSECPlatformUtils.hpp>]],
258             [[XSECPlatformUtils::Initialise()]])],,
259         [AC_MSG_ERROR([unable to link with XML-Security])])
260
261 # XML-Tooling settings
262 AC_ARG_WITH(xmltooling,
263     AS_HELP_STRING([--with-xmltooling=PATH],[where xmltooling is installed]),,
264     [with_xmltooling=/usr])
265 if test x_$with_xmltooling != x_/usr; then
266     CPPFLAGS="-I${with_xmltooling}/include $CPPFLAGS"
267     DX_INCLUDE="${with_xmltooling}/include"
268     LIBS="-L${with_xmltooling}/lib -lxmltooling $LIBS"
269 else
270     LIBS="-lxmltooling $LIBS"
271 fi
272
273 AC_CHECK_HEADER([xmltooling/XMLToolingConfig.h],,AC_MSG_ERROR([unable to find xmltooling header files]))
274
275 AC_LINK_IFELSE(
276     [AC_LANG_PROGRAM([[#include <xmltooling/XMLToolingConfig.h>
277 #include <xmltooling/version.h>]],
278         [[#if _XMLTOOLING_VERSION >= 10400
279 xmltooling::XMLToolingConfig::getConfig();
280 #else
281 #error Need XMLTooling version 1.4 or higher
282 #endif]])],
283     ,[AC_MSG_ERROR([unable to link with XMLTooling, or version was too old])])
284
285 # Check for unit test support
286 CXXTEST="/usr/bin/cxxtestgen.pl"
287 CXXTESTFLAGS=""
288 AC_ARG_WITH(cxxtest,
289     AS_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
290     [if test x_$with_cxxtest != x_/usr; then
291         CXXTEST="${with_cxxtest}/cxxtestgen.pl"
292         CXXTESTFLAGS="-I${with_cxxtest}"
293     fi])
294 if ! test -f "${CXXTEST}"; then
295     AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
296 fi
297
298 AC_SUBST(CXXTEST)
299 AC_SUBST(CXXTESTFLAGS)
300 AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
301
302 AX_CREATE_PKGCONFIG_INFO(,,[$LIBS -lsaml],[OpenSAML library])
303
304 AC_SUBST(DX_INCLUDE)
305 LIBTOOL="$LIBTOOL --silent"
306
307 # output packaging and makefiles
308 AC_OUTPUT