Update README with bug fix list.
[shibboleth/cpp-opensaml.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([opensaml], [2.1], [mace-opensaml-users@internet2.edu], [saml])
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE([opensaml], [2.1])
5
6 sinclude(doxygen.m4)
7 sinclude(acx_pthread.m4)
8
9 # Docygen features
10 DX_HTML_FEATURE(ON)
11 DX_CHM_FEATURE(OFF)
12 DX_CHI_FEATURE(OFF)
13 DX_MAN_FEATURE(OFF)
14 DX_RTF_FEATURE(OFF)
15 DX_XML_FEATURE(OFF)
16 DX_PDF_FEATURE(OFF)
17 DX_PS_FEATURE(OFF)
18 DX_INIT_DOXYGEN(opensaml, doxygen.cfg, doc/api)
19 DX_INCLUDE=
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 AC_CANONICAL_HOST
36
37 if test "$GCC" = "yes" ; then
38 #    AC_HAVE_GCC_VERSION(4,0,0,0,
39 #        [
40 #        AC_DEFINE(GCC_HASCLASSVISIBILITY,1,
41 #            [Define to enable class visibility control in gcc.])
42 #        GCC_CFLAGS="$GCC_CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
43 #        GCC_CXXFLAGS="$GCC_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
44 #        ])
45     CFLAGS="$GCC_CFLAGS"
46     CXXFLAGS="$GCC_CXXFLAGS"
47 else
48 # Fix for Sun Workshop compiler in debug mode, may be Sun case #6360993
49         case "${host_cpu}-${host_os}" in
50                 *solaris*)
51                         if test "$CXX" = "CC" ; then
52                                 CXXFLAGS="$CXXFLAGS -Qoption ccfe -stabs=no%dfltlit+no%dflthlp"
53                         fi
54                 ;;
55         esac
56 fi
57
58 AC_DISABLE_STATIC
59 AC_PROG_LIBTOOL
60
61 # Checks for typedefs, structures, and compiler characteristics.
62 AC_C_CONST
63 AC_TYPE_SIZE_T
64
65 # Checks for library functions.
66 AC_CHECK_FUNCS([strchr strdup strstr])
67 AC_CHECK_SIZEOF(time_t)
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     LIBS="$PTHREAD_LIBS $LIBS"
76     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
77     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
78 fi
79
80 # zlib settings
81 AC_ARG_WITH(zlib,
82         AC_HELP_STRING([--with-zlib=PATH], [where zlib is installed]),
83         [
84                 if test -d "$withval"; then
85                         CPPFLAGS="${CPPFLAGS} -I$withval/include"
86                         LDFLAGS="${LDFLAGS} -L$withval/lib"
87                 fi
88         ]
89 )
90 AC_CHECK_HEADER([zlib.h],,AC_MSG_ERROR([unable to find zlib header files]))
91 AC_CHECK_LIB([z],[deflateInit2_],,AC_MSG_ERROR([unable to link with zlib library]))
92
93 # OpenSSL settings
94 AC_ARG_WITH(openssl,
95     AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
96     [if test x_$with_openssl != x_/usr; then
97         SSLFLAGS="-I${with_openssl}/include"
98     fi])
99
100 if test "x$SSLFLAGS" = "x" ; then
101     AC_PATH_PROG(PKG_CONFIG, pkg-config)
102     if test "x$PKG_CONFIG" != x && test "x$PKG_CONFIG" != "xno" ; then
103         if pkg-config openssl ; then
104             SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
105         else
106             AC_MSG_ERROR([OpenSSL not supported by pkg-config, try --with-openssl instead])
107         fi
108     fi
109 fi
110
111 AC_MSG_CHECKING(for OpenSSL cflags)
112 AC_MSG_RESULT($SSLFLAGS)
113 CPPFLAGS="$SSLFLAGS $CPPFLAGS"
114
115 AC_CHECK_HEADER([openssl/x509.h],,
116                 AC_MSG_ERROR([unable to find openssl header files]))
117
118 AC_LANG(C++)
119
120 # C++ requirements
121 AC_CXX_REQUIRE_STL
122 AC_CXX_NAMESPACES
123
124 # log4shib settings (favor this version over the log4cpp code)
125 AC_PATH_PROG(LOG4SHIB_CONFIG,log4shib-config)
126 AC_ARG_WITH(log4shib,
127     AC_HELP_STRING([--with-log4shib=PATH], [where log4shib-config is installed]),
128     [
129     LOG4SHIB_CONFIG="${with_log4shib}"
130     if ! test -f "${LOG4SHIB_CONFIG}" ; then
131         LOG4SHIB_CONFIG="${with_log4shib}/bin/log4shib-config"
132     fi
133     ])
134 if test -f "${LOG4SHIB_CONFIG}"; then
135     LDFLAGS="`${LOG4SHIB_CONFIG} --libs` $LDFLAGS"
136     CPPFLAGS="`${LOG4SHIB_CONFIG} --cflags` $CPPFLAGS"
137         AC_CHECK_HEADER([log4shib/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4shib header files]))
138         AC_TRY_LINK(
139                 [#include <log4shib/Category.hh>
140 #include <log4shib/CategoryStream.hh>],
141                 [log4shib::Category::getInstance("foo").errorStream() << log4shib::eol],
142                 [AC_DEFINE(OPENSAML_LOG4SHIB,1,[Define if log4shib library is used.])],
143                 [AC_MSG_ERROR([unable to link with log4shib])])
144 else
145     AC_MSG_WARN([log4shib-config not found, may need to use --with-log4shib option])
146     AC_MSG_WARN([will look for original log4cpp library])
147     
148         # log4cpp settings
149         AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
150         AC_ARG_WITH(log4cpp,
151             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
152             [
153             LOG4CPP_CONFIG="${with_log4cpp}"
154             if ! test -f "${LOG4CPP_CONFIG}" ; then
155                 LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
156             fi
157             ])
158         if test -f "${LOG4CPP_CONFIG}"; then
159                 AC_MSG_WARN([will try to use log4cpp, note that most non-Internet2 supplied versions are not thread-safe])
160             LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
161             CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
162                 AC_CHECK_HEADER([log4cpp/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
163                 AC_TRY_LINK(
164                         [#include <log4cpp/Category.hh>
165 #include <log4cpp/CategoryStream.hh>],
166                         [log4cpp::Category::getInstance("foo").errorStream() << log4cpp::eol],
167                         [AC_DEFINE(OPENSAML_LOG4CPP,1,[Define if log4cpp library is used.])],
168                         [AC_MSG_ERROR([unable to link with log4cpp, need version 1.0 or later])])
169         else
170             AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
171         fi
172 fi
173
174 # Xerces settings
175 AC_ARG_WITH(xerces, 
176             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
177             [if test x_$with_xerces != x_/usr; then
178                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
179                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
180             fi])
181 LIBS="-lxerces-c $LIBS"
182 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
183 AC_MSG_CHECKING([Xerces version])
184 AC_PREPROC_IFELSE(
185     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
186 [#if  _XERCES_VERSION != 20600
187 int i = 0;
188 #else
189 #error cannot use version 2.6.0
190 #endif])],
191     [AC_MSG_RESULT(OK)],
192     [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use special 2.6.1 tarball provided by Shibboleth Project])])
193 AC_TRY_LINK(
194     [#include <xercesc/util/PlatformUtils.hpp>],
195     [xercesc::XMLPlatformUtils::Initialize()],
196     [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
197     [AC_MSG_ERROR([unable to link with Xerces])])
198
199
200 # XML-Security settings
201 AC_ARG_WITH(xmlsec,
202     AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),
203     [if test x_$with_xmlsec != x_/usr; then
204         LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
205         CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
206     fi])
207 LIBS="-lxml-security-c $LIBS"
208 AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find xmlsec header files]))
209 AC_MSG_CHECKING([XML-Security version])
210 AC_PREPROC_IFELSE(
211     [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
212     [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3)
213 int i = 0;
214 #else
215 #error need version 1.4.0 or later
216 #endif])],
217     [AC_MSG_RESULT(OK)],
218     [AC_MSG_FAILURE([XML-Security version 1.4.0 or greater is required.])])
219 AC_TRY_LINK(
220     [#include <xsec/utils/XSECPlatformUtils.hpp>],
221     [XSECPlatformUtils::Initialise()],
222     [AC_DEFINE(HAVE_LIBXSEC,1,[Define if XML-Security library was found])],
223     [AC_MSG_ERROR([unable to link with XML-Security library])]
224     )
225
226 # XML-Tooling settings
227 AC_ARG_WITH(xmltooling,
228     AC_HELP_STRING([--with-xmltooling=PATH], [where xmltooling is installed]),
229     [if test x_$with_xmltooling != x_/usr; then
230         LDFLAGS="-L${with_xmltooling}/lib $LDFLAGS"
231         CPPFLAGS="-I${with_xmltooling}/include $CPPFLAGS"
232         DX_INCLUDE="${with_xmltooling}/include"
233     fi])
234 LIBS="-lxmltooling $LIBS"
235 AC_CHECK_HEADER([xmltooling/XMLToolingConfig.h],,AC_MSG_ERROR([unable to find xmltooling header files]))
236 AC_TRY_LINK(
237     [#include <xmltooling/XMLToolingConfig.h>],
238     [xmltooling::XMLToolingConfig::getConfig().init()],
239     [AC_DEFINE(HAVE_LIBXMLTOOLING,1,[Define if XML-Tooling library was found])],
240     [AC_MSG_ERROR([unable to link with xmltooling library])]
241     )
242
243 # Check for unit test support
244 CXXTEST="/usr/bin/cxxtestgen.pl"
245 CXXTESTFLAGS=""
246 AC_ARG_WITH(cxxtest,
247             AC_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
248             [if test x_$with_cxxtest != x_/usr; then
249                 CXXTEST="${with_cxxtest}/cxxtestgen.pl"
250                 CXXTESTFLAGS="-I${with_cxxtest}"
251             fi])
252 if ! test -f "${CXXTEST}"; then
253     AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
254 fi
255
256 AC_SUBST(CXXTEST)
257 AC_SUBST(CXXTESTFLAGS)
258 AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
259
260 AC_SUBST(DX_INCLUDE)
261 LIBTOOL="$LIBTOOL --silent"
262
263 # output makefiles
264 AC_OUTPUT(Makefile saml/Makefile samltest/Makefile samlsign/Makefile schemas/Makefile doc/Makefile)