Fix test for non-plugin remoting in SP.
[shibboleth/cpp-sp-resolver.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([shibboleth-resolver], [0.2], [MOONSHOT-COMMUNITY@JISCMAIL.AC.UK], [shibboleth-resolver])
3 AC_CONFIG_SRCDIR(src)
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 AC_ARG_ENABLE(debug,
11     AS_HELP_STRING([--enable-debug],[Have GCC compile with symbols (Default = no)]),
12     enable_debug=$enableval, enable_debug=no)
13
14 if test "$enable_debug" = "yes" ; then
15     GCC_CFLAGS="$CFLAGS -g -D_DEBUG"
16     GCC_CXXFLAGS="$CXXFLAGS -g -D_DEBUG"
17 else
18     GCC_CFLAGS="$CFLAGS -O2 -DNDEBUG"
19     GCC_CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG"
20 fi
21
22 AC_CONFIG_HEADERS([config.h])
23 AC_CONFIG_FILES([resolver.spec Portfile])
24 AC_CONFIG_FILES([Makefile doc/Makefile src/shibresolver/Makefile])
25
26 AC_PROG_CC([gcc gcc3 cc])
27 AC_PROG_CXX([g++ g++3 c++ CC])
28 AC_CANONICAL_HOST
29
30 if test "$GCC" = "yes" ; then
31 #    AC_HAVE_GCC_VERSION(4,0,0,0,
32 #        [
33 #        AC_DEFINE(GCC_HASCLASSVISIBILITY,1,
34 #            [Define to enable class visibility control in gcc.])
35 #        GCC_CFLAGS="$GCC_CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
36 #        GCC_CXXFLAGS="$GCC_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
37 #        ])
38     CFLAGS="-Wall $GCC_CFLAGS"
39     CXXFLAGS="-Wall $GCC_CXXFLAGS"
40 else
41 # Fix for Sun Workshop compiler in debug mode, may be Sun case #6360993
42         case "${host_cpu}-${host_os}" in
43                 *solaris*)
44                         if test "$CXX" = "CC" ; then
45                                 CXXFLAGS="$CXXFLAGS -Qoption ccfe -stabs=no%dfltlit+no%dflthlp"
46                         fi
47                         ;;
48                 *osf*)
49                         CXXFLAGS="$CXXFLAGS -D_POSIX_PII_SOCKET"
50                         ;;
51         esac
52 fi
53
54 AC_LANG(C)
55
56 # Checks for typedefs, structures, and compiler characteristics.
57 AC_C_CONST
58 AC_TYPE_SIZE_T
59 AC_STRUCT_TM
60
61 # Checks for library functions.
62 AC_CHECK_FUNCS([strcasecmp])
63
64 # checks for pthreads
65 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
66 if test $enable_threads != "pthread"; then
67     AC_MSG_ERROR([unable to find pthreads, currently this is required])
68 else
69     AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])
70     LIBS="$PTHREAD_LIBS $LIBS"
71     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
72     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
73 fi
74
75 AC_LANG(C++)
76
77 # C++ requirements
78 AC_CXX_NAMESPACES
79 AC_CXX_REQUIRE_STL
80
81 # are covariant methods allowed?
82 AC_LINK_IFELSE(
83     [AC_LANG_PROGRAM([[]],
84         [[
85         class base { public: virtual base *GetPtr( void ) { return this; } };
86         class derived: virtual public base { public: virtual derived *GetPtr( void ) { return this; } };
87         ]])],
88     [AC_DEFINE([HAVE_COVARIANT_RETURNS],[1],[Define to 1 if C++ compiler supports covariant virtual methods.])])
89
90 # is nullptr supported?
91 AC_COMPILE_IFELSE(
92     [AC_LANG_PROGRAM([[]],[[const char* ptr = nullptr;]])],
93     [AC_DEFINE([HAVE_NULLPTR],[1],[Define to 1 if C++ compiler supports nullptr keyword.])])
94
95 # log4shib settings (favor this version over the log4cpp code)
96 AC_PATH_PROG(LOG4SHIB_CONFIG,log4shib-config)
97 AC_ARG_WITH(log4shib,
98     AS_HELP_STRING([--with-log4shib=PATH],[where log4shib-config is installed]),
99     [
100     LOG4SHIB_CONFIG="${with_log4shib}"
101     if ! test -f "${LOG4SHIB_CONFIG}" ; then
102         LOG4SHIB_CONFIG="${with_log4shib}/bin/log4shib-config"
103     fi
104     ])
105 if test -f "${LOG4SHIB_CONFIG}"; then
106     LDFLAGS="`${LOG4SHIB_CONFIG} --libs` $LDFLAGS"
107     CPPFLAGS="`${LOG4SHIB_CONFIG} --cflags` $CPPFLAGS"
108         AC_CHECK_HEADER([log4shib/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4shib header files]))
109     AC_LINK_IFELSE(
110         [AC_LANG_PROGRAM([[#include <log4shib/Category.hh>
111 #include <log4shib/CategoryStream.hh>]],
112             [[log4shib::Category::getInstance("foo").errorStream() << log4shib::eol]])],
113         [AC_DEFINE([SHIBRESOLVER_LOG4SHIB],[1],[Define to 1 if log4shib library is used.])],
114         [AC_MSG_ERROR([unable to link with log4shib])])
115 else
116     AC_MSG_WARN([log4shib-config not found, may need to use --with-log4shib option])
117     AC_MSG_WARN([will look for original log4cpp library])
118     
119         # log4cpp settings
120         AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
121         AC_ARG_WITH(log4cpp,
122             AS_HELP_STRING([--with-log4cpp=PATH],[where log4cpp-config is installed]),
123             [
124             LOG4CPP_CONFIG="${with_log4cpp}"
125             if ! test -f "${LOG4CPP_CONFIG}" ; then
126                 LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
127             fi
128             ])
129         if test -f "${LOG4CPP_CONFIG}"; then
130                 AC_MSG_WARN([will try to use log4cpp, note that most non-Internet2 supplied versions are not thread-safe])
131             LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
132             CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
133                 AC_CHECK_HEADER([log4cpp/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
134         AC_LINK_IFELSE(
135             [AC_LANG_PROGRAM([[#include <log4cpp/Category.hh>
136 #include <log4cpp/CategoryStream.hh>]],
137                 [[log4cpp::Category::getInstance("foo").errorStream() << log4cpp::eol]])],
138             [AC_DEFINE([SHIBRESOLVER_LOG4CPP],[1],[Define to 1 if log4cpp library is used.])],
139             [AC_MSG_ERROR([unable to link with log4cpp, need version 1.0 or later])])
140         else
141             AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
142         fi
143 fi
144
145 # Xerces settings
146 # Xerces settings
147 AC_ARG_WITH(xerces,
148     AS_HELP_STRING([--with-xerces=PATH],[where xerces-c is installed]),
149     [if test x_$with_xerces != x_/usr; then
150         LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
151         CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
152     fi])
153 LIBS="-lxerces-c $LIBS"
154 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,AC_MSG_ERROR([unable to find xerces header files]))
155 AC_MSG_CHECKING([Xerces version])
156 AC_PREPROC_IFELSE(
157     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
158 [#if  _XERCES_VERSION != 20600
159 int i = 0;
160 #else
161 #error cannot use version 2.6.0
162 #endif])],
163     [AC_MSG_RESULT(OK)],
164     [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use a newer version])])
165 AC_LINK_IFELSE(
166     [AC_LANG_PROGRAM([[#include <xercesc/util/PlatformUtils.hpp>]],
167         [[xercesc::XMLPlatformUtils::Initialize()]])],
168     ,[AC_MSG_ERROR([unable to link with Xerces])])
169
170
171 #XML-Tooling settings
172 AC_ARG_WITH(xmltooling,
173     AS_HELP_STRING([--with-xmltooling=PATH],[where xmltooling-c is installed]),
174     [if test x_$with_xmltooling != x_/usr; then
175         LDFLAGS="-L${with_xmltooling}/lib $LDFLAGS"
176         CPPFLAGS="-I${with_xmltooling}/include $CPPFLAGS"
177     fi])
178 LITE_LIBS="-lxmltooling-lite"
179 XMLSEC_LIBS="-lxmltooling"
180 AC_CHECK_HEADER([xmltooling/base.h],,AC_MSG_ERROR([unable to find xmltooling header files]))
181
182 # XML-Security settings
183 AC_ARG_WITH(xmlsec,
184     AS_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
185     [with_xmlsec=/usr])
186
187 if test x_$with_xmlsec != x_/usr; then
188     LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
189     CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
190 fi        
191 XMLSEC_LIBS="-lxml-security-c $XMLSEC_LIBS"
192
193 # save and append master libs
194 save_LIBS="$LIBS"
195 LIBS="$XMLSEC_LIBS $LIBS"
196
197 AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
198 AC_MSG_CHECKING([XML-Security version])
199 AC_PREPROC_IFELSE(
200     [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
201     [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3)
202 int i = 0;
203 #else
204 #error need version 1.4.0 or later
205 #endif])],
206     [AC_MSG_RESULT(OK)],
207     [AC_MSG_FAILURE([XML-Security version 1.4.0 or greater is required.])])
208 AC_LINK_IFELSE(
209     [AC_LANG_PROGRAM([[#include <xsec/utils/XSECPlatformUtils.hpp>]],
210         [[XSECPlatformUtils::Initialise()]])],,
211     [AC_MSG_ERROR([unable to link with XML-Security])])
212
213 # restore master libs
214 LIBS="$save_LIBS"
215
216 # OpenSAML settings
217 AC_ARG_WITH(saml,
218     AS_HELP_STRING([--with-saml=PATH],[where saml is installed]),
219     [if test x_$with_saml != x_/usr; then
220         LDFLAGS="-L${with_saml}/lib $LDFLAGS"
221         CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
222     fi])
223 XMLSEC_LIBS="-lsaml $XMLSEC_LIBS"
224
225 # save and append master libs
226 save_LIBS="$LIBS"
227 LIBS="$XMLSEC_LIBS $LIBS"
228
229 AC_CHECK_HEADER([saml/saml2/metadata/Metadata.h],,AC_MSG_ERROR([unable to find OpenSAML header files]))
230 AC_LINK_IFELSE(
231     [AC_LANG_PROGRAM([[#include <saml/SAMLConfig.h>]],
232     [[opensaml::SAMLConfig::getConfig()]])],
233     ,[AC_MSG_ERROR([unable to link with OpenSAML])])
234
235 # restore master libs
236 LIBS="$save_LIBS"
237
238 # Shibboleth SP settings
239 AC_ARG_WITH(shibsp,
240     AS_HELP_STRING([--with-shibsp=PATH],[where Shibboleth SP is installed]),
241     [if test x_$with_shibsp != x_/usr; then
242         LDFLAGS="-L${with_shibsp}/lib $LDFLAGS"
243         CPPFLAGS="-I${with_shibsp}/include $CPPFLAGS"
244     fi])
245 LITE_LIBS="-lshibsp-lite $LITE_LIBS"
246 XMLSEC_LIBS="-lshibsp $XMLSEC_LIBS"
247
248 # save and append master libs
249 save_LIBS="$LIBS"
250 LIBS="$XMLSEC_LIBS $LIBS"
251
252 AC_CHECK_HEADER([shibsp/SPConfig.h],,AC_MSG_ERROR([unable to find Shibboleth SP header files]))
253 AC_LINK_IFELSE(
254     [AC_LANG_PROGRAM([[#include <shibsp/SPConfig.h>]],
255     [[shibsp::SPConfig::getConfig()]])],
256     ,[AC_MSG_ERROR([unable to link with Shibboleth SP])])
257
258 AC_MSG_CHECKING([whether SP library supports non-plugin remoting])
259 AC_COMPILE_IFELSE(
260     [AC_LANG_PROGRAM(
261     [[
262 #include <vector>
263 #include <shibsp/ServiceProvider.h>
264     ]],
265     [[shibsp::ServiceProvider* sp; sp->regListener(NULL,NULL);]])],
266     [AC_MSG_RESULT([yes])AC_DEFINE([SHIBRESOLVER_SHIBSP_HAS_REMOTING],[1],[Define to 1 if Shibboleth SP supports non-plugin remoting.])],
267     [AC_MSG_RESULT([no])])
268
269 # restore master libs
270 LIBS="$save_LIBS"
271
272 AC_SUBST(LITE_LIBS)
273 AC_SUBST(XMLSEC_LIBS)
274
275 LIBTOOL="$LIBTOOL --silent"
276
277 AC_OUTPUT