Fix log4shib/log4cpp link check.
[shibboleth/cpp-sp.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([shibboleth], [1.3.1], [shibboleth-users@internet2.edu], [shibboleth])
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE([shibboleth],[1.3.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 -Wall -g -D_DEBUG"
16     GCC_CXXFLAGS="$CXXFLAGS -Wall -g -D_DEBUG"
17 else
18     GCC_CFLAGS="$CFLAGS -Wall -O2 -DNDEBUG"
19     GCC_CXXFLAGS="$CXXFLAGS -Wall -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 ctime_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 # Test RPC now -- finish dealing with it later
70 AC_ARG_ENABLE(native-rpc,
71         AC_HELP_STRING([--enable-native-rpc], [use the OS-supplied Sun RPC library, default is NO, except Linux]),
72         [ if test "x$enableval" = "x" ; then
73               NATIVE_RPC=yes
74           else
75               NATIVE_RPC="$enableval"
76           fi
77         ], [ NATIVE_RPC=no ])
78 ACX_RPCTEST([rpctest="yes"],[rpctest="no"])
79 AC_MSG_NOTICE([does the native Sun RPC library support svcfd_create...$rpctest])
80 if test $NATIVE_RPC = "no"; then
81         case "${host}" in
82                 *-*-linux*)
83                         if test $rpctest = "yes"; then
84                                 AC_MSG_WARN([embedded Sun RPC library does not support Linux])
85                                 NATIVE_RPC="yes"
86                         else
87                                 AC_MSG_ERROR([embedded Sun RPC library won't work, but neither will native version])
88                         fi
89                 ;;
90         esac
91 fi
92 if test $NATIVE_RPC = "yes" && test $rpctest = "no"; then
93         AC_MSG_WARN([native Sun RPC won't work, using internal version])
94         NATIVE_RPC = "no"
95 fi
96 if test $NATIVE_RPC = "yes"; then
97         AC_CHECK_DECLS([svcfd_create],,,[#include <rpc/rpc.h>])
98         AC_LANG_PUSH(C++)
99         AC_COMPILE_IFELSE(
100                 AC_LANG_PROGRAM(
101                         [[#include <rpc/rpc.h>
102 static SVCXPRT* xprt = NULL;]],
103                 [[svc_destroy(xprt);]]),
104         AC_DEFINE(HAVE_WORKING_SVC_DESTROY,1,[Define if RPC SVC macros work on this platform]),)
105         AC_LANG_POP(C++)
106 else
107         AC_CHECK_TYPES([struct rpcent],,,[#include <netdb.h>])
108         AC_CHECK_DECLS(sys_errlist)
109         AC_DEFINE(HAVE_DECL_SVCFD_CREATE,1,[ Define to 1 if you have the declaration of svcfd_create, and to 0 if you don't.])
110         AC_DEFINE(HAVE_WORKING_SVC_DESTROY,1,[Define if RPC SVC macros work on this platform])
111 fi
112
113 AC_ARG_WITH(dmalloc,
114             AC_HELP_STRING([--with-dmalloc=PATH], [where dmalloc is installed]),
115             [if test x_$with_dmalloc != x_/usr; then
116                 LDFLAGS="-L${with_dmalloc}/lib $LDFLAGS"
117                 CPPFLAGS="-I${with_dmalloc}/include $CPPFLAGS"
118             fi
119             AC_CHECK_LIB(dmallocxx, dmalloc_shutdown,,
120                          AC_MSG_ERROR([unable to find dmallocxx library]))
121             ])
122
123 # OpenSSL settings
124 AC_PATH_PROG(PKG_CONFIG, pkg-config)
125 if test "x$PKG_CONFIG" = x || test "x$PKG_CONFIG" = "xno" ; then
126     AC_ARG_WITH(openssl, 
127             AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
128             [if test x_$with_openssl != x_/usr; then
129             SSLLIBS="-L${with_openssl}/lib"
130             SSLFLAGS="-I${with_openssl}/include"
131             fi])
132     SSLLIBS="$SSLLIBS -lssl -lcrypto"
133 else
134     SSLLIBS="`$PKG_CONFIG --libs openssl`"
135     SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
136 fi
137 AC_MSG_CHECKING(for OpenSSL libraries)
138 AC_MSG_RESULT($SSLLIBS)
139 LIBS="$LIBS $SSLLIBS"
140 AC_MSG_CHECKING(for OpenSSL cflags)
141 AC_MSG_RESULT($SSLFLAGS)
142 CPPFLAGS="$SSLFLAGS $CPPFLAGS"
143
144 AC_CHECK_HEADER([openssl/ssl.h],,
145                 AC_MSG_ERROR([unable to find openssl header files]))
146 AC_MSG_CHECKING(for ERR_load_CRYPTO_string)
147 AC_TRY_LINK_FUNC([ERR_load_CRYPTO_strings],,
148              AC_MSG_ERROR([unable to link with openssl libraries]))
149 AC_MSG_RESULT(yes)
150 AC_MSG_CHECKING(for SSL_library_init)
151 AC_TRY_LINK_FUNC([SSL_library_init],, 
152              AC_MSG_ERROR([unable to link with openssl libraries]))
153 AC_MSG_RESULT(yes)
154
155 AC_LANG(C++)
156
157 # log4shib settings (favor this version over the log4cpp code)
158 AC_PATH_PROG(LOG4SHIB_CONFIG,log4shib-config)
159 AC_ARG_WITH(log4shib,
160     AC_HELP_STRING([--with-log4shib=PATH], [where log4shib-config is installed]),
161     [
162     LOG4SHIB_CONFIG="${with_log4shib}"
163     if ! test -f "${LOG4SHIB_CONFIG}" ; then
164         LOG4SHIB_CONFIG="${with_log4shib}/bin/log4shib-config"
165     fi
166     ])
167 if test -f "${LOG4SHIB_CONFIG}"; then
168     LDFLAGS="`${LOG4SHIB_CONFIG} --libs` $LDFLAGS"
169     CPPFLAGS="`${LOG4SHIB_CONFIG} --cflags` $CPPFLAGS"
170         AC_CHECK_HEADER([log4shib/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4shib header files]))
171         AC_TRY_LINK(
172                 [#include <log4shib/Category.hh> #include <log4shib/CategoryStream.hh>],
173                 [log4shib::Category::getInstance("foo").errorStream() << log4shib::eol],
174                 [AC_DEFINE(HAVE_LOG4SHIB,1,[Define if log4shib library is used.])],
175                 [AC_MSG_ERROR([unable to link with log4shib])])
176 else
177     AC_MSG_WARN([log4shib-config not found, may need to use --with-log4shib option])
178     AC_MSG_WARN([will look for original log4cpp library])
179     
180         # log4cpp settings
181         AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
182         AC_ARG_WITH(log4cpp,
183             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
184             [
185             LOG4CPP_CONFIG="${with_log4cpp}"
186             if ! test -f "${LOG4CPP_CONFIG}" ; then
187                 LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
188             fi
189             ])
190         if test -f "${LOG4CPP_CONFIG}"; then
191                 AC_MSG_WARN([will try to use log4cpp, note that most non-Internet2 supplied versions are not thread-safe])
192             LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
193             CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
194                 AC_CHECK_HEADER([log4cpp/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
195                 AC_TRY_LINK(
196                         [#include <log4cpp/Category.hh> #include <log4cpp/CategoryStream.hh>],
197                         [log4cpp::Category::getInstance("foo").errorStream() << log4cpp::eol],
198                         [AC_DEFINE(HAVE_LOG4CPP,1,[Define if log4cpp library is used.])],
199                         [AC_MSG_ERROR([unable to link with log4cpp, at least version 1.0 needed])])
200         else
201             AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
202         fi
203 fi
204
205 # Xerces settings
206 AC_ARG_WITH(xerces, 
207             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
208             [if test x_$with_xerces != x_/usr; then
209                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
210                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
211             fi])
212 LIBS="-lxerces-c $LIBS"
213 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
214                 AC_MSG_ERROR([unable to find xerces header files]))
215 AC_MSG_CHECKING([Xerces version])
216 AC_PREPROC_IFELSE(
217         [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
218 [#if  _XERCES_VERSION > 20200 && _XERCES_VERSION != 20600
219 int i = 0;
220 #else
221 #error requires version > 2.2.0 but not 2.6.0
222 #endif])],
223         [AC_MSG_RESULT(OK)],
224         [AC_MSG_ERROR([Shibboleth requires patched Xerces version 2.6.1 (http://shibboleth.internet2.edu/downloads/)])])
225 AC_TRY_LINK(
226         [#include <xercesc/util/PlatformUtils.hpp>],
227         [xercesc::XMLPlatformUtils::Initialize()],
228         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
229         [AC_MSG_ERROR([unable to link with Xerces])])
230
231
232 # XML-Security settings
233 AC_ARG_WITH(xmlsec,
234             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),
235             [if test x_$with_xmlsec != x_/usr; then
236                 LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
237                 CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
238             fi])
239 LIBS="-lxml-security-c $LIBS"
240 AC_CHECK_HEADER([xsec/xenc/XENCEncryptionMethod.hpp],,AC_MSG_ERROR([unable to find xml-security 1.1 header files]),[#include <xercesc/dom/DOM.hpp>])
241 AC_TRY_LINK(
242         [#include <xsec/utils/XSECPlatformUtils.hpp>],
243         [XSECPlatformUtils::Initialise()],
244         [AC_DEFINE(HAVE_LIBXSEC,1,[Define if XML-Sec library was found])],
245         [AC_MSG_ERROR([unable to link with xml-security])])
246
247 # OpenSAML settings
248 AC_ARG_WITH(saml,
249             AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
250             [if test x_$with_saml != x_/usr; then
251                 LDFLAGS="-L${with_saml}/lib $LDFLAGS"
252                 CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
253             fi])
254 AC_CHECK_HEADER([saml/saml.h],,
255                 AC_MSG_ERROR([unable to find saml header files]))
256 LIBS="-lsaml $LIBS"
257 AC_TRY_LINK(
258         [#include <saml/saml.h>
259 #include <saml/version.h>],
260         [#if _OPENSAML_VERSION >= 10100
261 saml::SAMLConfig::getConfig();
262 #else
263 #error Need OpenSAML version 1.1 or higher
264 #endif],
265         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
266         [AC_MSG_ERROR([unable to link with saml, or version too old])])
267
268 # output the underlying makefiles
269 WANT_SUBDIRS="doc shib schemas configs shib-target shar siterefresh test xmlproviders adfs"
270 AC_CONFIG_FILES([Makefile doc/Makefile shib/Makefile schemas/Makefile \
271                  configs/Makefile oncrpc/Makefile oncrpc/rpc/Makefile \
272                  shib-target/Makefile shar/Makefile siterefresh/Makefile \
273                  test/Makefile xmlproviders/Makefile adfs/Makefile selinux/Makefile])
274
275
276 # now deal with the rpc library, to see if we need to build our own
277 if test $NATIVE_RPC = "no"; then
278     WANT_SUBDIRS="oncrpc $WANT_SUBDIRS"
279         AC_DEFINE(USE_OUR_ONCRPC,1,[Define if using embedded version of ONC RPC.])
280 fi
281 AM_CONDITIONAL(USE_OUR_ONCRPC,test "$NATIVE_RPC" = "no")
282
283 #
284 # Build NSAPI module?
285 #
286 AC_MSG_CHECKING(for NSAPI module option)
287 AC_ARG_WITH(nsapi,
288         AC_HELP_STRING([--with-nsapi=DIR], [Build NSAPI module for Netscape/iPlanet/SunONE]),
289         [WANT_NSAPI=$withval],[WANT_NSAPI=no])
290 AC_MSG_RESULT($WANT_NSAPI)
291
292 if test "$WANT_NSAPI" != "no"; then
293   if test ! -d $WANT_NSAPI/bin ; then
294     AC_MSG_ERROR(Please specify the path to the root of your Netscape/iPlanet/SunONE server using --with-nsapi=DIR)
295   fi
296   AC_MSG_CHECKING(for NSAPI include files)
297   if test -d $WANT_NSAPI/include ; then
298     NSAPI_INCLUDE=$WANT_NSAPI/include
299     AC_MSG_RESULT(Netscape-Enterprise 3.x style)
300     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
301     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
302   fi
303   if test -d $WANT_NSAPI/plugins/include ; then
304     test -n "$NSAPI_INCLUDE" && NSAPI_INC_DIR="-I$NSAPI_INCLUDE"
305     NSAPI_INCLUDE="$WANT_NSAPI/plugins/include"
306     AC_MSG_RESULT(iPlanet 4.x / SunONE 6.x style)
307     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
308     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
309   fi
310   if test "$NSAPI_INCLUDE" = ""; then
311     AC_MSG_ERROR(Please check you have nsapi.h in either $WANT_NSAPI/include or $WANT_NSAPI/plugins/include)
312   fi
313 fi
314
315 AC_SUBST(NSAPI_INCLUDE)
316
317 # always output the Makefile, even if you don't use it
318 AC_CONFIG_FILES([nsapi_shib/Makefile])
319 AM_CONDITIONAL(BUILD_NSAPI,test ! "$WANT_NSAPI" = "no")
320
321 # add the NSAPI module to the list of wanted subdirs..
322 if test ! "$WANT_NSAPI" = "no" ; then
323     WANT_SUBDIRS="$WANT_SUBDIRS nsapi_shib"
324 fi
325
326
327 #
328 # Build FastCGI support?
329 #
330 AC_MSG_CHECKING(for FastCGI support)
331 AC_ARG_WITH(fastcgi,
332     AC_HELP_STRING([--with-fastcgi=DIR], [Build FastCGI support]),
333     [WANT_FASTCGI=$withval],[WANT_FASTCGI=no])
334 AC_MSG_RESULT($WANT_FASTCGI)
335
336 if test "$WANT_FASTCGI" != "no"; then
337     if test "$WANT_FASTCGI" != "yes"; then
338         if test x_$WANT_FASTCGI != x_/usr; then
339             FASTCGI_INCLUDE="-I$WANT_FASTCGI/include"
340             FASTCGI_LDFLAGS="-L$WANT_FASTCGI/lib"
341         fi
342     fi
343     AC_CHECK_HEADER([fcgio.h],,
344         AC_MSG_ERROR([unable to find FastCGI header files]))
345     FASTCGI_LIBS="-lfcgi -lfcgi++"
346 fi
347
348 AC_SUBST(FASTCGI_INCLUDE)
349 AC_SUBST(FASTCGI_LDFLAGS)
350 AC_SUBST(FASTCGI_LIBS)
351
352 # always output the Makefile, even if you don't use it
353 AC_CONFIG_FILES([fastcgi/Makefile])
354 AM_CONDITIONAL(BUILD_FASTCGI,test ! "$WANT_FASTCGI" = "no")
355 if test ! "$WANT_FASTCGI" = "no" ; then
356     WANT_SUBDIRS="$WANT_SUBDIRS fastcgi"
357 fi
358
359
360 #
361 # If no --enable-apache-xx specified 
362 # find a default and fake the specific parameters
363 #
364
365 # simple macro to peek at an enable or a with
366 AC_DEFUN([Peek],
367 if test "[${[$1]_][$2]+set}" = set; then
368   peekval="${[$1]_[$2]}"
369   $3
370 fi; dnl
371 )
372
373 AC_MSG_CHECKING(if default apache needed)
374 need_default=yes
375 Peek(enable,apache_13,need_default=no)
376 Peek(enable,apache_20,need_default=no)
377 Peek(enable,apache_22,need_default=no)
378 AC_MSG_RESULT($need_default)
379
380 if test "$need_default" = "yes"; then
381   # find an apxs, then the httpd
382   xs=
383   Peek(with,apxs,xs="$peekval")
384   Peek(with,apxs2,xs="$peekval")
385   Peek(with,apxs22,xs="$peekval")
386   if test "x$xs" = "x"; then
387      AC_PATH_PROGS(xs, apxs2 apxs,
388         AC_MSG_ERROR(No apxs, no apache found.  Try --with-apxs),
389         [/usr/local/apache2/bin:/usr/local/apache/bin:/usr/sbin:$PATH])
390   fi
391   # ask the daemon for the version and set parameters
392   AC_MSG_CHECKING(default apache version)
393   httpd="`$xs -q SBINDIR`/`$xs -q TARGET`"
394   if test "x$httpd" != "x" && test -f $httpd ; then
395      v=`$httpd -v|$SED -n -e 's/.*Apache\/\.*//p'`
396      case $v in
397        1.3*)   [enable_apache_13]=yes
398                [with_apxs]=$xs
399                AC_MSG_RESULT(1.3)
400                ;;
401        2.0*)   [enable_apache_20]=yes
402                [with_apxs2]=$xs
403                AC_MSG_RESULT(2.0)
404                ;;
405        2.2*)   [enable_apache_22]=yes
406                [with_apxs22]=$xs
407                AC_MSG_RESULT(2.2)
408                ;;
409        *)      AC_MSG_ERROR(unusable apache versions: $v. Try setting --with-apxs)
410      esac
411   else 
412      AC_MSG_RESULT(cannot determine version.  Try setting --with-apxs)
413   fi
414 fi
415
416
417 # Apache 1.3 (mod_shib_13)
418 #   --enable-apache-13
419 #   --with-apxs      (DSO build, the normal way, uses apxs to derive build flags)
420
421 AC_ARG_ENABLE(apache-13,
422         AC_HELP_STRING([--enable-apache-13], [enable the Apache 1.3 module]),
423         [ if test "x$enableval" = "x" ; then
424               WANT_APACHE_13=yes
425           else
426               WANT_APACHE_13="$enableval"
427           fi
428         ],[ WANT_APACHE_13=no ])
429 AC_MSG_CHECKING(whether to build Apache 1.3 module)
430 if test "$WANT_APACHE_13" != yes && test "$WANT_APACHE_13" != no ; then
431    WANT_APACHE_13=yes
432 fi
433 AC_MSG_RESULT($WANT_APACHE_13)
434
435 if test "$WANT_APACHE_13" = "yes" ; then
436     AC_ARG_WITH(apxs, 
437         AC_HELP_STRING([--with-apxs=FILE], [Specifies where to find the Apache 1.3 apxs script.]),
438         [
439         AC_MSG_CHECKING(for user-specified apxs name/location)
440         if test "$withval" != "no" ; then
441           if test "$withval" != "yes"; then
442             APXS=$withval
443             AC_MSG_RESULT("$withval")
444           fi
445         fi
446         ],
447         [
448         AC_PATH_PROG(APXS, apxs, no)
449         if test "$APXS" = "no" ; then
450           for i in /usr/sbin /usr/local/apache/bin ; do
451             if test "$APXS" = "no" && test -f "$i/apxs"; then
452               APXS="$i/apxs"
453             fi
454           done
455         fi
456         ])
457
458     AC_MSG_CHECKING([to see if apxs was located])
459     if test ! -f "$APXS" ; then
460         AC_MSG_RESULT(no)
461         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.])
462     fi
463     AC_MSG_RESULT($APXS)
464     AC_SUBST(APXS)
465
466     # extract settings we need from APXS -q
467     APXS_CC="`$APXS -q CC`"
468     APXS_CFLAGS="`$APXS -q CPPFLAGS` `$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
469     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
470 fi
471
472 AC_SUBST(APXS_CFLAGS)
473 AC_SUBST(APXS_INCLUDE)
474
475
476 # Apache 2.0 (mod_shib_20)
477 #   --enable-apache-20
478 #   --with-apxs2      (DSO build, the normal way, uses apxs to derive build flags)
479 #       --with-apr        (DSO build, APR development package installed separately)
480
481 AC_ARG_ENABLE(apache-20,
482         AC_HELP_STRING([--enable-apache-20], [enable the Apache 2.0 module]),
483         [ if test "x$enableval" = "x" ; then
484               WANT_APACHE_20=yes
485           else
486               WANT_APACHE_20="$enableval"
487           fi
488         ],[ WANT_APACHE_20=no ])
489 AC_MSG_CHECKING(whether to build Apache 2.0 module)
490 if test "$WANT_APACHE_20" != yes && test "$WANT_APACHE_20" != no ; then
491    WANT_APACHE_20=yes
492 fi
493 AC_MSG_RESULT($WANT_APACHE_20)
494
495 if test "$WANT_APACHE_20" = "yes" ; then
496     AC_ARG_WITH(apxs2, 
497         AC_HELP_STRING([--with-apxs2=FILE], [Specifies where to find the Apache 2.0 apxs script.]),
498         [
499         AC_MSG_CHECKING(for user-specified Apache2 apxs name/location)
500         if test "$withval" != "no" ; then
501           if test "$withval" != "yes"; then
502             APXS2=$withval
503             AC_MSG_RESULT("$withval")
504           fi
505         fi
506         ],
507         [
508         AC_PATH_PROG(APXS2, apxs2, no)
509         if test "$APXS2" = "no" ; then
510             AC_PATH_PROG(APXS2, apxs, no)
511         fi
512         if test "$APXS2" = "no" ; then
513           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
514             if test "$APXS2" = "no" && test -f "$i/apxs2" ; then
515               APXS2="$i/apxs2"
516             fi
517           done
518           if test "$APXS2" = "no" ; then
519             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
520               if test "$APXS2" = "no" && test -f "$i/apxs" ; then
521                 APXS2="$i/apxs"
522               fi
523             done
524           fi
525         fi
526         ])
527
528     AC_MSG_CHECKING([to see if Apache2 apxs was located])
529     if test ! -f "$APXS2" ; then
530         AC_MSG_RESULT(no)
531         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.])
532     fi
533     AC_MSG_RESULT($APXS2)
534     AC_SUBST(APXS2)
535
536     # APR settings
537     AC_ARG_WITH(apr, 
538         AC_HELP_STRING([--with-apr=PATH], [where apr-config is installed]),
539         [
540         AC_MSG_CHECKING(for user-specified apr-config name/location)
541         if test "$withval" != "no" ; then
542             if test "$withval" != "yes"; then
543                 APR_CONFIG=$withval
544                 AC_MSG_RESULT("$withval")
545             fi
546         fi
547         ],
548         [
549         AC_PATH_PROG(APR_CONFIG, apr-config,,[`$APXS2 -q SBINDIR`]:[$PATH])
550         ])
551         if test -f "${APR_CONFIG}"; then
552         APR_CFLAGS="`${APR_CONFIG} --cflags` `${APR_CONFIG} --cppflags` `${APR_CONFIG} --includes`"
553     else
554         AC_MSG_ERROR([Unable to locate apr-config, may need --with-apr option.])
555     fi
556
557     # extract settings we need from APXS2 -q
558     APXS2_CC="`$APXS2 -q CC`"
559     APXS2_CFLAGS="`$APXS2 -q CPPFLAGS` `$APXS2 -q CFLAGS` `$APXS2 -q CFLAGS_SHLIB` $APR_CFLAGS"
560     APXS2_INCLUDE="`$APXS2 -q INCLUDEDIR`"
561 fi
562
563 AC_SUBST(APXS2_CFLAGS)
564 AC_SUBST(APXS2_INCLUDE)
565
566
567 # Apache 2.2 (mod_shib_22)
568 #   --enable-apache-22
569 #   --with-apxs22     (DSO build, the normal way, uses apxs to derive build flags)
570 #       --with-apr1       (DSO build, APR development package installed separately)
571
572 AC_ARG_ENABLE(apache-22,
573         AC_HELP_STRING([--enable-apache-22], [enable the Apache 2.2 module]),
574         [ if test "x$enableval" = "x" ; then
575               WANT_APACHE_22=yes
576           else
577               WANT_APACHE_22="$enableval"
578           fi
579         ],[ WANT_APACHE_22=no ])
580 AC_MSG_CHECKING(whether to build Apache 2.2 module)
581 if test "$WANT_APACHE_22" != yes && test "$WANT_APACHE_22" != no ; then
582    WANT_APACHE_22=yes
583 fi
584 AC_MSG_RESULT($WANT_APACHE_22)
585
586 if test "$WANT_APACHE_22" = "yes" ; then
587     AC_ARG_WITH(apxs22, 
588         AC_HELP_STRING([--with-apxs22=FILE], [Specifies where to find the Apache 2.2 apxs script.]),
589         [
590         AC_MSG_CHECKING(for user-specified Apache2.2 apxs name/location)
591         if test "$withval" != "no" ; then
592           if test "$withval" != "yes"; then
593             APXS22=$withval
594             AC_MSG_RESULT("$withval")
595           fi
596         fi
597         ],
598         [
599         AC_PATH_PROG(APXS22, apxs2, no)
600         if test "$APXS22" = "no" ; then
601             AC_PATH_PROG(APXS22, apxs, no)
602         fi
603         if test "$APXS22" = "no" ; then
604           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
605             if test "$APXS22" = "no" && test -f "$i/apxs2" ; then
606               APXS22="$i/apxs2"
607             fi
608           done
609           if test "$APXS22" = "no" ; then
610             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
611               if test "$APXS22" = "no" && test -f "$i/apxs" ; then
612                 APXS22="$i/apxs"
613               fi
614             done
615           fi
616         fi
617         ])
618
619     AC_MSG_CHECKING([to see if Apache2.2 apxs was located])
620     if test ! -f "$APXS22" ; then
621         AC_MSG_RESULT(no)
622         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.])
623     fi
624     AC_MSG_RESULT($APXS22)
625     AC_SUBST(APXS22)
626
627     # APR1 settings
628     AC_ARG_WITH(apr1, 
629         AC_HELP_STRING([--with-apr1=PATH], [where apr-1-config is installed]),
630         [
631         AC_MSG_CHECKING(for user-specified apr-1-config name/location)
632         if test "$withval" != "no" ; then
633             if test "$withval" != "yes"; then
634                 APR1_CONFIG=$withval
635                 AC_MSG_RESULT("$withval")
636             fi
637         fi
638         ],
639         [
640         AC_PATH_PROG(APR1_CONFIG, apr-1-config,,[`$APXS22 -q SBINDIR`]:[$PATH])
641         ])
642         if test -f "${APR1_CONFIG}"; then
643         APR1_CFLAGS="`${APR1_CONFIG} --cflags` `${APR1_CONFIG} --cppflags` `${APR1_CONFIG} --includes`"
644     else
645         AC_MSG_ERROR([Unable to locate apr-1-config, may need --with-apr1 option.])
646     fi
647
648     # extract settings we need from APXS22 -q
649     APXS22_CC="`$APXS22 -q CC`"
650     APXS22_CFLAGS="`$APXS22 -q CPPFLAGS` `$APXS22 -q CFLAGS` `$APXS22 -q CFLAGS_SHLIB` $APR1_CFLAGS"
651     APXS22_INCLUDE="`$APXS22 -q INCLUDEDIR`"
652 fi
653
654 AC_SUBST(APXS22_CFLAGS)
655 AC_SUBST(APXS22_INCLUDE)
656
657 # always output the Makefile, even if you don't use it
658 AC_CONFIG_FILES([apache/Makefile])
659 AM_CONDITIONAL(BUILD_AP13,test "$WANT_APACHE_13" = "yes")
660 AM_CONDITIONAL(BUILD_AP20,test "$WANT_APACHE_20" = "yes")
661 AM_CONDITIONAL(BUILD_AP22,test "$WANT_APACHE_22" = "yes")
662
663 # add the apache module to the list of wanted subdirs..
664 if test "$WANT_APACHE_13" = "yes" || test "$WANT_APACHE_20" = "yes" || test "$WANT_APACHE_22" = "yes" ; then
665     WANT_SUBDIRS="$WANT_SUBDIRS apache"
666 fi
667
668
669 #
670 # Implement the checks of the MySQL Credential Cache
671 #
672 # 1) Assume the user wants MySQL; if it's not found then just continue without
673 # 2) If the user specifically requested Mysql, look for it and ERROR if not found
674 # 3) If the user specifically requested no-mysql, don't build it.
675 #
676
677 AC_CONFIG_FILES([shib-mysql-ccache/Makefile])
678
679 # determine whether we should enable the mysql ccache
680 AC_ARG_ENABLE([mysql],
681         AC_HELP_STRING([--disable-mysql], [disable the MySQL Credential Cache]),
682         [mysql_enabled=$enableval], [mysql_enabled=default])
683
684 if test "x$mysql_enabled" = "x" ; then
685    mysql_enabled=yes
686 fi
687
688 # Are we trying to build MySQL?
689 AC_MSG_CHECKING(whether to build the MySQL ccache)
690 if test "$mysql_enabled" = "yes" ; then
691    build_mysql=yes
692    AC_MSG_RESULT(yes)
693 elif test "$mysql_enabled" = "default" ; then
694    build_mysql=yes
695    AC_MSG_RESULT([yes, if it can be found])
696 else
697    build_mysql=no
698    AC_MSG_RESULT(no)
699 fi
700
701 # If we're trying to build MySQL, try to find the mysql_config program,
702 # verify we've got mysql >= 4, and make sure we can build with mysqld
703 if test "$build_mysql" = "yes" ; then
704    mysql_dir=""
705    AC_ARG_WITH(mysql,
706         AC_HELP_STRING([--with-mysql=PATH], [directory where mysql is installed]),
707             [if test "$with_mysql" = no ; then
708              AC_MSG_ERROR([Try running --disable-mysql instead.])
709          elif test "$with_mysql" != yes ; then
710              mysql_dir="$with_mysql/bin"
711          fi ])
712
713    # Try to find the mysql_config program
714    AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no, $mysql_dir $PATH )
715
716    if test "$MYSQL_CONFIG" = no ; then
717       if test "$mysql_enabled" = "yes" ; then
718         AC_MSG_ERROR(Cannot find mysql_config)
719       else
720         AC_MSG_WARN(MySQL not found.  skipping.)
721       fi
722    fi
723 fi
724
725 # if we found mysql_config then build_mysql is 'yes'
726 if test "$MYSQL_CONFIG" != no ; then
727    AC_MSG_CHECKING(for mysql version >= 4)
728    mysql_version=`$MYSQL_CONFIG --version`
729    mysql_major_version=`echo $mysql_version | awk -F. '{print $1}'`
730    mysql_version_ok=yes
731    if test $mysql_major_version -lt 4 ; then
732      mysql_version_ok=no
733      if test "$mysql_enabled" = "yes" ; then
734        AC_MSG_ERROR(You need MySQL version >= 4, found $mysql_version)
735      fi
736      AC_MSG_RESULT(no.. skipping MySQL)
737    else
738      AC_MSG_RESULT(yes)
739    fi
740 fi
741
742 # if mysql_version_ok is 'yes', then we've made it this far.. ;)
743 if test "$mysql_version_ok" = "yes" ; then
744    AC_MSG_CHECKING(for embedded-MySQL libraries)
745    MYSQL_LIBS=`$MYSQL_CONFIG --libmysqld-libs`
746    if test $? != 0 ; then
747       found_mysql=no
748       if test "$mysql_enabled" = "yes" ; then
749         AC_MSG_ERROR(Could not find the MySQL Embedded-server libraries.)
750       else
751         AC_MSG_RESULT(no.. skipping MySQL)
752       fi
753    else
754       found_mysql=yes
755       AC_MSG_RESULT(yes)
756    fi
757 fi
758
759 # if found_mysql=yes then test that we can actually build mysql
760 if test "$found_mysql" = yes ; then
761    MYSQL_CFLAGS=`$MYSQL_CONFIG --cflags`
762    MYSQL_CFLAGS=`eval echo $MYSQL_CFLAGS`
763    MYSQL_LIBS=`eval echo $MYSQL_LIBS`
764
765    save_CPPFLAGS="$CPPFLAGS"
766    CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
767
768    AC_CHECK_HEADER([mysql.h], [have_mysql_h=yes], [have_mysql_h=no])
769    if test "$have_mysql_h" = no -a "$mysql_enabled" = "yes" ; then
770      AC_MSG_ERROR(unable to find MySQL header files)
771    fi
772
773    if test "$have_mysql_h" = yes ; then
774       save_LIBS="$LIBS"
775       LIBS="$LIBS $MYSQL_LIBS"
776       AC_MSG_CHECKING(if we can link againt mysql)
777       AC_TRY_LINK(
778         [#include <mysql.h>
779          #include <stdio.h>],
780         [mysql_server_init(0, NULL, NULL)],
781         [have_mysql_libs=yes],
782         [have_mysql_libs=no])
783       LIBS="$save_LIBS"
784
785       if test "$have_mysql_libs" = no ; then
786          if test "$mysql_enabled" = "yes" ; then
787             AC_MSG_ERROR([unable to link with MySQL Embedded Server Library])
788          else
789             AC_MSG_RESULT(no.  skipping MySQL)
790          fi
791       fi
792    fi
793
794    CPPFLAGS="$save_CPPFLAGS"
795 fi
796
797 # if have_mysql_libs=yes then go ahead with building MySQL
798 if test "$have_mysql_libs" = yes ; then
799    # this AC_MSG_RESULT is from above!
800    AC_MSG_RESULT(yes)
801    WANT_SUBDIRS="$WANT_SUBDIRS shib-mysql-ccache"
802    AC_SUBST(MYSQL_CFLAGS)
803    AC_SUBST(MYSQL_LIBS)
804 fi
805
806
807 AC_SUBST(WANT_SUBDIRS)
808
809 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
810   echo "=================================================================="
811   echo "WARNING: You have chosen to compile Apache-1.3 modules with a different"
812   echo "         compiler than the one used to compile Apache."
813   echo ""
814   echo "    Current compiler:      $CC"
815   echo "   Apache's compiler:      $APXS_CC"
816   echo ""
817   echo "This could cause problems."
818   echo "=================================================================="
819 fi
820
821 if test -n "$APXS2_CC" && test "$APXS2_CC" != "$CC" ; then
822   echo "=================================================================="
823   echo "WARNING: You have chosen to compile Apache-2 modules with a different"
824   echo "         compiler than the one used to compile Apache."
825   echo ""
826   echo "    Current compiler:      $CC"
827   echo "   Apache's compiler:      $APXS2_CC"
828   echo ""
829   echo "This could cause problems."
830   echo "=================================================================="
831 fi
832
833 LIBTOOL="$LIBTOOL --silent"
834
835 AC_OUTPUT
836