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