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