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