First pass at an apache-2 module. It compiles on Linux
[shibboleth/sp.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([shibboleth], [1.1], [mace-shib-users@internet2.edu], [shibboleth])
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE(shibboleth, 1.1)
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 strtok_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 # Determine whether to use TCP for the shar socket
52 AC_ARG_ENABLE([tcp],
53     AC_HELP_STRING([--enable-tcp], [enable the SHAR to use a TCP socket on Unix]),
54     [tcp_enabled=$enableval], [tcp_enabled=default])
55
56 if test "x$tcp_enabled" = "x" ; then
57    tcp_enabled=yes
58 fi
59
60 if test "$tcp_enabled" = "yes" ; then
61     CFLAGS="$CFLAGS -DWANT_TCP_SHAR"
62     CXXFLAGS="$CXXFLAGS -DWANT_TCP_SHAR"
63 fi
64
65 AC_ARG_WITH(dmalloc,
66             AC_HELP_STRING([--with-dmalloc=PATH], [where dmalloc is installed]),
67             [if test x_$with_dmalloc != x_/usr; then
68                 LDFLAGS="-L${with_dmalloc}/lib $LDFLAGS"
69                 CPPFLAGS="-I${with_dmalloc}/include $CPPFLAGS"
70             fi
71             AC_CHECK_LIB(dmallocxx, dmalloc_shutdown,,
72                          AC_MSG_ERROR([unable to find dmallocxx library]))
73             ])
74
75 AC_ARG_WITH(xerces, 
76             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
77             [if test x_$with_xerces != x_/usr; then
78                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
79                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
80             fi])
81
82
83 AC_ARG_WITH(openssl, 
84             AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
85             [if test x_$with_openssl != x_/usr; then
86                 LDFLAGS="-L${with_openssl}/lib $LDFLAGS"
87                 CPPFLAGS="-I${with_openssl}/include $CPPFLAGS"
88             fi])
89
90 AC_ARG_WITH(log4cpp, 
91             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp is installed]),
92             [if test x_$with_log4cpp != x_/usr; then
93                 LDFLAGS="-L${with_log4cpp}/lib $LDFLAGS"
94                 CPPFLAGS="-I${with_log4cpp}/include $CPPFLAGS"
95             fi])
96
97 AC_ARG_WITH(xmlsec,
98             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),
99             [if test x_$with_xmlsec != x_/usr; then
100                 LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
101                 CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
102             fi])
103
104 AC_ARG_WITH(saml,
105             AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
106             [if test x_$with_saml != x_/usr; then
107                 LDFLAGS="-L${with_saml}/lib $LDFLAGS"
108                 CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
109             fi])
110
111 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
112                 AC_MSG_ERROR([unable to find xerces header files]))
113 saved_LIBS="$LIBS"
114 LIBS="-lxerces-c $LIBS"
115 AC_TRY_LINK(
116         [#include <xercesc/util/PlatformUtils.hpp>],
117         [xercesc::XMLPlatformUtils::Initialize()],
118         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
119         [AC_MSG_ERROR([unable to link with Xerces])
120                 LIBS="$saved_LIBS"
121         ])
122
123 AC_CHECK_HEADER([openssl/ssl.h],,
124                 AC_MSG_ERROR([unable to find openssl header files]))
125 AC_CHECK_LIB([crypto], [ERR_load_CRYPTO_strings],,
126              AC_MSG_ERROR([unable to link with openssl libraries]))
127 AC_CHECK_LIB([ssl], [SSL_library_init],, 
128              AC_MSG_ERROR([unable to link with openssl libraries]))
129
130 AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,
131                 AC_MSG_ERROR([unable to find xsec header files]))
132 saved_LIBS="$LIBS"
133 LIBS="-lxml-security-c $LIBS"
134 AC_TRY_LINK(
135         [#include <xsec/utils/XSECPlatformUtils.hpp>],
136         [XSECPlatformUtils::Initialise()],
137         [AC_DEFINE(HAVE_LIBXSEC,1,[Define if XML-Sec library was found])],
138         [AC_MSG_ERROR([unable to link with XML-Sec])
139                 LIBS="$saved_LIBS"
140         ])
141
142 AC_CHECK_HEADER([log4cpp/Category.hh],,
143                 AC_MSG_ERROR([unable to find log4cpp header files]))
144
145 AC_CHECK_HEADER([saml/saml.h],,
146                 AC_MSG_ERROR([unable to find saml header files]))
147
148 saved_LIBS="$LIBS"
149 LIBS="-llog4cpp $LIBS"
150 AC_TRY_LINK(
151         [#include <log4cpp/Category.hh>],
152         [log4cpp::Category::getInstance("foo")],
153         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
154         [AC_MSG_ERROR([unable to link with log4cpp])
155                 LIBS="$saved_LIBS"
156         ])
157
158 saved_LIBS="$LIBS"
159 LIBS="-lsaml $LIBS"
160 AC_TRY_LINK(
161         [#include <saml/saml.h>],
162         [saml::SAMLConfig::getConfig()],
163         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
164         [AC_MSG_ERROR([unable to link with saml])
165                 LIBS="$saved_LIBS"
166         ])
167
168 # output the underlying makefiles
169 WANT_SUBDIRS="doc shib schemas configs shib-target shar siterefresh test"
170 AC_CONFIG_FILES([Makefile doc/Makefile shib/Makefile schemas/Makefile \
171                  configs/Makefile oncrpc/Makefile oncrpc/rpc/Makefile \
172                  shib-target/Makefile shar/Makefile siterefresh/Makefile \
173                  test/Makefile])
174
175 # now deal with the rpc library, to see if we need to build our own
176 if test $rpctest = "no"; then
177     WANT_SUBDIRS="oncrpc $WANT_SUBDIRS"
178         AC_DEFINE(USE_OUR_ONCRPC,1,[Define if using embedded version of ONC RPC.])
179 fi
180 AM_CONDITIONAL(USE_OUR_ONCRPC,test "$rpctest" = "no")
181
182 # Much of this is taken from mod_dav.
183 # The basic idea is to use configure options to control whether/which types
184 # of web server modules get built. We assume there may eventually be multiple
185 # types (Apache 1/2, iPlanet, others).
186
187 # Apache 1.3 (mod_shire/mod_shibrm)
188 #   --with-apache-13 (static build, no idea how to do this yet, so not supported)
189 #   --with-apxs      (DSO build, the normal way, uses apxs to derive build flags)
190 #   --without-apxs   (DSO build, you tell us how to build using the environment)
191
192 AC_ARG_ENABLE(apache-13,
193         AC_HELP_STRING([--enable-apache-13], [enable the Apache 1.3 modules]),
194         [ if test "x$enableval" = "x" ; then
195               WANT_APACHE_13=yes
196           else
197               WANT_APACHE_13="$enableval"
198           fi
199         ], [ WANT_APACHE_13=no ])
200 AC_MSG_CHECKING(whether to build Apache-1.3 support)
201 if test "$WANT_APACHE_13" != yes && test "$WANT_APACHE_13" != no ; then
202    WANT_APACHE_13=yes
203 fi
204 AC_MSG_RESULT($WANT_APACHE_13)
205
206 if test "$WANT_APACHE_13" = yes ; then
207
208 AC_ARG_WITH(apxs,
209 [  --with-apxs[=FILE]        Build shared Apache module(s). FILE is the optional
210                           pathname to the Apache apxs tool; defaults to "apxs".],
211 [
212     if test "$withval" = "yes"; then
213       for i in /usr/sbin /usr/local/apache/bin ; do
214         if test -f "$i/apxs"; then
215           APXS="$i/apxs"
216         fi
217       done
218       if test -z "$APXS"; then
219         APXS=apxs
220       fi
221     else
222       APXS="$withval"
223     fi
224 ],
225 [
226     AC_PATH_PROG(APXS, apxs, no)
227 ])
228
229 AC_MSG_CHECKING([for dynamic Apache-1.3 module support (w/ or w/o APXS)])
230 if test "$APXS" = "no"; then
231
232     # --without-apxs means you want the modules,
233     #       but want to tell us how to build them
234     AC_MSG_RESULT(yes, but use environment, not apxs)
235     echo
236     echo "Did you set one or more of these?"
237     echo
238     echo "APXS_CFLAGS APXS_PREFIX APXS_INCLUDE APXS_LIBEXEC APXS_SYSCONFDIR"
239     echo
240
241     AC_MSG_NOTICE([APXS_CFLAGS is $APXS_CFLAGS])
242
243     # try and find the Apache root
244     if test -z "$APXS_PREFIX"; then
245         if test -d "/usr/local/apache"; then
246             APXS_PREFIX="/usr/local/apache"
247         else
248             AC_MSG_ERROR([You MUST set APXS_PREFIX so the right Apache can be located!])
249         fi
250     elif test ! -d "$APXS_PREFIX"; then
251         AC_MSG_ERROR([APXS_PREFIX of $APXS_PREFIX cannot be found])
252     fi
253     AC_MSG_NOTICE([APXS_PREFIX is $APXS_PREFIX])
254     
255
256     # other subfolders might be derived from APXS_PREFIX
257     if test -z "$APXS_INCLUDE"; then
258         if test -f "$APXS_PREFIX/include/httpd.h"; then
259             APXS_INCLUDE="$APXS_PREFIX/include"
260         else
261             AC_MSG_ERROR([can't find Apache include files beneath $APXS_PREFIX])
262         fi
263     elif ! test -f "$APXS_INCLUDE/httpd.h"; then
264         AC_MSG_ERROR([APXS_INCLUDE of $APXS_INCLUDE does not contain Apache headers])
265     fi
266     AC_MSG_NOTICE([APXS_INCLUDE is $APXS_INCLUDE])
267
268     if test -z "$APXS_LIBEXEC"; then
269         if test -d "$APXS_PREFIX/libexec"; then
270             APXS_LIBEXEC="$APXS_PREFIX/libexec"
271         elif test -d "$APXS_PREFIX/modules"; then
272             APXS_LIBEXEC="$APXS_PREFIX/modules"
273         else
274             AC_MSG_ERROR([can't find Apache libexec/module directory beneath $APXS_PREFIX])
275         fi
276     elif ! test -d "$APXS_LIBEXEC"; then
277         AC_MSG_ERROR([APXS_LIBEXEC of $APXS_LIBEXEC does not exist])
278     fi
279     AC_MSG_NOTICE([APXS_LIBEXEC is $APXS_LIBEXEC])
280
281     if test -z "$APXS_SYSCONFDIR"; then
282         if test -d "$APXS_PREFIX/conf"; then
283             APXS_SYSCONFDIR="$APXS_PREFIX/conf"
284         else
285             AC_MSG_ERROR([can't find Apache conf directory beneath $APXS_PREFIX])
286         fi
287     elif ! test -d "$APXS_SYSCONFDIR"; then
288         AC_MSG_ERROR([APXS_SYSCONFDIR of $APXS_SYSCONFDIR does not exist])
289     fi
290     AC_MSG_NOTICE([APXS_SYSCONFDIR is $APXS_SYSCONFDIR])
291
292     WANT_APACHE_13="yes"
293
294 elif test -n "$APXS"; then
295
296     # extract settings we need from APXS -q
297     APXS_CC="`$APXS -q CC`"
298     APXS_CFLAGS="`$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
299     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
300     APXS_LIBEXEC="`$APXS -q LIBEXECDIR`"
301     APXS_SYSCONFDIR="`$APXS -q SYSCONFDIR`"
302
303     AC_SUBST(APXS)
304     AC_MSG_RESULT(found at $APXS)
305
306     if test -z "`$APXS -q LD_SHLIB`" || test "$APXS_LIBEXEC" = "modules"; then
307             AC_MSG_ERROR(
308 [Your APXS installation is broken and cannot be used.
309     Please see http://www.webdav.org/mod_dav/install.html#apxs for
310     more information.])
311     fi
312
313     WANT_APACHE_13="yes"
314
315 else
316     # guess we're not doing Apache 1.3
317     AC_MSG_RESULT(no)
318     WANT_APACHE_13="no"
319 fi
320 fi
321
322 if test "$WANT_APACHE_13" = "yes"; then
323     AC_ARG_WITH(apreq,
324                 AC_HELP_STRING([--with-apreq=PATH], [where libapreq is installed]),
325                 [if test x_$with_apreq != x_/usr; then
326                     LDFLAGS="-L${with_apreq}/lib $LDFLAGS"
327                     CPPFLAGS="-I${with_apreq}/include $CPPFLAGS"
328                 fi])
329
330     saved_CPPFLAGS="$CPPFLAGS"
331     CPPFLAGS="-I$APXS_INCLUDE $APXS_CFLAGS $CPPFLAGS"
332     AC_TRY_COMPILE([#include <libapreq/apache_request.h>],
333                    [int i=0],
334                    test_apreq="yes",test_apreq="no")
335     if test "$test_apreq" = "no"; then
336         CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
337         APXS_CFLAGS="$APXS_CFLAGS -U_XOPEN_SOURCE"
338         AC_CHECK_HEADER([libapreq/apache_request.h],,
339             AC_MSG_ERROR([unable to find a usable libapreq header]))
340     fi
341
342 dnl    saved_LIBS="$LIBS"
343 dnl    LIBS="-lapreq $LIBS"
344 dnl    AC_TRY_LINK(
345 dnl        [#include <libapreq/apache_request.h>],
346 dnl        [ApacheRequest_expires],
347 dnl        [AC_DEFINE(HAVE_APREQ,1,[Define if apreq library was found])],
348 dnl        [AC_MSG_ERROR([unable to link with apreq])
349 dnl        ])
350 dnl    LIBS="$saved_LIBS"
351     CPPFLAGS="$saved_CPPFLAGS"
352
353     AC_ARG_ENABLE([apxs-install],
354         AC_HELP_STRING([--enable-apxs-install],
355                         [use apxs to install the apache modules]),
356         APXS_INSTALL="yes", )
357
358
359     AC_SUBST(APXS_CFLAGS)
360     AC_SUBST(APXS_INCLUDE)
361     AC_SUBST(APXS_LIBEXEC)
362     AC_SUBST(APXS_SYSCONFDIR)
363
364     # output the Apache 1.3 makefiles
365     WANT_SUBDIRS="$WANT_SUBDIRS mod_shire mod_shibrm"
366 fi
367 # always output the Makefile, even if we don't use it
368 AC_CONFIG_FILES([mod_shire/Makefile mod_shibrm/Makefile])
369 AM_CONDITIONAL(HAVE_APXS,test -n "$APXS")
370 AM_CONDITIONAL(DO_APXS_INSTALL,test -n "$APXS_INSTALL")
371
372
373 # Apache 2.0 (mod_shib in apache-2.0)
374 #   --with-apache-20   (static build, no idea how to do this yet, so not supported)
375 #   --with-apxs2       (DSO build, the normal way, uses apxs to derive build flags)
376 #   --without-apxs2    (DSO build, you tell us how to build using the environment)
377
378 AC_ARG_ENABLE(apache-20,
379         AC_HELP_STRING([--enable-apache-20], [enable the Apache 2.0 modules]),
380         [ if test "x$enableval" = "x" ; then
381               WANT_APACHE_20=yes
382           else
383               WANT_APACHE_20="$enableval"
384           fi
385         ], [ WANT_APACHE_20=no ])
386
387 AC_MSG_CHECKING(whether to build Apache-2.0 support)
388 if test "$WANT_APACHE_20" != yes && test "$WANT_APACHE_20" != no ; then
389    WANT_APACHE_20=yes
390 fi
391 AC_MSG_RESULT($WANT_APACHE_20)
392
393 if test "$WANT_APACHE_20" = yes ; then
394
395 AC_ARG_WITH(apxs2,
396 [  --with-apxs2[=FILE]        Build shared Apache module(s). FILE is the optional
397                           pathname to the Apache apxs tool; defaults to "apxs".],
398 [
399     if test "$withval" = "yes"; then
400       for i in /usr/sbin /usr/local/apache/bin ; do
401         if test -f "$i/apxs"; then
402           APXS2="$i/apxs"
403         fi
404       done
405       if test -z "$APXS2"; then
406         APXS2=apxs
407       fi
408     else
409       APXS2="$withval"
410     fi
411 ],
412 [
413     AC_PATH_PROG(APXS2, apxs, no)
414 ])
415
416 AC_MSG_CHECKING([for dynamic Apache-2 module support (w/ or w/o APXS)])
417 if test "$APXS2" = "no"; then
418
419     # --without-apxs2 means you want the modules,
420     #       but want to tell us how to build them
421     AC_MSG_RESULT(yes, but use environment, not apxs)
422     echo
423     echo "Did you set one or more of these?"
424     echo
425     echo "APXS2_CFLAGS APXS2_PREFIX APXS2_INCLUDE APXS2_LIBEXEC APXS2_SYSCONFDIR"
426     echo
427
428     AC_MSG_NOTICE([APXS2_CFLAGS is $APXS2_CFLAGS])
429
430     # try and find the Apache root
431     if test -z "$APXS2_PREFIX"; then
432         if test -d "/usr/local/apache"; then
433             APXS2_PREFIX="/usr/local/apache"
434         else
435             AC_MSG_ERROR([You MUST set APXS2_PREFIX so the right Apache-2 can be located!])
436         fi
437     elif test ! -d "$APXS2_PREFIX"; then
438         AC_MSG_ERROR([APXS2_PREFIX of $APXS2_PREFIX cannot be found])
439     fi
440     AC_MSG_NOTICE([APXS2_PREFIX is $APXS2_PREFIX])
441     
442
443     # other subfolders might be derived from APXS2_PREFIX
444     if test -z "$APXS2_INCLUDE"; then
445         if test -f "$APXS2_PREFIX/include/httpd.h"; then
446             APXS2_INCLUDE="$APXS2_PREFIX/include"
447         else
448             AC_MSG_ERROR([can't find Apache-2 include files beneath $APXS2_PREFIX])
449         fi
450     elif ! test -f "$APXS2_INCLUDE/httpd.h"; then
451         AC_MSG_ERROR([APXS2_INCLUDE of $APXS2_INCLUDE does not contain Apache-2 headers])
452     fi
453     AC_MSG_NOTICE([APXS2_INCLUDE is $APXS2_INCLUDE])
454
455     if test -z "$APXS2_LIBEXEC"; then
456         if test -d "$APXS2_PREFIX/libexec"; then
457             APXS2_LIBEXEC="$APXS2_PREFIX/libexec"
458         elif test -d "$APXS2_PREFIX/modules"; then
459             APXS2_LIBEXEC="$APXS2_PREFIX/modules"
460         else
461             AC_MSG_ERROR([can't find Apache-2 libexec/module directory beneath $APXS2_PREFIX])
462         fi
463     elif ! test -d "$APXS2_LIBEXEC"; then
464         AC_MSG_ERROR([APXS2_LIBEXEC of $APXS2_LIBEXEC does not exist])
465     fi
466     AC_MSG_NOTICE([APXS2_LIBEXEC is $APXS2_LIBEXEC])
467
468     if test -z "$APXS2_SYSCONFDIR"; then
469         if test -d "$APXS2_PREFIX/conf"; then
470             APXS2_SYSCONFDIR="$APXS2_PREFIX/conf"
471         else
472             AC_MSG_ERROR([can't find Apache-2 conf directory beneath $APXS2_PREFIX])
473         fi
474     elif ! test -d "$APXS2_SYSCONFDIR"; then
475         AC_MSG_ERROR([APXS2_SYSCONFDIR of $APXS2_SYSCONFDIR does not exist])
476     fi
477     AC_MSG_NOTICE([APXS2_SYSCONFDIR is $APXS2_SYSCONFDIR])
478
479     WANT_APACHE_20="yes"
480
481 elif test -n "$APXS2"; then
482
483     # extract settings we need from APXS2 -q
484     APXS2_CC="`$APXS2 -q CC`"
485     APXS2_CFLAGS="`$APXS2 -q CFLAGS` `$APXS2 -q CFLAGS_SHLIB`"
486     APXS2_INCLUDE="`$APXS2 -q INCLUDEDIR`"
487     APXS2_LIBEXEC="`$APXS2 -q LIBEXECDIR`"
488     APXS2_SYSCONFDIR="`$APXS2 -q SYSCONFDIR`"
489
490     AC_SUBST(APXS2)
491     AC_MSG_RESULT(found at $APXS2)
492
493     if test -z "`$APXS2 -q LD_SHLIB`" && test -z "`$APXS2 -q LIBEXECDIR`" \
494        || test "$APXS2_LIBEXEC" = "modules"; then
495             AC_MSG_ERROR(
496 [Your APXS installation is broken and cannot be used.
497     Please see http://www.webdav.org/mod_dav/install.html#apxs for
498     more information.])
499     fi
500
501     WANT_APACHE_20="yes"
502
503 else
504     # guess we're not doing Apache 2.0
505     AC_MSG_RESULT(no)
506     WANT_APACHE_20="no"
507 fi
508 fi
509
510 if test "$WANT_APACHE_20" = "yes"; then
511     AC_ARG_WITH(apreq2,
512                 AC_HELP_STRING([--with-apreq2=PATH], [where http-apreq-2 is installed]),
513                 [if test x_$with_apreq2 != x_/usr; then
514                     LDFLAGS="-L${with_apreq2}/lib $LDFLAGS"
515                     CPPFLAGS="-I${with_apreq2}/include $CPPFLAGS"
516                 fi])
517
518     saved_CPPFLAGS="$CPPFLAGS"
519     CPPFLAGS="-I$APXS2_INCLUDE $APXS2_CFLAGS $CPPFLAGS"
520     AC_TRY_COMPILE([#include <apreq.h>],
521                    [int i=0],
522                    test_apreq2="yes",test_apreq2="no")
523     if test "$test_apreq2" = "no"; then
524         CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
525         APXS2_CFLAGS="$APXS2_CFLAGS -U_XOPEN_SOURCE"
526         AC_CHECK_HEADER([apreq.h],,
527             AC_MSG_ERROR([unable to find a usable libapreq2 header]))
528     fi
529
530 dnl    saved_LIBS="$LIBS"
531 dnl    LIBS="-lapreq $LIBS"
532 dnl    AC_TRY_LINK(
533 dnl        [#include <apreq.h>],
534 dnl        [apreq_param],
535 dnl        [AC_DEFINE(HAVE_APREQ2,1,[Define if apreq2 library was found])],
536 dnl        [AC_MSG_ERROR([unable to link with apreq2])
537 dnl        ])
538 dnl    LIBS="$saved_LIBS"
539     CPPFLAGS="$saved_CPPFLAGS"
540
541     AC_ARG_ENABLE([apxs2-install],
542         AC_HELP_STRING([--enable-apxs2-install],
543                         [use apxs to install the apache-2 modules]),
544         APXS2_INSTALL="yes", )
545
546
547     AC_SUBST(APXS2_CFLAGS)
548     AC_SUBST(APXS2_INCLUDE)
549     AC_SUBST(APXS2_LIBEXEC)
550     AC_SUBST(APXS2_SYSCONFDIR)
551
552     # output the Apache 2.0 makefiles
553     WANT_SUBDIRS="$WANT_SUBDIRS apache-2.0"
554 fi
555 # always output the Makefile, even if we don't use it
556 AC_CONFIG_FILES([apache-2.0/Makefile])
557 AM_CONDITIONAL(HAVE_APXS2,test -n "$APXS2")
558 AM_CONDITIONAL(DO_APXS2_INSTALL,test -n "$APXS2_INSTALL")
559
560
561 #
562 # Implement the checks of the MySQL Credential Cache
563 #
564 # 1) Assume the user wants MySQL; if it's not found then just continue without
565 # 2) If the user specifically requested Mysql, look for it and ERROR if not found
566 # 3) If the user specifically requested no-mysql, don't build it.
567 #
568
569 AC_CONFIG_FILES([shib-mysql-ccache/Makefile])
570
571 # determine whether we should enable the mysql ccache
572 AC_ARG_ENABLE([mysql],
573         AC_HELP_STRING([--disable-mysql], [disable the MySQL Credential Cache]),
574         [mysql_enabled=$enableval], [mysql_enabled=default])
575
576 if test "x$mysql_enabled" = "x" ; then
577    mysql_enabled=yes
578 fi
579
580 # Are we trying to build MySQL?
581 AC_MSG_CHECKING(whether to build the MySQL ccache)
582 if test "$mysql_enabled" = "yes" ; then
583    build_mysql=yes
584    AC_MSG_RESULT(yes)
585 elif test "$mysql_enabled" = "default" ; then
586    build_mysql=yes
587    AC_MSG_RESULT([yes, if it can be found])
588 else
589    build_mysql=no
590    AC_MSG_RESULT(no)
591 fi
592
593 # If we're trying to build MySQL, try to find the mysql_config program,
594 # verify we've got mysql >= 4, and make sure we can build with mysqld
595 if test "$build_mysql" = "yes" ; then
596    mysql_dir=""
597    AC_ARG_WITH(mysql,
598         AC_HELP_STRING([--with-mysql=PATH], [directory where mysql is installed]),
599             [if test "$with_mysql" = no ; then
600                AC_MSG_ERROR([Try running --disable-mysql instead.])
601              elif test "$with_mysql" != yes ; then
602                mysql_dir="$with_mysql/bin"
603              fi ])
604
605    # Try to find the mysql_config program
606    AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no, $mysql_dir $PATH )
607
608    if test "$MYSQL_CONFIG" = no ; then
609       if test "$mysql_enabled" = "yes" ; then
610         AC_MSG_ERROR(Cannot find mysql_config)
611       else
612         AC_MSG_WARN(MySQL not found.  skipping.)
613       fi
614    fi
615 fi
616
617 # if we found mysql_config then build_mysql is 'yes'
618 if test "$MYSQL_CONFIG" != no ; then
619    AC_MSG_CHECKING(for mysql version >= 4)
620    mysql_version=`$MYSQL_CONFIG --version`
621    mysql_major_version=`echo $mysql_version | awk -F. '{print $1}'`
622    mysql_version_ok=yes
623    if test $mysql_major_version -lt 4 ; then
624      mysql_version_ok=no
625      if test "$mysql_enabled" = "yes" ; then
626        AC_MSG_ERROR(You need MySQL version >= 4, found $mysql_version)
627      fi
628      AC_MSG_RESULT(no.. skipping MySQL)
629    else
630      AC_MSG_RESULT(yes)
631    fi
632 fi
633
634 # if mysql_version_ok is 'yes', then we've made it this far.. ;)
635 if test "$mysql_version_ok" = "yes" ; then
636    AC_MSG_CHECKING(for embedded-MySQL libraries)
637    MYSQL_LIBS=`$MYSQL_CONFIG --libmysqld-libs`
638    if test $? != 0 ; then
639       found_mysql=no
640       if test "$mysql_enabled" = "yes" ; then
641         AC_MSG_ERROR(Could not find the MySQL Embedded-server libraries.)
642       else
643         AC_MSG_RESULT(no.. skipping MySQL)
644       fi
645    else
646       found_mysql=yes
647       AC_MSG_RESULT(yes)
648    fi
649 fi
650
651 # if found_mysql=yes then test that we can actually build mysql
652 if test "$found_mysql" = yes ; then
653    MYSQL_CFLAGS=`$MYSQL_CONFIG --cflags`
654    MYSQL_CFLAGS=`eval echo $MYSQL_CFLAGS`
655    MYSQL_LIBS=`eval echo $MYSQL_LIBS`
656
657    save_CPPFLAGS="$CPPFLAGS"
658    CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
659
660    AC_CHECK_HEADER([mysql.h], [have_mysql_h=yes], [have_mysql_h=no])
661    if test "$have_mysql_h" = no -a "$mysql_enabled" = "yes" ; then
662      AC_MSG_ERROR(unable to find MySQL header files)
663    fi
664
665    if test "$have_mysql_h" = yes ; then
666       save_LIBS="$LIBS"
667       LIBS="$LIBS $MYSQL_LIBS"
668       AC_MSG_CHECKING(if we can link againt mysql)
669       AC_TRY_LINK(
670         [#include <mysql.h>],
671         [mysql_server_init(0, NULL, NULL)],
672         [have_mysql_libs=yes],
673         [have_mysql_libs=no])
674       LIBS="$save_LIBS"
675
676       if test "$have_mysql_libs" = no ; then
677          if "$mysql_enabled" = "yes" ; then
678             AC_MSG_ERROR([unable to link with MySQL Embedded Server Library])
679          else
680             AC_MSG_RESULT(no.  skipping MySQL)
681          fi
682       fi
683    fi
684
685    CPPFLAGS="$save_CPPFLAGS"
686 fi
687
688 # if have_mysql_libs=yes then go ahead with building MySQL
689 if test "$have_mysql_libs" = yes ; then
690    # this AC_MSG_RESULT is from above!
691    AC_MSG_RESULT(yes)
692    WANT_SUBDIRS="$WANT_SUBDIRS shib-mysql-ccache"
693    AC_SUBST(MYSQL_CFLAGS)
694    AC_SUBST(MYSQL_LIBS)
695 fi
696
697
698 AC_SUBST(WANT_SUBDIRS)
699
700 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
701   echo "=================================================================="
702   echo "WARNING: You have chosen to compile Apache-1.3 modules with a different"
703   echo "         compiler than the one used to compile Apache."
704   echo ""
705   echo "    Current compiler:      $CC"
706   echo "   Apache's compiler:      $APXS_CC"
707   echo ""
708   echo "This could cause some problems."
709   echo "=================================================================="
710 fi
711
712 if test -n "$APXS2_CC" && test "$APXS2_CC" != "$CC" ; then
713   echo "=================================================================="
714   echo "WARNING: You have chosen to compile Apache-2 modules with a different"
715   echo "         compiler than the one used to compile Apache."
716   echo ""
717   echo "    Current compiler:      $CC"
718   echo "   Apache's compiler:      $APXS2_CC"
719   echo ""
720   echo "This could cause some problems."
721   echo "=================================================================="
722 fi
723
724 AC_OUTPUT
725