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