Properly find Xerces-C 2.2 (it needs a namespace)
[shibboleth/sp.git] / configure.ac
1 dnl $Id$ 
2
3 AC_PREREQ([2.50])
4 AC_INIT([shibboleth], [0.8], [mace-shib-users@internet2.edu], [shibboleth])
5 AM_CONFIG_HEADER(config.h)
6 AM_INIT_AUTOMAKE(shibboleth, 0.8)
7
8 sinclude(acx_pthread.m4)
9 sinclude(acx_rpctest.m4)
10
11 AC_PROG_CC([gcc3 gcc cc])
12 AC_PROG_CXX([g++3 g++ c++ CC])
13 AC_DISABLE_STATIC
14 AC_PROG_LIBTOOL
15
16 AC_LANG(C++)
17
18 # Checks for typedefs, structures, and compiler characteristics.
19 AC_C_CONST
20 AC_TYPE_SIZE_T
21 AC_STRUCT_TM
22
23 # Checks for library functions.
24 AC_FUNC_STRFTIME
25 AC_CHECK_FUNCS([strchr strdup strstr gmtime_r strcasecmp])
26 AC_CHECK_HEADERS([dlfcn.h])
27
28 # C++ requirements
29 AC_CXX_REQUIRE_STL
30 AC_CXX_NAMESPACES
31
32
33 # old_LIBS="$LIBS"
34 # AC_SEARCH_LIBS(xdr_uint64_t,nsl,,
35 #       [CFLAGS="$CFLAGS -DNEED_XDR_LONGLONG"
36 #        CXXFLAGS="$CXXFLAGS -DNEED_XDR_LONGLONG"])
37 # LIBS="$old_LIBS"
38
39 # checks for pthreads
40 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
41 if test $enable_threads != "pthread"; then
42     AC_MSG_ERROR([unable to find pthreads, currently this is required])
43 else
44     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
45     LIBS="$PTHREAD_LIBS $LIBS"
46     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
47     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
48 fi
49
50 # Test RPC now -- deal with it later
51 ACX_RPCTEST([rpctest="yes"],[rpctest="no"])
52
53 AC_ARG_WITH(dmalloc,
54             AC_HELP_STRING([--with-dmalloc=PATH], [where dmalloc is installed]),
55             [if test x_$with_dmalloc != x_/usr; then
56                 LDFLAGS="-L${with_dmalloc}/lib $LDFLAGS"
57                 CPPFLAGS="-I${with_dmalloc}/include $CPPFLAGS"
58             fi
59             AC_CHECK_LIB(dmallocxx, dmalloc_shutdown,,
60                          AC_MSG_ERROR([unable to find dmallocxx library]))
61             ])
62
63 AC_ARG_WITH(xerces, 
64             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
65             [if test x_$with_xerces != x_/usr; then
66                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
67                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
68             fi])
69
70
71 AC_ARG_WITH(openssl, 
72             AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
73             [if test x_$with_openssl != x_/usr; then
74                 LDFLAGS="-L${with_openssl}/lib $LDFLAGS"
75                 CPPFLAGS="-I${with_openssl}/include $CPPFLAGS"
76             fi])
77
78 AC_ARG_WITH(log4cpp, 
79             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp is installed]),
80             [if test x_$with_log4cpp != x_/usr; then
81                 LDFLAGS="-L${with_log4cpp}/lib $LDFLAGS"
82                 CPPFLAGS="-I${with_log4cpp}/include $CPPFLAGS"
83             fi])
84
85 AC_ARG_WITH(xmlsec,
86             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),
87             [if test -f "${with_xmlsec}/bin/xmlsec-config"; then
88                 LDFLAGS="`${with_xmlsec}/bin/xmlsec-config --libs` $LDFLAGS"
89                 CPPFLAGS="`${with_xmlsec}/bin/xmlsec-config --cflags` $CPPFLAGS"
90             fi])
91
92 AC_ARG_WITH(saml,
93             AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
94             [if test x_$with_saml != x_/usr; then
95                 LDFLAGS="-L${with_saml}/lib $LDFLAGS"
96                 CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
97             fi])
98
99 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
100                 AC_MSG_ERROR([unable to find xerces header files]))
101 saved_LIBS="$LIBS"
102 LIBS="-lxerces-c $LIBS"
103 AC_TRY_LINK(
104         [#include <xercesc/util/PlatformUtils.hpp>],
105         [xercesc::XMLPlatformUtils::Initialize()],
106         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
107         [AC_MSG_ERROR([unable to link with Xerces])
108                 LIBS="$saved_LIBS"
109         ])
110
111 AC_CHECK_HEADER([openssl/ssl.h],,
112                 AC_MSG_ERROR([unable to find openssl header files]))
113 AC_CHECK_LIB([crypto], [ERR_load_CRYPTO_strings],,
114              AC_MSG_ERROR([unable to link with openssl libraries]))
115 AC_CHECK_LIB([ssl], [SSL_library_init],, 
116              AC_MSG_ERROR([unable to link with openssl libraries]))
117
118 AC_CHECK_HEADER([libxml/parser.h],,
119                 AC_MSG_ERROR([unable to find libxml2 header files]))
120 AC_CHECK_LIB([xml2], [xmlInitParser],echo "foo" > /dev/null,
121              AC_MSG_ERROR([unable to link with libxml2]))
122
123 AC_CHECK_HEADER([xmlsec/xmlsec.h],,
124                 AC_MSG_ERROR([unable to find xmlsec header files]))
125 AC_CHECK_LIB([xmlsec], [xmlSecInit],echo "foo" > /dev/null,
126              AC_MSG_ERROR([unable to link with xmlsec]))
127
128 AC_CHECK_HEADER([log4cpp/Category.hh],,
129                 AC_MSG_ERROR([unable to find log4cpp header files]))
130
131 AC_CHECK_HEADER([saml/saml.h],,
132                 AC_MSG_ERROR([unable to find saml header files]))
133
134 saved_LIBS="$LIBS"
135 LIBS="-llog4cpp $LIBS"
136 AC_TRY_LINK(
137         [#include <log4cpp/Category.hh>],
138         [log4cpp::Category::getInstance("foo")],
139         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
140         [AC_MSG_ERROR([unable to link with log4cpp])
141                 LIBS="$saved_LIBS"
142         ])
143
144 saved_LIBS="$LIBS"
145 LIBS="-lsaml $LIBS"
146 AC_TRY_LINK(
147         [#include <saml/saml.h>],
148         [saml::SAMLConfig::getConfig()],
149         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
150         [AC_MSG_ERROR([unable to link with saml])
151                 LIBS="$saved_LIBS"
152         ])
153
154 # output the underlying makefiles
155 WANT_SUBDIRS="shib schemas configs shib-target shar test"
156 AC_CONFIG_FILES([Makefile shib/Makefile schemas/Makefile \
157                  configs/Makefile oncrpc/Makefile oncrpc/rpc/Makefile \
158                  shib-target/Makefile shar/Makefile test/Makefile])
159
160 # now deal with the rpc library, to see if we need to build our own
161 if test $rpctest = "no"; then
162     WANT_SUBDIRS="oncrpc $WANT_SUBDIRS"
163 fi
164 AM_CONDITIONAL(USE_OUR_ONCRPC,test "$rpctest" = "no")
165
166 # Much of this is taken from mod_dav.
167 # The basic idea is to use configure options to control whether/which types
168 # of web server modules get built. We assume there may eventually be multiple
169 # types (Apache 1/2, iPlanet, others).
170
171 # Apache 1.3 (mod_shire/mod_shibrm)
172 #   --with-apache   (static build, no idea how to do this yet, so not supported)
173 #   --with-apxs     (DSO build, the normal way, uses apxs to derive build flags)
174 #   --without-apxs  (DSO build, you tell us how to build using the environment)
175
176 AC_MSG_CHECKING([for dynamic Apache module support (w/ or w/o APXS)])
177 AC_ARG_WITH(apxs,
178 [  --with-apxs[=FILE]        Build shared Apache module(s). FILE is the optional
179                           pathname to the Apache apxs tool; defaults to "apxs".],
180 [
181     if test "$withval" = "yes"; then
182       for i in /usr/sbin /usr/local/apache/bin ; do
183         if test -f "$i/apxs"; then
184           APXS="$i/apxs"
185         fi
186       done
187       if test -z "$APXS"; then
188         APXS=apxs
189       fi
190     else
191       APXS="$withval"
192     fi
193 ])
194
195 if test "$APXS" = "no"; then
196
197     # --without-apxs means you want the modules,
198     #       but want to tell us how to build them
199     AC_MSG_RESULT(yes, but use environment, not apxs)
200     echo
201     echo "Did you set one or more of these?"
202     echo
203     echo "APXS_CFLAGS APXS_PREFIX APXS_INCLUDE APXS_LIBEXEC APXS_SYSCONFDIR"
204     echo
205
206     AC_MSG_NOTICE([APXS_CFLAGS is $APXS_CFLAGS])
207
208     # try and find the Apache root
209     if test -z "$APXS_PREFIX"; then
210         if test -d "/usr/local/apache"; then
211             APXS_PREFIX="/usr/local/apache"
212         else
213             AC_MSG_ERROR([You MUST set APXS_PREFIX so the right Apache can be located!])
214         fi
215     elif test ! -d "$APXS_PREFIX"; then
216         AC_MSG_ERROR([APXS_PREFIX of $APXS_PREFIX cannot be found])
217     fi
218     AC_MSG_NOTICE([APXS_PREFIX is $APXS_PREFIX])
219     
220
221     # other subfolders might be derived from APXS_PREFIX
222     if test -z "$APXS_INCLUDE"; then
223         if test -f "$APXS_PREFIX/include/httpd.h"; then
224             APXS_INCLUDE="$APXS_PREFIX/include"
225         else
226             AC_MSG_ERROR([can't find Apache include files beneath $APXS_PREFIX])
227         fi
228     elif ! test -f "$APXS_INCLUDE/httpd.h"; then
229         AC_MSG_ERROR([APXS_INCLUDE of $APXS_INCLUDE does not contain Apache headers])
230     fi
231     AC_MSG_NOTICE([APXS_INCLUDE is $APXS_INCLUDE])
232
233     if test -z "$APXS_LIBEXEC"; then
234         if test -d "$APXS_PREFIX/libexec"; then
235             APXS_LIBEXEC="$APXS_PREFIX/libexec"
236         elif test -d "$APXS_PREFIX/modules"; then
237             APXS_LIBEXEC="$APXS_PREFIX/modules"
238         else
239             AC_MSG_ERROR([can't find Apache libexec/module directory beneath $APXS_PREFIX])
240         fi
241     elif ! test -d "$APXS_LIBEXEC"; then
242         AC_MSG_ERROR([APXS_LIBEXEC of $APXS_LIBEXEC does not exist])
243     fi
244     AC_MSG_NOTICE([APXS_LIBEXEC is $APXS_LIBEXEC])
245
246     if test -z "$APXS_SYSCONFDIR"; then
247         if test -d "$APXS_PREFIX/conf"; then
248             APXS_SYSCONFDIR="$APXS_PREFIX/conf"
249         else
250             AC_MSG_ERROR([can't find Apache conf directory beneath $APXS_PREFIX])
251         fi
252     elif ! test -d "$APXS_SYSCONFDIR"; then
253         AC_MSG_ERROR([APXS_SYSCONFDIR of $APXS_SYSCONFDIR does not exist])
254     fi
255     AC_MSG_NOTICE([APXS_SYSCONFDIR is $APXS_SYSCONFDIR])
256
257     WANT_APACHE="yes"
258
259 elif test -n "$APXS"; then
260
261     # extract settings we need from APXS -q
262     APXS_CC="`$APXS -q CC`"
263     APXS_CFLAGS="`$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
264     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
265     APXS_LIBEXEC="`$APXS -q LIBEXECDIR`"
266     APXS_SYSCONFDIR="`$APXS -q SYSCONFDIR`"
267
268     AC_SUBST(APXS)
269     AC_MSG_RESULT(found at $APXS)
270
271     if test -z "`$APXS -q LD_SHLIB`" || test "$APXS_LIBEXEC" = "modules"; then
272             AC_MSG_ERROR(
273 [Your APXS installation is broken and cannot be used.
274     Please see http://www.webdav.org/mod_dav/install.html#apxs for
275     more information.])
276     fi
277
278     WANT_APACHE="yes"
279
280 else
281     # guess we're not doing Apache 1.3
282     AC_MSG_RESULT(no)
283     WANT_APACHE="no"
284 fi
285
286 AM_CONDITIONAL(HAVE_APXS,test -n "$APXS")
287
288 if test "$WANT_APACHE" = "yes"; then
289     AC_ARG_WITH(apreq,
290                 AC_HELP_STRING([--with-apreq=PATH], [where libapreq is installed]),
291                 [if test x_$with_apreq != x_/usr; then
292                     LDFLAGS="-L${with_apreq}/lib $LDFLAGS"
293                     CPPFLAGS="-I${with_apreq}/include $CPPFLAGS"
294                 fi])
295
296     saved_CPPFLAGS="$CPPFLAGS"
297     CPPFLAGS="-I$APXS_INCLUDE $APXS_CFLAGS $CPPFLAGS"
298     AC_TRY_COMPILE([#include <libapreq/apache_request.h>],
299                    [int i=0],
300                    test_apreq="yes",test_apreq="no")
301     if test "$test_apreq" = "no"; then
302         CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
303         APXS_CFLAGS="$APXS_CFLAGS -U_XOPEN_SOURCE"
304         AC_CHECK_HEADER([libapreq/apache_request.h],,
305             AC_MSG_ERROR([unable to find a usable libapreq header]))
306     fi
307
308 dnl    saved_LIBS="$LIBS"
309 dnl    LIBS="-lapreq $LIBS"
310 dnl    AC_TRY_LINK(
311 dnl        [#include <libapreq/apache_request.h>],
312 dnl        [ApacheRequest_expires],
313 dnl        [AC_DEFINE(HAVE_APREQ,1,[Define if apreq library was found])],
314 dnl        [AC_MSG_ERROR([unable to link with apreq])
315 dnl        ])
316 dnl    LIBS="$saved_LIBS"
317     CPPFLAGS="$saved_CPPFLAGS"
318
319     AC_ARG_ENABLE([apxs-install],
320         AC_HELP_STRING([--enable-apxs-install],
321                         [use apxs to install the apache modules]),
322         APXS_INSTALL="yes", )
323
324
325     AC_SUBST(APXS_CFLAGS)
326     AC_SUBST(APXS_INCLUDE)
327     AC_SUBST(APXS_LIBEXEC)
328     AC_SUBST(APXS_SYSCONFDIR)
329
330     # output the Apache 1.3 makefiles
331     WANT_SUBDIRS="$WANT_SUBDIRS mod_shire mod_shibrm"
332 fi
333 # always output the Makefile, even if we don't use it
334 AC_CONFIG_FILES([mod_shire/Makefile mod_shibrm/Makefile])
335
336 AM_CONDITIONAL(DO_APXS_INSTALL,test -n "$APXS_INSTALL")
337
338 AC_SUBST(WANT_SUBDIRS)
339
340 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
341   echo "=================================================================="
342   echo "WARNING: You have chosen to compile Apache modules with a different"
343   echo "         compiler than the one used to compile Apache."
344   echo ""
345   echo "    Current compiler:      $CC"
346   echo "   Apache's compiler:      $APXS_CC"
347   echo ""
348   echo "This could cause some problems."
349   echo "=================================================================="
350 fi
351
352 AC_OUTPUT
353