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