Merged up NSAPI option.
[shibboleth/sp.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([shibboleth], [1.3], [shibboleth-users@internet2.edu], [shibboleth])
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE([shibboleth],[1.3])
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 # 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 # log4cpp settings
158 AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
159 AC_ARG_WITH(log4cpp,
160             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp is installed]),
161             [LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"])
162 if test -f "${LOG4CPP_CONFIG}"; then
163     LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
164     CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
165 else
166     AC_MSG_WARN([log4cpp-config not found, guessing at log4cpp build settings])
167     LIBS="-llog4cpp $LIBS"
168 fi
169 AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
170 AC_TRY_LINK(
171         [#include <log4cpp/Category.hh>],
172         [log4cpp::Category::getInstance("foo")],
173         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
174         [AC_MSG_ERROR([unable to link with log4cpp])])
175
176 # Xerces settings
177 AC_ARG_WITH(xerces, 
178             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
179             [if test x_$with_xerces != x_/usr; then
180                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
181                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
182             fi])
183 LIBS="-lxerces-c $LIBS"
184 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
185                 AC_MSG_ERROR([unable to find xerces header files]))
186 AC_MSG_CHECKING([Xerces version])
187 AC_PREPROC_IFELSE(
188         [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
189 [#if  _XERCES_VERSION == 20601
190 int i = 0;
191 #else
192 #error must use patched version 2.6.1 provided by Shibboleth project (http://wayf.internet2.edu/shibboleth/)
193 #endif])],
194         [AC_MSG_RESULT(OK)],
195         [AC_MSG_ERROR([Shibboleth requires patched Xerces version 2.6.1 (http://wayf.internet2.edu/shibboleth/)])])
196 AC_TRY_LINK(
197         [#include <xercesc/util/PlatformUtils.hpp>],
198         [xercesc::XMLPlatformUtils::Initialize()],
199         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
200         [AC_MSG_ERROR([unable to link with Xerces])])
201
202
203 # XML-Security settings
204 AC_ARG_WITH(xmlsec,
205             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),
206             [if test x_$with_xmlsec != x_/usr; then
207                 LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
208                 CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
209             fi])
210 LIBS="-lxml-security-c $LIBS"
211 AC_CHECK_HEADER([xsec/xenc/XENCEncryptionMethod.hpp],,AC_MSG_ERROR([unable to find xml-security 1.1 header files]),[#include <xercesc/dom/DOM.hpp>])
212 AC_TRY_LINK(
213         [#include <xsec/utils/XSECPlatformUtils.hpp>],
214         [XSECPlatformUtils::Initialise()],
215         [AC_DEFINE(HAVE_LIBXSEC,1,[Define if XML-Sec library was found])],
216         [AC_MSG_ERROR([unable to link with xml-security])])
217
218 # OpenSAML settings
219 AC_ARG_WITH(saml,
220             AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
221             [if test x_$with_saml != x_/usr; then
222                 LDFLAGS="-L${with_saml}/lib $LDFLAGS"
223                 CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
224             fi])
225 AC_CHECK_HEADER([saml/saml.h],,
226                 AC_MSG_ERROR([unable to find saml header files]))
227 LIBS="-lsaml $LIBS"
228 AC_TRY_LINK(
229         [#include <saml/saml.h>
230 #include <saml/version.h>],
231         [#if _OPENSAML_VERSION >= 10100
232 saml::SAMLConfig::getConfig();
233 #else
234 #error Need OpenSAML version 1.1 or higher
235 #endif],
236         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
237         [AC_MSG_ERROR([unable to link with saml, or version too old])])
238
239 # output the underlying makefiles
240 WANT_SUBDIRS="doc shib schemas configs shib-target shar siterefresh test xmlproviders"
241 AC_CONFIG_FILES([Makefile doc/Makefile shib/Makefile schemas/Makefile \
242                  configs/Makefile oncrpc/Makefile oncrpc/rpc/Makefile \
243                  shib-target/Makefile shar/Makefile siterefresh/Makefile \
244                  test/Makefile xmlproviders/Makefile selinux/Makefile])
245
246
247 # now deal with the rpc library, to see if we need to build our own
248 if test $NATIVE_RPC = "no"; then
249     WANT_SUBDIRS="oncrpc $WANT_SUBDIRS"
250         AC_DEFINE(USE_OUR_ONCRPC,1,[Define if using embedded version of ONC RPC.])
251 fi
252 AM_CONDITIONAL(USE_OUR_ONCRPC,test "$NATIVE_RPC" = "no")
253
254 #
255 # Build NSAPI module?
256 #
257 AC_MSG_CHECKING(for NSAPI module option)
258 AC_ARG_WITH(nsapi,
259         AC_HELP_STRING([--with-nsapi=DIR], [Build NSAPI module for Netscape/iPlanet/SunONE]),
260         [WANT_NSAPI=$withval],[WANT_NSAPI=no])
261 AC_MSG_RESULT($WANT_NSAPI)
262
263 if test "$WANT_NSAPI" != "no"; then
264   if test ! -d $WANT_NSAPI/bin ; then
265     AC_MSG_ERROR(Please specify the path to the root of your Netscape/iPlanet/SunONE server using --with-nsapi=DIR)
266   fi
267   AC_MSG_CHECKING(for NSAPI include files)
268   if test -d $WANT_NSAPI/include ; then
269     NSAPI_INCLUDE=$WANT_NSAPI/include
270     AC_MSG_RESULT(Netscape-Enterprise 3.x style)
271     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
272   fi
273   if test -d $WANT_NSAPI/plugins/include ; then
274     test -n "$NSAPI_INCLUDE" && NSAPI_INC_DIR="-I$NSAPI_INCLUDE"
275     NSAPI_INCLUDE="$WANT_NSAPI/plugins/include"
276     AC_MSG_RESULT(iPlanet 4.x / SunONE 6.x style)
277     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
278     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
279   fi
280   if test "$NSAPI_INCLUDE" = ""; then
281     AC_MSG_ERROR(Please check you have nsapi.h in either $WANT_NSAPI/include or $WANT_NSAPI/plugins/include)
282   fi
283 fi
284
285 AC_SUBST(NSAPI_INCLUDE)
286
287 # always output the Makefile, even if you don't use it
288 AC_CONFIG_FILES([nsapi_shib/Makefile])
289 AM_CONDITIONAL(BUILD_NSAPI,test ! "$WANT_NSAPI" = "no")
290
291 # add the NSAPI module to the list of wanted subdirs..
292 if test ! "$WANT_NSAPI" = "no" ; then
293     WANT_SUBDIRS="$WANT_SUBDIRS nsapi_shib"
294 fi
295
296
297 # Apache 1.3 (mod_shib_13)
298 #   --enable-apache-13
299 #   --with-apxs      (DSO build, the normal way, uses apxs to derive build flags)
300 #   --without-apxs   (DSO build, you tell us how to build using the environment)
301
302 AC_ARG_ENABLE(apache-13,
303         AC_HELP_STRING([--enable-apache-13], [enable the Apache 1.3 modules]),
304         [ if test "x$enableval" = "x" ; then
305               WANT_APACHE_13=yes
306           else
307               WANT_APACHE_13="$enableval"
308           fi
309         ], [ WANT_APACHE_13=no ])
310 AC_MSG_CHECKING(whether to build Apache-1.3 support)
311 if test "$WANT_APACHE_13" != yes && test "$WANT_APACHE_13" != no ; then
312    WANT_APACHE_13=yes
313 fi
314 AC_MSG_RESULT($WANT_APACHE_13)
315
316 if test "$WANT_APACHE_13" = yes ; then
317
318 AC_ARG_WITH(apxs,
319 [  --with-apxs[=FILE]        Build shared Apache module(s). FILE is the optional
320                           pathname to the Apache apxs tool; defaults to "apxs".],
321 [
322     if test "$withval" = "yes"; then
323       for i in /usr/sbin /usr/local/apache/bin ; do
324         if test -f "$i/apxs"; then
325           APXS="$i/apxs"
326         fi
327       done
328       if test -z "$APXS"; then
329         APXS=apxs
330       fi
331     else
332       APXS="$withval"
333     fi
334 ],
335 [
336     AC_PATH_PROG(APXS, apxs, no)
337 ])
338
339 AC_MSG_CHECKING([for dynamic Apache-1.3 module support (w/ or w/o APXS)])
340 if test "$APXS" = "no"; then
341
342     # --without-apxs means you want the modules,
343     #       but want to tell us how to build them
344     AC_MSG_RESULT(yes, but use environment, not apxs)
345     echo
346     echo "Did you set one or more of these?"
347     echo
348     echo "APXS_CFLAGS APXS_PREFIX APXS_INCLUDE APXS_LIBEXEC APXS_SYSCONFDIR"
349     echo
350
351     AC_MSG_NOTICE([APXS_CFLAGS is $APXS_CFLAGS])
352
353     # try and find the Apache root
354     if test -z "$APXS_PREFIX"; then
355         if test -d "/usr/local/apache"; then
356             APXS_PREFIX="/usr/local/apache"
357         else
358             AC_MSG_ERROR([You MUST set APXS_PREFIX so the right Apache can be located!])
359         fi
360     elif test ! -d "$APXS_PREFIX"; then
361         AC_MSG_ERROR([APXS_PREFIX of $APXS_PREFIX cannot be found])
362     fi
363     AC_MSG_NOTICE([APXS_PREFIX is $APXS_PREFIX])
364     
365
366     # other subfolders might be derived from APXS_PREFIX
367     if test -z "$APXS_INCLUDE"; then
368         if test -f "$APXS_PREFIX/include/httpd.h"; then
369             APXS_INCLUDE="$APXS_PREFIX/include"
370         else
371             AC_MSG_ERROR([can't find Apache include files beneath $APXS_PREFIX])
372         fi
373     elif ! test -f "$APXS_INCLUDE/httpd.h"; then
374         AC_MSG_ERROR([APXS_INCLUDE of $APXS_INCLUDE does not contain Apache headers])
375     fi
376     AC_MSG_NOTICE([APXS_INCLUDE is $APXS_INCLUDE])
377
378     if test -z "$APXS_LIBEXEC"; then
379         if test -d "$APXS_PREFIX/libexec"; then
380             APXS_LIBEXEC="$APXS_PREFIX/libexec"
381         elif test -d "$APXS_PREFIX/modules"; then
382             APXS_LIBEXEC="$APXS_PREFIX/modules"
383         else
384             AC_MSG_ERROR([can't find Apache libexec/module directory beneath $APXS_PREFIX])
385         fi
386     elif ! test -d "$APXS_LIBEXEC"; then
387         AC_MSG_ERROR([APXS_LIBEXEC of $APXS_LIBEXEC does not exist])
388     fi
389     AC_MSG_NOTICE([APXS_LIBEXEC is $APXS_LIBEXEC])
390
391     if test -z "$APXS_SYSCONFDIR"; then
392         if test -d "$APXS_PREFIX/conf"; then
393             APXS_SYSCONFDIR="$APXS_PREFIX/conf"
394         else
395             AC_MSG_ERROR([can't find Apache conf directory beneath $APXS_PREFIX])
396         fi
397     elif ! test -d "$APXS_SYSCONFDIR"; then
398         AC_MSG_ERROR([APXS_SYSCONFDIR of $APXS_SYSCONFDIR does not exist])
399     fi
400     AC_MSG_NOTICE([APXS_SYSCONFDIR is $APXS_SYSCONFDIR])
401
402     WANT_APACHE_13="yes"
403
404 elif test -n "$APXS"; then
405
406     # extract settings we need from APXS -q
407     APXS_CC="`$APXS -q CC`"
408     APXS_CFLAGS="`$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
409     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
410     APXS_LIBEXEC="`$APXS -q LIBEXECDIR`"
411     APXS_SYSCONFDIR="`$APXS -q SYSCONFDIR`"
412
413     AC_SUBST(APXS)
414     AC_MSG_RESULT(found at $APXS)
415
416     if test -z "`$APXS -q LD_SHLIB`" || test "$APXS_LIBEXEC" = "modules"; then
417             AC_MSG_ERROR(
418 [Your APXS installation is broken and cannot be used.
419     Please see http://www.webdav.org/mod_dav/install.html#apxs for
420     more information.])
421     fi
422
423     WANT_APACHE_13="yes"
424
425 else
426     # guess we're not doing Apache 1.3
427     AC_MSG_RESULT(no)
428     WANT_APACHE_13="no"
429 fi
430 fi
431
432 AC_SUBST(APXS_CFLAGS)
433 AC_SUBST(APXS_INCLUDE)
434 AC_SUBST(APXS_LIBEXEC)
435 AC_SUBST(APXS_SYSCONFDIR)
436 AM_CONDITIONAL(HAVE_APXS,test -n "$APXS")
437
438
439 # Apache 2.0 (mod_shib_20)
440 #   --enable-apache-20
441 #   --with-apxs2       (DSO build, the normal way, uses apxs to derive build flags)
442 #       --with-apr         (DSO build, APR development package installed separately)
443 #   --without-apxs2    (DSO build, you tell us how to build using the environment)
444
445 AC_ARG_ENABLE(apache-20,
446         AC_HELP_STRING([--enable-apache-20], [enable the Apache 2.0 modules]),
447         [ if test "x$enableval" = "x" ; then
448               WANT_APACHE_20=yes
449           else
450               WANT_APACHE_20="$enableval"
451           fi
452         ], [ WANT_APACHE_20=no ])
453
454 AC_MSG_CHECKING(whether to build Apache-2.0 support)
455 if test "$WANT_APACHE_20" != yes && test "$WANT_APACHE_20" != no ; then
456    WANT_APACHE_20=yes
457 fi
458 AC_MSG_RESULT($WANT_APACHE_20)
459
460 if test "$WANT_APACHE_20" = yes ; then
461
462 AC_ARG_WITH(apxs2,
463 [  --with-apxs2[=FILE]        Build shared Apache module(s). FILE is the optional
464                           pathname to the Apache apxs tool; defaults to "apxs".],
465 [
466     if test "$withval" = "yes"; then
467       for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
468         if test -f "$i/apxs"; then
469           APXS2="$i/apxs"
470         fi
471       done
472       if test -z "$APXS2"; then
473         APXS2=apxs
474       fi
475     else
476       APXS2="$withval"
477     fi
478 ],
479 [
480     AC_PATH_PROG(APXS2, apxs, no)
481 ])
482
483 AC_MSG_CHECKING([for dynamic Apache-2 module support (w/ or w/o APXS)])
484 if test "$APXS2" = "no"; then
485
486     # --without-apxs2 means you want the modules,
487     #       but want to tell us how to build them
488     AC_MSG_RESULT(yes, but use environment, not apxs)
489     echo
490     echo "Did you set one or more of these?"
491     echo
492     echo "APXS2_CFLAGS APXS2_PREFIX APXS2_INCLUDE APXS2_LIBEXEC APXS2_SYSCONFDIR"
493     echo
494
495     AC_MSG_NOTICE([APXS2_CFLAGS is $APXS2_CFLAGS])
496
497     # try and find the Apache root
498     if test -z "$APXS2_PREFIX"; then
499         if test -d "/usr/local/apache"; then
500             APXS2_PREFIX="/usr/local/apache"
501         else
502             AC_MSG_ERROR([You MUST set APXS2_PREFIX so the right Apache-2 can be located!])
503         fi
504     elif test ! -d "$APXS2_PREFIX"; then
505         AC_MSG_ERROR([APXS2_PREFIX of $APXS2_PREFIX cannot be found])
506     fi
507     AC_MSG_NOTICE([APXS2_PREFIX is $APXS2_PREFIX])
508     
509
510     # other subfolders might be derived from APXS2_PREFIX
511     if test -z "$APXS2_INCLUDE"; then
512         if test -f "$APXS2_PREFIX/include/httpd.h"; then
513             APXS2_INCLUDE="$APXS2_PREFIX/include"
514         else
515             AC_MSG_ERROR([can't find Apache-2 include files beneath $APXS2_PREFIX])
516         fi
517     elif ! test -f "$APXS2_INCLUDE/httpd.h"; then
518         AC_MSG_ERROR([APXS2_INCLUDE of $APXS2_INCLUDE does not contain Apache-2 headers])
519     fi
520     AC_MSG_NOTICE([APXS2_INCLUDE is $APXS2_INCLUDE])
521
522     if test -z "$APXS2_LIBEXEC"; then
523         if test -d "$APXS2_PREFIX/libexec"; then
524             APXS2_LIBEXEC="$APXS2_PREFIX/libexec"
525         elif test -d "$APXS2_PREFIX/modules"; then
526             APXS2_LIBEXEC="$APXS2_PREFIX/modules"
527         else
528             AC_MSG_ERROR([can't find Apache-2 libexec/module directory beneath $APXS2_PREFIX])
529         fi
530     elif ! test -d "$APXS2_LIBEXEC"; then
531         AC_MSG_ERROR([APXS2_LIBEXEC of $APXS2_LIBEXEC does not exist])
532     fi
533     AC_MSG_NOTICE([APXS2_LIBEXEC is $APXS2_LIBEXEC])
534
535     if test -z "$APXS2_SYSCONFDIR"; then
536         if test -d "$APXS2_PREFIX/conf"; then
537             APXS2_SYSCONFDIR="$APXS2_PREFIX/conf"
538         else
539             AC_MSG_ERROR([can't find Apache-2 conf directory beneath $APXS2_PREFIX])
540         fi
541     elif ! test -d "$APXS2_SYSCONFDIR"; then
542         AC_MSG_ERROR([APXS2_SYSCONFDIR of $APXS2_SYSCONFDIR does not exist])
543     fi
544     AC_MSG_NOTICE([APXS2_SYSCONFDIR is $APXS2_SYSCONFDIR])
545
546     WANT_APACHE_20="yes"
547
548 elif test -n "$APXS2"; then
549
550         # APR settings
551         AC_PATH_PROG(APR_CONFIG,apr-config)
552         AC_ARG_WITH(apr,
553                     AC_HELP_STRING([--with-apr=PATH], [where APR is installed]),
554                     [APR_CONFIG="${with_apr}/bin/apr-config"])
555         if test -f "${APR_CONFIG}"; then
556             APR_CFLAGS="`${APR_CONFIG} --cflags` `${APR_CONFIG} --cppflags` `${APR_CONFIG} --includes`"
557         fi
558
559     # extract settings we need from APXS2 -q
560     APXS2_CC="`$APXS2 -q CC`"
561     APXS2_CFLAGS="`$APXS2 -q CFLAGS` `$APXS2 -q CFLAGS_SHLIB` $APR_CFLAGS"
562     APXS2_INCLUDE="`$APXS2 -q INCLUDEDIR`"
563     APXS2_LIBEXEC="`$APXS2 -q LIBEXECDIR`"
564     APXS2_SYSCONFDIR="`$APXS2 -q SYSCONFDIR`"
565
566     AC_SUBST(APXS2)
567     AC_MSG_RESULT(found at $APXS2)
568
569     if test -z "`$APXS2 -q LD_SHLIB`" && test -z "`$APXS2 -q LIBEXECDIR`" \
570        || test "$APXS2_LIBEXEC" = "modules"; then
571             AC_MSG_ERROR(
572 [Your APXS installation is broken and cannot be used.
573     Please see http://www.webdav.org/mod_dav/install.html#apxs for
574     more information.])
575     fi
576
577     WANT_APACHE_20="yes"
578
579 else
580     # guess we're not doing Apache 2.0
581     AC_MSG_RESULT(no)
582     WANT_APACHE_20="no"
583 fi
584 fi
585
586 AC_SUBST(APXS2_CFLAGS)
587 AC_SUBST(APXS2_INCLUDE)
588 AC_SUBST(APXS2_LIBEXEC)
589 AC_SUBST(APXS2_SYSCONFDIR)
590 AM_CONDITIONAL(HAVE_APXS2,test -n "$APXS2")
591
592 # always output the Makefile, even if you don't use it
593 AC_CONFIG_FILES([apache/Makefile])
594 AM_CONDITIONAL(BUILD_AP13,test "$WANT_APACHE_13" = "yes")
595 AM_CONDITIONAL(BUILD_AP20,test "$WANT_APACHE_20" = "yes")
596
597 # add the apache module to the list of wanted subdirs..
598 if test "$WANT_APACHE_13" = "yes" || test "$WANT_APACHE_20" = "yes" ; then
599     WANT_SUBDIRS="$WANT_SUBDIRS apache"
600 fi
601
602
603 #
604 # Implement the checks of the MySQL Credential Cache
605 #
606 # 1) Assume the user wants MySQL; if it's not found then just continue without
607 # 2) If the user specifically requested Mysql, look for it and ERROR if not found
608 # 3) If the user specifically requested no-mysql, don't build it.
609 #
610
611 AC_CONFIG_FILES([shib-mysql-ccache/Makefile])
612
613 # determine whether we should enable the mysql ccache
614 AC_ARG_ENABLE([mysql],
615         AC_HELP_STRING([--disable-mysql], [disable the MySQL Credential Cache]),
616         [mysql_enabled=$enableval], [mysql_enabled=default])
617
618 if test "x$mysql_enabled" = "x" ; then
619    mysql_enabled=yes
620 fi
621
622 # Are we trying to build MySQL?
623 AC_MSG_CHECKING(whether to build the MySQL ccache)
624 if test "$mysql_enabled" = "yes" ; then
625    build_mysql=yes
626    AC_MSG_RESULT(yes)
627 elif test "$mysql_enabled" = "default" ; then
628    build_mysql=yes
629    AC_MSG_RESULT([yes, if it can be found])
630 else
631    build_mysql=no
632    AC_MSG_RESULT(no)
633 fi
634
635 # If we're trying to build MySQL, try to find the mysql_config program,
636 # verify we've got mysql >= 4, and make sure we can build with mysqld
637 if test "$build_mysql" = "yes" ; then
638    mysql_dir=""
639    AC_ARG_WITH(mysql,
640         AC_HELP_STRING([--with-mysql=PATH], [directory where mysql is installed]),
641             [if test "$with_mysql" = no ; then
642                AC_MSG_ERROR([Try running --disable-mysql instead.])
643              elif test "$with_mysql" != yes ; then
644                mysql_dir="$with_mysql/bin"
645              fi ])
646
647    # Try to find the mysql_config program
648    AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no, $mysql_dir $PATH )
649
650    if test "$MYSQL_CONFIG" = no ; then
651       if test "$mysql_enabled" = "yes" ; then
652         AC_MSG_ERROR(Cannot find mysql_config)
653       else
654         AC_MSG_WARN(MySQL not found.  skipping.)
655       fi
656    fi
657 fi
658
659 # if we found mysql_config then build_mysql is 'yes'
660 if test "$MYSQL_CONFIG" != no ; then
661    AC_MSG_CHECKING(for mysql version >= 4)
662    mysql_version=`$MYSQL_CONFIG --version`
663    mysql_major_version=`echo $mysql_version | awk -F. '{print $1}'`
664    mysql_version_ok=yes
665    if test $mysql_major_version -lt 4 ; then
666      mysql_version_ok=no
667      if test "$mysql_enabled" = "yes" ; then
668        AC_MSG_ERROR(You need MySQL version >= 4, found $mysql_version)
669      fi
670      AC_MSG_RESULT(no.. skipping MySQL)
671    else
672      AC_MSG_RESULT(yes)
673    fi
674 fi
675
676 # if mysql_version_ok is 'yes', then we've made it this far.. ;)
677 if test "$mysql_version_ok" = "yes" ; then
678    AC_MSG_CHECKING(for embedded-MySQL libraries)
679    MYSQL_LIBS=`$MYSQL_CONFIG --libmysqld-libs`
680    if test $? != 0 ; then
681       found_mysql=no
682       if test "$mysql_enabled" = "yes" ; then
683         AC_MSG_ERROR(Could not find the MySQL Embedded-server libraries.)
684       else
685         AC_MSG_RESULT(no.. skipping MySQL)
686       fi
687    else
688       found_mysql=yes
689       AC_MSG_RESULT(yes)
690    fi
691 fi
692
693 # if found_mysql=yes then test that we can actually build mysql
694 if test "$found_mysql" = yes ; then
695    MYSQL_CFLAGS=`$MYSQL_CONFIG --cflags`
696    MYSQL_CFLAGS=`eval echo $MYSQL_CFLAGS`
697    MYSQL_LIBS=`eval echo $MYSQL_LIBS`
698
699    save_CPPFLAGS="$CPPFLAGS"
700    CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
701
702    AC_CHECK_HEADER([mysql.h], [have_mysql_h=yes], [have_mysql_h=no])
703    if test "$have_mysql_h" = no -a "$mysql_enabled" = "yes" ; then
704      AC_MSG_ERROR(unable to find MySQL header files)
705    fi
706
707    if test "$have_mysql_h" = yes ; then
708       save_LIBS="$LIBS"
709       LIBS="$LIBS $MYSQL_LIBS"
710       AC_MSG_CHECKING(if we can link againt mysql)
711       AC_TRY_LINK(
712         [#include <mysql.h>
713          #include <stdio.h>],
714         [mysql_server_init(0, NULL, NULL)],
715         [have_mysql_libs=yes],
716         [have_mysql_libs=no])
717       LIBS="$save_LIBS"
718
719       if test "$have_mysql_libs" = no ; then
720          if test "$mysql_enabled" = "yes" ; then
721             AC_MSG_ERROR([unable to link with MySQL Embedded Server Library])
722          else
723             AC_MSG_RESULT(no.  skipping MySQL)
724          fi
725       fi
726    fi
727
728    CPPFLAGS="$save_CPPFLAGS"
729 fi
730
731 # if have_mysql_libs=yes then go ahead with building MySQL
732 if test "$have_mysql_libs" = yes ; then
733    # this AC_MSG_RESULT is from above!
734    AC_MSG_RESULT(yes)
735    WANT_SUBDIRS="$WANT_SUBDIRS shib-mysql-ccache"
736    AC_SUBST(MYSQL_CFLAGS)
737    AC_SUBST(MYSQL_LIBS)
738 fi
739
740
741 AC_SUBST(WANT_SUBDIRS)
742
743 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
744   echo "=================================================================="
745   echo "WARNING: You have chosen to compile Apache-1.3 modules with a different"
746   echo "         compiler than the one used to compile Apache."
747   echo ""
748   echo "    Current compiler:      $CC"
749   echo "   Apache's compiler:      $APXS_CC"
750   echo ""
751   echo "This could cause some problems."
752   echo "=================================================================="
753 fi
754
755 if test -n "$APXS2_CC" && test "$APXS2_CC" != "$CC" ; then
756   echo "=================================================================="
757   echo "WARNING: You have chosen to compile Apache-2 modules with a different"
758   echo "         compiler than the one used to compile Apache."
759   echo ""
760   echo "    Current compiler:      $CC"
761   echo "   Apache's compiler:      $APXS2_CC"
762   echo ""
763   echo "This could cause some problems."
764   echo "=================================================================="
765 fi
766
767 AC_OUTPUT
768