Update thread config macro, add openssl headers to libsaml build.
[shibboleth/cpp-opensaml.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([opensaml], [2.0], [mace-opensaml-users@internet2.edu], [saml])
3 AM_CONFIG_HEADER(config.h)
4 #AM_CONFIG_HEADER(saml/config_pub.h)
5 AM_INIT_AUTOMAKE([opensaml], [2.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(opensaml, doxygen.cfg, doc/api)
20 DX_INCLUDE=
21
22 AC_ARG_ENABLE(debug,
23     AC_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_PROG_CC([gcc gcc3 cc])
35 AC_PROG_CXX([g++ g++3 c++ CC])
36 AC_CANONICAL_HOST
37
38 if test "$GCC" = "yes" ; then
39 #    AC_HAVE_GCC_VERSION(4,0,0,0,
40 #        [
41 #        AC_DEFINE(GCC_HASCLASSVISIBILITY,1,
42 #            [Define to enable class visibility control in gcc.])
43 #        GCC_CFLAGS="$GCC_CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
44 #        GCC_CXXFLAGS="$GCC_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
45 #        ])
46     CFLAGS="$GCC_CFLAGS"
47     CXXFLAGS="$GCC_CXXFLAGS"
48 else
49 # Fix for Sun Workshop compiler in debug mode, may be Sun case #6360993
50         case "${host_cpu}-${host_os}" in
51                 *solaris*)
52                         if test "$CXX" = "CC" ; then
53                                 CXXFLAGS="$CXXFLAGS -Qoption ccfe -stabs=no%dfltlit+no%dflthlp"
54                         fi
55                 ;;
56         esac
57 fi
58
59 AC_DISABLE_STATIC
60 AC_PROG_LIBTOOL
61
62 # Checks for typedefs, structures, and compiler characteristics.
63 AC_C_CONST
64 AC_TYPE_SIZE_T
65
66 # Checks for library functions.
67 AC_CHECK_FUNCS([strchr strdup strstr])
68 AC_CHECK_SIZEOF(time_t)
69
70 # checks for pthreads
71 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
72 if test $enable_threads != "pthread"; then
73     AC_MSG_ERROR([unable to find pthreads, currently this is required])
74 else
75     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
76     LIBS="$PTHREAD_LIBS $LIBS"
77     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
78     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
79 fi
80
81 # zlib settings
82 AC_ARG_WITH(zlib,
83         AC_HELP_STRING([--with-zlib=PATH], [where zlib is installed]),
84         [
85                 if test -d "$withval"; then
86                         CPPFLAGS="${CPPFLAGS} -I$withval/include"
87                         LDFLAGS="${LDFLAGS} -L$withval/lib"
88                 fi
89         ]
90 )
91 AC_CHECK_HEADER([zlib.h],,AC_MSG_ERROR([unable to find zlib header files]))
92 AC_CHECK_LIB([z],[deflateInit2_],,AC_MSG_ERROR([unable to link with zlib library]))
93
94 # OpenSSL settings
95 AC_ARG_WITH(openssl,
96     AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
97     [if test x_$with_openssl != x_/usr; then
98         SSLFLAGS="-I${with_openssl}/include"
99     fi])
100
101 if test "x$SSLFLAGS" = "x" ; then
102     AC_PATH_PROG(PKG_CONFIG, pkg-config)
103     if test "x$PKG_CONFIG" != x && test "x$PKG_CONFIG" != "xno" ; then
104         if pkg-config openssl ; then
105             SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
106         else
107             AC_MSG_ERROR([OpenSSL not supported by pkg-config, try --with-openssl instead])
108         fi
109     fi
110 fi
111
112 AC_MSG_CHECKING(for OpenSSL cflags)
113 AC_MSG_RESULT($SSLFLAGS)
114 CPPFLAGS="$SSLFLAGS $CPPFLAGS"
115
116 AC_CHECK_HEADER([openssl/x509.h],,
117                 AC_MSG_ERROR([unable to find openssl header files]))
118
119 AC_LANG(C++)
120
121 # C++ requirements
122 AC_CXX_REQUIRE_STL
123 AC_CXX_NAMESPACES
124
125 # log4cpp settings
126 AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
127 AC_ARG_WITH(log4cpp,
128     AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
129     [
130     LOG4CPP_CONFIG="${with_log4cpp}"
131     if ! test -f "${LOG4CPP_CONFIG}" ; then
132         LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
133     fi
134     ])
135 if test -f "${LOG4CPP_CONFIG}"; then
136     LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
137     CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
138 else
139     AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
140     LIBS="-llog4cpp $LIBS"
141 fi
142 AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
143 AC_CHECK_HEADER([log4cpp/PropertyConfigurator.hh],,AC_MSG_ERROR([you need at least log4cpp 0.3.x]))
144 AC_TRY_LINK(
145         [#include <log4cpp/Category.hh>],
146         [log4cpp::Category::getInstance("foo")],
147         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
148         [AC_MSG_ERROR([unable to link with log4cpp])])
149
150 # Xerces settings
151 AC_ARG_WITH(xerces, 
152             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
153             [if test x_$with_xerces != x_/usr; then
154                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
155                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
156             fi])
157 LIBS="-lxerces-c $LIBS"
158 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
159 AC_MSG_CHECKING([Xerces version])
160 AC_PREPROC_IFELSE(
161     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
162 [#if  _XERCES_VERSION != 20600
163 int i = 0;
164 #else
165 #error cannot use version 2.6.0
166 #endif])],
167     [AC_MSG_RESULT(OK)],
168     [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])])
169 AC_TRY_LINK(
170     [#include <xercesc/util/PlatformUtils.hpp>],
171     [xercesc::XMLPlatformUtils::Initialize()],
172     [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
173     [AC_MSG_ERROR([unable to link with Xerces])])
174
175
176 # XML-Security settings
177 AC_ARG_WITH(xmlsec,
178     AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),
179     [if test x_$with_xmlsec != x_/usr; then
180         LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
181         CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
182     fi])
183 LIBS="-lxml-security-c $LIBS"
184 AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find xmlsec header files]))
185 AC_MSG_CHECKING([XML-Security version])
186 AC_PREPROC_IFELSE(
187     [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
188     [#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)
189 int i = 0;
190 #else
191 #error need version 1.3.1 or later
192 #endif])],
193     [AC_MSG_RESULT(OK)],
194     [AC_MSG_FAILURE([XML-Security version 1.3.1 or greater is required.])])
195 AC_TRY_LINK(
196     [#include <xsec/utils/XSECPlatformUtils.hpp>],
197     [XSECPlatformUtils::Initialise()],
198     [AC_DEFINE(HAVE_LIBXSEC,1,[Define if XML-Sec library was found])],
199     [AC_MSG_ERROR([unable to link with xmlsec library])]
200     )
201
202 # XML-Tooling settings
203 AC_ARG_WITH(xmltooling,
204     AC_HELP_STRING([--with-xmltooling=PATH], [where xmltooling is installed]),
205     [if test x_$with_xmltooling != x_/usr; then
206         LDFLAGS="-L${with_xmltooling}/lib $LDFLAGS"
207         CPPFLAGS="-I${with_xmltooling}/include $CPPFLAGS"
208         DX_INCLUDE="${with_xmltooling}/include"
209     fi])
210 LIBS="-lxmltooling $LIBS"
211 AC_CHECK_HEADER([xmltooling/XMLToolingConfig.h],,AC_MSG_ERROR([unable to find xmltooling header files]))
212 AC_TRY_LINK(
213     [#include <xmltooling/XMLToolingConfig.h>],
214     [xmltooling::XMLToolingConfig::getConfig().init()],
215     [AC_DEFINE(HAVE_LIBXMLTOOLING,1,[Define if XML-Tooling library was found])],
216     [AC_MSG_ERROR([unable to link with xmltooling library])]
217     )
218
219 # Does the STL in use help or screw us?
220 AC_TRY_LINK(
221     [#include <string>],
222     [std::basic_string<unsigned short> foo; foo=foo+(unsigned short)65],
223     [AC_DEFINE(HAVE_GOOD_STL,1,
224         [Define if you have an STL implementation that supports useful string specialization.])],
225     )
226
227 # Check for unit test support
228 CXXTEST="/usr/bin/cxxtestgen.pl"
229 CXXTESTFLAGS=""
230 AC_ARG_WITH(cxxtest,
231             AC_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
232             [if test x_$with_cxxtest != x_/usr; then
233                 CXXTEST="${with_cxxtest}/cxxtestgen.pl"
234                 CXXTESTFLAGS="-I${with_cxxtest}"
235             fi])
236 if ! test -f "${CXXTEST}"; then
237     AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
238 fi
239
240 AC_SUBST(CXXTEST)
241 AC_SUBST(CXXTESTFLAGS)
242 AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
243
244 AC_SUBST(DX_INCLUDE)
245 LIBTOOL="$LIBTOOL --silent"
246
247 # output makefiles
248 AC_OUTPUT(Makefile saml/Makefile samltest/Makefile schemas/Makefile)