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