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