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