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