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