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