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