Accidental semicolons.
[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 else
188     if test -f $with_xerces/share/xml/xmltooling/catalog.xml ; then
189         XMLTOOLINGXMLDIR="$with_xerces"
190     else
191         if test -f $with_log4shib/share/xml/xmltooling/catalog.xml ; then
192             XMLTOOLINGXMLDIR="$with_log4shib"
193         fi
194     fi
195 fi
196 if test "x$XMLTOOLINGXMLDIR" = "x" ; then
197     AC_MSG_ERROR([xmltooling XML catalog not found, may need to use --with-xmltooling option])
198 fi
199 XMLTOOLINGXMLDIR="$XMLTOOLINGXMLDIR/share/xml/xmltooling"
200 AC_SUBST(XMLTOOLINGXMLDIR)
201
202 # XML-Security settings
203 AC_ARG_WITH(xmlsec,
204             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
205             [with_xmlsec=/usr])
206
207 if test x_$with_xmlsec != x_/usr; then
208     LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
209     CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
210 fi        
211 XMLSEC_LIBS="-lxml-security-c $XMLSEC_LIBS"
212
213 # save and append master libs
214 save_LIBS="$LIBS"
215 LIBS="$XMLSEC_LIBS $LIBS"
216
217 AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
218 AC_MSG_CHECKING([XML-Security version])
219 AC_PREPROC_IFELSE(
220     [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
221     [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3)
222 int i = 0;
223 #else
224 #error need version 1.4.0 or later
225 #endif])],
226     [AC_MSG_RESULT(OK)],
227     [AC_MSG_FAILURE([XML-Security version 1.4.0 or greater is required.])])
228 AC_TRY_LINK(
229         [#include <xsec/utils/XSECPlatformUtils.hpp>],
230         [XSECPlatformUtils::Initialise()],,
231         [AC_MSG_ERROR([unable to link with XML-Security])])
232
233 # restore master libs
234 LIBS="$save_LIBS"
235
236 # OpenSAML settings
237 AC_ARG_WITH(saml,
238     AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
239     [if test x_$with_saml != x_/usr; then
240         LDFLAGS="-L${with_saml}/lib $LDFLAGS"
241         CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
242     fi])
243 XMLSEC_LIBS="-lsaml $XMLSEC_LIBS"
244
245 # save and append master libs
246 save_LIBS="$LIBS"
247 LIBS="$XMLSEC_LIBS $LIBS"
248
249 AC_CHECK_HEADER([saml/saml2/metadata/Metadata.h],,
250                 AC_MSG_ERROR([unable to find OpenSAML header files]))
251 AC_TRY_LINK(
252         [#include <saml/SAMLConfig.h>
253 #include <saml/version.h>],
254         [#if _OPENSAML_VERSION >= 20000
255 opensaml::SAMLConfig::getConfig();
256 #else
257 #error Need OpenSAML version 2.0 or higher
258 #endif],
259         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
260         [AC_MSG_ERROR([unable to link with OpenSAML, or version was too old])])
261
262 # restore master libs
263 LIBS="$save_LIBS"
264
265 # Establish location of opensaml catalogs.
266 OPENSAMLXMLDIR=""
267 if test "x$with_saml" = "x" ; then
268     with_saml="/usr"
269 fi
270 if test -f $with_saml/share/xml/opensaml/saml20-catalog.xml ; then
271     OPENSAMLXMLDIR="$with_saml"
272 else
273     if test -f $with_xmltooling/share/xml/opensaml/saml20-catalog.xml ; then
274         OPENSAMLXMLDIR="$with_xmltooling"
275     else
276         if test -f $with_xerces/share/xml/opensaml/saml20-catalog.xml ; then
277             OPENSAMLXMLDIR="$with_xerces"
278         else
279             if test -f $with_log4shib/share/xml/opensaml/saml20-catalog.xml ; then
280                 OPENSAMLXMLDIR="$with_log4shib"
281             fi
282         fi
283     fi
284 fi
285 if test "x$OPENSAMLXMLDIR" = "x" ; then
286     AC_MSG_ERROR([opensaml XML catalogs not found, may need to use --with-saml option])
287 fi
288 OPENSAMLXMLDIR="$OPENSAMLXMLDIR/share/xml/opensaml"
289 AC_SUBST(OPENSAMLXMLDIR)
290
291 AC_SUBST(LITE_LIBS)
292 AC_SUBST(XMLSEC_LIBS)
293
294 # output the underlying makefiles
295 WANT_SUBDIRS="doc schemas configs shibsp shibd util"
296 AC_CONFIG_FILES([Makefile doc/Makefile schemas/Makefile \
297         configs/Makefile shibsp/Makefile shibd/Makefile \
298         util/Makefile selinux/Makefile])
299
300 ## ADFS?
301 AC_CONFIG_FILES([adfs/Makefile])
302 AC_ARG_ENABLE([adfs],
303         AC_HELP_STRING([--disable-adfs], [don't build the ADFS module]),
304         [adfs_enabled=$enableval], [adfs_enabled=yes])
305 if test "x$adfs_enabled" = "x" ; then
306    adfs_enabled=yes
307 fi
308 AC_MSG_CHECKING(whether to build the ADFS module)
309 if test "$adfs_enabled" = "no" ; then
310    AC_MSG_RESULT(no)
311 else
312    AC_MSG_RESULT(yes)
313    WANT_SUBDIRS="$WANT_SUBDIRS adfs"
314 fi
315
316
317 #
318 # Build NSAPI module?
319 #
320 AC_MSG_CHECKING(for NSAPI module option)
321 AC_ARG_WITH(nsapi,
322         AC_HELP_STRING([--with-nsapi=DIR], [Build NSAPI module for Netscape/iPlanet/SunONE]),
323         [WANT_NSAPI=$withval],[WANT_NSAPI=no])
324 AC_MSG_RESULT($WANT_NSAPI)
325
326 if test "$WANT_NSAPI" != "no"; then
327   if test ! -d $WANT_NSAPI/bin ; then
328     AC_MSG_ERROR(Please specify the path to the root of your Netscape/iPlanet/SunONE server using --with-nsapi=DIR)
329   fi
330   AC_MSG_CHECKING(for NSAPI include files)
331   if test -d $WANT_NSAPI/include ; then
332     NSAPI_INCLUDE=$WANT_NSAPI/include
333     AC_MSG_RESULT(Netscape-Enterprise 3.x style)
334     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
335     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
336   fi
337   if test -d $WANT_NSAPI/plugins/include ; then
338     test -n "$NSAPI_INCLUDE" && NSAPI_INC_DIR="-I$NSAPI_INCLUDE"
339     NSAPI_INCLUDE="$WANT_NSAPI/plugins/include"
340     AC_MSG_RESULT(iPlanet 4.x / SunONE 6.x style)
341     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h])
342     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
343   fi
344   if test "$NSAPI_INCLUDE" = ""; then
345     AC_MSG_ERROR(Please check you have nsapi.h in either $WANT_NSAPI/include or $WANT_NSAPI/plugins/include)
346   fi
347 fi
348
349 AC_SUBST(NSAPI_INCLUDE)
350
351 # always output the Makefile, even if you don't use it
352 AC_CONFIG_FILES([nsapi_shib/Makefile])
353 AM_CONDITIONAL(BUILD_NSAPI,test ! "$WANT_NSAPI" = "no")
354
355 # add the NSAPI module to the list of wanted subdirs..
356 if test ! "$WANT_NSAPI" = "no" ; then
357     WANT_SUBDIRS="$WANT_SUBDIRS nsapi_shib"
358 fi
359
360
361 #
362 # Build FastCGI support?
363 #
364 AC_MSG_CHECKING(for FastCGI support)
365 AC_ARG_WITH(fastcgi,
366     AC_HELP_STRING([--with-fastcgi=DIR], [Build FastCGI support]),
367     [WANT_FASTCGI=$withval],[WANT_FASTCGI=no])
368 AC_MSG_RESULT($WANT_FASTCGI)
369
370 if test "$WANT_FASTCGI" != "no"; then
371     if test "$WANT_FASTCGI" != "yes"; then
372         if test x_$WANT_FASTCGI != x_/usr; then
373             FASTCGI_INCLUDE="-I$WANT_FASTCGI/include"
374             FASTCGI_LDFLAGS="-L$WANT_FASTCGI/lib"
375         fi
376     fi
377     AC_CHECK_HEADER([fcgio.h],,
378         AC_MSG_ERROR([unable to find FastCGI header files]))
379     FASTCGI_LIBS="-lfcgi -lfcgi++"
380 fi
381
382 AC_SUBST(FASTCGI_INCLUDE)
383 AC_SUBST(FASTCGI_LDFLAGS)
384 AC_SUBST(FASTCGI_LIBS)
385
386 # always output the Makefile, even if you don't use it
387 AC_CONFIG_FILES([fastcgi/Makefile])
388 AM_CONDITIONAL(BUILD_FASTCGI,test ! "$WANT_FASTCGI" = "no")
389
390 if test ! "$WANT_FASTCGI" = "no" ; then
391     WANT_SUBDIRS="$WANT_SUBDIRS fastcgi"
392 fi
393
394
395 #
396 # If no --enable-apache-xx specified 
397 # find a default and fake the specific parameters
398 #
399
400 # simple macro to peek at an enable or a with
401 AC_DEFUN([Peek],
402 if test "[${[$1]_][$2]+set}" = set; then
403   peekval="${[$1]_[$2]}"
404   $3
405 fi; dnl
406 )
407
408 AC_MSG_CHECKING(if default apache needed)
409 need_default=yes
410 Peek(enable,apache_13,need_default=no)
411 Peek(enable,apache_20,need_default=no)
412 Peek(enable,apache_22,need_default=no)
413 AC_MSG_RESULT($need_default)
414
415 if test "$need_default" = "yes"; then
416   # find an apxs, then the httpd
417   xs=
418   Peek(with,apxs,xs="$peekval")
419   Peek(with,apxs2,xs="$peekval")
420   Peek(with,apxs22,xs="$peekval")
421   if test "x$xs" = "x"; then
422      AC_PATH_PROGS(xs, apxs2 apxs,
423         AC_MSG_ERROR(No apxs, no apache found.  Try --with-apxs),
424         [/usr/local/apache2/bin:/usr/local/apache/bin:/usr/sbin:$PATH])
425   fi
426   # ask the daemon for the version and set parameters
427   AC_MSG_CHECKING(default apache version)
428   httpd="`$xs -q SBINDIR`/`$xs -q TARGET`"
429   if test "x$httpd" != "x" && test -f $httpd ; then
430      v=`$httpd -v|$SED -n -e 's/.*Apache\/\.*//p'`
431      case $v in
432        1.3*)   [enable_apache_13]=yes
433                [with_apxs]=$xs
434                AC_MSG_RESULT(1.3)
435                ;;
436        2.0*)   [enable_apache_20]=yes
437                [with_apxs2]=$xs
438                AC_MSG_RESULT(2.0)
439                ;;
440        2.2*)   [enable_apache_22]=yes
441                [with_apxs22]=$xs
442                AC_MSG_RESULT(2.2)
443                ;;
444        *)      AC_MSG_ERROR(unusable apache versions: $v. Try setting --with-apxs)
445      esac
446   else 
447      AC_MSG_RESULT(cannot determine version.  Try setting --with-apxs)
448   fi
449 fi
450
451 # Apache 1.3 (mod_shib_13)
452 #   --enable-apache-13
453 #   --with-apxs      (DSO build, the normal way, uses apxs to derive build flags)
454
455 AC_ARG_ENABLE(apache-13,
456         AC_HELP_STRING([--enable-apache-13], [enable the Apache 1.3 module]),
457         [ if test "x$enableval" = "x" ; then
458               WANT_APACHE_13=yes
459           else
460               WANT_APACHE_13="$enableval"
461           fi
462         ],[ WANT_APACHE_13=no ])
463 AC_MSG_CHECKING(whether to build Apache 1.3 module)
464 if test "$WANT_APACHE_13" != yes && test "$WANT_APACHE_13" != no ; then
465    WANT_APACHE_13=yes
466 fi
467 AC_MSG_RESULT($WANT_APACHE_13)
468
469 if test "$WANT_APACHE_13" = "yes" ; then
470     AC_ARG_WITH(apxs, 
471         AC_HELP_STRING([--with-apxs=FILE], [Specifies where to find the Apache 1.3 apxs script.]),
472         [
473         AC_MSG_CHECKING(for user-specified apxs name/location)
474         if test "$withval" != "no" ; then
475           if test "$withval" != "yes"; then
476             APXS=$withval
477             AC_MSG_RESULT("$withval")
478           fi
479         fi
480         ],
481         [
482         AC_PATH_PROG(APXS, apxs, no)
483         if test "$APXS" = "no" ; then
484           for i in /usr/sbin /usr/local/apache/bin ; do
485             if test "$APXS" = "no" && test -f "$i/apxs"; then
486               APXS="$i/apxs"
487             fi
488           done
489         fi
490         ])
491
492     AC_MSG_CHECKING([to see if apxs was located])
493     if test ! -f "$APXS" ; then
494         AC_MSG_RESULT(no)
495         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.])
496     fi
497     AC_MSG_RESULT($APXS)
498     AC_SUBST(APXS)
499
500     # extract settings we need from APXS -q
501     APXS_CC="`$APXS -q CC`"
502     APXS_CFLAGS="`$APXS -q CPPFLAGS` `$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
503     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
504 fi
505
506 AC_SUBST(APXS_CFLAGS)
507 AC_SUBST(APXS_INCLUDE)
508
509
510 # Apache 2.0 (mod_shib_20)
511 #   --enable-apache-20
512 #   --with-apxs2      (DSO build, the normal way, uses apxs to derive build flags)
513 #       --with-apr        (DSO build, APR development package installed separately)
514
515 AC_ARG_ENABLE(apache-20,
516         AC_HELP_STRING([--enable-apache-20], [enable the Apache 2.0 module]),
517         [ if test "x$enableval" = "x" ; then
518               WANT_APACHE_20=yes
519           else
520               WANT_APACHE_20="$enableval"
521           fi
522         ],[ WANT_APACHE_20=no ])
523 AC_MSG_CHECKING(whether to build Apache 2.0 module)
524 if test "$WANT_APACHE_20" != yes && test "$WANT_APACHE_20" != no ; then
525    WANT_APACHE_20=yes
526 fi
527 AC_MSG_RESULT($WANT_APACHE_20)
528
529 if test "$WANT_APACHE_20" = "yes" ; then
530     AC_ARG_WITH(apxs2, 
531         AC_HELP_STRING([--with-apxs2=FILE], [Specifies where to find the Apache 2.0 apxs script.]),
532         [
533         AC_MSG_CHECKING(for user-specified Apache2 apxs name/location)
534         if test "$withval" != "no" ; then
535           if test "$withval" != "yes"; then
536             APXS2=$withval
537             AC_MSG_RESULT("$withval")
538           fi
539         fi
540         ],
541         [
542         AC_PATH_PROG(APXS2, apxs2, no)
543         if test "$APXS2" = "no" ; then
544             AC_PATH_PROG(APXS2, apxs, no)
545         fi
546         if test "$APXS2" = "no" ; then
547           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
548             if test "$APXS2" = "no" && test -f "$i/apxs2" ; then
549               APXS2="$i/apxs2"
550             fi
551           done
552           if test "$APXS2" = "no" ; then
553             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
554               if test "$APXS2" = "no" && test -f "$i/apxs" ; then
555                 APXS2="$i/apxs"
556               fi
557             done
558           fi
559         fi
560         ])
561
562     AC_MSG_CHECKING([to see if Apache2 apxs was located])
563     if test ! -f "$APXS2" ; then
564         AC_MSG_RESULT(no)
565         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.])
566     fi
567     AC_MSG_RESULT($APXS2)
568     AC_SUBST(APXS2)
569
570     # APR settings
571     AC_ARG_WITH(apr, 
572         AC_HELP_STRING([--with-apr=PATH], [where apr-config is installed]),
573         [
574         AC_MSG_CHECKING(for user-specified apr-config name/location)
575         if test "$withval" != "no" ; then
576             if test "$withval" != "yes"; then
577                 APR_CONFIG=$withval
578                 AC_MSG_RESULT("$withval")
579             fi
580         fi
581         ],
582         [
583         AC_PATH_PROG(APR_CONFIG, apr-config)
584         ])
585         if test -f "${APR_CONFIG}"; then
586         APR_CFLAGS="`${APR_CONFIG} --cflags` `${APR_CONFIG} --cppflags` `${APR_CONFIG} --includes`"
587     else
588         AC_MSG_ERROR([Unable to locate apr-config, may need --with-apr option.])
589     fi
590
591     # extract settings we need from APXS2 -q
592     APXS2_CC="`$APXS2 -q CC`"
593     APXS2_CFLAGS="`$APXS2 -q CPPFLAGS` `$APXS2 -q CFLAGS` `$APXS2 -q CFLAGS_SHLIB` $APR_CFLAGS"
594     APXS2_INCLUDE="`$APXS2 -q INCLUDEDIR`"
595 fi
596
597 AC_SUBST(APXS2_CFLAGS)
598 AC_SUBST(APXS2_INCLUDE)
599
600
601 # Apache 2.2 (mod_shib_22)
602 #   --enable-apache-22
603 #   --with-apxs22     (DSO build, the normal way, uses apxs to derive build flags)
604 #       --with-apr1       (DSO build, APR development package installed separately)
605
606 AC_ARG_ENABLE(apache-22,
607         AC_HELP_STRING([--enable-apache-22], [enable the Apache 2.2 module]),
608         [ if test "x$enableval" = "x" ; then
609               WANT_APACHE_22=yes
610           else
611               WANT_APACHE_22="$enableval"
612           fi
613         ],[ WANT_APACHE_22=no ])
614 AC_MSG_CHECKING(whether to build Apache 2.2 module)
615 if test "$WANT_APACHE_22" != yes && test "$WANT_APACHE_22" != no ; then
616    WANT_APACHE_22=yes
617 fi
618 AC_MSG_RESULT($WANT_APACHE_22)
619
620 if test "$WANT_APACHE_22" = "yes" ; then
621     AC_ARG_WITH(apxs22, 
622         AC_HELP_STRING([--with-apxs22=FILE], [Specifies where to find the Apache 2.2 apxs script.]),
623         [
624         AC_MSG_CHECKING(for user-specified Apache2.2 apxs name/location)
625         if test "$withval" != "no" ; then
626           if test "$withval" != "yes"; then
627             APXS22=$withval
628             AC_MSG_RESULT("$withval")
629           fi
630         fi
631         ],
632         [
633         AC_PATH_PROG(APXS22, apxs2, no)
634         if test "$APXS22" = "no" ; then
635             AC_PATH_PROG(APXS22, apxs, no)
636         fi
637         if test "$APXS22" = "no" ; then
638           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
639             if test "$APXS22" = "no" && test -f "$i/apxs2" ; then
640               APXS22="$i/apxs2"
641             fi
642           done
643           if test "$APXS22" = "no" ; then
644             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
645               if test "$APXS22" = "no" && test -f "$i/apxs" ; then
646                 APXS22="$i/apxs"
647               fi
648             done
649           fi
650         fi
651         ])
652
653     AC_MSG_CHECKING([to see if Apache2.2 apxs was located])
654     if test ! -f "$APXS22" ; then
655         AC_MSG_RESULT(no)
656         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.])
657     fi
658     AC_MSG_RESULT($APXS22)
659     AC_SUBST(APXS22)
660
661     # APR1 settings
662     AC_ARG_WITH(apr1, 
663         AC_HELP_STRING([--with-apr1=PATH], [where apr-1-config is installed]),
664         [
665         AC_MSG_CHECKING(for user-specified apr-1-config name/location)
666         if test "$withval" != "no" ; then
667             if test "$withval" != "yes"; then
668                 APR1_CONFIG=$withval
669                 AC_MSG_RESULT("$withval")
670             fi
671         fi
672         ],
673         [
674         AC_PATH_PROG(APR1_CONFIG, apr-1-config)
675         ])
676         if test -f "${APR1_CONFIG}"; then
677         APR1_CFLAGS="`${APR1_CONFIG} --cflags` `${APR1_CONFIG} --cppflags` `${APR1_CONFIG} --includes`"
678     else
679         AC_MSG_ERROR([Unable to locate apr-1-config, may need --with-apr1 option.])
680     fi
681
682     # extract settings we need from APXS22 -q
683     APXS22_CC="`$APXS22 -q CC`"
684     APXS22_CFLAGS="`$APXS22 -q CPPFLAGS` `$APXS22 -q CFLAGS` `$APXS22 -q CFLAGS_SHLIB` $APR1_CFLAGS"
685     APXS22_INCLUDE="`$APXS22 -q INCLUDEDIR`"
686 fi
687
688 AC_SUBST(APXS22_CFLAGS)
689 AC_SUBST(APXS22_INCLUDE)
690
691 # always output the Makefile, even if you don't use it
692 AC_CONFIG_FILES([apache/Makefile])
693 AM_CONDITIONAL(BUILD_AP13,test "$WANT_APACHE_13" = "yes")
694 AM_CONDITIONAL(BUILD_AP20,test "$WANT_APACHE_20" = "yes")
695 AM_CONDITIONAL(BUILD_AP22,test "$WANT_APACHE_22" = "yes")
696
697 # add the apache module to the list of wanted subdirs..
698 if test "$WANT_APACHE_13" = "yes" || test "$WANT_APACHE_20" = "yes" || test "$WANT_APACHE_22" = "yes" ; then
699     WANT_SUBDIRS="$WANT_SUBDIRS apache"
700 fi
701
702
703 #
704 # Implement the checks of the ODBC Storage Service
705 #
706 # 1) Assume the user wants ODBC; if it's not found then just continue without
707 # 2) If the user specifically requested odbc, look for it and ERROR if not found
708 # 3) If the user specifically requested no odbc, don't build it.
709 #
710
711 AC_CONFIG_FILES([odbc-store/Makefile])
712
713 # determine whether we should enable the odbc ccache
714 AC_ARG_ENABLE([odbc],
715         AC_HELP_STRING([--disable-odbc], [disable the ODBC Storage Service]),
716         [odbc_enabled=$enableval], [odbc_enabled=default])
717
718 if test "x$odbc_enabled" = "x" ; then
719    odbc_enabled=yes
720 fi
721
722 # Are we trying to build ODBC?
723 AC_MSG_CHECKING(whether to build the ODBC storage service)
724 if test "$odbc_enabled" = "yes" ; then
725    build_odbc=yes
726    AC_MSG_RESULT(yes)
727 elif test "$odbc_enabled" = "default" ; then
728    build_odbc=yes
729    AC_MSG_RESULT([yes, if it can be found])
730 else
731    build_odbc=no
732    AC_MSG_RESULT(no)
733 fi
734
735 # If we're trying to build ODBC, try to find the odbc_config program.
736 if test "$build_odbc" = "yes" ; then
737    odbc_dir=""
738    AC_ARG_WITH(odbc,
739         AC_HELP_STRING([--with-odbc=PATH], [directory where odbc is installed]),
740             [if test "$with_odbc" = no ; then
741                AC_MSG_ERROR([Try running --disable-odbc instead.])
742              elif test "$with_odbc" != yes ; then
743                odbc_dir="$with_odbc/bin"
744              fi ])
745
746    AC_PATH_PROG(ODBC_CONFIG, odbc_config, no, $odbc_dir $PATH )
747
748    if test "$ODBC_CONFIG" = no ; then
749       if test "$odbc_enabled" = "yes" ; then
750         AC_MSG_ERROR(Cannot find odbc_config)
751       else
752         AC_MSG_WARN(ODBC not found, skipping.)
753       fi
754    fi
755 fi
756
757 if test "$build_odbc" = yes ; then
758    ODBC_CFLAGS=`$ODBC_CONFIG --cflags`
759    ODBC_CFLAGS=`eval echo $ODBC_CFLAGS`
760    ODBC_LIBS=`$ODBC_CONFIG --libs`
761    ODBC_LIBS=`eval echo $ODBC_LIBS`
762
763    save_CPPFLAGS="$CPPFLAGS"
764    CPPFLAGS="$CPPFLAGS $ODBC_CFLAGS"
765
766    AC_CHECK_HEADER([sql.h], [have_sql_h=yes], [have_sql_h=no])
767    if test "$have_sql_h" = no -a "$odbc_enabled" = "yes" ; then
768      AC_MSG_ERROR(unable to find ODBC header files)
769    fi
770
771    if test "$have_sql_h" = yes ; then
772       save_LIBS="$LIBS"
773       LIBS="$LIBS $ODBC_LIBS"
774       AC_MSG_CHECKING(if we can link againt ODBC)
775       AC_TRY_LINK(
776         [#include <sql.h>
777          #include <sqlext.h>
778          #include <stdio.h>],
779         [SQLSetEnvAttr(SQL_NULL_HANDLE, SQL_ATTR_CONNECTION_POOLING, (void*)SQL_CP_ONE_PER_HENV, 0)],
780         [have_odbc_libs=yes],
781         [have_odbc_libs=no])
782       LIBS="$save_LIBS"
783
784       if test "$have_odbc_libs" = no ; then
785          if test "$odbc_enabled" = "yes" ; then
786             AC_MSG_ERROR([unable to link with ODBC Library])
787          else
788             AC_MSG_RESULT(no, skipping ODBC)
789          fi
790       fi
791    fi
792
793    CPPFLAGS="$save_CPPFLAGS"
794 fi
795
796 # if have_odbc_libs=yes then go ahead with building ODBC
797 if test "$have_odbc_libs" = yes ; then
798    # this AC_MSG_RESULT is from above!
799    AC_MSG_RESULT(yes)
800    WANT_SUBDIRS="$WANT_SUBDIRS odbc-store"
801    AC_SUBST(ODBC_CFLAGS)
802    AC_SUBST(ODBC_LIBS)
803 fi
804
805
806 AC_SUBST(WANT_SUBDIRS)
807
808 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
809   echo "=================================================================="
810   echo "WARNING: You have chosen to compile Apache-1.3 modules with a different"
811   echo "         compiler than the one used to compile Apache."
812   echo ""
813   echo "    Current compiler:      $CC"
814   echo "   Apache's compiler:      $APXS_CC"
815   echo ""
816   echo "This could cause problems."
817   echo "=================================================================="
818 fi
819
820 if test -n "$APXS2_CC" && test "$APXS2_CC" != "$CC" ; then
821   echo "=================================================================="
822   echo "WARNING: You have chosen to compile Apache-2.0 modules with a different"
823   echo "         compiler than the one used to compile Apache."
824   echo ""
825   echo "    Current compiler:      $CC"
826   echo "   Apache's compiler:      $APXS2_CC"
827   echo ""
828   echo "This could cause problems."
829   echo "=================================================================="
830 fi
831
832 if test -n "$APXS22_CC" && test "$APXS22_CC" != "$CC" ; then
833   echo "=================================================================="
834   echo "WARNING: You have chosen to compile Apache-2.2 modules with a different"
835   echo "         compiler than the one used to compile Apache."
836   echo ""
837   echo "    Current compiler:      $CC"
838   echo "   Apache's compiler:      $APXS22_CC"
839   echo ""
840   echo "This could cause problems."
841   echo "=================================================================="
842 fi
843
844 LIBTOOL="$LIBTOOL --silent"
845
846 AC_OUTPUT
847