Fix ODBC checks.
[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(doxygen.m4)
7 sinclude(acx_pthread.m4)
8
9 # Docygen features
10 DX_HTML_FEATURE(ON)
11 DX_CHM_FEATURE(OFF)
12 DX_CHI_FEATURE(OFF)
13 DX_MAN_FEATURE(OFF)
14 DX_RTF_FEATURE(OFF)
15 DX_XML_FEATURE(OFF)
16 DX_PDF_FEATURE(OFF)
17 DX_PS_FEATURE(OFF)
18 DX_INIT_DOXYGEN(shibboleth, doxygen.cfg, doc/api)
19 DX_INCLUDE=
20
21 AC_ARG_ENABLE(debug,
22     AC_HELP_STRING(--enable-debug, [Have GCC compile with symbols (Default = no)
23 ]),
24     enable_debug=$enableval, enable_debug=no)
25
26 if test "$enable_debug" = "yes" ; then
27     GCC_CFLAGS="$CFLAGS -g -D_DEBUG"
28     GCC_CXXFLAGS="$CXXFLAGS -g -D_DEBUG"
29 else
30     GCC_CFLAGS="$CFLAGS -O2 -DNDEBUG"
31     GCC_CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG"
32 fi
33
34 AC_PROG_CC([gcc gcc3 cc])
35 AC_PROG_CXX([g++ g++3 c++ CC])
36 AC_CANONICAL_HOST
37
38 if test "$GCC" = "yes" ; then
39 #    AC_HAVE_GCC_VERSION(4,0,0,0,
40 #        [
41 #        AC_DEFINE(GCC_HASCLASSVISIBILITY,1,
42 #            [Define to enable class visibility control in gcc.])
43 #        GCC_CFLAGS="$GCC_CFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
44 #        GCC_CXXFLAGS="$GCC_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
45 #        ])
46     CFLAGS="-Wall $GCC_CFLAGS"
47     CXXFLAGS="-Wall $GCC_CXXFLAGS"
48 else
49 # Fix for Sun Workshop compiler in debug mode, may be Sun case #6360993
50         case "${host_cpu}-${host_os}" in
51                 *solaris*)
52                         if test "$CXX" = "CC" ; then
53                                 CXXFLAGS="$CXXFLAGS -Qoption ccfe -stabs=no%dfltlit+no%dflthlp"
54                         fi
55                 ;;
56         esac
57 fi
58
59 AC_DISABLE_STATIC
60 AC_PROG_LIBTOOL
61
62 AC_LANG(C)
63
64 # Checks for typedefs, structures, and compiler characteristics.
65 AC_C_CONST
66 AC_TYPE_SIZE_T
67 AC_STRUCT_TM
68
69 # Checks for library functions.
70 AC_FUNC_STRFTIME
71 AC_FUNC_STRERROR_R
72 AC_CHECK_FUNCS([strchr strdup strstr timegm gmtime_r ctime_r strtok_r strcasecmp])
73
74 # checks for pthreads
75 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
76 if test $enable_threads != "pthread"; then
77     AC_MSG_ERROR([unable to find pthreads, currently this is required])
78 else
79     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
80     LIBS="$PTHREAD_LIBS $LIBS"
81     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
82     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
83 fi
84
85 AC_LANG(C++)
86
87 # C++ requirements
88 AC_CXX_REQUIRE_STL
89 AC_CXX_NAMESPACES
90
91 # log4shib settings (favor this version over the log4cpp code)
92 AC_PATH_PROG(LOG4SHIB_CONFIG,log4shib-config)
93 AC_ARG_WITH(log4shib,
94     AC_HELP_STRING([--with-log4shib=PATH], [where log4shib-config is installed]),
95     [
96     LOG4SHIB_CONFIG="${with_log4shib}"
97     if ! test -f "${LOG4SHIB_CONFIG}" ; then
98         LOG4SHIB_CONFIG="${with_log4shib}/bin/log4shib-config"
99     fi
100     ])
101 if test -f "${LOG4SHIB_CONFIG}"; then
102     LDFLAGS="`${LOG4SHIB_CONFIG} --libs` $LDFLAGS"
103     CPPFLAGS="`${LOG4SHIB_CONFIG} --cflags` $CPPFLAGS"
104         AC_CHECK_HEADER([log4shib/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4shib header files]))
105         AC_TRY_LINK(
106                 [#include <log4shib/Category.hh>
107 #include <log4shib/CategoryStream.hh>],
108                 [log4shib::Category::getInstance("foo").errorStream() << log4shib::eol],
109                 [AC_DEFINE(SHIBSP_LOG4SHIB,1,[Define if log4shib library is used.])],
110                 [AC_MSG_ERROR([unable to link with log4shib])])
111 else
112     AC_MSG_WARN([log4shib-config not found, may need to use --with-log4shib option])
113     AC_MSG_WARN([will look for original log4cpp library])
114     
115         # log4cpp settings
116         AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
117         AC_ARG_WITH(log4cpp,
118             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
119             [
120             LOG4CPP_CONFIG="${with_log4cpp}"
121             if ! test -f "${LOG4CPP_CONFIG}" ; then
122                 LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
123             fi
124             ])
125         if test -f "${LOG4CPP_CONFIG}"; then
126                 AC_MSG_WARN([will try to use log4cpp, note that most non-Internet2 supplied versions are not thread-safe])
127             LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
128             CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
129                 AC_CHECK_HEADER([log4cpp/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
130                 AC_TRY_LINK(
131                         [#include <log4cpp/Category.hh>
132 #include <log4cpp/CategoryStream.hh>],
133                         [log4cpp::Category::getInstance("foo").errorStream() << log4cpp::eol],
134                         [AC_DEFINE(SHIBSP_LOG4CPP,1,[Define if log4cpp library is used.])],
135                         [AC_MSG_ERROR([unable to link with log4cpp, need version 1.0 or later])])
136         else
137             AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
138         fi
139 fi
140
141 # Xerces settings
142 AC_ARG_WITH(xerces, 
143             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
144             [if test x_$with_xerces != x_/usr; then
145                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
146                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
147             fi])
148 LIBS="-lxerces-c $LIBS"
149 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
150                 AC_MSG_ERROR([unable to find xerces header files]))
151 AC_MSG_CHECKING([Xerces version])
152 AC_PREPROC_IFELSE(
153     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
154 [#if  _XERCES_VERSION != 20600
155 int i = 0;
156 #else
157 #error cannot use version 2.6.0
158 #endif])],
159     [AC_MSG_RESULT(OK)],
160     [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use a newer version])])
161 AC_TRY_LINK(
162         [#include <xercesc/util/PlatformUtils.hpp>],
163         [xercesc::XMLPlatformUtils::Initialize()],
164         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
165         [AC_MSG_ERROR([unable to link with Xerces])])
166
167
168 #XML-Tooling settings
169 AC_ARG_WITH(xmltooling,
170             AC_HELP_STRING([--with-xmltooling=PATH], [where xmltooling-c is installed]),
171             [if test x_$with_xmltooling != x_/usr; then
172                 LDFLAGS="-L${with_xmltooling}/lib $LDFLAGS"
173                 CPPFLAGS="-I${with_xmltooling}/include $CPPFLAGS"
174             fi])
175 LITE_LIBS="-lxmltooling-lite"
176 XMLSEC_LIBS="-lxmltooling"
177 AC_CHECK_HEADER([xmltooling/base.h],,
178                 AC_MSG_ERROR([unable to find xmltooling header files]))
179
180 # Establish location of xmltooling catalog.
181 XMLTOOLINGXMLDIR=""
182 if test "x$with_xmltooling" = "x" ; then
183    with_xmltooling="/usr"
184 fi
185 if test -f $with_xmltooling/share/xml/xmltooling/catalog.xml ; then
186     XMLTOOLINGXMLDIR="$with_xmltooling"
187 elif test -f $with_xerces/share/xml/xmltooling/catalog.xml ; then
188     XMLTOOLINGXMLDIR="$with_xerces"
189 elif test -f $with_log4shib/share/xml/xmltooling/catalog.xml ; then
190     XMLTOOLINGXMLDIR="$with_log4shib"
191 fi
192 if test "x$XMLTOOLINGXMLDIR" = "x" ; then
193     AC_MSG_ERROR([xmltooling XML catalog not found, may need to use --with-xmltooling option])
194 fi
195 XMLTOOLINGXMLDIR="$XMLTOOLINGXMLDIR/share/xml/xmltooling"
196 AC_SUBST(XMLTOOLINGXMLDIR)
197
198 # XML-Security settings
199 AC_ARG_WITH(xmlsec,
200             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
201             [with_xmlsec=/usr])
202
203 if test x_$with_xmlsec != x_/usr; then
204     LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
205     CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
206 fi        
207 XMLSEC_LIBS="-lxml-security-c $XMLSEC_LIBS"
208
209 # save and append master libs
210 save_LIBS="$LIBS"
211 LIBS="$XMLSEC_LIBS $LIBS"
212
213 AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
214 AC_MSG_CHECKING([XML-Security version])
215 AC_PREPROC_IFELSE(
216     [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
217     [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3)
218 int i = 0;
219 #else
220 #error need version 1.4.0 or later
221 #endif])],
222     [AC_MSG_RESULT(OK)],
223     [AC_MSG_FAILURE([XML-Security version 1.4.0 or greater is required.])])
224 AC_TRY_LINK(
225         [#include <xsec/utils/XSECPlatformUtils.hpp>],
226         [XSECPlatformUtils::Initialise()],,
227         [AC_MSG_ERROR([unable to link with XML-Security])])
228
229 # restore master libs
230 LIBS="$save_LIBS"
231
232 # OpenSAML settings
233 AC_ARG_WITH(saml,
234     AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
235     [if test x_$with_saml != x_/usr; then
236         LDFLAGS="-L${with_saml}/lib $LDFLAGS"
237         CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
238     fi])
239 XMLSEC_LIBS="-lsaml $XMLSEC_LIBS"
240
241 # save and append master libs
242 save_LIBS="$LIBS"
243 LIBS="$XMLSEC_LIBS $LIBS"
244
245 AC_CHECK_HEADER([saml/saml2/metadata/Metadata.h],,
246                 AC_MSG_ERROR([unable to find OpenSAML header files]))
247 AC_TRY_LINK(
248         [#include <saml/SAMLConfig.h>
249 #include <saml/version.h>],
250         [#if _OPENSAML_VERSION >= 20000
251 opensaml::SAMLConfig::getConfig();
252 #else
253 #error Need OpenSAML version 2.0 or higher
254 #endif],
255         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
256         [AC_MSG_ERROR([unable to link with OpenSAML, or version was too old])])
257
258 # restore master libs
259 LIBS="$save_LIBS"
260
261 # Establish location of opensaml catalogs.
262 OPENSAMLXMLDIR=""
263 if test "x$with_saml" = "x" ; then
264     with_saml="/usr"
265 fi
266 if test -f $with_saml/share/xml/opensaml/saml20-catalog.xml ; then
267     OPENSAMLXMLDIR="$with_saml"
268 elif test -f $with_xmltooling/share/xml/opensaml/saml20-catalog.xml ; then
269     OPENSAMLXMLDIR="$with_xmltooling"
270 elif test -f $with_xerces/share/xml/opensaml/saml20-catalog.xml ; then
271     OPENSAMLXMLDIR="$with_xerces"
272 elif test -f $with_log4shib/share/xml/opensaml/saml20-catalog.xml ; then
273     OPENSAMLXMLDIR="$with_log4shib"
274 fi
275 if test "x$OPENSAMLXMLDIR" = "x" ; then
276     AC_MSG_ERROR([opensaml XML catalogs not found, may need to use --with-saml option])
277 fi
278 OPENSAMLXMLDIR="$OPENSAMLXMLDIR/share/xml/opensaml"
279 AC_SUBST(OPENSAMLXMLDIR)
280
281 AC_SUBST(LITE_LIBS)
282 AC_SUBST(XMLSEC_LIBS)
283
284 # output the underlying makefiles
285 WANT_SUBDIRS="doc schemas configs shibsp shibd util"
286 AC_CONFIG_FILES([Makefile doc/Makefile schemas/Makefile \
287         configs/Makefile shibsp/Makefile shibd/Makefile \
288         util/Makefile selinux/Makefile])
289
290 ## ADFS?
291 AC_CONFIG_FILES([adfs/Makefile])
292 AC_ARG_ENABLE([adfs],
293         AC_HELP_STRING([--disable-adfs], [don't build the ADFS module]),
294         [adfs_enabled=$enableval], [adfs_enabled=yes])
295 if test "x$adfs_enabled" = "x" ; then
296    adfs_enabled=yes
297 fi
298 AC_MSG_CHECKING(whether to build the ADFS module)
299 if test "$adfs_enabled" = "no" ; then
300    AC_MSG_RESULT(no)
301 else
302    AC_MSG_RESULT(yes)
303    WANT_SUBDIRS="$WANT_SUBDIRS adfs"
304 fi
305
306
307 #
308 # Build NSAPI module?
309 #
310 AC_MSG_CHECKING(for NSAPI module option)
311 AC_ARG_WITH(nsapi,
312         AC_HELP_STRING([--with-nsapi=DIR], [Build NSAPI module for Netscape/iPlanet/SunONE]),
313         [WANT_NSAPI=$withval],[WANT_NSAPI=no])
314 AC_MSG_RESULT($WANT_NSAPI)
315
316 if test "$WANT_NSAPI" != "no"; then
317   if test ! -d $WANT_NSAPI/bin ; then
318     AC_MSG_ERROR(Please specify the path to the root of your Netscape/iPlanet/SunONE server using --with-nsapi=DIR)
319   fi
320   AC_MSG_CHECKING(for NSAPI include files)
321   if test -d $WANT_NSAPI/include ; then
322     NSAPI_INCLUDE=$WANT_NSAPI/include
323     AC_MSG_RESULT(Netscape-Enterprise 3.x style)
324     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
325     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
326   fi
327   if test -d $WANT_NSAPI/plugins/include ; then
328     test -n "$NSAPI_INCLUDE" && NSAPI_INC_DIR="-I$NSAPI_INCLUDE"
329     NSAPI_INCLUDE="$WANT_NSAPI/plugins/include"
330     AC_MSG_RESULT(iPlanet 4.x / SunONE 6.x style)
331     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
332     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
333   fi
334   if test "$NSAPI_INCLUDE" = ""; then
335     AC_MSG_ERROR(Please check you have nsapi.h in either $WANT_NSAPI/include or $WANT_NSAPI/plugins/include)
336   fi
337 fi
338
339 AC_SUBST(NSAPI_INCLUDE)
340
341 # always output the Makefile, even if you don't use it
342 AC_CONFIG_FILES([nsapi_shib/Makefile])
343 AM_CONDITIONAL(BUILD_NSAPI,test ! "$WANT_NSAPI" = "no")
344
345 # add the NSAPI module to the list of wanted subdirs..
346 if test ! "$WANT_NSAPI" = "no" ; then
347     WANT_SUBDIRS="$WANT_SUBDIRS nsapi_shib"
348 fi
349
350
351 #
352 # Build FastCGI support?
353 #
354 AC_MSG_CHECKING(for FastCGI support)
355 AC_ARG_WITH(fastcgi,
356     AC_HELP_STRING([--with-fastcgi=DIR], [Build FastCGI support]),
357     [WANT_FASTCGI=$withval],[WANT_FASTCGI=no])
358 AC_MSG_RESULT($WANT_FASTCGI)
359
360 if test "$WANT_FASTCGI" != "no"; then
361     if test "$WANT_FASTCGI" != "yes"; then
362         if test x_$WANT_FASTCGI != x_/usr; then
363             FASTCGI_INCLUDE="-I$WANT_FASTCGI/include"
364             FASTCGI_LDFLAGS="-L$WANT_FASTCGI/lib"
365         fi
366     fi
367     AC_CHECK_HEADER([fcgio.h],,
368         AC_MSG_ERROR([unable to find FastCGI header files]))
369     FASTCGI_LIBS="-lfcgi -lfcgi++"
370 fi
371
372 AC_SUBST(FASTCGI_INCLUDE)
373 AC_SUBST(FASTCGI_LDFLAGS)
374 AC_SUBST(FASTCGI_LIBS)
375
376 # always output the Makefile, even if you don't use it
377 AC_CONFIG_FILES([fastcgi/Makefile])
378 AM_CONDITIONAL(BUILD_FASTCGI,test ! "$WANT_FASTCGI" = "no")
379
380 if test ! "$WANT_FASTCGI" = "no" ; then
381     WANT_SUBDIRS="$WANT_SUBDIRS fastcgi"
382 fi
383
384
385 #
386 # If no --enable-apache-xx specified 
387 # find a default and fake the specific parameters
388 #
389
390 # simple macro to peek at an enable or a with
391 AC_DEFUN([Peek],
392 if test "[${[$1]_][$2]+set}" = set; then
393   peekval="${[$1]_[$2]}"
394   $3
395 fi; dnl
396 )
397
398 AC_MSG_CHECKING(if default apache needed)
399 need_default=yes
400 Peek(enable,apache_13,need_default=no)
401 Peek(enable,apache_20,need_default=no)
402 Peek(enable,apache_22,need_default=no)
403 AC_MSG_RESULT($need_default)
404
405 if test "$need_default" = "yes"; then
406   # find an apxs, then the httpd
407   xs=
408   Peek(with,apxs,xs="$peekval")
409   Peek(with,apxs2,xs="$peekval")
410   Peek(with,apxs22,xs="$peekval")
411   if test "x$xs" = "x"; then
412      AC_PATH_PROGS(xs, apxs2 apxs,
413         AC_MSG_ERROR(No apxs, no apache found.  Try --with-apxs),
414         [/usr/local/apache2/bin:/usr/local/apache/bin:/usr/sbin:$PATH])
415   fi
416   # ask the daemon for the version and set parameters
417   AC_MSG_CHECKING(default apache version)
418   httpd="`$xs -q SBINDIR`/`$xs -q TARGET`"
419   if test "x$httpd" != "x" && test -f $httpd ; then
420      v=`$httpd -v|$SED -n -e 's/.*Apache\/\.*//p'`
421      case $v in
422        1.3*)   [enable_apache_13]=yes
423                [with_apxs]=$xs
424                AC_MSG_RESULT(1.3)
425                ;;
426        2.0*)   [enable_apache_20]=yes
427                [with_apxs2]=$xs
428                AC_MSG_RESULT(2.0)
429                ;;
430        2.2*)   [enable_apache_22]=yes
431                [with_apxs22]=$xs
432                AC_MSG_RESULT(2.2)
433                ;;
434        *)      AC_MSG_ERROR(unusable apache versions: $v. Try setting --with-apxs)
435      esac
436   else 
437      AC_MSG_RESULT(cannot determine version.  Try setting --with-apxs)
438   fi
439 fi
440
441 # Apache 1.3 (mod_shib_13)
442 #   --enable-apache-13
443 #   --with-apxs      (DSO build, the normal way, uses apxs to derive build flags)
444
445 AC_ARG_ENABLE(apache-13,
446         AC_HELP_STRING([--enable-apache-13], [enable the Apache 1.3 module]),
447         [ if test "x$enableval" = "x" ; then
448               WANT_APACHE_13=yes
449           else
450               WANT_APACHE_13="$enableval"
451           fi
452         ],[ WANT_APACHE_13=no ])
453 AC_MSG_CHECKING(whether to build Apache 1.3 module)
454 if test "$WANT_APACHE_13" != yes && test "$WANT_APACHE_13" != no ; then
455    WANT_APACHE_13=yes
456 fi
457 AC_MSG_RESULT($WANT_APACHE_13)
458
459 if test "$WANT_APACHE_13" = "yes" ; then
460     AC_ARG_WITH(apxs, 
461         AC_HELP_STRING([--with-apxs=FILE], [Specifies where to find the Apache 1.3 apxs script.]),
462         [
463         AC_MSG_CHECKING(for user-specified apxs name/location)
464         if test "$withval" != "no" ; then
465           if test "$withval" != "yes"; then
466             APXS=$withval
467             AC_MSG_RESULT("$withval")
468           fi
469         fi
470         ],
471         [
472         AC_PATH_PROG(APXS, apxs, no)
473         if test "$APXS" = "no" ; then
474           for i in /usr/sbin /usr/local/apache/bin ; do
475             if test "$APXS" = "no" && test -f "$i/apxs"; then
476               APXS="$i/apxs"
477             fi
478           done
479         fi
480         ])
481
482     AC_MSG_CHECKING([to see if apxs was located])
483     if test ! -f "$APXS" ; then
484         AC_MSG_RESULT(no)
485         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.])
486     fi
487     AC_MSG_RESULT($APXS)
488     AC_SUBST(APXS)
489
490     # extract settings we need from APXS -q
491     APXS_CC="`$APXS -q CC`"
492     APXS_CFLAGS="`$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
493     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
494 fi
495
496 AC_SUBST(APXS_CFLAGS)
497 AC_SUBST(APXS_INCLUDE)
498
499
500 # Apache 2.0 (mod_shib_20)
501 #   --enable-apache-20
502 #   --with-apxs2      (DSO build, the normal way, uses apxs to derive build flags)
503 #       --with-apr        (DSO build, APR development package installed separately)
504
505 AC_ARG_ENABLE(apache-20,
506         AC_HELP_STRING([--enable-apache-20], [enable the Apache 2.0 module]),
507         [ if test "x$enableval" = "x" ; then
508               WANT_APACHE_20=yes
509           else
510               WANT_APACHE_20="$enableval"
511           fi
512         ],[ WANT_APACHE_20=no ])
513 AC_MSG_CHECKING(whether to build Apache 2.0 module)
514 if test "$WANT_APACHE_20" != yes && test "$WANT_APACHE_20" != no ; then
515    WANT_APACHE_20=yes
516 fi
517 AC_MSG_RESULT($WANT_APACHE_20)
518
519 if test "$WANT_APACHE_20" = "yes" ; then
520     AC_ARG_WITH(apxs2, 
521         AC_HELP_STRING([--with-apxs2=FILE], [Specifies where to find the Apache 2.0 apxs script.]),
522         [
523         AC_MSG_CHECKING(for user-specified Apache2 apxs name/location)
524         if test "$withval" != "no" ; then
525           if test "$withval" != "yes"; then
526             APXS2=$withval
527             AC_MSG_RESULT("$withval")
528           fi
529         fi
530         ],
531         [
532         AC_PATH_PROG(APXS2, apxs2, no)
533         if test "$APXS2" = "no" ; then
534             AC_PATH_PROG(APXS2, apxs, no)
535         fi
536         if test "$APXS2" = "no" ; then
537           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
538             if test "$APXS2" = "no" && test -f "$i/apxs2" ; then
539               APXS2="$i/apxs2"
540             fi
541           done
542           if test "$APXS2" = "no" ; then
543             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
544               if test "$APXS2" = "no" && test -f "$i/apxs" ; then
545                 APXS2="$i/apxs"
546               fi
547             done
548           fi
549         fi
550         ])
551
552     AC_MSG_CHECKING([to see if Apache2 apxs was located])
553     if test ! -f "$APXS2" ; then
554         AC_MSG_RESULT(no)
555         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.])
556     fi
557     AC_MSG_RESULT($APXS2)
558     AC_SUBST(APXS2)
559
560     # APR settings
561     AC_ARG_WITH(apr, 
562         AC_HELP_STRING([--with-apr=PATH], [where apr-config is installed]),
563         [
564         AC_MSG_CHECKING(for user-specified apr-config name/location)
565         if test "$withval" != "no" ; then
566             if test "$withval" != "yes"; then
567                 APR_CONFIG=$withval
568                 AC_MSG_RESULT("$withval")
569             fi
570         fi
571         ],
572         [
573         AC_PATH_PROG(APR_CONFIG, apr-config,,[`$APXS2 -q SBINDIR`]:[$PATH])
574         ])
575         if test -f "${APR_CONFIG}"; then
576         APR_CFLAGS="`${APR_CONFIG} --cflags` `${APR_CONFIG} --cppflags` `${APR_CONFIG} --includes`"
577     else
578         AC_MSG_ERROR([Unable to locate apr-config, may need --with-apr option.])
579     fi
580
581     # extract settings we need from APXS2 -q
582     APXS2_CC="`$APXS2 -q CC`"
583     APXS2_CFLAGS="`$APXS2 -q CPPFLAGS` `$APXS2 -q CFLAGS` $APR_CFLAGS"
584     APXS2_INCLUDE="`$APXS2 -q INCLUDEDIR`"
585 fi
586
587 AC_SUBST(APXS2_CFLAGS)
588 AC_SUBST(APXS2_INCLUDE)
589
590
591 # Apache 2.2 (mod_shib_22)
592 #   --enable-apache-22
593 #   --with-apxs22     (DSO build, the normal way, uses apxs to derive build flags)
594 #       --with-apr1       (DSO build, APR development package installed separately)
595
596 AC_ARG_ENABLE(apache-22,
597         AC_HELP_STRING([--enable-apache-22], [enable the Apache 2.2 module]),
598         [ if test "x$enableval" = "x" ; then
599               WANT_APACHE_22=yes
600           else
601               WANT_APACHE_22="$enableval"
602           fi
603         ],[ WANT_APACHE_22=no ])
604 AC_MSG_CHECKING(whether to build Apache 2.2 module)
605 if test "$WANT_APACHE_22" != yes && test "$WANT_APACHE_22" != no ; then
606    WANT_APACHE_22=yes
607 fi
608 AC_MSG_RESULT($WANT_APACHE_22)
609
610 if test "$WANT_APACHE_22" = "yes" ; then
611     AC_ARG_WITH(apxs22, 
612         AC_HELP_STRING([--with-apxs22=FILE], [Specifies where to find the Apache 2.2 apxs script.]),
613         [
614         AC_MSG_CHECKING(for user-specified Apache2.2 apxs name/location)
615         if test "$withval" != "no" ; then
616           if test "$withval" != "yes"; then
617             APXS22=$withval
618             AC_MSG_RESULT("$withval")
619           fi
620         fi
621         ],
622         [
623         AC_PATH_PROG(APXS22, apxs2, no)
624         if test "$APXS22" = "no" ; then
625             AC_PATH_PROG(APXS22, apxs, no)
626         fi
627         if test "$APXS22" = "no" ; then
628           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
629             if test "$APXS22" = "no" && test -f "$i/apxs2" ; then
630               APXS22="$i/apxs2"
631             fi
632           done
633           if test "$APXS22" = "no" ; then
634             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
635               if test "$APXS22" = "no" && test -f "$i/apxs" ; then
636                 APXS22="$i/apxs"
637               fi
638             done
639           fi
640         fi
641         ])
642
643     AC_MSG_CHECKING([to see if Apache2.2 apxs was located])
644     if test ! -f "$APXS22" ; then
645         AC_MSG_RESULT(no)
646         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.])
647     fi
648     AC_MSG_RESULT($APXS22)
649     AC_SUBST(APXS22)
650
651     # APR1 settings
652     AC_ARG_WITH(apr1, 
653         AC_HELP_STRING([--with-apr1=PATH], [where apr-1-config is installed]),
654         [
655         AC_MSG_CHECKING(for user-specified apr-1-config name/location)
656         if test "$withval" != "no" ; then
657             if test "$withval" != "yes"; then
658                 APR1_CONFIG=$withval
659                 AC_MSG_RESULT("$withval")
660             fi
661         fi
662         ],
663         [
664         AC_PATH_PROG(APR1_CONFIG, apr-1-config,,[`$APXS22 -q SBINDIR`]:[$PATH])
665         ])
666         if test -f "${APR1_CONFIG}"; then
667         APR1_CFLAGS="`${APR1_CONFIG} --cflags` `${APR1_CONFIG} --cppflags` `${APR1_CONFIG} --includes`"
668     else
669         AC_MSG_ERROR([Unable to locate apr-1-config, may need --with-apr1 option.])
670     fi
671
672     # extract settings we need from APXS22 -q
673     APXS22_CC="`$APXS22 -q CC`"
674     APXS22_CFLAGS="`$APXS22 -q CPPFLAGS` `$APXS22 -q CFLAGS` $APR1_CFLAGS"
675     APXS22_INCLUDE="`$APXS22 -q INCLUDEDIR`"
676 fi
677
678 AC_SUBST(APXS22_CFLAGS)
679 AC_SUBST(APXS22_INCLUDE)
680
681 # always output the Makefile, even if you don't use it
682 AC_CONFIG_FILES([apache/Makefile])
683 AM_CONDITIONAL(BUILD_AP13,test "$WANT_APACHE_13" = "yes")
684 AM_CONDITIONAL(BUILD_AP20,test "$WANT_APACHE_20" = "yes")
685 AM_CONDITIONAL(BUILD_AP22,test "$WANT_APACHE_22" = "yes")
686
687 # add the apache module to the list of wanted subdirs..
688 if test "$WANT_APACHE_13" = "yes" || test "$WANT_APACHE_20" = "yes" || test "$WANT_APACHE_22" = "yes" ; then
689     WANT_SUBDIRS="$WANT_SUBDIRS apache"
690 fi
691
692
693 #
694 # Implement the checks of the ODBC Storage Service
695 #
696 # 1) Assume the user wants ODBC; if it's not found then just continue without
697 # 2) If the user specifically requested odbc, look for it and ERROR if not found
698 # 3) If the user specifically requested no odbc, don't build it.
699 #
700
701 AC_CONFIG_FILES([odbc-store/Makefile])
702
703 # determine whether we should enable the odbc ccache
704 AC_ARG_ENABLE([odbc],
705         AC_HELP_STRING([--disable-odbc], [disable the ODBC Storage Service]),
706         [odbc_enabled=$enableval], [odbc_enabled=default])
707
708 if test "x$odbc_enabled" = "x" ; then
709    odbc_enabled=yes
710 fi
711
712 # Are we trying to build ODBC?
713 AC_MSG_CHECKING(whether to build the ODBC storage service)
714 if test "$odbc_enabled" = "yes" ; then
715    build_odbc=yes
716    AC_MSG_RESULT(yes)
717 elif test "$odbc_enabled" = "default" ; then
718    build_odbc=yes
719    AC_MSG_RESULT([yes, if it can be found])
720 else
721    build_odbc=no
722    AC_MSG_RESULT(no)
723 fi
724
725 # If we're trying to build ODBC, try to find the odbc_config program.
726 if test "$build_odbc" = "yes" ; then
727    odbc_dir=""
728    AC_ARG_WITH(odbc,
729         AC_HELP_STRING([--with-odbc=PATH], [directory where odbc is installed]),
730             [if test "$with_odbc" = no ; then
731                AC_MSG_ERROR([Try running --disable-odbc instead.])
732              elif test "$with_odbc" != yes ; then
733                odbc_dir="$with_odbc/bin"
734                if test "$with_odbc" != /usr ; then
735                  ODBC_CFLAGS="-I$with_odbc/include"
736                  ODBC_LIBS="-L$with_odbc/lib"
737                fi
738              fi ])
739
740    AC_PATH_PROG(ODBC_CONFIG, odbc_config, no, $odbc_dir $PATH )
741    if test "$ODBC_CONFIG" = no ; then
742       AC_MSG_WARN(Cannot find odbc_config, will try to guess settings.)
743       ODBC_LIBS="$ODBC_LIBS -lodbc"
744    else
745       ODBC_CFLAGS=`$ODBC_CONFIG --cflags`
746       ODBC_LIBS=`$ODBC_CONFIG --libs`
747    fi
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-store"
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.0 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 if test -n "$APXS22_CC" && test "$APXS22_CC" != "$CC" ; then
819   echo "=================================================================="
820   echo "WARNING: You have chosen to compile Apache-2.2 modules with a different"
821   echo "         compiler than the one used to compile Apache."
822   echo ""
823   echo "    Current compiler:      $CC"
824   echo "   Apache's compiler:      $APXS22_CC"
825   echo ""
826   echo "This could cause problems."
827   echo "=================================================================="
828 fi
829
830 LIBTOOL="$LIBTOOL --silent"
831
832 AC_OUTPUT
833