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