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