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