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