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