Add doc folder.
[shibboleth/sp.git] / configure.ac
1 dnl $Id$ 
2
3 AC_PREREQ([2.50])
4 AC_INIT([shibboleth], [1.0], [mace-shib-users@internet2.edu], [shibboleth])
5 AM_CONFIG_HEADER(config.h)
6 AM_INIT_AUTOMAKE(shibboleth, 1.0)
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 x_$with_xmlsec != x_/usr; then
88                 LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
89                 CPPFLAGS="-I${with_xmlsec}/include $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([xsec/utils/XSECPlatformUtils.hpp],,
119                 AC_MSG_ERROR([unable to find xsec header files]))
120 saved_LIBS="$LIBS"
121 LIBS="-lxml-security-c $LIBS"
122 AC_TRY_LINK(
123         [#include <xsec/utils/XSECPlatformUtils.hpp>],
124         [XSECPlatformUtils::Initialise()],
125         [AC_DEFINE(HAVE_LIBXSEC,1,[Define if XML-Sec library was found])],
126         [AC_MSG_ERROR([unable to link with XML-Sec])
127                 LIBS="$saved_LIBS"
128         ])
129
130 AC_CHECK_HEADER([log4cpp/Category.hh],,
131                 AC_MSG_ERROR([unable to find log4cpp header files]))
132
133 AC_CHECK_HEADER([saml/saml.h],,
134                 AC_MSG_ERROR([unable to find saml header files]))
135
136 saved_LIBS="$LIBS"
137 LIBS="-llog4cpp $LIBS"
138 AC_TRY_LINK(
139         [#include <log4cpp/Category.hh>],
140         [log4cpp::Category::getInstance("foo")],
141         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
142         [AC_MSG_ERROR([unable to link with log4cpp])
143                 LIBS="$saved_LIBS"
144         ])
145
146 saved_LIBS="$LIBS"
147 LIBS="-lsaml $LIBS"
148 AC_TRY_LINK(
149         [#include <saml/saml.h>],
150         [saml::SAMLConfig::getConfig()],
151         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
152         [AC_MSG_ERROR([unable to link with saml])
153                 LIBS="$saved_LIBS"
154         ])
155
156 # output the underlying makefiles
157 WANT_SUBDIRS="doc shib schemas configs shib-target shar siterefresh test"
158 AC_CONFIG_FILES([Makefile doc/Makefile shib/Makefile schemas/Makefile \
159                  configs/Makefile oncrpc/Makefile oncrpc/rpc/Makefile \
160                  shib-target/Makefile shar/Makefile siterefresh/Makefile \
161                  test/Makefile])
162
163 # now deal with the rpc library, to see if we need to build our own
164 if test $rpctest = "no"; then
165     WANT_SUBDIRS="oncrpc $WANT_SUBDIRS"
166 fi
167 AM_CONDITIONAL(USE_OUR_ONCRPC,test "$rpctest" = "no")
168
169 # Much of this is taken from mod_dav.
170 # The basic idea is to use configure options to control whether/which types
171 # of web server modules get built. We assume there may eventually be multiple
172 # types (Apache 1/2, iPlanet, others).
173
174 # Apache 1.3 (mod_shire/mod_shibrm)
175 #   --with-apache   (static build, no idea how to do this yet, so not supported)
176 #   --with-apxs     (DSO build, the normal way, uses apxs to derive build flags)
177 #   --without-apxs  (DSO build, you tell us how to build using the environment)
178
179 AC_MSG_CHECKING([for dynamic Apache module support (w/ or w/o APXS)])
180 AC_ARG_WITH(apxs,
181 [  --with-apxs[=FILE]        Build shared Apache module(s). FILE is the optional
182                           pathname to the Apache apxs tool; defaults to "apxs".],
183 [
184     if test "$withval" = "yes"; then
185       for i in /usr/sbin /usr/local/apache/bin ; do
186         if test -f "$i/apxs"; then
187           APXS="$i/apxs"
188         fi
189       done
190       if test -z "$APXS"; then
191         APXS=apxs
192       fi
193     else
194       APXS="$withval"
195     fi
196 ])
197
198 if test "$APXS" = "no"; then
199
200     # --without-apxs means you want the modules,
201     #       but want to tell us how to build them
202     AC_MSG_RESULT(yes, but use environment, not apxs)
203     echo
204     echo "Did you set one or more of these?"
205     echo
206     echo "APXS_CFLAGS APXS_PREFIX APXS_INCLUDE APXS_LIBEXEC APXS_SYSCONFDIR"
207     echo
208
209     AC_MSG_NOTICE([APXS_CFLAGS is $APXS_CFLAGS])
210
211     # try and find the Apache root
212     if test -z "$APXS_PREFIX"; then
213         if test -d "/usr/local/apache"; then
214             APXS_PREFIX="/usr/local/apache"
215         else
216             AC_MSG_ERROR([You MUST set APXS_PREFIX so the right Apache can be located!])
217         fi
218     elif test ! -d "$APXS_PREFIX"; then
219         AC_MSG_ERROR([APXS_PREFIX of $APXS_PREFIX cannot be found])
220     fi
221     AC_MSG_NOTICE([APXS_PREFIX is $APXS_PREFIX])
222     
223
224     # other subfolders might be derived from APXS_PREFIX
225     if test -z "$APXS_INCLUDE"; then
226         if test -f "$APXS_PREFIX/include/httpd.h"; then
227             APXS_INCLUDE="$APXS_PREFIX/include"
228         else
229             AC_MSG_ERROR([can't find Apache include files beneath $APXS_PREFIX])
230         fi
231     elif ! test -f "$APXS_INCLUDE/httpd.h"; then
232         AC_MSG_ERROR([APXS_INCLUDE of $APXS_INCLUDE does not contain Apache headers])
233     fi
234     AC_MSG_NOTICE([APXS_INCLUDE is $APXS_INCLUDE])
235
236     if test -z "$APXS_LIBEXEC"; then
237         if test -d "$APXS_PREFIX/libexec"; then
238             APXS_LIBEXEC="$APXS_PREFIX/libexec"
239         elif test -d "$APXS_PREFIX/modules"; then
240             APXS_LIBEXEC="$APXS_PREFIX/modules"
241         else
242             AC_MSG_ERROR([can't find Apache libexec/module directory beneath $APXS_PREFIX])
243         fi
244     elif ! test -d "$APXS_LIBEXEC"; then
245         AC_MSG_ERROR([APXS_LIBEXEC of $APXS_LIBEXEC does not exist])
246     fi
247     AC_MSG_NOTICE([APXS_LIBEXEC is $APXS_LIBEXEC])
248
249     if test -z "$APXS_SYSCONFDIR"; then
250         if test -d "$APXS_PREFIX/conf"; then
251             APXS_SYSCONFDIR="$APXS_PREFIX/conf"
252         else
253             AC_MSG_ERROR([can't find Apache conf directory beneath $APXS_PREFIX])
254         fi
255     elif ! test -d "$APXS_SYSCONFDIR"; then
256         AC_MSG_ERROR([APXS_SYSCONFDIR of $APXS_SYSCONFDIR does not exist])
257     fi
258     AC_MSG_NOTICE([APXS_SYSCONFDIR is $APXS_SYSCONFDIR])
259
260     WANT_APACHE="yes"
261
262 elif test -n "$APXS"; then
263
264     # extract settings we need from APXS -q
265     APXS_CC="`$APXS -q CC`"
266     APXS_CFLAGS="`$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
267     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
268     APXS_LIBEXEC="`$APXS -q LIBEXECDIR`"
269     APXS_SYSCONFDIR="`$APXS -q SYSCONFDIR`"
270
271     AC_SUBST(APXS)
272     AC_MSG_RESULT(found at $APXS)
273
274     if test -z "`$APXS -q LD_SHLIB`" || test "$APXS_LIBEXEC" = "modules"; then
275             AC_MSG_ERROR(
276 [Your APXS installation is broken and cannot be used.
277     Please see http://www.webdav.org/mod_dav/install.html#apxs for
278     more information.])
279     fi
280
281     WANT_APACHE="yes"
282
283 else
284     # guess we're not doing Apache 1.3
285     AC_MSG_RESULT(no)
286     WANT_APACHE="no"
287 fi
288
289 AM_CONDITIONAL(HAVE_APXS,test -n "$APXS")
290
291 if test "$WANT_APACHE" = "yes"; then
292     AC_ARG_WITH(apreq,
293                 AC_HELP_STRING([--with-apreq=PATH], [where libapreq is installed]),
294                 [if test x_$with_apreq != x_/usr; then
295                     LDFLAGS="-L${with_apreq}/lib $LDFLAGS"
296                     CPPFLAGS="-I${with_apreq}/include $CPPFLAGS"
297                 fi])
298
299     saved_CPPFLAGS="$CPPFLAGS"
300     CPPFLAGS="-I$APXS_INCLUDE $APXS_CFLAGS $CPPFLAGS"
301     AC_TRY_COMPILE([#include <libapreq/apache_request.h>],
302                    [int i=0],
303                    test_apreq="yes",test_apreq="no")
304     if test "$test_apreq" = "no"; then
305         CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
306         APXS_CFLAGS="$APXS_CFLAGS -U_XOPEN_SOURCE"
307         AC_CHECK_HEADER([libapreq/apache_request.h],,
308             AC_MSG_ERROR([unable to find a usable libapreq header]))
309     fi
310
311 dnl    saved_LIBS="$LIBS"
312 dnl    LIBS="-lapreq $LIBS"
313 dnl    AC_TRY_LINK(
314 dnl        [#include <libapreq/apache_request.h>],
315 dnl        [ApacheRequest_expires],
316 dnl        [AC_DEFINE(HAVE_APREQ,1,[Define if apreq library was found])],
317 dnl        [AC_MSG_ERROR([unable to link with apreq])
318 dnl        ])
319 dnl    LIBS="$saved_LIBS"
320     CPPFLAGS="$saved_CPPFLAGS"
321
322     AC_ARG_ENABLE([apxs-install],
323         AC_HELP_STRING([--enable-apxs-install],
324                         [use apxs to install the apache modules]),
325         APXS_INSTALL="yes", )
326
327
328     AC_SUBST(APXS_CFLAGS)
329     AC_SUBST(APXS_INCLUDE)
330     AC_SUBST(APXS_LIBEXEC)
331     AC_SUBST(APXS_SYSCONFDIR)
332
333     # output the Apache 1.3 makefiles
334     WANT_SUBDIRS="$WANT_SUBDIRS mod_shire mod_shibrm"
335 fi
336 # always output the Makefile, even if we don't use it
337 AC_CONFIG_FILES([mod_shire/Makefile mod_shibrm/Makefile])
338
339 AM_CONDITIONAL(DO_APXS_INSTALL,test -n "$APXS_INSTALL")
340
341 AC_SUBST(WANT_SUBDIRS)
342
343 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
344   echo "=================================================================="
345   echo "WARNING: You have chosen to compile Apache modules with a different"
346   echo "         compiler than the one used to compile Apache."
347   echo ""
348   echo "    Current compiler:      $CC"
349   echo "   Apache's compiler:      $APXS_CC"
350   echo ""
351   echo "This could cause some problems."
352   echo "=================================================================="
353 fi
354
355 AC_OUTPUT
356