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