Replaced RPC remoting with plain sockets and length-prefixed XML.
[shibboleth/sp.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([shibboleth], [2.0], [shibboleth-users@internet2.edu], [shibboleth])
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE([shibboleth],[2.0])
5
6 sinclude(acx_pthread.m4)
7
8 AC_ARG_ENABLE(debug,
9     AC_HELP_STRING(--enable-debug, [Have GCC compile with symbols (Default = no)
10 ]),
11     enable_debug=$enableval, enable_debug=no)
12
13 if test "$enable_debug" = "yes" ; then
14     GCC_CFLAGS="$CFLAGS -Wall -g -D_DEBUG"
15     GCC_CXXFLAGS="$CXXFLAGS -Wall -g -D_DEBUG"
16 else
17     GCC_CFLAGS="$CFLAGS -Wall -O2 -DNDEBUG"
18     GCC_CXXFLAGS="$CXXFLAGS -Wall -O2 -DNDEBUG"
19 fi
20
21 AC_PROG_CC([gcc gcc3 cc])
22 AC_PROG_CXX([g++ g++3 c++ CC])
23
24 if test "$GCC" = "yes" ; then
25     CFLAGS="$GCC_CFLAGS"
26     CXXFLAGS="$GCC_CXXFLAGS"
27 fi
28
29 AC_DISABLE_STATIC
30 AC_PROG_LIBTOOL
31
32 AC_LANG(C++)
33
34 # C++ requirements
35 AC_CXX_REQUIRE_STL
36 AC_CXX_NAMESPACES
37
38 AC_LANG(C)
39
40 # Checks for typedefs, structures, and compiler characteristics.
41 AC_C_CONST
42 AC_TYPE_SIZE_T
43 AC_STRUCT_TM
44
45 # Checks for library functions.
46 AC_FUNC_STRFTIME
47 AC_FUNC_STRERROR_R
48 AC_CHECK_FUNCS([strchr strdup strstr gmtime_r ctime_r strtok_r strcasecmp])
49 AC_CHECK_HEADERS([dlfcn.h])
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 AC_ARG_WITH(dmalloc,
69             AC_HELP_STRING([--with-dmalloc=PATH], [where dmalloc is installed]),
70             [if test x_$with_dmalloc != x_/usr; then
71                 LDFLAGS="-L${with_dmalloc}/lib $LDFLAGS"
72                 CPPFLAGS="-I${with_dmalloc}/include $CPPFLAGS"
73             fi
74             AC_CHECK_LIB(dmallocxx, dmalloc_shutdown,,
75                          AC_MSG_ERROR([unable to find dmallocxx library]))
76             ])
77
78 # OpenSSL settings
79 AC_PATH_PROG(PKG_CONFIG, pkg-config)
80 if test "x$PKG_CONFIG" = x || test "x$PKG_CONFIG" = "xno" ; then
81     AC_ARG_WITH(openssl, 
82             AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
83             [if test x_$with_openssl != x_/usr; then
84             SSLLIBS="-L${with_openssl}/lib"
85             SSLFLAGS="-I${with_openssl}/include"
86             fi])
87     SSLLIBS="$SSLLIBS -lssl -lcrypto"
88 else
89     SSLLIBS="`$PKG_CONFIG --libs openssl`"
90     SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
91 fi
92 AC_MSG_CHECKING(for OpenSSL libraries)
93 AC_MSG_RESULT($SSLLIBS)
94 LIBS="$LIBS $SSLLIBS"
95 AC_MSG_CHECKING(for OpenSSL cflags)
96 AC_MSG_RESULT($SSLFLAGS)
97 CPPFLAGS="$SSLFLAGS $CPPFLAGS"
98
99 AC_CHECK_HEADER([openssl/ssl.h],,
100                 AC_MSG_ERROR([unable to find openssl header files]))
101 AC_MSG_CHECKING(for ERR_load_CRYPTO_string)
102 AC_TRY_LINK_FUNC([ERR_load_CRYPTO_strings],,
103              AC_MSG_ERROR([unable to link with openssl libraries]))
104 AC_MSG_RESULT(yes)
105 AC_MSG_CHECKING(for SSL_library_init)
106 AC_TRY_LINK_FUNC([SSL_library_init],, 
107              AC_MSG_ERROR([unable to link with openssl libraries]))
108 AC_MSG_RESULT(yes)
109
110 AC_LANG(C++)
111
112 # log4cpp settings
113 AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
114 AC_ARG_WITH(log4cpp,
115             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp is installed]),
116             [LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"])
117 if test -f "${LOG4CPP_CONFIG}"; then
118     LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
119     CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
120 else
121     AC_MSG_WARN([log4cpp-config not found, guessing at log4cpp build settings])
122     LIBS="-llog4cpp $LIBS"
123 fi
124 AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
125 AC_TRY_LINK(
126         [#include <log4cpp/Category.hh>],
127         [log4cpp::Category::getInstance("foo")],
128         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
129         [AC_MSG_ERROR([unable to link with log4cpp])])
130
131 # Xerces settings
132 AC_ARG_WITH(xerces, 
133             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
134             [if test x_$with_xerces != x_/usr; then
135                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
136                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
137             fi])
138 LIBS="-lxerces-c $LIBS"
139 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
140                 AC_MSG_ERROR([unable to find xerces header files]))
141 AC_MSG_CHECKING([Xerces version])
142 AC_PREPROC_IFELSE(
143         [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
144 [#if  _XERCES_VERSION > 20200 && _XERCES_VERSION != 20600
145 int i = 0;
146 #else
147 #error requires version > 2.2.0 but not 2.6.0
148 #endif])],
149         [AC_MSG_RESULT(OK)],
150         [AC_MSG_ERROR([Shibboleth requires patched Xerces version 2.6.1 (http://shibboleth.internet2.edu/downloads/)])])
151 AC_TRY_LINK(
152         [#include <xercesc/util/PlatformUtils.hpp>],
153         [xercesc::XMLPlatformUtils::Initialize()],
154         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
155         [AC_MSG_ERROR([unable to link with Xerces])])
156
157
158 # XML-Security settings
159 AC_ARG_WITH(xmlsec,
160             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),
161             [if test x_$with_xmlsec != x_/usr; then
162                 LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
163                 CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
164             fi])
165 LIBS="-lxml-security-c $LIBS"
166 AC_CHECK_HEADER([xsec/xenc/XENCEncryptionMethod.hpp],,AC_MSG_ERROR([unable to find xml-security 1.1 header files]),[#include <xercesc/dom/DOM.hpp>])
167 AC_TRY_LINK(
168         [#include <xsec/utils/XSECPlatformUtils.hpp>],
169         [XSECPlatformUtils::Initialise()],
170         [AC_DEFINE(HAVE_LIBXSEC,1,[Define if XML-Sec library was found])],
171         [AC_MSG_ERROR([unable to link with xml-security])])
172
173 # OpenSAML settings
174 AC_ARG_WITH(saml,
175             AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
176             [if test x_$with_saml != x_/usr; then
177                 LDFLAGS="-L${with_saml}/lib $LDFLAGS"
178                 CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
179             fi])
180 AC_CHECK_HEADER([saml/saml.h],,
181                 AC_MSG_ERROR([unable to find saml header files]))
182 LIBS="-lsaml $LIBS"
183 AC_TRY_LINK(
184         [#include <saml/saml.h>
185 #include <saml/version.h>],
186         [#if _OPENSAML_VERSION >= 10100
187 saml::SAMLConfig::getConfig();
188 #else
189 #error Need OpenSAML version 1.1 or higher
190 #endif],
191         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
192         [AC_MSG_ERROR([unable to link with saml, or version too old])])
193
194 # output the underlying makefiles
195 WANT_SUBDIRS="doc shib schemas configs shib-target shar siterefresh test xmlproviders"
196 AC_CONFIG_FILES([Makefile doc/Makefile shib/Makefile schemas/Makefile \
197                  configs/Makefile shib-target/Makefile shar/Makefile siterefresh/Makefile \
198                  test/Makefile xmlproviders/Makefile selinux/Makefile])
199
200
201 #
202 # Build NSAPI module?
203 #
204 AC_MSG_CHECKING(for NSAPI module option)
205 AC_ARG_WITH(nsapi,
206         AC_HELP_STRING([--with-nsapi=DIR], [Build NSAPI module for Netscape/iPlanet/SunONE]),
207         [WANT_NSAPI=$withval],[WANT_NSAPI=no])
208 AC_MSG_RESULT($WANT_NSAPI)
209
210 if test "$WANT_NSAPI" != "no"; then
211   if test ! -d $WANT_NSAPI/bin ; then
212     AC_MSG_ERROR(Please specify the path to the root of your Netscape/iPlanet/SunONE server using --with-nsapi=DIR)
213   fi
214   AC_MSG_CHECKING(for NSAPI include files)
215   if test -d $WANT_NSAPI/include ; then
216     NSAPI_INCLUDE=$WANT_NSAPI/include
217     AC_MSG_RESULT(Netscape-Enterprise 3.x style)
218     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
219     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
220   fi
221   if test -d $WANT_NSAPI/plugins/include ; then
222     test -n "$NSAPI_INCLUDE" && NSAPI_INC_DIR="-I$NSAPI_INCLUDE"
223     NSAPI_INCLUDE="$WANT_NSAPI/plugins/include"
224     AC_MSG_RESULT(iPlanet 4.x / SunONE 6.x style)
225     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
226     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
227   fi
228   if test "$NSAPI_INCLUDE" = ""; then
229     AC_MSG_ERROR(Please check you have nsapi.h in either $WANT_NSAPI/include or $WANT_NSAPI/plugins/include)
230   fi
231 fi
232
233 AC_SUBST(NSAPI_INCLUDE)
234
235 # always output the Makefile, even if you don't use it
236 AC_CONFIG_FILES([nsapi_shib/Makefile])
237 AM_CONDITIONAL(BUILD_NSAPI,test ! "$WANT_NSAPI" = "no")
238
239 # add the NSAPI module to the list of wanted subdirs..
240 if test ! "$WANT_NSAPI" = "no" ; then
241     WANT_SUBDIRS="$WANT_SUBDIRS nsapi_shib"
242 fi
243
244
245 # Apache 1.3 (mod_shib_13)
246 #   --enable-apache-13
247 #   --with-apxs      (DSO build, the normal way, uses apxs to derive build flags)
248
249 AC_ARG_ENABLE(apache-13,
250         AC_HELP_STRING([--enable-apache-13], [enable the Apache 1.3 module]),
251         [ if test "x$enableval" = "x" ; then
252               WANT_APACHE_13=yes
253           else
254               WANT_APACHE_13="$enableval"
255           fi
256         ],[ WANT_APACHE_13=no ])
257 AC_MSG_CHECKING(whether to build Apache 1.3 module)
258 if test "$WANT_APACHE_13" != yes && test "$WANT_APACHE_13" != no ; then
259    WANT_APACHE_13=yes
260 fi
261 AC_MSG_RESULT($WANT_APACHE_13)
262
263 if test "$WANT_APACHE_13" = "yes" ; then
264     AC_ARG_WITH(apxs, 
265         AC_HELP_STRING([--with-apxs=FILE], [Specifies where to find the Apache 1.3 apxs script.]),
266         [
267         AC_MSG_CHECKING(for user-specified apxs name/location)
268         if test "$withval" != "no" ; then
269           if test "$withval" != "yes"; then
270             APXS=$withval
271             AC_MSG_RESULT("$withval")
272           fi
273         fi
274         ],
275         [
276         AC_PATH_PROG(APXS, apxs, no)
277         if test "$APXS" = "no" ; then
278           for i in /usr/sbin /usr/local/apache/bin ; do
279             if test "$APXS" = "no" && test -f "$i/apxs"; then
280               APXS="$i/apxs"
281             fi
282           done
283         fi
284         ])
285
286     AC_MSG_CHECKING([to see if apxs was located])
287     if test ! -f "$APXS" ; then
288         AC_MSG_RESULT(no)
289         AC_MSG_ERROR([Unable to locate apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs option.])
290     fi
291     AC_MSG_RESULT($APXS)
292     AC_SUBST(APXS)
293
294     # extract settings we need from APXS -q
295     APXS_CC="`$APXS -q CC`"
296     APXS_CFLAGS="`$APXS -q CPPFLAGS` `$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
297     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
298 fi
299
300 AC_SUBST(APXS_CFLAGS)
301 AC_SUBST(APXS_INCLUDE)
302
303
304 # Apache 2.0 (mod_shib_20)
305 #   --enable-apache-20
306 #   --with-apxs2      (DSO build, the normal way, uses apxs to derive build flags)
307 #       --with-apr        (DSO build, APR development package installed separately)
308
309 AC_ARG_ENABLE(apache-20,
310         AC_HELP_STRING([--enable-apache-20], [enable the Apache 2.0 module]),
311         [ if test "x$enableval" = "x" ; then
312               WANT_APACHE_20=yes
313           else
314               WANT_APACHE_20="$enableval"
315           fi
316         ],[ WANT_APACHE_20=no ])
317 AC_MSG_CHECKING(whether to build Apache 2.0 module)
318 if test "$WANT_APACHE_20" != yes && test "$WANT_APACHE_20" != no ; then
319    WANT_APACHE_20=yes
320 fi
321 AC_MSG_RESULT($WANT_APACHE_20)
322
323 if test "$WANT_APACHE_20" = "yes" ; then
324     AC_ARG_WITH(apxs2, 
325         AC_HELP_STRING([--with-apxs2=FILE], [Specifies where to find the Apache 2.0 apxs script.]),
326         [
327         AC_MSG_CHECKING(for user-specified Apache2 apxs name/location)
328         if test "$withval" != "no" ; then
329           if test "$withval" != "yes"; then
330             APXS2=$withval
331             AC_MSG_RESULT("$withval")
332           fi
333         fi
334         ],
335         [
336         AC_PATH_PROG(APXS2, apxs2, no)
337         if test "$APXS2" = "no" ; then
338             AC_PATH_PROG(APXS2, apxs, no)
339         fi
340         if test "$APXS2" = "no" ; then
341           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
342             if test "$APXS2" = "no" && test -f "$i/apxs2" ; then
343               APXS2="$i/apxs2"
344             fi
345           done
346           if test "$APXS2" = "no" ; then
347             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
348               if test "$APXS2" = "no" && test -f "$i/apxs" ; then
349                 APXS2="$i/apxs"
350               fi
351             done
352           fi
353         fi
354         ])
355
356     AC_MSG_CHECKING([to see if Apache2 apxs was located])
357     if test ! -f "$APXS2" ; then
358         AC_MSG_RESULT(no)
359         AC_MSG_ERROR([Unable to locate Apache2 apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs2 option.])
360     fi
361     AC_MSG_RESULT($APXS2)
362     AC_SUBST(APXS2)
363
364     # APR settings
365     AC_ARG_WITH(apr, 
366         AC_HELP_STRING([--with-apr=PATH], [where apr-config is installed]),
367         [
368         AC_MSG_CHECKING(for user-specified apr-config name/location)
369         if test "$withval" != "no" ; then
370             if test "$withval" != "yes"; then
371                 APR_CONFIG=$withval
372                 AC_MSG_RESULT("$withval")
373             fi
374         fi
375         ],
376         [
377         AC_PATH_PROG(APR_CONFIG, apr-config)
378         ])
379         if test -f "${APR_CONFIG}"; then
380         APR_CFLAGS="`${APR_CONFIG} --cflags` `${APR_CONFIG} --cppflags` `${APR_CONFIG} --includes`"
381     else
382         AC_MSG_ERROR([Unable to locate apr-config, may need --with-apr option.])
383     fi
384
385     # extract settings we need from APXS2 -q
386     APXS2_CC="`$APXS2 -q CC`"
387     APXS2_CFLAGS="`$APXS2 -q CPPFLAGS` `$APXS2 -q CFLAGS` `$APXS2 -q CFLAGS_SHLIB` $APR_CFLAGS"
388     APXS2_INCLUDE="`$APXS2 -q INCLUDEDIR`"
389 fi
390
391 AC_SUBST(APXS2_CFLAGS)
392 AC_SUBST(APXS2_INCLUDE)
393
394
395 # Apache 2.2 (mod_shib_22)
396 #   --enable-apache-22
397 #   --with-apxs22     (DSO build, the normal way, uses apxs to derive build flags)
398 #       --with-apr1       (DSO build, APR development package installed separately)
399
400 AC_ARG_ENABLE(apache-22,
401         AC_HELP_STRING([--enable-apache-22], [enable the Apache 2.2 module]),
402         [ if test "x$enableval" = "x" ; then
403               WANT_APACHE_22=yes
404           else
405               WANT_APACHE_22="$enableval"
406           fi
407         ],[ WANT_APACHE_22=no ])
408 AC_MSG_CHECKING(whether to build Apache 2.2 module)
409 if test "$WANT_APACHE_22" != yes && test "$WANT_APACHE_22" != no ; then
410    WANT_APACHE_22=yes
411 fi
412 AC_MSG_RESULT($WANT_APACHE_22)
413
414 if test "$WANT_APACHE_22" = "yes" ; then
415     AC_ARG_WITH(apxs22, 
416         AC_HELP_STRING([--with-apxs22=FILE], [Specifies where to find the Apache 2.2 apxs script.]),
417         [
418         AC_MSG_CHECKING(for user-specified Apache2.2 apxs name/location)
419         if test "$withval" != "no" ; then
420           if test "$withval" != "yes"; then
421             APXS22=$withval
422             AC_MSG_RESULT("$withval")
423           fi
424         fi
425         ],
426         [
427         AC_PATH_PROG(APXS22, apxs2, no)
428         if test "$APXS22" = "no" ; then
429             AC_PATH_PROG(APXS22, apxs, no)
430         fi
431         if test "$APXS22" = "no" ; then
432           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
433             if test "$APXS22" = "no" && test -f "$i/apxs2" ; then
434               APXS22="$i/apxs2"
435             fi
436           done
437           if test "$APXS22" = "no" ; then
438             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
439               if test "$APXS22" = "no" && test -f "$i/apxs" ; then
440                 APXS22="$i/apxs"
441               fi
442             done
443           fi
444         fi
445         ])
446
447     AC_MSG_CHECKING([to see if Apache2.2 apxs was located])
448     if test ! -f "$APXS22" ; then
449         AC_MSG_RESULT(no)
450         AC_MSG_ERROR([Unable to locate Apache2.2 apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs22 option.])
451     fi
452     AC_MSG_RESULT($APXS22)
453     AC_SUBST(APXS22)
454
455     # APR1 settings
456     AC_ARG_WITH(apr1, 
457         AC_HELP_STRING([--with-apr1=PATH], [where apr-1-config is installed]),
458         [
459         AC_MSG_CHECKING(for user-specified apr-1-config name/location)
460         if test "$withval" != "no" ; then
461             if test "$withval" != "yes"; then
462                 APR1_CONFIG=$withval
463                 AC_MSG_RESULT("$withval")
464             fi
465         fi
466         ],
467         [
468         AC_PATH_PROG(APR1_CONFIG, apr-1-config)
469         ])
470         if test -f "${APR1_CONFIG}"; then
471         APR1_CFLAGS="`${APR1_CONFIG} --cflags` `${APR1_CONFIG} --cppflags` `${APR1_CONFIG} --includes`"
472     else
473         AC_MSG_ERROR([Unable to locate apr-1-config, may need --with-apr1 option.])
474     fi
475
476     # extract settings we need from APXS22 -q
477     APXS22_CC="`$APXS22 -q CC`"
478     APXS22_CFLAGS="`$APXS22 -q CPPFLAGS` `$APXS22 -q CFLAGS` `$APXS22 -q CFLAGS_SHLIB` $APR1_CFLAGS"
479     APXS22_INCLUDE="`$APXS22 -q INCLUDEDIR`"
480 fi
481
482 AC_SUBST(APXS22_CFLAGS)
483 AC_SUBST(APXS22_INCLUDE)
484
485 # always output the Makefile, even if you don't use it
486 AC_CONFIG_FILES([apache/Makefile])
487 AM_CONDITIONAL(BUILD_AP13,test "$WANT_APACHE_13" = "yes")
488 AM_CONDITIONAL(BUILD_AP20,test "$WANT_APACHE_20" = "yes")
489 AM_CONDITIONAL(BUILD_AP22,test "$WANT_APACHE_22" = "yes")
490
491 # add the apache module to the list of wanted subdirs..
492 if test "$WANT_APACHE_13" = "yes" || test "$WANT_APACHE_20" = "yes" || test "$WANT_APACHE_22" = "yes" ; then
493     WANT_SUBDIRS="$WANT_SUBDIRS apache"
494 fi
495
496
497 #
498 # Implement the checks of the MySQL Credential Cache
499 #
500 # 1) Assume the user wants MySQL; if it's not found then just continue without
501 # 2) If the user specifically requested Mysql, look for it and ERROR if not found
502 # 3) If the user specifically requested no-mysql, don't build it.
503 #
504
505 AC_CONFIG_FILES([shib-mysql-ccache/Makefile])
506
507 # determine whether we should enable the mysql ccache
508 AC_ARG_ENABLE([mysql],
509         AC_HELP_STRING([--disable-mysql], [disable the MySQL Credential Cache]),
510         [mysql_enabled=$enableval], [mysql_enabled=default])
511
512 if test "x$mysql_enabled" = "x" ; then
513    mysql_enabled=yes
514 fi
515
516 # Are we trying to build MySQL?
517 AC_MSG_CHECKING(whether to build the MySQL ccache)
518 if test "$mysql_enabled" = "yes" ; then
519    build_mysql=yes
520    AC_MSG_RESULT(yes)
521 elif test "$mysql_enabled" = "default" ; then
522    build_mysql=yes
523    AC_MSG_RESULT([yes, if it can be found])
524 else
525    build_mysql=no
526    AC_MSG_RESULT(no)
527 fi
528
529 # If we're trying to build MySQL, try to find the mysql_config program,
530 # verify we've got mysql >= 4, and make sure we can build with mysqld
531 if test "$build_mysql" = "yes" ; then
532    mysql_dir=""
533    AC_ARG_WITH(mysql,
534         AC_HELP_STRING([--with-mysql=PATH], [directory where mysql is installed]),
535             [if test "$with_mysql" = no ; then
536              AC_MSG_ERROR([Try running --disable-mysql instead.])
537          elif test "$with_mysql" != yes ; then
538              mysql_dir="$with_mysql/bin"
539          fi ])
540
541    # Try to find the mysql_config program
542    AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no, $mysql_dir $PATH )
543
544    if test "$MYSQL_CONFIG" = no ; then
545       if test "$mysql_enabled" = "yes" ; then
546         AC_MSG_ERROR(Cannot find mysql_config)
547       else
548         AC_MSG_WARN(MySQL not found.  skipping.)
549       fi
550    fi
551 fi
552
553 # if we found mysql_config then build_mysql is 'yes'
554 if test "$MYSQL_CONFIG" != no ; then
555    AC_MSG_CHECKING(for mysql version >= 4)
556    mysql_version=`$MYSQL_CONFIG --version`
557    mysql_major_version=`echo $mysql_version | awk -F. '{print $1}'`
558    mysql_version_ok=yes
559    if test $mysql_major_version -lt 4 ; then
560      mysql_version_ok=no
561      if test "$mysql_enabled" = "yes" ; then
562        AC_MSG_ERROR(You need MySQL version >= 4, found $mysql_version)
563      fi
564      AC_MSG_RESULT(no.. skipping MySQL)
565    else
566      AC_MSG_RESULT(yes)
567    fi
568 fi
569
570 # if mysql_version_ok is 'yes', then we've made it this far.. ;)
571 if test "$mysql_version_ok" = "yes" ; then
572    AC_MSG_CHECKING(for embedded-MySQL libraries)
573    MYSQL_LIBS=`$MYSQL_CONFIG --libmysqld-libs`
574    if test $? != 0 ; then
575       found_mysql=no
576       if test "$mysql_enabled" = "yes" ; then
577         AC_MSG_ERROR(Could not find the MySQL Embedded-server libraries.)
578       else
579         AC_MSG_RESULT(no.. skipping MySQL)
580       fi
581    else
582       found_mysql=yes
583       AC_MSG_RESULT(yes)
584    fi
585 fi
586
587 # if found_mysql=yes then test that we can actually build mysql
588 if test "$found_mysql" = yes ; then
589    MYSQL_CFLAGS=`$MYSQL_CONFIG --cflags`
590    MYSQL_CFLAGS=`eval echo $MYSQL_CFLAGS`
591    MYSQL_LIBS=`eval echo $MYSQL_LIBS`
592
593    save_CPPFLAGS="$CPPFLAGS"
594    CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
595
596    AC_CHECK_HEADER([mysql.h], [have_mysql_h=yes], [have_mysql_h=no])
597    if test "$have_mysql_h" = no -a "$mysql_enabled" = "yes" ; then
598      AC_MSG_ERROR(unable to find MySQL header files)
599    fi
600
601    if test "$have_mysql_h" = yes ; then
602       save_LIBS="$LIBS"
603       LIBS="$LIBS $MYSQL_LIBS"
604       AC_MSG_CHECKING(if we can link againt mysql)
605       AC_TRY_LINK(
606         [#include <mysql.h>
607          #include <stdio.h>],
608         [mysql_server_init(0, NULL, NULL)],
609         [have_mysql_libs=yes],
610         [have_mysql_libs=no])
611       LIBS="$save_LIBS"
612
613       if test "$have_mysql_libs" = no ; then
614          if test "$mysql_enabled" = "yes" ; then
615             AC_MSG_ERROR([unable to link with MySQL Embedded Server Library])
616          else
617             AC_MSG_RESULT(no.  skipping MySQL)
618          fi
619       fi
620    fi
621
622    CPPFLAGS="$save_CPPFLAGS"
623 fi
624
625 # if have_mysql_libs=yes then go ahead with building MySQL
626 if test "$have_mysql_libs" = yes ; then
627    # this AC_MSG_RESULT is from above!
628    AC_MSG_RESULT(yes)
629    WANT_SUBDIRS="$WANT_SUBDIRS shib-mysql-ccache"
630    AC_SUBST(MYSQL_CFLAGS)
631    AC_SUBST(MYSQL_LIBS)
632 fi
633
634
635 #
636 # Implement the checks of the ODBC Credential Cache
637 #
638 # 1) Assume the user wants ODBC; if it's not found then just continue without
639 # 2) If the user specifically requested odbc, look for it and ERROR if not found
640 # 3) If the user specifically requested no-odbc, don't build it.
641 #
642
643 AC_CONFIG_FILES([odbc_ccache/Makefile])
644
645 # determine whether we should enable the odbc ccache
646 AC_ARG_ENABLE([odbc],
647         AC_HELP_STRING([--disable-odbc], [disable the ODBC Credential Cache]),
648         [odbc_enabled=$enableval], [odbc_enabled=default])
649
650 if test "x$odbc_enabled" = "x" ; then
651    odbc_enabled=yes
652 fi
653
654 # Are we trying to build ODBC?
655 AC_MSG_CHECKING(whether to build the ODBC ccache)
656 if test "$odbc_enabled" = "yes" ; then
657    build_odbc=yes
658    AC_MSG_RESULT(yes)
659 elif test "$odbc_enabled" = "default" ; then
660    build_odbc=yes
661    AC_MSG_RESULT([yes, if it can be found])
662 else
663    build_odbc=no
664    AC_MSG_RESULT(no)
665 fi
666
667 # If we're trying to build ODBC, try to find the odbc_config program.
668 if test "$build_odbc" = "yes" ; then
669    odbc_dir=""
670    AC_ARG_WITH(odbc,
671         AC_HELP_STRING([--with-odbc=PATH], [directory where odbc is installed]),
672             [if test "$with_odbc" = no ; then
673                AC_MSG_ERROR([Try running --disable-odbc instead.])
674              elif test "$with_odbc" != yes ; then
675                odbc_dir="$with_odbc/bin"
676              fi ])
677
678    # Try to find the mysql_config program
679    AC_PATH_PROG(ODBC_CONFIG, odbc_config, no, $odbc_dir $PATH )
680
681    if test "$ODBC_CONFIG" = no ; then
682       if test "$odbc_enabled" = "yes" ; then
683         AC_MSG_ERROR(Cannot find odbc_config)
684       else
685         AC_MSG_WARN(ODBC not found, skipping.)
686       fi
687    fi
688 fi
689
690 if test "$build_odbc" = yes ; then
691    ODBC_CFLAGS=`$ODBC_CONFIG --cflags`
692    ODBC_CFLAGS=`eval echo $ODBC_CFLAGS`
693    ODBC_LIBS=`$ODBC_CONFIG --libs`
694    ODBC_LIBS=`eval echo $ODBC_LIBS`
695
696    save_CPPFLAGS="$CPPFLAGS"
697    CPPFLAGS="$CPPFLAGS $ODBC_CFLAGS"
698
699    AC_CHECK_HEADER([sql.h], [have_sql_h=yes], [have_sql_h=no])
700    if test "$have_sql_h" = no -a "$odbc_enabled" = "yes" ; then
701      AC_MSG_ERROR(unable to find ODBC header files)
702    fi
703
704    if test "$have_sql_h" = yes ; then
705       save_LIBS="$LIBS"
706       LIBS="$LIBS $ODBC_LIBS"
707       AC_MSG_CHECKING(if we can link againt ODBC)
708       AC_TRY_LINK(
709         [#include <sql.h>
710          #include <sqlext.h>
711          #include <stdio.h>],
712         [SQLSetEnvAttr(SQL_NULL_HANDLE, SQL_ATTR_CONNECTION_POOLING, (void*)SQL_CP_ONE_PER_HENV, 0)],
713         [have_odbc_libs=yes],
714         [have_odbc_libs=no])
715       LIBS="$save_LIBS"
716
717       if test "$have_odbc_libs" = no ; then
718          if test "$odbc_enabled" = "yes" ; then
719             AC_MSG_ERROR([unable to link with ODBC Library])
720          else
721             AC_MSG_RESULT(no, skipping ODBC)
722          fi
723       fi
724    fi
725
726    CPPFLAGS="$save_CPPFLAGS"
727 fi
728
729 # if have_odbc_libs=yes then go ahead with building ODBC
730 if test "$have_odbc_libs" = yes ; then
731    # this AC_MSG_RESULT is from above!
732    AC_MSG_RESULT(yes)
733    WANT_SUBDIRS="$WANT_SUBDIRS odbc_ccache"
734    AC_SUBST(ODBC_CFLAGS)
735    AC_SUBST(ODBC_LIBS)
736 fi
737
738
739 AC_SUBST(WANT_SUBDIRS)
740
741 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
742   echo "=================================================================="
743   echo "WARNING: You have chosen to compile Apache-1.3 modules with a different"
744   echo "         compiler than the one used to compile Apache."
745   echo ""
746   echo "    Current compiler:      $CC"
747   echo "   Apache's compiler:      $APXS_CC"
748   echo ""
749   echo "This could cause problems."
750   echo "=================================================================="
751 fi
752
753 if test -n "$APXS2_CC" && test "$APXS2_CC" != "$CC" ; then
754   echo "=================================================================="
755   echo "WARNING: You have chosen to compile Apache-2 modules with a different"
756   echo "         compiler than the one used to compile Apache."
757   echo ""
758   echo "    Current compiler:      $CC"
759   echo "   Apache's compiler:      $APXS2_CC"
760   echo ""
761   echo "This could cause problems."
762   echo "=================================================================="
763 fi
764
765 LIBTOOL="$LIBTOOL --silent"
766
767 AC_OUTPUT
768