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