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