Bump version, version schema directories.
[shibboleth/cpp-sp.git] / configure.ac
1 AC_PREREQ([2.50])
2 AC_INIT([shibboleth], [2.4], [shibboleth-users@internet2.edu], [shibboleth])
3 AM_CONFIG_HEADER(config.h)
4 AM_INIT_AUTOMAKE([shibboleth],[2.4])
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                 *osf*)
57                         CXXFLAGS="$CXXFLAGS -D_POSIX_PII_SOCKET"
58                         ;;
59         esac
60 fi
61
62 AC_DISABLE_STATIC
63 AC_PROG_LIBTOOL
64 AC_PATH_PROG(PKG_CONFIG, pkg-config)
65
66 AC_LANG(C)
67
68 # Checks for typedefs, structures, and compiler characteristics.
69 AC_C_CONST
70 AC_TYPE_SIZE_T
71 AC_STRUCT_TM
72
73 # Checks for library functions.
74 AC_FUNC_STRFTIME
75 AC_FUNC_STRERROR_R
76 AC_CHECK_FUNCS([strchr strdup strstr timegm gmtime_r strtok_r strcasecmp])
77
78 # checks for pthreads
79 ACX_PTHREAD([enable_threads="pthread"],[enable_threads="no"])
80 if test $enable_threads != "pthread"; then
81     AC_MSG_ERROR([unable to find pthreads, currently this is required])
82 else
83     AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
84     LIBS="$PTHREAD_LIBS $LIBS"
85     CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
86     CXXFLAGS="$PTHREAD_CFLAGS $CXXFLAGS"
87 fi
88
89 # OpenSSL settings
90 AC_ARG_WITH(openssl,
91     AC_HELP_STRING([--with-openssl=PATH], [where openssl is installed]),
92     [if test x_$with_openssl != x_/usr; then
93         SSLFLAGS="-I${with_openssl}/include"
94     fi])
95
96 if test "x$SSLFLAGS" = "x" ; then
97     if test "x$PKG_CONFIG" != x && test "x$PKG_CONFIG" != "xno" ; then
98         if pkg-config openssl ; then
99             SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
100         else
101             AC_MSG_WARN([OpenSSL not supported by pkg-config, try --with-openssl instead])
102         fi
103     fi
104 fi
105
106 AC_MSG_CHECKING(for OpenSSL cflags)
107 AC_MSG_RESULT($SSLFLAGS)
108 CPPFLAGS="$SSLFLAGS $CPPFLAGS"
109
110 AC_CHECK_HEADER([openssl/x509.h],,
111                 AC_MSG_ERROR([unable to find openssl header files]))
112
113 AC_LANG(C++)
114
115 # C++ requirements
116 AC_CXX_REQUIRE_STL
117 AC_CXX_NAMESPACES
118
119 # Thank you Solaris, really.
120 AC_MSG_CHECKING(for ctime_r)
121  if test -z "$ac_cv_ctime_args"; then
122      AC_TRY_COMPILE(
123      [#include <time.h>],
124      [
125          time_t clock;
126          char buf[26];
127          ctime_r(&clock, buf);
128      ], ac_cv_ctime_args=2)
129
130      AC_TRY_COMPILE(
131      [#include <time.h>],
132      [
133          time_t clock;
134          char buf[26];
135          ctime_r(&clock, buf, 26);
136      ], ac_cv_ctime_args=3)
137  fi
138  if test -z "$ac_cv_ctime_args"; then
139      AC_MSG_RESULT(no)
140  else
141      if test "$ac_cv_ctime_args" = 2; then
142          AC_DEFINE(HAVE_CTIME_R_2,1,[Define if ctime_r is present with 2 parameters.])
143      elif test "$ac_cv_ctime_args" = 3; then
144          AC_DEFINE(HAVE_CTIME_R_3,1,[Define if ctime_r is present with 3 parameters.])
145      fi
146      AC_MSG_RESULT([yes, and it takes $ac_cv_ctime_args arguments])
147  fi 
148
149 # log4shib settings (favor this version over the log4cpp code)
150 AC_PATH_PROG(LOG4SHIB_CONFIG,log4shib-config)
151 AC_ARG_WITH(log4shib,
152     AC_HELP_STRING([--with-log4shib=PATH], [where log4shib-config is installed]),
153     [
154     LOG4SHIB_CONFIG="${with_log4shib}"
155     if ! test -f "${LOG4SHIB_CONFIG}" ; then
156         LOG4SHIB_CONFIG="${with_log4shib}/bin/log4shib-config"
157     fi
158     ])
159 if test -f "${LOG4SHIB_CONFIG}"; then
160     LDFLAGS="`${LOG4SHIB_CONFIG} --libs` $LDFLAGS"
161     CPPFLAGS="`${LOG4SHIB_CONFIG} --cflags` $CPPFLAGS"
162         AC_CHECK_HEADER([log4shib/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4shib header files]))
163         AC_TRY_LINK(
164                 [#include <log4shib/Category.hh>
165 #include <log4shib/CategoryStream.hh>],
166                 [log4shib::Category::getInstance("foo").errorStream() << log4shib::eol],
167                 [AC_DEFINE(SHIBSP_LOG4SHIB,1,[Define if log4shib library is used.])],
168                 [AC_MSG_ERROR([unable to link with log4shib])])
169 else
170     AC_MSG_WARN([log4shib-config not found, may need to use --with-log4shib option])
171     AC_MSG_WARN([will look for original log4cpp library])
172     
173         # log4cpp settings
174         AC_PATH_PROG(LOG4CPP_CONFIG,log4cpp-config)
175         AC_ARG_WITH(log4cpp,
176             AC_HELP_STRING([--with-log4cpp=PATH], [where log4cpp-config is installed]),
177             [
178             LOG4CPP_CONFIG="${with_log4cpp}"
179             if ! test -f "${LOG4CPP_CONFIG}" ; then
180                 LOG4CPP_CONFIG="${with_log4cpp}/bin/log4cpp-config"
181             fi
182             ])
183         if test -f "${LOG4CPP_CONFIG}"; then
184                 AC_MSG_WARN([will try to use log4cpp, note that most non-Internet2 supplied versions are not thread-safe])
185             LDFLAGS="`${LOG4CPP_CONFIG} --libs` $LDFLAGS"
186             CPPFLAGS="`${LOG4CPP_CONFIG} --cflags` $CPPFLAGS"
187                 AC_CHECK_HEADER([log4cpp/CategoryStream.hh],,AC_MSG_ERROR([unable to find log4cpp header files]))
188                 AC_TRY_LINK(
189                         [#include <log4cpp/Category.hh>
190 #include <log4cpp/CategoryStream.hh>],
191                         [log4cpp::Category::getInstance("foo").errorStream() << log4cpp::eol],
192                         [AC_DEFINE(SHIBSP_LOG4CPP,1,[Define if log4cpp library is used.])],
193                         [AC_MSG_ERROR([unable to link with log4cpp, need version 1.0 or later])])
194         else
195             AC_MSG_ERROR([log4cpp-config not found, may need to use --with-log4cpp option])
196         fi
197 fi
198
199 # Xerces settings
200 AC_ARG_WITH(xerces, 
201             AC_HELP_STRING([--with-xerces=PATH], [where xerces-c is installed]),
202             [if test x_$with_xerces != x_/usr; then
203                 LDFLAGS="-L${with_xerces}/lib $LDFLAGS"
204                 CPPFLAGS="-I${with_xerces}/include $CPPFLAGS"
205             fi])
206 LIBS="-lxerces-c $LIBS"
207 AC_CHECK_HEADER([xercesc/dom/DOM.hpp],,
208                 AC_MSG_ERROR([unable to find xerces header files]))
209 AC_MSG_CHECKING([Xerces version])
210 AC_PREPROC_IFELSE(
211     [AC_LANG_PROGRAM([#include <xercesc/util/XercesVersion.hpp>],
212 [#if  _XERCES_VERSION != 20600
213 int i = 0;
214 #else
215 #error cannot use version 2.6.0
216 #endif])],
217     [AC_MSG_RESULT(OK)],
218     [AC_MSG_FAILURE([Xerces-C v2.6.0 has bugs that inhibit use with signed XML, please use a newer version])])
219 AC_TRY_LINK(
220         [#include <xercesc/util/PlatformUtils.hpp>],
221         [xercesc::XMLPlatformUtils::Initialize()],
222         [AC_DEFINE(HAVE_LIBXERCESC,1,[Define if Xerces-C library was found])],
223         [AC_MSG_ERROR([unable to link with Xerces])])
224
225 AC_MSG_CHECKING([whether Xerces XMLString::release(XMLByte**) exists])
226 AC_TRY_COMPILE([#include <xercesc/util/XMLString.hpp>],
227     [using namespace XERCES_CPP_NAMESPACE;
228       XMLByte* buf=NULL;
229       XMLString::release(&buf);
230     ],
231     [AC_MSG_RESULT([yes])]
232     [AC_DEFINE([SHIBSP_XERCESC_HAS_XMLBYTE_RELEASE], [1], [Define to 1 if Xerces XMLString includes XMLByte release.])],
233     [AC_MSG_RESULT([no])])
234
235 AC_MSG_CHECKING([whether Xerces DOMNodeFilter API returns a short])
236 AC_TRY_COMPILE([#include <xercesc/dom/DOM.hpp>],
237     [using namespace XERCES_CPP_NAMESPACE;
238       class Blocker : public DOMNodeFilter {
239       public:
240         short acceptNode(const DOMNode* node) const {
241             return FILTER_REJECT;
242         }
243       };
244       static Blocker g_Blocker;
245     ],
246     [AC_MSG_RESULT([yes])]
247     [AC_DEFINE([SHIBSP_XERCESC_SHORT_ACCEPTNODE], [1], [Define to 1 if Xerces DOMNodeFilter API returns a short.])],
248     [AC_MSG_RESULT([no])])
249
250 #XML-Tooling settings
251 AC_ARG_WITH(xmltooling,
252             AC_HELP_STRING([--with-xmltooling=PATH], [where xmltooling-c is installed]),
253             [if test x_$with_xmltooling != x_/usr; then
254                 LDFLAGS="-L${with_xmltooling}/lib $LDFLAGS"
255                 CPPFLAGS="-I${with_xmltooling}/include $CPPFLAGS"
256                 export PKG_CONFIG_PATH="${with_xmltooling}/lib/pkgconfig"
257             fi])
258 LITE_LIBS="-lxmltooling-lite"
259 XMLSEC_LIBS="-lxmltooling"
260 AC_CHECK_HEADER([xmltooling/base.h],,
261                 AC_MSG_ERROR([unable to find xmltooling header files]))
262                 
263
264 # save and append master libs
265 save_LIBS="$LIBS"
266 LIBS="$XMLSEC_LIBS $LIBS"
267
268 AC_TRY_LINK(
269     [#include <xmltooling/io/HTTPResponse.h>],
270     [xmltooling::HTTPResponse::sanitizeURL("http://test")],
271     [AC_DEFINE(HAVE_XMLTOOLING,1,[Define if xmltooling library was found])],
272     [AC_MSG_ERROR([unable to link with XMLTooling, or version was too old])])
273
274 # restore master libs
275 LIBS="$save_LIBS"
276
277 # Determine xmltooling version.
278 XMLTOOLINGVER="1.4"
279 AC_ARG_WITH(xmltoolingver,
280     AC_HELP_STRING([--with-xmltoolingver=VERSION], [xmltooling version, normally derived via pkg-config]),
281     [XMLTOOLINGVER="$with_xmltoolingver"],
282     [if test "x$PKG_CONFIG" != "x" && test "x$PKG_CONFIG" != "xno" ; then
283         if pkg-config xmltooling ; then
284             XMLTOOLINGVER="`$PKG_CONFIG --modversion xmltooling`"
285         fi
286     fi])
287
288 # Establish location of xmltooling catalog.
289 XMLTOOLINGXMLDIR=""
290 if test "x$with_xmltooling" = "x" ; then
291    with_xmltooling="/usr"
292 fi
293 if test -f $with_xmltooling/share/xml/xmltooling-$XMLTOOLINGVER/catalog.xml ; then
294     XMLTOOLINGXMLDIR="$with_xmltooling"
295 elif test -f $with_xerces/share/xml/xmltooling-$XMLTOOLINGVER/catalog.xml ; then
296     XMLTOOLINGXMLDIR="$with_xerces"
297 elif test -f $with_log4shib/share/xml/xmltooling-$XMLTOOLINGVER/catalog.xml ; then
298     XMLTOOLINGXMLDIR="$with_log4shib"
299 fi
300 if test "x$XMLTOOLINGXMLDIR" = "x" ; then
301     AC_MSG_ERROR([xmltooling XML catalog not found, may need to use --with-xmltooling option])
302 fi
303 XMLTOOLINGXMLDIR="$XMLTOOLINGXMLDIR/share/xml/xmltooling-$XMLTOOLINGVER"
304 AC_SUBST(XMLTOOLINGXMLDIR)
305
306 # XML-Security settings
307 AC_ARG_WITH(xmlsec,
308             AC_HELP_STRING([--with-xmlsec=PATH], [where xmlsec is installed]),,
309             [with_xmlsec=/usr])
310
311 if test x_$with_xmlsec != x_/usr; then
312     LDFLAGS="-L${with_xmlsec}/lib $LDFLAGS"
313     CPPFLAGS="-I${with_xmlsec}/include $CPPFLAGS"
314 fi        
315 XMLSEC_LIBS="-lxml-security-c $XMLSEC_LIBS"
316
317 # save and append master libs
318 save_LIBS="$LIBS"
319 LIBS="$XMLSEC_LIBS $LIBS"
320
321 AC_CHECK_HEADER([xsec/utils/XSECPlatformUtils.hpp],,AC_MSG_ERROR([unable to find XML-Security header files]))
322 AC_MSG_CHECKING([XML-Security version])
323 AC_PREPROC_IFELSE(
324     [AC_LANG_PROGRAM([#include <xsec/utils/XSECPlatformUtils.hpp>],
325     [#if XSEC_VERSION_MAJOR > 1 || (XSEC_VERSION_MAJOR == 1 && XSEC_VERSION_MEDIUM > 3)
326 int i = 0;
327 #else
328 #error need version 1.4.0 or later
329 #endif])],
330     [AC_MSG_RESULT(OK)],
331     [AC_MSG_FAILURE([XML-Security version 1.4.0 or greater is required.])])
332 AC_TRY_LINK(
333         [#include <xsec/utils/XSECPlatformUtils.hpp>],
334         [XSECPlatformUtils::Initialise()],,
335         [AC_MSG_ERROR([unable to link with XML-Security])])
336
337 # restore master libs
338 LIBS="$save_LIBS"
339
340 # OpenSAML settings
341 AC_ARG_WITH(saml,
342     AC_HELP_STRING([--with-saml=PATH], [where saml is installed]),
343     [if test x_$with_saml != x_/usr; then
344         LDFLAGS="-L${with_saml}/lib $LDFLAGS"
345         CPPFLAGS="-I${with_saml}/include $CPPFLAGS"
346     fi])
347 XMLSEC_LIBS="-lsaml $XMLSEC_LIBS"
348
349 # save and append master libs
350 save_LIBS="$LIBS"
351 LIBS="$XMLSEC_LIBS $LIBS"
352
353 AC_CHECK_HEADER([saml/saml2/metadata/Metadata.h],,
354                 AC_MSG_ERROR([unable to find OpenSAML header files]))
355 AC_TRY_LINK(
356         [#include <saml/SAMLConfig.h>
357 #include <saml/version.h>],
358         [#if _OPENSAML_VERSION >= 20200
359 opensaml::SAMLConfig::getConfig();
360 #else
361 #error Need OpenSAML version 2.2 or higher
362 #endif],
363         [AC_DEFINE(HAVE_SAML,1,[Define if saml library was found])],
364         [AC_MSG_ERROR([unable to link with OpenSAML, or version was too old])])
365
366 # restore master libs
367 LIBS="$save_LIBS"
368
369 # Determine opensaml version.
370 OPENSAMLVER="2.4"
371 AC_ARG_WITH(samlver,
372     AC_HELP_STRING([--with-samlver=VERSION], [opensaml version, normally derived via pkg-config]),
373     [OPENSAMLVER="$with_samlver"],
374     [if test "x$PKG_CONFIG" != "x" && test "x$PKG_CONFIG" != "xno" ; then
375         if pkg-config opensaml ; then
376             OPENSAMLVER="`$PKG_CONFIG --modversion opensaml`"
377         fi
378     fi])
379
380 # Establish location of opensaml catalogs.
381 OPENSAMLXMLDIR=""
382 if test "x$with_saml" = "x" ; then
383     with_saml="/usr"
384 fi
385 if test -f $with_saml/share/xml/opensaml-$OPENSAMLVER/saml20-catalog.xml ; then
386     OPENSAMLXMLDIR="$with_saml"
387 elif test -f $with_xmltooling/share/xml/opensaml-$OPENSAMLVER/saml20-catalog.xml ; then
388     OPENSAMLXMLDIR="$with_xmltooling"
389 elif test -f $with_xerces/share/xml/opensaml-$OPENSAMLVER/saml20-catalog.xml ; then
390     OPENSAMLXMLDIR="$with_xerces"
391 elif test -f $with_log4shib/share/xml/opensaml-$OPENSAMLVER/saml20-catalog.xml ; then
392     OPENSAMLXMLDIR="$with_log4shib"
393 fi
394 if test "x$OPENSAMLXMLDIR" = "x" ; then
395     AC_MSG_ERROR([opensaml XML catalogs not found, may need to use --with-saml option])
396 fi
397 OPENSAMLXMLDIR="$OPENSAMLXMLDIR/share/xml/opensaml-$OPENSAMLVER"
398 AC_SUBST(OPENSAMLXMLDIR)
399
400 AC_SUBST(LITE_LIBS)
401 AC_SUBST(XMLSEC_LIBS)
402
403 AC_CONFIG_FILES([shibboleth.spec pkginfo Portfile])
404
405 # output the underlying makefiles
406 WANT_SUBDIRS="doc schemas configs shibsp shibd util"
407 AC_CONFIG_FILES([Makefile doc/Makefile schemas/Makefile \
408         configs/Makefile shibsp/Makefile shibd/Makefile \
409         util/Makefile selinux/Makefile])
410
411 ## ADFS?
412 AC_CONFIG_FILES([adfs/Makefile])
413 AC_ARG_ENABLE([adfs],
414         AC_HELP_STRING([--disable-adfs], [don't build the ADFS module]),
415         [adfs_enabled=$enableval], [adfs_enabled=yes])
416 if test "x$adfs_enabled" = "x" ; then
417    adfs_enabled=yes
418 fi
419 AC_MSG_CHECKING(whether to build the ADFS module)
420 if test "$adfs_enabled" = "no" ; then
421    AC_MSG_RESULT(no)
422 else
423    AC_MSG_RESULT(yes)
424    WANT_SUBDIRS="$WANT_SUBDIRS adfs"
425 fi
426
427
428 #
429 # Build NSAPI module?
430 #
431 AC_MSG_CHECKING(for NSAPI module option)
432 AC_ARG_WITH(nsapi,
433         AC_HELP_STRING([--with-nsapi=DIR], [Build NSAPI module for Netscape/iPlanet/SunONE]),
434         [WANT_NSAPI=$withval],[WANT_NSAPI=no])
435 AC_MSG_RESULT($WANT_NSAPI)
436
437 if test "$WANT_NSAPI" != "no"; then
438   if test ! -d $WANT_NSAPI/bin ; then
439     AC_MSG_ERROR(Please specify the path to the root of your Netscape/iPlanet/SunONE server using --with-nsapi=DIR)
440   fi
441   AC_MSG_CHECKING(for NSAPI include files)
442   if test -d $WANT_NSAPI/include ; then
443     NSAPI_INCLUDE=$WANT_NSAPI/include
444     AC_MSG_RESULT(Netscape-Enterprise 3.x style)
445     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h],,,[#define XP_UNIX])
446     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
447   fi
448   if test -d $WANT_NSAPI/plugins/include ; then
449     test -n "$NSAPI_INCLUDE" && NSAPI_INC_DIR="-I$NSAPI_INCLUDE"
450     NSAPI_INCLUDE="$WANT_NSAPI/plugins/include"
451     AC_MSG_RESULT(iPlanet 4.x / SunONE 6.x style)
452     AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h],,,[#define XP_UNIX])
453     NSAPI_INCLUDE="$NSAPI_INC_DIR -I$NSAPI_INCLUDE"
454   fi
455   if test "$NSAPI_INCLUDE" = ""; then
456     AC_MSG_ERROR(Please check you have nsapi.h in either $WANT_NSAPI/include or $WANT_NSAPI/plugins/include)
457   fi
458 fi
459
460 AC_SUBST(NSAPI_INCLUDE)
461
462 # always output the Makefile, even if you don't use it
463 AC_CONFIG_FILES([nsapi_shib/Makefile])
464 AM_CONDITIONAL(BUILD_NSAPI,test ! "$WANT_NSAPI" = "no")
465
466 # add the NSAPI module to the list of wanted subdirs..
467 if test ! "$WANT_NSAPI" = "no" ; then
468     WANT_SUBDIRS="$WANT_SUBDIRS nsapi_shib"
469 fi
470
471
472 #
473 # Build FastCGI support?
474 #
475 AC_MSG_CHECKING(for FastCGI support)
476 AC_ARG_WITH(fastcgi,
477     AC_HELP_STRING([--with-fastcgi=DIR], [Build FastCGI support]),
478     [WANT_FASTCGI=$withval],[WANT_FASTCGI=no])
479 AC_MSG_RESULT($WANT_FASTCGI)
480
481 if test "$WANT_FASTCGI" != "no"; then
482     if test "$WANT_FASTCGI" != "yes"; then
483         if test x_$WANT_FASTCGI != x_/usr; then
484             FASTCGI_INCLUDE="-I$WANT_FASTCGI/include"
485             FASTCGI_LDFLAGS="-L$WANT_FASTCGI/lib"
486         fi
487     fi
488     AC_CHECK_HEADER([fcgio.h],,
489         AC_MSG_ERROR([unable to find FastCGI header files]))
490     FASTCGI_LIBS="-lfcgi -lfcgi++"
491 fi
492
493 AC_SUBST(FASTCGI_INCLUDE)
494 AC_SUBST(FASTCGI_LDFLAGS)
495 AC_SUBST(FASTCGI_LIBS)
496
497 # always output the Makefile, even if you don't use it
498 AC_CONFIG_FILES([fastcgi/Makefile])
499 AM_CONDITIONAL(BUILD_FASTCGI,test ! "$WANT_FASTCGI" = "no")
500
501 if test ! "$WANT_FASTCGI" = "no" ; then
502     WANT_SUBDIRS="$WANT_SUBDIRS fastcgi"
503 fi
504
505 #
506 # Build Memcached support?
507 #
508 AC_MSG_CHECKING(for Memcached support)
509 AC_ARG_WITH(memcached,
510     AC_HELP_STRING([--with-memcached=DIR], [Build Memcached support]),
511     [WANT_MEMCACHED=$withval],[WANT_MEMCACHED=no])
512 AC_MSG_RESULT($WANT_MEMCACHED)
513
514 if test "$WANT_MEMCACHED" != "no"; then
515     if test "$WANT_MEMCACHED" != "yes"; then
516         if test x_$WANT_MEMCACHED != x_/usr; then
517             MEMCACHED_INCLUDE="-I$WANT_MEMCACHED/include"
518             MEMCACHED_LDFLAGS="-L$WANT_MEMCACHED/lib"
519         fi
520     fi
521     AC_CHECK_HEADER([libmemcached/memcached.h],,
522         AC_MSG_ERROR([unable to find Memcached header files]))
523     MEMCACHED_LIBS="-lmemcached"
524 fi
525
526 AC_SUBST(MEMCACHED_INCLUDE)
527 AC_SUBST(MEMCACHED_LDFLAGS)
528 AC_SUBST(MEMCACHED_LIBS)
529
530 # always output the Makefile, even if you don't use it
531 AC_CONFIG_FILES([memcache-store/Makefile])
532 AM_CONDITIONAL(BUILD_MEMCACHED,test ! "$WANT_MEMCACHED" = "no")
533
534 if test ! "$WANT_MEMCACHED" = "no" ; then
535     WANT_SUBDIRS="$WANT_SUBDIRS memcache-store"
536 fi
537
538
539 #
540 # If no --enable-apache-xx specified 
541 # find a default and fake the specific parameters
542 #
543
544 # simple macro to peek at an enable or a with
545 AC_DEFUN([Peek],
546 if test "[${[$1]_][$2]+set}" = set; then
547   peekval="${[$1]_[$2]}"
548   $3
549 fi; dnl
550 )
551
552 AC_MSG_CHECKING(if default apache needed)
553 need_default=yes
554 Peek(enable,apache_13,need_default=no)
555 Peek(enable,apache_20,need_default=no)
556 Peek(enable,apache_22,need_default=no)
557 AC_MSG_RESULT($need_default)
558
559 if test "$need_default" = "yes"; then
560   # find an apxs, then the httpd
561   xs=
562   Peek(with,apxs,xs="$peekval")
563   Peek(with,apxs2,xs="$peekval")
564   Peek(with,apxs22,xs="$peekval")
565   if test "x$xs" = "x"; then
566      AC_PATH_PROGS(xs, apxs2 apxs,
567         AC_MSG_ERROR(No apxs, no apache found.  Try --with-apxs),
568         [/usr/local/apache2/bin:/usr/local/apache/bin:/usr/sbin:$PATH])
569   fi
570   # ask the daemon for the version and set parameters
571   AC_MSG_CHECKING(default apache version)
572   httpd="`$xs -q SBINDIR`/`$xs -q TARGET`"
573   if test "x$httpd" != "x" && test -f $httpd ; then
574      v=`$httpd -v|$SED -n -e 's/.*Apache\/\.*//p'`
575      case $v in
576        1.3*)   [enable_apache_13]=yes
577                [with_apxs]=$xs
578                AC_MSG_RESULT(1.3)
579                ;;
580        2.0*)   [enable_apache_20]=yes
581                [with_apxs2]=$xs
582                AC_MSG_RESULT(2.0)
583                ;;
584        2.2*)   [enable_apache_22]=yes
585                [with_apxs22]=$xs
586                AC_MSG_RESULT(2.2)
587                ;;
588        *)      AC_MSG_ERROR(unusable apache versions: $v. Try setting --with-apxs)
589      esac
590   else 
591      AC_MSG_RESULT(cannot determine version.  Try setting --with-apxs)
592   fi
593 fi
594
595 # Apache 1.3 (mod_shib_13)
596 #   --enable-apache-13
597 #   --with-apxs      (DSO build, the normal way, uses apxs to derive build flags)
598
599 AC_ARG_ENABLE(apache-13,
600         AC_HELP_STRING([--enable-apache-13], [enable the Apache 1.3 module]),
601         [ if test "x$enableval" = "x" ; then
602               WANT_APACHE_13=yes
603           else
604               WANT_APACHE_13="$enableval"
605           fi
606         ],[ WANT_APACHE_13=no ])
607 AC_MSG_CHECKING(whether to build Apache 1.3 module)
608 if test "$WANT_APACHE_13" != yes && test "$WANT_APACHE_13" != no ; then
609    WANT_APACHE_13=yes
610 fi
611 AC_MSG_RESULT($WANT_APACHE_13)
612
613 if test "$WANT_APACHE_13" = "yes" ; then
614     AC_ARG_WITH(apxs, 
615         AC_HELP_STRING([--with-apxs=FILE], [Specifies where to find the Apache 1.3 apxs script.]),
616         [
617         AC_MSG_CHECKING(for user-specified apxs name/location)
618         if test "$withval" != "no" ; then
619           if test "$withval" != "yes"; then
620             APXS=$withval
621             AC_MSG_RESULT("$withval")
622           fi
623         fi
624         ],
625         [
626         AC_PATH_PROG(APXS, apxs, no)
627         if test "$APXS" = "no" ; then
628           for i in /usr/sbin /usr/local/apache/bin ; do
629             if test "$APXS" = "no" && test -f "$i/apxs"; then
630               APXS="$i/apxs"
631             fi
632           done
633         fi
634         ])
635
636     AC_MSG_CHECKING([to see if apxs was located])
637     if test ! -f "$APXS" ; then
638         AC_MSG_RESULT(no)
639         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.])
640     fi
641     AC_MSG_RESULT($APXS)
642     AC_SUBST(APXS)
643
644     # extract settings we need from APXS -q
645     APXS_CC="`$APXS -q CC`"
646     APXS_CFLAGS="`$APXS -q CFLAGS` `$APXS -q CFLAGS_SHLIB`"
647     APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
648 fi
649
650 AC_SUBST(APXS_CFLAGS)
651 AC_SUBST(APXS_INCLUDE)
652
653
654 # Apache 2.0 (mod_shib_20)
655 #   --enable-apache-20
656 #   --with-apxs2      (DSO build, the normal way, uses apxs to derive build flags)
657 #       --with-apr        (DSO build, APR development package installed separately)
658 #   --with-apu        (DSO build, APR-UTIL development package installed separately)
659
660 AC_ARG_ENABLE(apache-20,
661         AC_HELP_STRING([--enable-apache-20], [enable the Apache 2.0 module]),
662         [ if test "x$enableval" = "x" ; then
663               WANT_APACHE_20=yes
664           else
665               WANT_APACHE_20="$enableval"
666           fi
667         ],[ WANT_APACHE_20=no ])
668 AC_MSG_CHECKING(whether to build Apache 2.0 module)
669 if test "$WANT_APACHE_20" != yes && test "$WANT_APACHE_20" != no ; then
670    WANT_APACHE_20=yes
671 fi
672 AC_MSG_RESULT($WANT_APACHE_20)
673
674 if test "$WANT_APACHE_20" = "yes" ; then
675     AC_ARG_WITH(apxs2, 
676         AC_HELP_STRING([--with-apxs2=FILE], [Specifies where to find the Apache 2.0 apxs script.]),
677         [
678         AC_MSG_CHECKING(for user-specified Apache2 apxs name/location)
679         if test "$withval" != "no" ; then
680           if test "$withval" != "yes"; then
681             APXS2=$withval
682             AC_MSG_RESULT("$withval")
683           fi
684         fi
685         ],
686         [
687         AC_PATH_PROG(APXS2, apxs2, no)
688         if test "$APXS2" = "no" ; then
689             AC_PATH_PROG(APXS2, apxs, no)
690         fi
691         if test "$APXS2" = "no" ; then
692           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
693             if test "$APXS2" = "no" && test -f "$i/apxs2" ; then
694               APXS2="$i/apxs2"
695             fi
696           done
697           if test "$APXS2" = "no" ; then
698             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
699               if test "$APXS2" = "no" && test -f "$i/apxs" ; then
700                 APXS2="$i/apxs"
701               fi
702             done
703           fi
704         fi
705         ])
706
707     AC_MSG_CHECKING([to see if Apache2 apxs was located])
708     if test ! -f "$APXS2" ; then
709         AC_MSG_RESULT(no)
710         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.])
711     fi
712     AC_MSG_RESULT($APXS2)
713     AC_SUBST(APXS2)
714
715     # APR settings
716     AC_ARG_WITH(apr, 
717         AC_HELP_STRING([--with-apr=PATH], [where apr-config is installed]),
718         [
719         AC_MSG_CHECKING(for user-specified apr-config name/location)
720         if test "$withval" != "no" ; then
721             if test "$withval" != "yes"; then
722                 APR_CONFIG=$withval
723                 AC_MSG_RESULT("$withval")
724             fi
725         fi
726         ],
727         [
728         AC_PATH_PROG(APR_CONFIG, apr-config,,[`$APXS2 -q SBINDIR`]:[$PATH])
729         ])
730         if test -f "${APR_CONFIG}"; then
731         APR_CFLAGS="`${APR_CONFIG} --cflags` `${APR_CONFIG} --cppflags` `${APR_CONFIG} --includes`"
732     else
733         AC_MSG_ERROR([Unable to locate apr-config, may need --with-apr option.])
734     fi
735
736     # APU settings
737     AC_ARG_WITH(apu, 
738         AC_HELP_STRING([--with-apu=PATH], [where apu-config is installed]),
739         [
740         AC_MSG_CHECKING(for user-specified apu-config name/location)
741         if test "$withval" != "no" ; then
742             if test "$withval" != "yes"; then
743                 APR_CONFIG=$withval
744                 AC_MSG_RESULT("$withval")
745             fi
746         fi
747         ],
748         [
749         AC_PATH_PROG(APU_CONFIG, apu-config,,[`$APXS2 -q SBINDIR`]:[$PATH])
750         ])
751     if test -f "${APU_CONFIG}"; then
752         APU_CFLAGS="`${APU_CONFIG} --includes`"
753     else
754         AC_MSG_ERROR([Unable to locate apu-config, may need --with-apu option.])
755     fi
756
757     # extract settings we need from APXS2 -q
758     APXS2_CC="`$APXS2 -q CC`"
759     APXS2_CFLAGS="`$APXS2 -q CPPFLAGS` `$APXS2 -q CFLAGS` $APU_CFLAGS"
760     APXS2_INCLUDE="`$APXS2 -q INCLUDEDIR`"
761 fi
762
763 AC_SUBST(APXS2_CFLAGS)
764 AC_SUBST(APXS2_INCLUDE)
765
766
767 # Apache 2.2 (mod_shib_22)
768 #   --enable-apache-22
769 #   --with-apxs22     (DSO build, the normal way, uses apxs to derive build flags)
770 #       --with-apr1       (DSO build, APR development package installed separately)
771 #   --with-apu1       (DSO build, APR-UTIL development package installed separately)
772
773 AC_ARG_ENABLE(apache-22,
774         AC_HELP_STRING([--enable-apache-22], [enable the Apache 2.2 module]),
775         [ if test "x$enableval" = "x" ; then
776               WANT_APACHE_22=yes
777           else
778               WANT_APACHE_22="$enableval"
779           fi
780         ],[ WANT_APACHE_22=no ])
781 AC_MSG_CHECKING(whether to build Apache 2.2 module)
782 if test "$WANT_APACHE_22" != yes && test "$WANT_APACHE_22" != no ; then
783    WANT_APACHE_22=yes
784 fi
785 AC_MSG_RESULT($WANT_APACHE_22)
786
787 if test "$WANT_APACHE_22" = "yes" ; then
788     AC_ARG_WITH(apxs22, 
789         AC_HELP_STRING([--with-apxs22=FILE], [Specifies where to find the Apache 2.2 apxs script.]),
790         [
791         AC_MSG_CHECKING(for user-specified Apache2.2 apxs name/location)
792         if test "$withval" != "no" ; then
793           if test "$withval" != "yes"; then
794             APXS22=$withval
795             AC_MSG_RESULT("$withval")
796           fi
797         fi
798         ],
799         [
800         AC_PATH_PROG(APXS22, apxs2, no)
801         if test "$APXS22" = "no" ; then
802             AC_PATH_PROG(APXS22, apxs, no)
803         fi
804         if test "$APXS22" = "no" ; then
805           for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
806             if test "$APXS22" = "no" && test -f "$i/apxs2" ; then
807               APXS22="$i/apxs2"
808             fi
809           done
810           if test "$APXS22" = "no" ; then
811             for i in /usr/sbin /usr/local/apache2/bin /usr/local/apache/bin ; do
812               if test "$APXS22" = "no" && test -f "$i/apxs" ; then
813                 APXS22="$i/apxs"
814               fi
815             done
816           fi
817         fi
818         ])
819
820     AC_MSG_CHECKING([to see if Apache2.2 apxs was located])
821     if test ! -f "$APXS22" ; then
822         AC_MSG_RESULT(no)
823         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.])
824     fi
825     AC_MSG_RESULT($APXS22)
826     AC_SUBST(APXS22)
827
828     # APR1 settings
829     AC_ARG_WITH(apr1, 
830         AC_HELP_STRING([--with-apr1=PATH], [where apr-1-config is installed]),
831         [
832         AC_MSG_CHECKING(for user-specified apr-1-config name/location)
833         if test "$withval" != "no" ; then
834             if test "$withval" != "yes"; then
835                 APR1_CONFIG=$withval
836                 AC_MSG_RESULT("$withval")
837             fi
838         fi
839         ],
840         [
841         AC_PATH_PROG(APR1_CONFIG, apr-1-config,,[`$APXS22 -q SBINDIR`]:[$PATH])
842         ])
843         if test -f "${APR1_CONFIG}"; then
844         APR1_CFLAGS="`${APR1_CONFIG} --cflags` `${APR1_CONFIG} --cppflags` `${APR1_CONFIG} --includes`"
845     else
846         AC_MSG_ERROR([Unable to locate apr-1-config, may need --with-apr1 option.])
847     fi
848
849     # APU1 settings
850     AC_ARG_WITH(apu1, 
851         AC_HELP_STRING([--with-apu1=PATH], [where apu-1-config is installed]),
852         [
853         AC_MSG_CHECKING(for user-specified apu-1-config name/location)
854         if test "$withval" != "no" ; then
855             if test "$withval" != "yes"; then
856                 APR1_CONFIG=$withval
857                 AC_MSG_RESULT("$withval")
858             fi
859         fi
860         ],
861         [
862         AC_PATH_PROG(APU1_CONFIG, apu-1-config,,[`$APXS22 -q SBINDIR`]:[$PATH])
863         ])
864     if test -f "${APU1_CONFIG}"; then
865         APU1_CFLAGS="`${APU1_CONFIG} --includes`"
866     else
867         AC_MSG_ERROR([Unable to locate apu-1-config, may need --with-apu1 option.])
868     fi
869
870     # extract settings we need from APXS22 -q
871     APXS22_CC="`$APXS22 -q CC`"
872     APXS22_CFLAGS="`$APXS22 -q CPPFLAGS` `$APXS22 -q CFLAGS` $APR1_CFLAGS $APU1_CFLAGS"
873     APXS22_INCLUDE="`$APXS22 -q INCLUDEDIR`"
874 fi
875
876 AC_SUBST(APXS22_CFLAGS)
877 AC_SUBST(APXS22_INCLUDE)
878
879 # always output the Makefile, even if you don't use it
880 AC_CONFIG_FILES([apache/Makefile])
881 AM_CONDITIONAL(BUILD_AP13,test "$WANT_APACHE_13" = "yes")
882 AM_CONDITIONAL(BUILD_AP20,test "$WANT_APACHE_20" = "yes")
883 AM_CONDITIONAL(BUILD_AP22,test "$WANT_APACHE_22" = "yes")
884
885 # add the apache module to the list of wanted subdirs..
886 if test "$WANT_APACHE_13" = "yes" || test "$WANT_APACHE_20" = "yes" || test "$WANT_APACHE_22" = "yes" ; then
887     WANT_SUBDIRS="$WANT_SUBDIRS apache"
888 fi
889
890
891 #
892 # Implement the checks of the ODBC Storage Service
893 #
894 # 1) Assume the user wants ODBC; if it's not found then just continue without
895 # 2) If the user specifically requested odbc, look for it and ERROR if not found
896 # 3) If the user specifically requested no odbc, don't build it.
897 #
898
899 AC_CONFIG_FILES([odbc-store/Makefile])
900
901 # determine whether we should enable the odbc ccache
902 AC_ARG_ENABLE([odbc],
903         AC_HELP_STRING([--disable-odbc], [disable the ODBC Storage Service]),
904         [odbc_enabled=$enableval], [odbc_enabled=default])
905
906 if test "x$odbc_enabled" = "x" ; then
907    odbc_enabled=yes
908 fi
909
910 # Are we trying to build ODBC?
911 AC_MSG_CHECKING(whether to build the ODBC storage service)
912 if test "$odbc_enabled" = "yes" ; then
913    build_odbc=yes
914    AC_MSG_RESULT(yes)
915 elif test "$odbc_enabled" = "default" ; then
916    build_odbc=yes
917    AC_MSG_RESULT([yes, if it can be found])
918 else
919    build_odbc=no
920    AC_MSG_RESULT(no)
921 fi
922
923 # If we're trying to build ODBC, try to find the odbc_config program.
924 if test "$build_odbc" = "yes" ; then
925    odbc_dir=""
926    AC_ARG_WITH(odbc,
927         AC_HELP_STRING([--with-odbc=PATH], [directory where odbc is installed]),
928             [if test "$with_odbc" = no ; then
929                AC_MSG_ERROR([Try running --disable-odbc instead.])
930              elif test "$with_odbc" != yes ; then
931                odbc_dir="$with_odbc/bin"
932                if test "$with_odbc" != /usr ; then
933                  ODBC_CFLAGS="-I$with_odbc/include"
934                  ODBC_LIBS="-L$with_odbc/lib"
935                fi
936              fi ])
937
938    AC_PATH_PROG(ODBC_CONFIG, odbc_config, no, $odbc_dir $PATH )
939    if test "$ODBC_CONFIG" = no ; then
940       AC_MSG_WARN([Cannot find odbc_config, will try to guess settings.])
941       ODBC_LIBS="$ODBC_LIBS -lodbc"
942    else
943       ODBC_CFLAGS=`$ODBC_CONFIG --cflags`
944       ODBC_LIBS=`$ODBC_CONFIG --libs`
945    fi
946
947    save_CPPFLAGS="$CPPFLAGS"
948    CPPFLAGS="$CPPFLAGS $ODBC_CFLAGS"
949
950    AC_CHECK_HEADER([sql.h], [have_sql_h=yes], [have_sql_h=no])
951    if test "$have_sql_h" = no -a "$odbc_enabled" = "yes" ; then
952      AC_MSG_ERROR(unable to find ODBC header files)
953    fi
954
955    if test "$have_sql_h" = yes ; then
956       save_LIBS="$LIBS"
957       LIBS="$LIBS $ODBC_LIBS"
958       AC_MSG_CHECKING(if we can link againt ODBC)
959       AC_TRY_LINK(
960         [#include <sql.h>
961          #include <sqlext.h>
962          #include <stdio.h>],
963         [SQLSetEnvAttr(SQL_NULL_HANDLE, SQL_ATTR_CONNECTION_POOLING, (void*)SQL_CP_ONE_PER_HENV, 0)],
964         [have_odbc_libs=yes],
965         [have_odbc_libs=no])
966       LIBS="$save_LIBS"
967
968       if test "$have_odbc_libs" = no ; then
969          if test "$odbc_enabled" = "yes" ; then
970             AC_MSG_ERROR([unable to link with ODBC Library])
971          else
972             AC_MSG_RESULT(no, skipping ODBC)
973          fi
974       fi
975    fi
976
977    CPPFLAGS="$save_CPPFLAGS"
978 fi
979
980 # if have_odbc_libs=yes then go ahead with building ODBC
981 if test "$have_odbc_libs" = yes ; then
982    # this AC_MSG_RESULT is from above!
983    AC_MSG_RESULT(yes)
984    WANT_SUBDIRS="$WANT_SUBDIRS odbc-store"
985    AC_SUBST(ODBC_CFLAGS)
986    AC_SUBST(ODBC_LIBS)
987 fi
988
989
990 AC_SUBST(WANT_SUBDIRS)
991
992 if test -n "$APXS_CC" && test "$APXS_CC" != "$CC" ; then
993   echo "=================================================================="
994   echo "WARNING: You have chosen to compile Apache-1.3 modules with a different"
995   echo "         compiler than the one used to compile Apache."
996   echo ""
997   echo "    Current compiler:      $CC"
998   echo "   Apache's compiler:      $APXS_CC"
999   echo ""
1000   echo "This could cause problems."
1001   echo "=================================================================="
1002 fi
1003
1004 if test -n "$APXS2_CC" && test "$APXS2_CC" != "$CC" ; then
1005   echo "=================================================================="
1006   echo "WARNING: You have chosen to compile Apache-2.0 modules with a different"
1007   echo "         compiler than the one used to compile Apache."
1008   echo ""
1009   echo "    Current compiler:      $CC"
1010   echo "   Apache's compiler:      $APXS2_CC"
1011   echo ""
1012   echo "This could cause problems."
1013   echo "=================================================================="
1014 fi
1015
1016 if test -n "$APXS22_CC" && test "$APXS22_CC" != "$CC" ; then
1017   echo "=================================================================="
1018   echo "WARNING: You have chosen to compile Apache-2.2 modules with a different"
1019   echo "         compiler than the one used to compile Apache."
1020   echo ""
1021   echo "    Current compiler:      $CC"
1022   echo "   Apache's compiler:      $APXS22_CC"
1023   echo ""
1024   echo "This could cause problems."
1025   echo "=================================================================="
1026 fi
1027
1028 LIBTOOL="$LIBTOOL --silent"
1029
1030 AC_OUTPUT