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