Bump version.
[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 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     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
273   fi
274   if test -d $WANT_NSAPI/plugins/include ; then
275     test -n "$NSAPI_INCLUDE" && NSAPI_INC_DIR="-I$NSAPI_INCLUDE"
276     NSAPI_INCLUDE="$WANT_NSAPI/plugins/include"
277     AC_MSG_RESULT(iPlanet 4.x / SunONE 6.x style)
278     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
279     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
280   fi
281   if test "$NSAPI_INCLUDE" = ""; then
282     AC_MSG_ERROR(Please check you have nsapi.h in either $WANT_NSAPI/include or $WANT_NSAPI/plugins/include)
283   fi
284 fi
285
286 AC_SUBST(NSAPI_INCLUDE)
287
288 # always output the Makefile, even if you don't use it
289 AC_CONFIG_FILES([nsapi_shib/Makefile])
290 AM_CONDITIONAL(BUILD_NSAPI,test ! "$WANT_NSAPI" = "no")
291
292 # add the NSAPI module to the list of wanted subdirs..
293 if test ! "$WANT_NSAPI" = "no" ; then
294     WANT_SUBDIRS="$WANT_SUBDIRS nsapi_shib"
295 fi
296
297
298 # Apache 1.3 (mod_shib_13)
299 #   --enable-apache-13
300 #   --with-apxs      (DSO build, the normal way, uses apxs to derive build flags)
301 #   --without-apxs   (DSO build, you tell us how to build using the environment)
302
303 AC_ARG_ENABLE(apache-13,
304         AC_HELP_STRING([--enable-apache-13], [enable the Apache 1.3 modules]),
305         [ if test "x$enableval" = "x" ; then
306               WANT_APACHE_13=yes
307           else
308               WANT_APACHE_13="$enableval"
309           fi
310         ], [ WANT_APACHE_13=no ])
311 AC_MSG_CHECKING(whether to build Apache-1.3 support)
312 if test "$WANT_APACHE_13" != yes && test "$WANT_APACHE_13" != no ; then
313    WANT_APACHE_13=yes
314 fi
315 AC_MSG_RESULT($WANT_APACHE_13)
316
317 if test "$WANT_APACHE_13" = yes ; then
318
319 AC_ARG_WITH(apxs,
320 [  --with-apxs[=FILE]        Build shared Apache module(s). FILE is the optional
321                           pathname to the Apache apxs tool; defaults to "apxs".],
322 [
323     if test "$withval" = "yes"; then
324       for i in /usr/sbin /usr/local/apache/bin ; do
325         if test -f "$i/apxs"; then
326           APXS="$i/apxs"
327         fi
328       done
329       if test -z "$APXS"; then
330         APXS=apxs
331       fi
332     else
333       APXS="$withval"
334     fi
335 ],
336 [
337     AC_PATH_PROG(APXS, apxs, no)
338 ])
339
340 AC_MSG_CHECKING([for dynamic Apache-1.3 module support (w/ or w/o APXS)])
341 if test "$APXS" = "no"; then
342
343     # --without-apxs means you want the modules,
344     #       but want to tell us how to build them
345     AC_MSG_RESULT(yes, but use environment, not apxs)
346     echo
347     echo "Did you set one or more of these?"
348     echo
349     echo "APXS_CFLAGS APXS_PREFIX APXS_INCLUDE APXS_LIBEXEC APXS_SYSCONFDIR"
350     echo
351
352     AC_MSG_NOTICE([APXS_CFLAGS is $APXS_CFLAGS])
353
354     # try and find the Apache root
355     if test -z "$APXS_PREFIX"; then
356         if test -d "/usr/local/apache"; then
357             APXS_PREFIX="/usr/local/apache"
358         else
359             AC_MSG_ERROR([You MUST set APXS_PREFIX so the right Apache can be located!])
360         fi
361     elif test ! -d "$APXS_PREFIX"; then
362         AC_MSG_ERROR([APXS_PREFIX of $APXS_PREFIX cannot be found])
363     fi
364     AC_MSG_NOTICE([APXS_PREFIX is $APXS_PREFIX])
365     
366
367     # other subfolders might be derived from APXS_PREFIX
368     if test -z "$APXS_INCLUDE"; then
369         if test -f "$APXS_PREFIX/include/httpd.h"; then
370             APXS_INCLUDE="$APXS_PREFIX/include"
371         else
372             AC_MSG_ERROR([can't find Apache include files beneath $APXS_PREFIX])
373         fi
374     elif ! test -f "$APXS_INCLUDE/httpd.h"; then
375         AC_MSG_ERROR([APXS_INCLUDE of $APXS_INCLUDE does not contain Apache headers])
376     fi
377     AC_MSG_NOTICE([APXS_INCLUDE is $APXS_INCLUDE])
378
379     if test -z "$APXS_LIBEXEC"; then
380         if test -d "$APXS_PREFIX/libexec"; then
381             APXS_LIBEXEC="$APXS_PREFIX/libexec"
382         elif test -d "$APXS_PREFIX/modules"; then
383             APXS_LIBEXEC="$APXS_PREFIX/modules"
384         else
385             AC_MSG_ERROR([can't find Apache libexec/module directory beneath $APXS_PREFIX])
386         fi
387     elif ! test -d "$APXS_LIBEXEC"; then
388         AC_MSG_ERROR([APXS_LIBEXEC of $APXS_LIBEXEC does not exist])
389     fi
390     AC_MSG_NOTICE([APXS_LIBEXEC is $APXS_LIBEXEC])
391
392     if test -z "$APXS_SYSCONFDIR"; then
393         if test -d "$APXS_PREFIX/conf"; then
394             APXS_SYSCONFDIR="$APXS_PREFIX/conf"
395         else
396             AC_MSG_ERROR([can't find Apache conf directory beneath $APXS_PREFIX])
397         fi
398     elif ! test -d "$APXS_SYSCONFDIR"; then
399         AC_MSG_ERROR([APXS_SYSCONFDIR of $APXS_SYSCONFDIR does not exist])
400     fi
401     AC_MSG_NOTICE([APXS_SYSCONFDIR is $APXS_SYSCONFDIR])
402
403     WANT_APACHE_13="yes"
404
405 elif test -n "$APXS"; then
406
407     # extract settings we need from APXS -q
408     APXS_CC="`$APXS -q CC`"
409     APXS_CFLAGS="`$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
410     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
411     APXS_LIBEXEC="`$APXS -q LIBEXECDIR`"
412     APXS_SYSCONFDIR="`$APXS -q SYSCONFDIR`"
413
414     AC_SUBST(APXS)
415     AC_MSG_RESULT(found at $APXS)
416
417     if test -z "`$APXS -q LD_SHLIB`" || test "$APXS_LIBEXEC" = "modules"; then
418             AC_MSG_ERROR(
419 [Your APXS installation is broken and cannot be used.
420     Please see http://www.webdav.org/mod_dav/install.html#apxs for
421     more information.])
422     fi
423
424     WANT_APACHE_13="yes"
425
426 else
427     # guess we're not doing Apache 1.3
428     AC_MSG_RESULT(no)
429     WANT_APACHE_13="no"
430 fi
431 fi
432
433 AC_SUBST(APXS_CFLAGS)
434 AC_SUBST(APXS_INCLUDE)
435 AC_SUBST(APXS_LIBEXEC)
436 AC_SUBST(APXS_SYSCONFDIR)
437 AM_CONDITIONAL(HAVE_APXS,test -n "$APXS")
438
439
440 # Apache 2.0 (mod_shib_20)
441 #   --enable-apache-20
442 #   --with-apxs2       (DSO build, the normal way, uses apxs to derive build flags)
443 #       --with-apr         (DSO build, APR development package installed separately)
444 #   --without-apxs2    (DSO build, you tell us how to build using the environment)
445
446 AC_ARG_ENABLE(apache-20,
447         AC_HELP_STRING([--enable-apache-20], [enable the Apache 2.0 modules]),
448         [ if test "x$enableval" = "x" ; then
449               WANT_APACHE_20=yes
450           else
451               WANT_APACHE_20="$enableval"
452           fi
453         ], [ WANT_APACHE_20=no ])
454
455 AC_MSG_CHECKING(whether to build Apache-2.0 support)
456 if test "$WANT_APACHE_20" != yes && test "$WANT_APACHE_20" != no ; then
457    WANT_APACHE_20=yes
458 fi
459 AC_MSG_RESULT($WANT_APACHE_20)
460
461 if test "$WANT_APACHE_20" = yes ; then
462
463 AC_ARG_WITH(apxs2,
464 [  --with-apxs2[=FILE]        Build shared Apache module(s). FILE is the optional
465                           pathname to the Apache apxs tool; defaults to "apxs".],
466 [
467     if test "$withval" = "yes"; then
468       for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
469         if test -f "$i/apxs"; then
470           APXS2="$i/apxs"
471         fi
472       done
473       if test -z "$APXS2"; then
474         APXS2=apxs
475       fi
476     else
477       APXS2="$withval"
478     fi
479 ],
480 [
481     AC_PATH_PROG(APXS2, apxs, no)
482 ])
483
484 AC_MSG_CHECKING([for dynamic Apache-2 module support (w/ or w/o APXS)])
485 if test "$APXS2" = "no"; then
486
487     # --without-apxs2 means you want the modules,
488     #       but want to tell us how to build them
489     AC_MSG_RESULT(yes, but use environment, not apxs)
490     echo
491     echo "Did you set one or more of these?"
492     echo
493     echo "APXS2_CFLAGS APXS2_PREFIX APXS2_INCLUDE APXS2_LIBEXEC APXS2_SYSCONFDIR"
494     echo
495
496     AC_MSG_NOTICE([APXS2_CFLAGS is $APXS2_CFLAGS])
497
498     # try and find the Apache root
499     if test -z "$APXS2_PREFIX"; then
500         if test -d "/usr/local/apache"; then
501             APXS2_PREFIX="/usr/local/apache"
502         else
503             AC_MSG_ERROR([You MUST set APXS2_PREFIX so the right Apache-2 can be located!])
504         fi
505     elif test ! -d "$APXS2_PREFIX"; then
506         AC_MSG_ERROR([APXS2_PREFIX of $APXS2_PREFIX cannot be found])
507     fi
508     AC_MSG_NOTICE([APXS2_PREFIX is $APXS2_PREFIX])
509     
510
511     # other subfolders might be derived from APXS2_PREFIX
512     if test -z "$APXS2_INCLUDE"; then
513         if test -f "$APXS2_PREFIX/include/httpd.h"; then
514             APXS2_INCLUDE="$APXS2_PREFIX/include"
515         else
516             AC_MSG_ERROR([can't find Apache-2 include files beneath $APXS2_PREFIX])
517         fi
518     elif ! test -f "$APXS2_INCLUDE/httpd.h"; then
519         AC_MSG_ERROR([APXS2_INCLUDE of $APXS2_INCLUDE does not contain Apache-2 headers])
520     fi
521     AC_MSG_NOTICE([APXS2_INCLUDE is $APXS2_INCLUDE])
522
523     if test -z "$APXS2_LIBEXEC"; then
524         if test -d "$APXS2_PREFIX/libexec"; then
525             APXS2_LIBEXEC="$APXS2_PREFIX/libexec"
526         elif test -d "$APXS2_PREFIX/modules"; then
527             APXS2_LIBEXEC="$APXS2_PREFIX/modules"
528         else
529             AC_MSG_ERROR([can't find Apache-2 libexec/module directory beneath $APXS2_PREFIX])
530         fi
531     elif ! test -d "$APXS2_LIBEXEC"; then
532         AC_MSG_ERROR([APXS2_LIBEXEC of $APXS2_LIBEXEC does not exist])
533     fi
534     AC_MSG_NOTICE([APXS2_LIBEXEC is $APXS2_LIBEXEC])
535
536     if test -z "$APXS2_SYSCONFDIR"; then
537         if test -d "$APXS2_PREFIX/conf"; then
538             APXS2_SYSCONFDIR="$APXS2_PREFIX/conf"
539         else
540             AC_MSG_ERROR([can't find Apache-2 conf directory beneath $APXS2_PREFIX])
541         fi
542     elif ! test -d "$APXS2_SYSCONFDIR"; then
543         AC_MSG_ERROR([APXS2_SYSCONFDIR of $APXS2_SYSCONFDIR does not exist])
544     fi
545     AC_MSG_NOTICE([APXS2_SYSCONFDIR is $APXS2_SYSCONFDIR])
546
547     WANT_APACHE_20="yes"
548
549 elif test -n "$APXS2"; then
550
551         # APR settings
552         AC_PATH_PROG(APR_CONFIG,apr-config)
553         AC_ARG_WITH(apr,
554                     AC_HELP_STRING([--with-apr=PATH], [where APR is installed]),
555                     [APR_CONFIG="${with_apr}/bin/apr-config"])
556         if test -f "${APR_CONFIG}"; then
557             APR_CFLAGS="`${APR_CONFIG} --cflags` `${APR_CONFIG} --cppflags` `${APR_CONFIG} --includes`"
558         fi
559
560     # extract settings we need from APXS2 -q
561     APXS2_CC="`$APXS2 -q CC`"
562     APXS2_CFLAGS="`$APXS2 -q CFLAGS` `$APXS2 -q CFLAGS_SHLIB` $APR_CFLAGS"
563     APXS2_INCLUDE="`$APXS2 -q INCLUDEDIR`"
564     APXS2_LIBEXEC="`$APXS2 -q LIBEXECDIR`"
565     APXS2_SYSCONFDIR="`$APXS2 -q SYSCONFDIR`"
566
567     AC_SUBST(APXS2)
568     AC_MSG_RESULT(found at $APXS2)
569
570     if test -z "`$APXS2 -q LD_SHLIB`" && test -z "`$APXS2 -q LIBEXECDIR`" \
571        || test "$APXS2_LIBEXEC" = "modules"; then
572             AC_MSG_ERROR(
573 [Your APXS installation is broken and cannot be used.
574     Please see http://www.webdav.org/mod_dav/install.html#apxs for
575     more information.])
576     fi
577
578     WANT_APACHE_20="yes"
579
580 else
581     # guess we're not doing Apache 2.0
582     AC_MSG_RESULT(no)
583     WANT_APACHE_20="no"
584 fi
585 fi
586
587 AC_SUBST(APXS2_CFLAGS)
588 AC_SUBST(APXS2_INCLUDE)
589 AC_SUBST(APXS2_LIBEXEC)
590 AC_SUBST(APXS2_SYSCONFDIR)
591 AM_CONDITIONAL(HAVE_APXS2,test -n "$APXS2")
592
593 # always output the Makefile, even if you don't use it
594 AC_CONFIG_FILES([apache/Makefile])
595 AM_CONDITIONAL(BUILD_AP13,test "$WANT_APACHE_13" = "yes")
596 AM_CONDITIONAL(BUILD_AP20,test "$WANT_APACHE_20" = "yes")
597
598 # add the apache module to the list of wanted subdirs..
599 if test "$WANT_APACHE_13" = "yes" || test "$WANT_APACHE_20" = "yes" ; then
600     WANT_SUBDIRS="$WANT_SUBDIRS apache"
601 fi
602
603
604 #
605 # Implement the checks of the MySQL Credential Cache
606 #
607 # 1) Assume the user wants MySQL; if it's not found then just continue without
608 # 2) If the user specifically requested Mysql, look for it and ERROR if not found
609 # 3) If the user specifically requested no-mysql, don't build it.
610 #
611
612 AC_CONFIG_FILES([shib-mysql-ccache/Makefile])
613
614 # determine whether we should enable the mysql ccache
615 AC_ARG_ENABLE([mysql],
616         AC_HELP_STRING([--disable-mysql], [disable the MySQL Credential Cache]),
617         [mysql_enabled=$enableval], [mysql_enabled=default])
618
619 if test "x$mysql_enabled" = "x" ; then
620    mysql_enabled=yes
621 fi
622
623 # Are we trying to build MySQL?
624 AC_MSG_CHECKING(whether to build the MySQL ccache)
625 if test "$mysql_enabled" = "yes" ; then
626    build_mysql=yes
627    AC_MSG_RESULT(yes)
628 elif test "$mysql_enabled" = "default" ; then
629    build_mysql=yes
630    AC_MSG_RESULT([yes, if it can be found])
631 else
632    build_mysql=no
633    AC_MSG_RESULT(no)
634 fi
635
636 # If we're trying to build MySQL, try to find the mysql_config program,
637 # verify we've got mysql >= 4, and make sure we can build with mysqld
638 if test "$build_mysql" = "yes" ; then
639    mysql_dir=""
640    AC_ARG_WITH(mysql,
641         AC_HELP_STRING([--with-mysql=PATH], [directory where mysql is installed]),
642             [if test "$with_mysql" = no ; then
643                AC_MSG_ERROR([Try running --disable-mysql instead.])
644              elif test "$with_mysql" != yes ; then
645                mysql_dir="$with_mysql/bin"
646              fi ])
647
648    # Try to find the mysql_config program
649    AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no, $mysql_dir $PATH )
650
651    if test "$MYSQL_CONFIG" = no ; then
652       if test "$mysql_enabled" = "yes" ; then
653         AC_MSG_ERROR(Cannot find mysql_config)
654       else
655         AC_MSG_WARN(MySQL not found.  skipping.)
656       fi
657    fi
658 fi
659
660 # if we found mysql_config then build_mysql is 'yes'
661 if test "$MYSQL_CONFIG" != no ; then
662    AC_MSG_CHECKING(for mysql version >= 4)
663    mysql_version=`$MYSQL_CONFIG --version`
664    mysql_major_version=`echo $mysql_version | awk -F. '{print $1}'`
665    mysql_version_ok=yes
666    if test $mysql_major_version -lt 4 ; then
667      mysql_version_ok=no
668      if test "$mysql_enabled" = "yes" ; then
669        AC_MSG_ERROR(You need MySQL version >= 4, found $mysql_version)
670      fi
671      AC_MSG_RESULT(no.. skipping MySQL)
672    else
673      AC_MSG_RESULT(yes)
674    fi
675 fi
676
677 # if mysql_version_ok is 'yes', then we've made it this far.. ;)
678 if test "$mysql_version_ok" = "yes" ; then
679    AC_MSG_CHECKING(for embedded-MySQL libraries)
680    MYSQL_LIBS=`$MYSQL_CONFIG --libmysqld-libs`
681    if test $? != 0 ; then
682       found_mysql=no
683       if test "$mysql_enabled" = "yes" ; then
684         AC_MSG_ERROR(Could not find the MySQL Embedded-server libraries.)
685       else
686         AC_MSG_RESULT(no.. skipping MySQL)
687       fi
688    else
689       found_mysql=yes
690       AC_MSG_RESULT(yes)
691    fi
692 fi
693
694 # if found_mysql=yes then test that we can actually build mysql
695 if test "$found_mysql" = yes ; then
696    MYSQL_CFLAGS=`$MYSQL_CONFIG --cflags`
697    MYSQL_CFLAGS=`eval echo $MYSQL_CFLAGS`
698    MYSQL_LIBS=`eval echo $MYSQL_LIBS`
699
700    save_CPPFLAGS="$CPPFLAGS"
701    CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
702
703    AC_CHECK_HEADER([mysql.h], [have_mysql_h=yes], [have_mysql_h=no])
704    if test "$have_mysql_h" = no -a "$mysql_enabled" = "yes" ; then
705      AC_MSG_ERROR(unable to find MySQL header files)
706    fi
707
708    if test "$have_mysql_h" = yes ; then
709       save_LIBS="$LIBS"
710       LIBS="$LIBS $MYSQL_LIBS"
711       AC_MSG_CHECKING(if we can link againt mysql)
712       AC_TRY_LINK(
713         [#include <mysql.h>
714          #include <stdio.h>],
715         [mysql_server_init(0, NULL, NULL)],
716         [have_mysql_libs=yes],
717         [have_mysql_libs=no])
718       LIBS="$save_LIBS"
719
720       if test "$have_mysql_libs" = no ; then
721          if test "$mysql_enabled" = "yes" ; then
722             AC_MSG_ERROR([unable to link with MySQL Embedded Server Library])
723          else
724             AC_MSG_RESULT(no.  skipping MySQL)
725          fi
726       fi
727    fi
728
729    CPPFLAGS="$save_CPPFLAGS"
730 fi
731
732 # if have_mysql_libs=yes then go ahead with building MySQL
733 if test "$have_mysql_libs" = yes ; then
734    # this AC_MSG_RESULT is from above!
735    AC_MSG_RESULT(yes)
736    WANT_SUBDIRS="$WANT_SUBDIRS shib-mysql-ccache"
737    AC_SUBST(MYSQL_CFLAGS)
738    AC_SUBST(MYSQL_LIBS)
739 fi
740
741
742 #
743 # Implement the checks of the ODBC Credential Cache
744 #
745 # 1) Assume the user wants ODBC; if it's not found then just continue without
746 # 2) If the user specifically requested odbc, look for it and ERROR if not found
747 # 3) If the user specifically requested no-odbc, don't build it.
748 #
749
750 AC_CONFIG_FILES([odbc_ccache/Makefile])
751
752 # determine whether we should enable the odbc ccache
753 AC_ARG_ENABLE([odbc],
754         AC_HELP_STRING([--disable-odbc], [disable the ODBC Credential Cache]),
755         [odbc_enabled=$enableval], [odbc_enabled=default])
756
757 if test "x$odbc_enabled" = "x" ; then
758    odbc_enabled=yes
759 fi
760
761 # Are we trying to build ODBC?
762 AC_MSG_CHECKING(whether to build the ODBC ccache)
763 if test "$odbc_enabled" = "yes" ; then
764    build_odbc=yes
765    AC_MSG_RESULT(yes)
766 elif test "$odbc_enabled" = "default" ; then
767    build_odbc=yes
768    AC_MSG_RESULT([yes, if it can be found])
769 else
770    build_odbc=no
771    AC_MSG_RESULT(no)
772 fi
773
774 # If we're trying to build ODBC, try to find the odbc_config program.
775 if test "$build_odbc" = "yes" ; then
776    odbc_dir=""
777    AC_ARG_WITH(odbc,
778         AC_HELP_STRING([--with-odbc=PATH], [directory where odbc is installed]),
779             [if test "$with_odbc" = no ; then
780                AC_MSG_ERROR([Try running --disable-odbc instead.])
781              elif test "$with_odbc" != yes ; then
782                odbc_dir="$with_odbc/bin"
783              fi ])
784
785    # Try to find the mysql_config program
786    AC_PATH_PROG(ODBC_CONFIG, odbc_config, no, $odbc_dir $PATH )
787
788    if test "$ODBC_CONFIG" = no ; then
789       if test "$odbc_enabled" = "yes" ; then
790         AC_MSG_ERROR(Cannot find odbc_config)
791       else
792         AC_MSG_WARN(ODBC not found, skipping.)
793       fi
794    fi
795 fi
796
797 if test "$build_odbc" = yes ; then
798    ODBC_CFLAGS=`$ODBC_CONFIG --cflags`
799    ODBC_CFLAGS=`eval echo $ODBC_CFLAGS`
800    ODBC_LIBS=`$ODBC_CONFIG --libs`
801    ODBC_LIBS=`eval echo $ODBC_LIBS`
802
803    save_CPPFLAGS="$CPPFLAGS"
804    CPPFLAGS="$CPPFLAGS $ODBC_CFLAGS"
805
806    AC_CHECK_HEADER([sql.h], [have_sql_h=yes], [have_sql_h=no])
807    if test "$have_sql_h" = no -a "$odbc_enabled" = "yes" ; then
808      AC_MSG_ERROR(unable to find ODBC header files)
809    fi
810
811    if test "$have_sql_h" = yes ; then
812       save_LIBS="$LIBS"
813       LIBS="$LIBS $ODBC_LIBS"
814       AC_MSG_CHECKING(if we can link againt ODBC)
815       AC_TRY_LINK(
816         [#include <sql.h>
817          #include <sqlext.h>
818          #include <stdio.h>],
819         [SQLSetEnvAttr(SQL_NULL_HANDLE, SQL_ATTR_CONNECTION_POOLING, (void*)SQL_CP_ONE_PER_HENV, 0)],
820         [have_odbc_libs=yes],
821         [have_odbc_libs=no])
822       LIBS="$save_LIBS"
823
824       if test "$have_odbc_libs" = no ; then
825          if test "$odbc_enabled" = "yes" ; then
826             AC_MSG_ERROR([unable to link with ODBC Library])
827          else
828             AC_MSG_RESULT(no, skipping ODBC)
829          fi
830       fi
831    fi
832
833    CPPFLAGS="$save_CPPFLAGS"
834 fi
835
836 # if have_odbc_libs=yes then go ahead with building ODBC
837 if test "$have_odbc_libs" = yes ; then
838    # this AC_MSG_RESULT is from above!
839    AC_MSG_RESULT(yes)
840    WANT_SUBDIRS="$WANT_SUBDIRS odbc_ccache"
841    AC_SUBST(ODBC_CFLAGS)
842    AC_SUBST(ODBC_LIBS)
843 fi
844
845
846 AC_SUBST(WANT_SUBDIRS)
847
848 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
849   echo "=================================================================="
850   echo "WARNING: You have chosen to compile Apache-1.3 modules with a different"
851   echo "         compiler than the one used to compile Apache."
852   echo ""
853   echo "    Current compiler:      $CC"
854   echo "   Apache's compiler:      $APXS_CC"
855   echo ""
856   echo "This could cause some problems."
857   echo "=================================================================="
858 fi
859
860 if test -n "$APXS2_CC" && test "$APXS2_CC" != "$CC" ; then
861   echo "=================================================================="
862   echo "WARNING: You have chosen to compile Apache-2 modules with a different"
863   echo "         compiler than the one used to compile Apache."
864   echo ""
865   echo "    Current compiler:      $CC"
866   echo "   Apache's compiler:      $APXS2_CC"
867   echo ""
868   echo "This could cause some problems."
869   echo "=================================================================="
870 fi
871
872 AC_OUTPUT
873