Merge up from branch.
[shibboleth/sp.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([shibboleth], [2.0], [shibboleth-users@internet2.edu], [shibboleth])
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE([shibboleth],[2.0])
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 -Wall -g -D_DEBUG"
16     GCC_CXXFLAGS="$CXXFLAGS -Wall -g -D_DEBUG"
17 else
18     GCC_CFLAGS="$CFLAGS -Wall -O2 -DNDEBUG"
19     GCC_CXXFLAGS="$CXXFLAGS -Wall -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 ctime_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 AC_ARG_ENABLE(native-rpc,
71         AC_HELP_STRING([--enable-native-rpc], [use the OS-supplied Sun RPC library, default is NO, except Linux]),
72         [ if test "x$enableval" = "x" ; then
73               NATIVE_RPC=yes
74           else
75               NATIVE_RPC="$enableval"
76           fi
77         ], [ NATIVE_RPC=no ])
78 ACX_RPCTEST([rpctest="yes"],[rpctest="no"])
79 AC_MSG_NOTICE([does the native Sun RPC library support svcfd_create...$rpctest])
80 if test $NATIVE_RPC = "no"; then
81         case "${host}" in
82                 *-*-linux*)
83                         if test $rpctest = "yes"; then
84                                 AC_MSG_WARN([embedded Sun RPC library does not support Linux])
85                                 NATIVE_RPC="yes"
86                         else
87                                 AC_MSG_ERROR([embedded Sun RPC library won't work, but neither will native version])
88                         fi
89                 ;;
90         esac
91 fi
92 if test $NATIVE_RPC = "yes" && test $rpctest = "no"; then
93         AC_MSG_WARN([native Sun RPC won't work, using internal version])
94         NATIVE_RPC = "no"
95 fi
96 if test $NATIVE_RPC = "yes"; then
97         AC_CHECK_DECLS([svcfd_create],,,[#include <rpc/rpc.h>])
98         AC_LANG_PUSH(C++)
99         AC_COMPILE_IFELSE(
100                 AC_LANG_PROGRAM(
101                         [[#include <rpc/rpc.h>
102 static SVCXPRT* xprt = NULL;]],
103                 [[svc_destroy(xprt);]]),
104         AC_DEFINE(HAVE_WORKING_SVC_DESTROY,1,[Define if RPC SVC macros work on this platform]),)
105         AC_LANG_POP(C++)
106 else
107         AC_CHECK_TYPES([struct rpcent],,,[#include <netdb.h>])
108         AC_CHECK_DECLS(sys_errlist)
109         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.])
110         AC_DEFINE(HAVE_WORKING_SVC_DESTROY,1,[Define if RPC SVC macros work on this platform])
111 fi
112
113 AC_ARG_WITH(dmalloc,
114             AC_HELP_STRING([--with-dmalloc=PATH], [where dmalloc is installed]),
115             [if test x_$with_dmalloc != x_/usr; then
116                 LDFLAGS="-L${with_dmalloc}/lib $LDFLAGS"
117                 CPPFLAGS="-I${with_dmalloc}/include $CPPFLAGS"
118             fi
119             AC_CHECK_LIB(dmallocxx, dmalloc_shutdown,,
120                          AC_MSG_ERROR([unable to find dmallocxx library]))
121             ])
122
123 # OpenSSL settings
124 AC_PATH_PROG(PKG_CONFIG, pkg-config)
125 if test "x$PKG_CONFIG" = x || test "x$PKG_CONFIG" = "xno" ; then
126     AC_ARG_WITH(openssl, 
127             AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
128             [if test x_$with_openssl != x_/usr; then
129             SSLLIBS="-L${with_openssl}/lib"
130             SSLFLAGS="-I${with_openssl}/include"
131             fi])
132     SSLLIBS="$SSLLIBS -lssl -lcrypto"
133 else
134     SSLLIBS="`$PKG_CONFIG --libs openssl`"
135     SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
136 fi
137 AC_MSG_CHECKING(for OpenSSL libraries)
138 AC_MSG_RESULT($SSLLIBS)
139 LIBS="$LIBS $SSLLIBS"
140 AC_MSG_CHECKING(for OpenSSL cflags)
141 AC_MSG_RESULT($SSLFLAGS)
142 CPPFLAGS="$SSLFLAGS $CPPFLAGS"
143
144 AC_CHECK_HEADER([openssl/ssl.h],,
145                 AC_MSG_ERROR([unable to find openssl header files]))
146 AC_MSG_CHECKING(for ERR_load_CRYPTO_string)
147 AC_TRY_LINK_FUNC([ERR_load_CRYPTO_strings],,
148              AC_MSG_ERROR([unable to link with openssl libraries]))
149 AC_MSG_RESULT(yes)
150 AC_MSG_CHECKING(for SSL_library_init)
151 AC_TRY_LINK_FUNC([SSL_library_init],, 
152              AC_MSG_ERROR([unable to link with openssl libraries]))
153 AC_MSG_RESULT(yes)
154
155 AC_LANG(C++)
156
157 # log4cpp settings
158 AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
159 AC_ARG_WITH(log4cpp,
160             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp is installed]),
161             [LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"])
162 if test -f "${LOG4CPP_CONFIG}"; then
163     LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
164     CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
165 else
166     AC_MSG_WARN([log4cpp-config not found, guessing at log4cpp build settings])
167     LIBS="-llog4cpp $LIBS"
168 fi
169 AC_CHECK_HEADER([log4cpp/Category.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
170 AC_TRY_LINK(
171         [#include <log4cpp/Category.hh>],
172         [log4cpp::Category::getInstance("foo")],
173         [AC_DEFINE(HAVE_LIBLOG4CPP,1,[Define if log4cpp library was found])],
174         [AC_MSG_ERROR([unable to link with log4cpp])])
175
176 # Xerces settings
177 AC_ARG_WITH(xerces, 
178             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
179             [if test x_$with_xerces != x_/usr; then
180                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
181                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
182             fi])
183 LIBS="-lxerces-c $LIBS"
184 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
185                 AC_MSG_ERROR([unable to find xerces header files]))
186 AC_MSG_CHECKING([Xerces version])
187 AC_PREPROC_IFELSE(
188         [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
189 [#if  _XERCES_VERSION > 20200 && _XERCES_VERSION != 20600
190 int i = 0;
191 #else
192 #error requires version > 2.2.0 but not 2.6.0
193 #endif])],
194         [AC_MSG_RESULT(OK)],
195         [AC_MSG_ERROR([Shibboleth requires patched Xerces version 2.6.1 (http://shibboleth.internet2.edu/downloads/)])])
196 AC_TRY_LINK(
197         [#include <xercesc/util/PlatformUtils.hpp>],
198         [xercesc::XMLPlatformUtils::Initialize()],
199         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
200         [AC_MSG_ERROR([unable to link with Xerces])])
201
202
203 # XML-Security settings
204 AC_ARG_WITH(xmlsec,
205             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),
206             [if test x_$with_xmlsec != x_/usr; then
207                 LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
208                 CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
209             fi])
210 LIBS="-lxml-security-c $LIBS"
211 AC_CHECK_HEADER([xsec/xenc/XENCEncryptionMethod.hpp],,AC_MSG_ERROR([unable to find xml-security 1.1 header files]),[#include <xercesc/dom/DOM.hpp>])
212 AC_TRY_LINK(
213         [#include <xsec/utils/XSECPlatformUtils.hpp>],
214         [XSECPlatformUtils::Initialise()],
215         [AC_DEFINE(HAVE_LIBXSEC,1,[Define if XML-Sec library was found])],
216         [AC_MSG_ERROR([unable to link with xml-security])])
217
218 # OpenSAML settings
219 AC_ARG_WITH(saml,
220             AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
221             [if test x_$with_saml != x_/usr; then
222                 LDFLAGS="-L${with_saml}/lib $LDFLAGS"
223                 CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
224             fi])
225 AC_CHECK_HEADER([saml/saml.h],,
226                 AC_MSG_ERROR([unable to find saml header files]))
227 LIBS="-lsaml $LIBS"
228 AC_TRY_LINK(
229         [#include <saml/saml.h>
230 #include <saml/version.h>],
231         [#if _OPENSAML_VERSION >= 10100
232 saml::SAMLConfig::getConfig();
233 #else
234 #error Need OpenSAML version 1.1 or higher
235 #endif],
236         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
237         [AC_MSG_ERROR([unable to link with saml, or version too old])])
238
239 # output the underlying makefiles
240 WANT_SUBDIRS="doc shib schemas configs shib-target shar siterefresh test xmlproviders"
241 AC_CONFIG_FILES([Makefile doc/Makefile shib/Makefile schemas/Makefile \
242                  configs/Makefile oncrpc/Makefile oncrpc/rpc/Makefile \
243                  shib-target/Makefile shar/Makefile siterefresh/Makefile \
244                  test/Makefile xmlproviders/Makefile selinux/Makefile])
245
246
247 # now deal with the rpc library, to see if we need to build our own
248 if test $NATIVE_RPC = "no"; then
249     WANT_SUBDIRS="oncrpc $WANT_SUBDIRS"
250         AC_DEFINE(USE_OUR_ONCRPC,1,[Define if using embedded version of ONC RPC.])
251 fi
252 AM_CONDITIONAL(USE_OUR_ONCRPC,test "$NATIVE_RPC" = "no")
253
254 #
255 # Build NSAPI module?
256 #
257 AC_MSG_CHECKING(for NSAPI module option)
258 AC_ARG_WITH(nsapi,
259         AC_HELP_STRING([--with-nsapi=DIR], [Build NSAPI module for Netscape/iPlanet/SunONE]),
260         [WANT_NSAPI=$withval],[WANT_NSAPI=no])
261 AC_MSG_RESULT($WANT_NSAPI)
262
263 if test "$WANT_NSAPI" != "no"; then
264   if test ! -d $WANT_NSAPI/bin ; then
265     AC_MSG_ERROR(Please specify the path to the root of your Netscape/iPlanet/SunONE server using --with-nsapi=DIR)
266   fi
267   AC_MSG_CHECKING(for NSAPI include files)
268   if test -d $WANT_NSAPI/include ; then
269     NSAPI_INCLUDE=$WANT_NSAPI/include
270     AC_MSG_RESULT(Netscape-Enterprise 3.x style)
271     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
272     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
273   fi
274   if test -d $WANT_NSAPI/plugins/include ; then
275     test -n "$NSAPI_INCLUDE" && NSAPI_INC_DIR="-I$NSAPI_INCLUDE"
276     NSAPI_INCLUDE="$WANT_NSAPI/plugins/include"
277     AC_MSG_RESULT(iPlanet 4.x / SunONE 6.x style)
278     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
279     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
280   fi
281   if test "$NSAPI_INCLUDE" = ""; then
282     AC_MSG_ERROR(Please check you have nsapi.h in either $WANT_NSAPI/include or $WANT_NSAPI/plugins/include)
283   fi
284 fi
285
286 AC_SUBST(NSAPI_INCLUDE)
287
288 # always output the Makefile, even if you don't use it
289 AC_CONFIG_FILES([nsapi_shib/Makefile])
290 AM_CONDITIONAL(BUILD_NSAPI,test ! "$WANT_NSAPI" = "no")
291
292 # add the NSAPI module to the list of wanted subdirs..
293 if test ! "$WANT_NSAPI" = "no" ; then
294     WANT_SUBDIRS="$WANT_SUBDIRS nsapi_shib"
295 fi
296
297
298 # Apache 1.3 (mod_shib_13)
299 #   --enable-apache-13
300 #   --with-apxs      (DSO build, the normal way, uses apxs to derive build flags)
301
302 AC_ARG_ENABLE(apache-13,
303         AC_HELP_STRING([--enable-apache-13], [enable the Apache 1.3 module]),
304         [ if test "x$enableval" = "x" ; then
305               WANT_APACHE_13=yes
306           else
307               WANT_APACHE_13="$enableval"
308           fi
309         ],[ WANT_APACHE_13=no ])
310 AC_MSG_CHECKING(whether to build Apache 1.3 module)
311 if test "$WANT_APACHE_13" != yes && test "$WANT_APACHE_13" != no ; then
312    WANT_APACHE_13=yes
313 fi
314 AC_MSG_RESULT($WANT_APACHE_13)
315
316 if test "$WANT_APACHE_13" = "yes" ; then
317     AC_ARG_WITH(apxs, 
318         AC_HELP_STRING([--with-apxs=FILE], [Specifies where to find the Apache 1.3 apxs script.]),
319         [
320         AC_MSG_CHECKING(for user-specified apxs name/location)
321         if test "$withval" != "no" ; then
322           if test "$withval" != "yes"; then
323             APXS=$withval
324             AC_MSG_RESULT("$withval")
325           fi
326         fi
327         ],
328         [
329         AC_PATH_PROG(APXS, apxs, no)
330         if test "$APXS" = "no" ; then
331           for i in /usr/sbin /usr/local/apache/bin ; do
332             if test "$APXS" = "no" && test -f "$i/apxs"; then
333               APXS="$i/apxs"
334             fi
335           done
336         fi
337         ])
338
339     AC_MSG_CHECKING([to see if apxs was located])
340     if test ! -f "$APXS" ; then
341         AC_MSG_RESULT(no)
342         AC_MSG_ERROR([Unable to locate apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs option.])
343     fi
344     AC_MSG_RESULT($APXS)
345     AC_SUBST(APXS)
346
347     # extract settings we need from APXS -q
348     APXS_CC="`$APXS -q CC`"
349     APXS_CFLAGS="`$APXS -q CPPFLAGS` `$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
350     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
351 fi
352
353 AC_SUBST(APXS_CFLAGS)
354 AC_SUBST(APXS_INCLUDE)
355
356
357 # Apache 2.0 (mod_shib_20)
358 #   --enable-apache-20
359 #   --with-apxs2      (DSO build, the normal way, uses apxs to derive build flags)
360 #       --with-apr        (DSO build, APR development package installed separately)
361
362 AC_ARG_ENABLE(apache-20,
363         AC_HELP_STRING([--enable-apache-20], [enable the Apache 2.0 module]),
364         [ if test "x$enableval" = "x" ; then
365               WANT_APACHE_20=yes
366           else
367               WANT_APACHE_20="$enableval"
368           fi
369         ],[ WANT_APACHE_20=no ])
370 AC_MSG_CHECKING(whether to build Apache 2.0 module)
371 if test "$WANT_APACHE_20" != yes && test "$WANT_APACHE_20" != no ; then
372    WANT_APACHE_20=yes
373 fi
374 AC_MSG_RESULT($WANT_APACHE_20)
375
376 if test "$WANT_APACHE_20" = "yes" ; then
377     AC_ARG_WITH(apxs2, 
378         AC_HELP_STRING([--with-apxs2=FILE], [Specifies where to find the Apache 2.0 apxs script.]),
379         [
380         AC_MSG_CHECKING(for user-specified Apache2 apxs name/location)
381         if test "$withval" != "no" ; then
382           if test "$withval" != "yes"; then
383             APXS2=$withval
384             AC_MSG_RESULT("$withval")
385           fi
386         fi
387         ],
388         [
389         AC_PATH_PROG(APXS2, apxs2, no)
390         if test "$APXS2" = "no" ; then
391             AC_PATH_PROG(APXS2, apxs, no)
392         fi
393         if test "$APXS2" = "no" ; then
394           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
395             if test "$APXS2" = "no" && test -f "$i/apxs2" ; then
396               APXS2="$i/apxs2"
397             fi
398           done
399           if test "$APXS2" = "no" ; then
400             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
401               if test "$APXS2" = "no" && test -f "$i/apxs" ; then
402                 APXS2="$i/apxs"
403               fi
404             done
405           fi
406         fi
407         ])
408
409     AC_MSG_CHECKING([to see if Apache2 apxs was located])
410     if test ! -f "$APXS2" ; then
411         AC_MSG_RESULT(no)
412         AC_MSG_ERROR([Unable to locate Apache2 apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs2 option.])
413     fi
414     AC_MSG_RESULT($APXS2)
415     AC_SUBST(APXS2)
416
417     # APR settings
418     AC_ARG_WITH(apr, 
419         AC_HELP_STRING([--with-apr=PATH], [where apr-config is installed]),
420         [
421         AC_MSG_CHECKING(for user-specified apr-config name/location)
422         if test "$withval" != "no" ; then
423             if test "$withval" != "yes"; then
424                 APR_CONFIG=$withval
425                 AC_MSG_RESULT("$withval")
426             fi
427         fi
428         ],
429         [
430         AC_PATH_PROG(APR_CONFIG, apr-config)
431         ])
432         if test -f "${APR_CONFIG}"; then
433         APR_CFLAGS="`${APR_CONFIG} --cflags` `${APR_CONFIG} --cppflags` `${APR_CONFIG} --includes`"
434     else
435         AC_MSG_ERROR([Unable to locate apr-config, may need --with-apr option.])
436     fi
437
438     # extract settings we need from APXS2 -q
439     APXS2_CC="`$APXS2 -q CC`"
440     APXS2_CFLAGS="`$APXS2 -q CPPFLAGS` `$APXS2 -q CFLAGS` `$APXS2 -q CFLAGS_SHLIB` $APR_CFLAGS"
441     APXS2_INCLUDE="`$APXS2 -q INCLUDEDIR`"
442 fi
443
444 AC_SUBST(APXS2_CFLAGS)
445 AC_SUBST(APXS2_INCLUDE)
446
447
448 # Apache 2.2 (mod_shib_22)
449 #   --enable-apache-22
450 #   --with-apxs22     (DSO build, the normal way, uses apxs to derive build flags)
451 #       --with-apr1       (DSO build, APR development package installed separately)
452
453 AC_ARG_ENABLE(apache-22,
454         AC_HELP_STRING([--enable-apache-22], [enable the Apache 2.2 module]),
455         [ if test "x$enableval" = "x" ; then
456               WANT_APACHE_22=yes
457           else
458               WANT_APACHE_22="$enableval"
459           fi
460         ],[ WANT_APACHE_22=no ])
461 AC_MSG_CHECKING(whether to build Apache 2.2 module)
462 if test "$WANT_APACHE_22" != yes && test "$WANT_APACHE_22" != no ; then
463    WANT_APACHE_22=yes
464 fi
465 AC_MSG_RESULT($WANT_APACHE_22)
466
467 if test "$WANT_APACHE_22" = "yes" ; then
468     AC_ARG_WITH(apxs22, 
469         AC_HELP_STRING([--with-apxs22=FILE], [Specifies where to find the Apache 2.2 apxs script.]),
470         [
471         AC_MSG_CHECKING(for user-specified Apache2.2 apxs name/location)
472         if test "$withval" != "no" ; then
473           if test "$withval" != "yes"; then
474             APXS22=$withval
475             AC_MSG_RESULT("$withval")
476           fi
477         fi
478         ],
479         [
480         AC_PATH_PROG(APXS22, apxs2, no)
481         if test "$APXS22" = "no" ; then
482             AC_PATH_PROG(APXS22, apxs, no)
483         fi
484         if test "$APXS22" = "no" ; then
485           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
486             if test "$APXS22" = "no" && test -f "$i/apxs2" ; then
487               APXS22="$i/apxs2"
488             fi
489           done
490           if test "$APXS22" = "no" ; then
491             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
492               if test "$APXS22" = "no" && test -f "$i/apxs" ; then
493                 APXS22="$i/apxs"
494               fi
495             done
496           fi
497         fi
498         ])
499
500     AC_MSG_CHECKING([to see if Apache2.2 apxs was located])
501     if test ! -f "$APXS22" ; then
502         AC_MSG_RESULT(no)
503         AC_MSG_ERROR([Unable to locate Apache2.2 apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs22 option.])
504     fi
505     AC_MSG_RESULT($APXS22)
506     AC_SUBST(APXS22)
507
508     # APR1 settings
509     AC_ARG_WITH(apr1, 
510         AC_HELP_STRING([--with-apr1=PATH], [where apr-1-config is installed]),
511         [
512         AC_MSG_CHECKING(for user-specified apr-1-config name/location)
513         if test "$withval" != "no" ; then
514             if test "$withval" != "yes"; then
515                 APR1_CONFIG=$withval
516                 AC_MSG_RESULT("$withval")
517             fi
518         fi
519         ],
520         [
521         AC_PATH_PROG(APR1_CONFIG, apr-1-config)
522         ])
523         if test -f "${APR1_CONFIG}"; then
524         APR1_CFLAGS="`${APR1_CONFIG} --cflags` `${APR1_CONFIG} --cppflags` `${APR1_CONFIG} --includes`"
525     else
526         AC_MSG_ERROR([Unable to locate apr-1-config, may need --with-apr1 option.])
527     fi
528
529     # extract settings we need from APXS22 -q
530     APXS22_CC="`$APXS22 -q CC`"
531     APXS22_CFLAGS="`$APXS22 -q CPPFLAGS` `$APXS22 -q CFLAGS` `$APXS22 -q CFLAGS_SHLIB` $APR1_CFLAGS"
532     APXS22_INCLUDE="`$APXS22 -q INCLUDEDIR`"
533 fi
534
535 AC_SUBST(APXS22_CFLAGS)
536 AC_SUBST(APXS22_INCLUDE)
537
538 # always output the Makefile, even if you don't use it
539 AC_CONFIG_FILES([apache/Makefile])
540 AM_CONDITIONAL(BUILD_AP13,test "$WANT_APACHE_13" = "yes")
541 AM_CONDITIONAL(BUILD_AP20,test "$WANT_APACHE_20" = "yes")
542 AM_CONDITIONAL(BUILD_AP22,test "$WANT_APACHE_22" = "yes")
543
544 # add the apache module to the list of wanted subdirs..
545 if test "$WANT_APACHE_13" = "yes" || test "$WANT_APACHE_20" = "yes" || test "$WANT_APACHE_22" = "yes" ; then
546     WANT_SUBDIRS="$WANT_SUBDIRS apache"
547 fi
548
549
550 #
551 # Implement the checks of the MySQL Credential Cache
552 #
553 # 1) Assume the user wants MySQL; if it's not found then just continue without
554 # 2) If the user specifically requested Mysql, look for it and ERROR if not found
555 # 3) If the user specifically requested no-mysql, don't build it.
556 #
557
558 AC_CONFIG_FILES([shib-mysql-ccache/Makefile])
559
560 # determine whether we should enable the mysql ccache
561 AC_ARG_ENABLE([mysql],
562         AC_HELP_STRING([--disable-mysql], [disable the MySQL Credential Cache]),
563         [mysql_enabled=$enableval], [mysql_enabled=default])
564
565 if test "x$mysql_enabled" = "x" ; then
566    mysql_enabled=yes
567 fi
568
569 # Are we trying to build MySQL?
570 AC_MSG_CHECKING(whether to build the MySQL ccache)
571 if test "$mysql_enabled" = "yes" ; then
572    build_mysql=yes
573    AC_MSG_RESULT(yes)
574 elif test "$mysql_enabled" = "default" ; then
575    build_mysql=yes
576    AC_MSG_RESULT([yes, if it can be found])
577 else
578    build_mysql=no
579    AC_MSG_RESULT(no)
580 fi
581
582 # If we're trying to build MySQL, try to find the mysql_config program,
583 # verify we've got mysql >= 4, and make sure we can build with mysqld
584 if test "$build_mysql" = "yes" ; then
585    mysql_dir=""
586    AC_ARG_WITH(mysql,
587         AC_HELP_STRING([--with-mysql=PATH], [directory where mysql is installed]),
588             [if test "$with_mysql" = no ; then
589              AC_MSG_ERROR([Try running --disable-mysql instead.])
590          elif test "$with_mysql" != yes ; then
591              mysql_dir="$with_mysql/bin"
592          fi ])
593
594    # Try to find the mysql_config program
595    AC_PATH_PROG(MYSQL_CONFIG, mysql_config, no, $mysql_dir $PATH )
596
597    if test "$MYSQL_CONFIG" = no ; then
598       if test "$mysql_enabled" = "yes" ; then
599         AC_MSG_ERROR(Cannot find mysql_config)
600       else
601         AC_MSG_WARN(MySQL not found.  skipping.)
602       fi
603    fi
604 fi
605
606 # if we found mysql_config then build_mysql is 'yes'
607 if test "$MYSQL_CONFIG" != no ; then
608    AC_MSG_CHECKING(for mysql version >= 4)
609    mysql_version=`$MYSQL_CONFIG --version`
610    mysql_major_version=`echo $mysql_version | awk -F. '{print $1}'`
611    mysql_version_ok=yes
612    if test $mysql_major_version -lt 4 ; then
613      mysql_version_ok=no
614      if test "$mysql_enabled" = "yes" ; then
615        AC_MSG_ERROR(You need MySQL version >= 4, found $mysql_version)
616      fi
617      AC_MSG_RESULT(no.. skipping MySQL)
618    else
619      AC_MSG_RESULT(yes)
620    fi
621 fi
622
623 # if mysql_version_ok is 'yes', then we've made it this far.. ;)
624 if test "$mysql_version_ok" = "yes" ; then
625    AC_MSG_CHECKING(for embedded-MySQL libraries)
626    MYSQL_LIBS=`$MYSQL_CONFIG --libmysqld-libs`
627    if test $? != 0 ; then
628       found_mysql=no
629       if test "$mysql_enabled" = "yes" ; then
630         AC_MSG_ERROR(Could not find the MySQL Embedded-server libraries.)
631       else
632         AC_MSG_RESULT(no.. skipping MySQL)
633       fi
634    else
635       found_mysql=yes
636       AC_MSG_RESULT(yes)
637    fi
638 fi
639
640 # if found_mysql=yes then test that we can actually build mysql
641 if test "$found_mysql" = yes ; then
642    MYSQL_CFLAGS=`$MYSQL_CONFIG --cflags`
643    MYSQL_CFLAGS=`eval echo $MYSQL_CFLAGS`
644    MYSQL_LIBS=`eval echo $MYSQL_LIBS`
645
646    save_CPPFLAGS="$CPPFLAGS"
647    CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
648
649    AC_CHECK_HEADER([mysql.h], [have_mysql_h=yes], [have_mysql_h=no])
650    if test "$have_mysql_h" = no -a "$mysql_enabled" = "yes" ; then
651      AC_MSG_ERROR(unable to find MySQL header files)
652    fi
653
654    if test "$have_mysql_h" = yes ; then
655       save_LIBS="$LIBS"
656       LIBS="$LIBS $MYSQL_LIBS"
657       AC_MSG_CHECKING(if we can link againt mysql)
658       AC_TRY_LINK(
659         [#include <mysql.h>
660          #include <stdio.h>],
661         [mysql_server_init(0, NULL, NULL)],
662         [have_mysql_libs=yes],
663         [have_mysql_libs=no])
664       LIBS="$save_LIBS"
665
666       if test "$have_mysql_libs" = no ; then
667          if test "$mysql_enabled" = "yes" ; then
668             AC_MSG_ERROR([unable to link with MySQL Embedded Server Library])
669          else
670             AC_MSG_RESULT(no.  skipping MySQL)
671          fi
672       fi
673    fi
674
675    CPPFLAGS="$save_CPPFLAGS"
676 fi
677
678 # if have_mysql_libs=yes then go ahead with building MySQL
679 if test "$have_mysql_libs" = yes ; then
680    # this AC_MSG_RESULT is from above!
681    AC_MSG_RESULT(yes)
682    WANT_SUBDIRS="$WANT_SUBDIRS shib-mysql-ccache"
683    AC_SUBST(MYSQL_CFLAGS)
684    AC_SUBST(MYSQL_LIBS)
685 fi
686
687
688 #
689 # Implement the checks of the ODBC Credential Cache
690 #
691 # 1) Assume the user wants ODBC; if it's not found then just continue without
692 # 2) If the user specifically requested odbc, look for it and ERROR if not found
693 # 3) If the user specifically requested no-odbc, don't build it.
694 #
695
696 AC_CONFIG_FILES([odbc_ccache/Makefile])
697
698 # determine whether we should enable the odbc ccache
699 AC_ARG_ENABLE([odbc],
700         AC_HELP_STRING([--disable-odbc], [disable the ODBC Credential Cache]),
701         [odbc_enabled=$enableval], [odbc_enabled=default])
702
703 if test "x$odbc_enabled" = "x" ; then
704    odbc_enabled=yes
705 fi
706
707 # Are we trying to build ODBC?
708 AC_MSG_CHECKING(whether to build the ODBC ccache)
709 if test "$odbc_enabled" = "yes" ; then
710    build_odbc=yes
711    AC_MSG_RESULT(yes)
712 elif test "$odbc_enabled" = "default" ; then
713    build_odbc=yes
714    AC_MSG_RESULT([yes, if it can be found])
715 else
716    build_odbc=no
717    AC_MSG_RESULT(no)
718 fi
719
720 # If we're trying to build ODBC, try to find the odbc_config program.
721 if test "$build_odbc" = "yes" ; then
722    odbc_dir=""
723    AC_ARG_WITH(odbc,
724         AC_HELP_STRING([--with-odbc=PATH], [directory where odbc is installed]),
725             [if test "$with_odbc" = no ; then
726                AC_MSG_ERROR([Try running --disable-odbc instead.])
727              elif test "$with_odbc" != yes ; then
728                odbc_dir="$with_odbc/bin"
729              fi ])
730
731    # Try to find the mysql_config program
732    AC_PATH_PROG(ODBC_CONFIG, odbc_config, no, $odbc_dir $PATH )
733
734    if test "$ODBC_CONFIG" = no ; then
735       if test "$odbc_enabled" = "yes" ; then
736         AC_MSG_ERROR(Cannot find odbc_config)
737       else
738         AC_MSG_WARN(ODBC not found, skipping.)
739       fi
740    fi
741 fi
742
743 if test "$build_odbc" = yes ; then
744    ODBC_CFLAGS=`$ODBC_CONFIG --cflags`
745    ODBC_CFLAGS=`eval echo $ODBC_CFLAGS`
746    ODBC_LIBS=`$ODBC_CONFIG --libs`
747    ODBC_LIBS=`eval echo $ODBC_LIBS`
748
749    save_CPPFLAGS="$CPPFLAGS"
750    CPPFLAGS="$CPPFLAGS $ODBC_CFLAGS"
751
752    AC_CHECK_HEADER([sql.h], [have_sql_h=yes], [have_sql_h=no])
753    if test "$have_sql_h" = no -a "$odbc_enabled" = "yes" ; then
754      AC_MSG_ERROR(unable to find ODBC header files)
755    fi
756
757    if test "$have_sql_h" = yes ; then
758       save_LIBS="$LIBS"
759       LIBS="$LIBS $ODBC_LIBS"
760       AC_MSG_CHECKING(if we can link againt ODBC)
761       AC_TRY_LINK(
762         [#include <sql.h>
763          #include <sqlext.h>
764          #include <stdio.h>],
765         [SQLSetEnvAttr(SQL_NULL_HANDLE, SQL_ATTR_CONNECTION_POOLING, (void*)SQL_CP_ONE_PER_HENV, 0)],
766         [have_odbc_libs=yes],
767         [have_odbc_libs=no])
768       LIBS="$save_LIBS"
769
770       if test "$have_odbc_libs" = no ; then
771          if test "$odbc_enabled" = "yes" ; then
772             AC_MSG_ERROR([unable to link with ODBC Library])
773          else
774             AC_MSG_RESULT(no, skipping ODBC)
775          fi
776       fi
777    fi
778
779    CPPFLAGS="$save_CPPFLAGS"
780 fi
781
782 # if have_odbc_libs=yes then go ahead with building ODBC
783 if test "$have_odbc_libs" = yes ; then
784    # this AC_MSG_RESULT is from above!
785    AC_MSG_RESULT(yes)
786    WANT_SUBDIRS="$WANT_SUBDIRS odbc_ccache"
787    AC_SUBST(ODBC_CFLAGS)
788    AC_SUBST(ODBC_LIBS)
789 fi
790
791
792 AC_SUBST(WANT_SUBDIRS)
793
794 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
795   echo "=================================================================="
796   echo "WARNING: You have chosen to compile Apache-1.3 modules with a different"
797   echo "         compiler than the one used to compile Apache."
798   echo ""
799   echo "    Current compiler:      $CC"
800   echo "   Apache's compiler:      $APXS_CC"
801   echo ""
802   echo "This could cause problems."
803   echo "=================================================================="
804 fi
805
806 if test -n "$APXS2_CC" && test "$APXS2_CC" != "$CC" ; then
807   echo "=================================================================="
808   echo "WARNING: You have chosen to compile Apache-2 modules with a different"
809   echo "         compiler than the one used to compile Apache."
810   echo ""
811   echo "    Current compiler:      $CC"
812   echo "   Apache's compiler:      $APXS2_CC"
813   echo ""
814   echo "This could cause problems."
815   echo "=================================================================="
816 fi
817
818 LIBTOOL="$LIBTOOL --silent"
819
820 AC_OUTPUT
821