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