Enable POSIX signatures on Solaris, and fix Unix directory parsing.
[shibboleth/cpp-opensaml.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([opensaml],[2.5],[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 AC_CHECK_SIZEOF(time_t)
74
75 # checks for pthreads
76 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
77 if test $enable_threads != "pthread"; then
78     AC_MSG_ERROR([unable to find pthreads, currently this is required])
79 else
80     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
81     LIBS="$PTHREAD_LIBS $LIBS"
82     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
83     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
84 fi
85
86 # zlib settings
87 AC_ARG_WITH(zlib,
88     AS_HELP_STRING([--with-zlib=PATH],[where zlib is installed]),
89     [
90         if test -d "$withval" ; then
91             CPPFLAGS="${CPPFLAGS} -I$withval/include"
92             LDFLAGS="${LDFLAGS} -L$withval/lib"
93         fi
94     ]
95 )
96
97 AC_ARG_WITH(zlib,
98     AS_HELP_STRING([--with-zlib=PATH],[where zlib is installed]),,
99     [with_zlib=/usr])
100 if test x_$with_zlib != x_/usr; then
101     CPPFLAGS="-I${with_zlib}/include $CPPFLAGS"
102     LIBS="-L${with_zlib}/lib -lz $LIBS"
103 else
104     LIBS="-lz $LIBS"
105 fi
106
107 AC_CHECK_HEADER([zlib.h],,AC_MSG_ERROR([unable to find zlib header files]))
108 AC_LINK_IFELSE(
109     [AC_LANG_PROGRAM([[#include <zlib.h>]],
110         [[zlibVersion()]])],,
111     [AC_MSG_ERROR([unable to link with zlib])])
112
113
114 # OpenSSL settings
115 AC_ARG_WITH(openssl,
116     AS_HELP_STRING([--with-openssl=PATH],[where openssl is installed]),
117     [if test x_$with_openssl != x_/usr; then
118         SSLFLAGS="-I${with_openssl}/include"
119     fi])
120
121 if test "x$with_openssl" = "x" ; then
122     AC_PATH_PROG(PKG_CONFIG, pkg-config)
123     if test "x$PKG_CONFIG" != x && test "x$PKG_CONFIG" != "xno" ; then
124         if pkg-config openssl ; then
125             SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
126         else
127             AC_MSG_WARN([OpenSSL not supported by pkg-config, try --with-openssl instead])
128         fi
129     fi
130 fi
131
132 AC_MSG_CHECKING(for OpenSSL cflags)
133 AC_MSG_RESULT($SSLFLAGS)
134 CPPFLAGS="$SSLFLAGS $CPPFLAGS"
135
136 AC_CHECK_HEADER([openssl/x509.h],,AC_MSG_ERROR([unable to find openssl header files]))
137
138 AC_LANG([C++])
139
140 # C++ requirements
141 AC_CXX_NAMESPACES
142 AC_CXX_REQUIRE_STL
143
144 # log4shib settings (favor this version over the log4cpp code)
145 AC_PATH_PROG(LOG4SHIB_CONFIG,log4shib-config)
146 AC_ARG_WITH(log4shib,
147     AS_HELP_STRING([--with-log4shib=PATH],[where log4shib-config is installed]),
148     [
149     LOG4SHIB_CONFIG="${with_log4shib}"
150     if ! test -f "${LOG4SHIB_CONFIG}"; then
151         LOG4SHIB_CONFIG="${with_log4shib}/bin/log4shib-config"
152     fi
153     ])
154 if test -f "${LOG4SHIB_CONFIG}" ; then
155     LIBS="`${LOG4SHIB_CONFIG} --libs` $LIBS"
156     CPPFLAGS="`${LOG4SHIB_CONFIG} --cflags` $CPPFLAGS"
157         AC_CHECK_HEADER([log4shib/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4shib header files]))
158     AC_LINK_IFELSE(
159         [AC_LANG_PROGRAM([[#include <log4shib/Category.hh>
160 #include <log4shib/CategoryStream.hh>]],
161             [[log4shib::Category::getInstance("foo").errorStream() << log4shib::eol]])],
162         [AC_DEFINE([OPENSAML_LOG4SHIB],[1],[Define to 1 if log4shib library is used.])],
163         [AC_MSG_ERROR([unable to link with log4shib])])
164 else
165     AC_MSG_WARN([log4shib-config not found, may need to use --with-log4shib option])
166     AC_MSG_WARN([will look for original log4cpp library])
167     
168     # log4cpp settings
169     AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
170     AC_ARG_WITH(log4cpp,
171         AS_HELP_STRING([--with-log4cpp=PATH],[where log4cpp-config is installed]),
172         [
173         LOG4CPP_CONFIG="${with_log4cpp}"
174         if ! test -f "${LOG4CPP_CONFIG}"; then
175                 LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
176         fi
177         ])
178     if test -f "${LOG4CPP_CONFIG}"; then
179         AC_MSG_WARN([will try to use log4cpp, note that most non-Internet2 supplied versions are not thread-safe])
180         LIBS="`${LOG4CPP_CONFIG} --libs` $LIBS"
181         CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
182         AC_CHECK_HEADER([log4cpp/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
183         AC_LINK_IFELSE(
184             [AC_LANG_PROGRAM([[#include <log4cpp/Category.hh>
185 #include <log4cpp/CategoryStream.hh>]],
186                 [[log4cpp::Category::getInstance("foo").errorStream() << log4cpp::eol]])],
187             [AC_DEFINE([OPENSAML_LOG4CPP],[1],[Define to 1 if log4cpp library is used.])],
188             [AC_MSG_ERROR([unable to link with log4cpp, need version 1.0 or later])])
189     else
190         AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
191     fi
192 fi
193
194 # Xerces settings
195 AC_ARG_WITH(xerces,
196     AS_HELP_STRING([--with-xerces=PATH],[where xerces-c is installed]),,
197     [with_xerces=/usr])
198 if test x_$with_xerces != x_/usr; then
199     CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
200     LIBS="-L${with_xerces}/lib -lxerces-c $LIBS"
201 else
202     LIBS="-lxerces-c $LIBS"
203 fi
204
205 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
206 AC_MSG_CHECKING([Xerces version])
207 AC_PREPROC_IFELSE(
208     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
209 [#if  _XERCES_VERSION != 20600
210 int i = 0;
211 #else
212 #error cannot use version 2.6.0
213 #endif])],
214     [AC_MSG_RESULT(OK)],
215     [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use a newer version])])
216 AC_LINK_IFELSE(
217     [AC_LANG_PROGRAM([[#include <xercesc/util/PlatformUtils.hpp>]],[[xercesc::XMLPlatformUtils::Initialize()]])],
218     ,[AC_MSG_ERROR([unable to link with Xerces])])
219
220 AC_MSG_CHECKING([whether Xerces XMLString::release(XMLByte**) exists])
221 AC_COMPILE_IFELSE(
222     [AC_LANG_PROGRAM([[#include <xercesc/util/XMLString.hpp>]],
223     [[using namespace XERCES_CPP_NAMESPACE; XMLByte* buf=NULL; XMLString::release(&buf);]])],
224     [AC_MSG_RESULT([yes])AC_DEFINE([OPENSAML_XERCESC_HAS_XMLBYTE_RELEASE],[1],[Define to 1 if Xerces XMLString includes XMLByte release.])],
225     [AC_MSG_RESULT([no])])
226
227 # XML-Security settings
228 AC_ARG_WITH(xmlsec,
229     AS_HELP_STRING([--with-xmlsec=PATH],[where xmlsec is installed]),,
230     [with_xmlsec=/usr])
231 if test x_$with_xmlsec != x_/usr; then
232     CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
233     LIBS="-L${with_xmlsec}/lib -lxml-security-c $LIBS"
234 else
235     LIBS="-lxml-security-c $LIBS"
236 fi
237 AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find xmlsec header files]))
238 AC_MSG_CHECKING([XML-Security version])
239 AC_PREPROC_IFELSE(
240     [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
241     [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3)
242 int i = 0;
243 #else
244 #error need version 1.4.0 or later
245 #endif])],
246     [AC_MSG_RESULT(OK)],
247     [AC_MSG_FAILURE([XML-Security version 1.4.0 or greater is required.])])
248     AC_LINK_IFELSE(
249         [AC_LANG_PROGRAM([[#include <xsec/utils/XSECPlatformUtils.hpp>]],
250             [[XSECPlatformUtils::Initialise()]])],,
251         [AC_MSG_ERROR([unable to link with XML-Security])])
252
253 # XML-Tooling settings
254 AC_ARG_WITH(xmltooling,
255     AS_HELP_STRING([--with-xmltooling=PATH],[where xmltooling is installed]),,
256     [with_xmltooling=/usr])
257 if test x_$with_xmltooling != x_/usr; then
258     CPPFLAGS="-I${with_xmltooling}/include $CPPFLAGS"
259     DX_INCLUDE="${with_xmltooling}/include"
260     LIBS="-L${with_xmltooling}/lib -lxmltooling $LIBS"
261 else
262     LIBS="-lxmltooling $LIBS"
263 fi
264
265 AC_CHECK_HEADER([xmltooling/XMLToolingConfig.h],,AC_MSG_ERROR([unable to find xmltooling header files]))
266
267 AC_LINK_IFELSE(
268     [AC_LANG_PROGRAM([[#include <xmltooling/XMLToolingConfig.h>
269 #include <xmltooling/version.h>]],
270         [[#if _XMLTOOLING_VERSION >= 10400
271 xmltooling::XMLToolingConfig::getConfig();
272 #else
273 #error Need XMLTooling version 1.4 or higher
274 #endif]])],
275     ,[AC_MSG_ERROR([unable to link with XMLTooling, or version was too old])])
276
277 # Check for unit test support
278 CXXTEST="/usr/bin/cxxtestgen.pl"
279 CXXTESTFLAGS=""
280 AC_ARG_WITH(cxxtest,
281     AS_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
282     [if test x_$with_cxxtest != x_/usr; then
283         CXXTEST="${with_cxxtest}/cxxtestgen.pl"
284         CXXTESTFLAGS="-I${with_cxxtest}"
285     fi])
286 if ! test -f "${CXXTEST}"; then
287     AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
288 fi
289
290 AC_SUBST(CXXTEST)
291 AC_SUBST(CXXTESTFLAGS)
292 AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
293
294 AX_CREATE_PKGCONFIG_INFO(,,[$LIBS -lsaml],[OpenSAML library])
295
296 AC_SUBST(DX_INCLUDE)
297 LIBTOOL="$LIBTOOL --silent"
298
299 # output packaging and makefiles
300 AC_OUTPUT