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